Eradicate TABs, make tests run
This commit is contained in:
parent
97674358da
commit
c487b9fac1
|
@ -27,7 +27,7 @@ class Client(object):
|
|||
def __init__(self, username, api_key, project_id, auth_url, timeout=None):
|
||||
self.flavors = flavors.FlavorManager(self)
|
||||
self.images = images.ImageManager(self)
|
||||
self.security_groups = security_groups.SecurityGroupManager(self)
|
||||
self.security_groups = security_groups.SecurityGroupManager(self)
|
||||
self.servers = servers.ServerManager(self)
|
||||
self.zones = zones.ZoneManager(self)
|
||||
|
||||
|
|
|
@ -25,45 +25,51 @@ class SecurityGroup(base.Resource):
|
|||
def __repr__(self):
|
||||
return "<Security_group: %s>" % self.uuid
|
||||
|
||||
def __str__(self):
|
||||
return self.uuid
|
||||
|
||||
@property
|
||||
def uuid(self):
|
||||
return self.name
|
||||
|
||||
def delete(self):
|
||||
self.manager.delete(self)
|
||||
|
||||
|
||||
class SecurityGroupManager(base.ManagerWithFind):
|
||||
resource_class = SecurityGroup
|
||||
|
||||
def create(self, name, description):
|
||||
"""
|
||||
Create a security group
|
||||
|
||||
:param name: name for the security group to dreate
|
||||
:param description: description of the security group
|
||||
"""
|
||||
Create a security group
|
||||
|
||||
:param name: name for the security group to dreate
|
||||
:param description: description of the security group
|
||||
"""
|
||||
body = {"security_group": {"name": name, 'description': description}}
|
||||
return self._create('/extras/security_groups', body, 'security_group')
|
||||
|
||||
def delete(self, id):
|
||||
"""
|
||||
Delete a security group
|
||||
|
||||
:param id: The security group ID to delete
|
||||
"""
|
||||
Delete a security group
|
||||
|
||||
:param id: The security group ID to delete
|
||||
"""
|
||||
return self._delete('/extras/security_groups/%s' % id)
|
||||
|
||||
def get(self, id):
|
||||
"""
|
||||
Get a security group
|
||||
|
||||
:param id: The security group ID to get
|
||||
:rtype: :class:`SecurityGroup`
|
||||
Get a security group
|
||||
|
||||
:param id: The security group ID to get
|
||||
:rtype: :class:`SecurityGroup`
|
||||
"""
|
||||
return self._get('/extras/security_groups/%s' % id, 'security_group')
|
||||
|
||||
def list(self):
|
||||
"""
|
||||
Get a list of all security_groups
|
||||
|
||||
|
||||
:rtype: list of :class:`SecurityGroup`
|
||||
"""
|
||||
return self._list("/extras/security_groups", "security_groups")
|
||||
|
|
|
@ -378,16 +378,16 @@ class FakeHTTPClient(base_client.HTTPClient):
|
|||
# Security Groups
|
||||
#
|
||||
def get_extras_security_groups(self, **kw):
|
||||
return (200, {"security_groups": [
|
||||
{'name': 'test', 'description': 'FAKE_SECURITY_GROUP'}
|
||||
]})
|
||||
return (200, {"security_groups": [
|
||||
{'name': 'test', 'description': 'FAKE_SECURITY_GROUP'}
|
||||
]})
|
||||
|
||||
def delete_extras_security_groups_test(self, **kw):
|
||||
return (202, None)
|
||||
return (202, None)
|
||||
|
||||
def post_extras_security_groups(self, body, **kw):
|
||||
assert body.keys() == ['security_group']
|
||||
fakes.assert_has_keys(body['security_group'],
|
||||
required=['name','description'])
|
||||
r = {'security_group': self.get_extras_security_groups()[1]['security_groups'][0]}
|
||||
return (202, r)
|
||||
assert body.keys() == ['security_group']
|
||||
fakes.assert_has_keys(body['security_group'],
|
||||
required=['name','description'])
|
||||
r = {'security_group': self.get_extras_security_groups()[1]['security_groups'][0]}
|
||||
return (202, r)
|
||||
|
|
Loading…
Reference in New Issue