progress on security groups

This commit is contained in:
Anthony Young 2011-08-23 20:59:25 -07:00
parent 128608f086
commit 0756829b43
3 changed files with 10 additions and 4 deletions

View File

@ -130,7 +130,7 @@ class BootingManagerWithFind(ManagerWithFind):
def _boot(self, resource_url, response_key, name, image, flavor,
meta=None, files=None, zone_blob=None,
reservation_id=None, return_raw=False, min_count=None,
max_count=None):
max_count=None, security_groups=None):
"""
Create (boot) a new server.
@ -151,6 +151,7 @@ class BootingManagerWithFind(ManagerWithFind):
:param reservation_id: a UUID for the set of servers being requested.
:param return_raw: If True, don't try to coearse the result into
a Resource object.
:param security_groups: list of security group names
"""
body = {"server": {
"name": name,
@ -171,6 +172,10 @@ class BootingManagerWithFind(ManagerWithFind):
body["server"]["min_count"] = min_count
body["server"]["max_count"] = max_count
if security_groups:
body["server"]["security_groups"] =\
[{'name': name} for sg in security_groups]
# Files are a slight bit tricky. They're passed in a "personality"
# list to the POST. Each item is a dict giving a file name and the
# base64-encoded contents of the file. We want to allow passing

View File

@ -44,7 +44,7 @@ class SecurityGroupManager(base.ManagerWithFind):
:param name: name for the security group to create
:param description: description of the security group
:rtype: Integer ID of created security group
:rtype: the security group object
"""
body = {"security_group": {"name": name, 'description': description}}
return self._create('/os-security-groups', body, 'security_group')

View File

@ -287,7 +287,7 @@ class ServerManager(local_base.BootingManagerWithFind):
def create(self, name, image, flavor, meta=None, files=None,
zone_blob=None, reservation_id=None, min_count=None,
max_count=None):
max_count=None,security_groups=None):
"""
Create (boot) a new server.
@ -316,7 +316,8 @@ class ServerManager(local_base.BootingManagerWithFind):
return self._boot("/servers", "server", name, image, flavor,
meta=meta, files=files,
zone_blob=zone_blob, reservation_id=reservation_id,
min_count=min_count, max_count=max_count)
min_count=min_count, max_count=max_count,
security_groups=security_groups)
def update(self, server, name=None):
"""