diff options
| author | Vishvananda Ishaya <vishvananda@gmail.com> | 2010-07-08 12:19:50 -0700 |
|---|---|---|
| committer | Vishvananda Ishaya <vishvananda@gmail.com> | 2010-07-08 12:19:50 -0700 |
| commit | 702391e5d3f3cee5fe1d5e34d175f0fe0b5d0d7a (patch) | |
| tree | 1c23127d372e998de3516a4020f491c848dae90a | |
| parent | c41bcdf19c9e5be4ba19a814132af0534d604555 (diff) | |
| download | nova-702391e5d3f3cee5fe1d5e34d175f0fe0b5d0d7a.tar.gz nova-702391e5d3f3cee5fe1d5e34d175f0fe0b5d0d7a.tar.xz nova-702391e5d3f3cee5fe1d5e34d175f0fe0b5d0d7a.zip | |
fixes from code review
| -rw-r--r-- | nova/auth/users.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/nova/auth/users.py b/nova/auth/users.py index a45fbc1c0..29d10affd 100644 --- a/nova/auth/users.py +++ b/nova/auth/users.py @@ -335,10 +335,13 @@ class Vpn(model.BasicModel): @classmethod def find_free_port_for_ip(cls, ip): - # TODO(vish): the redis access should be refactored into a - # base class + # TODO(vish): these redis commands should be generalized and + # placed into a base class. Conceptually, it is + # similar to an association, but we are just + # storing a set of values instead of keys that + # should be turned into objects. redis = datastore.Redis.instance() - key = 'ip:%s:ports' + key = 'ip:%s:ports' % ip # TODO(vish): these ports should be allocated through an admin # command instead of a flag if (not redis.exists(key) and @@ -346,14 +349,14 @@ class Vpn(model.BasicModel): for i in range(FLAGS.vpn_start_port, FLAGS.vpn_end_port + 1): redis.sadd(key, i) - port = datastore.Redis.instance().spop(key) + port = redis.spop(key) if not port: raise NoMorePorts() return port @classmethod def num_ports_for_ip(cls, ip): - return datastore.Redis.instance().scard('ip:%s:ports') + return datastore.Redis.instance().scard('ip:%s:ports' % ip) @property def ip(self): @@ -467,7 +470,9 @@ class UserManager(object): # create and destroy a project Vpn.create(name) return conn.create_project(name, - User.safe_id(manager_user), description, member_users) + User.safe_id(manager_user), + description, + member_users) def get_projects(self): |
