diff --git a/novaclient/v1_1/base.py b/novaclient/v1_1/base.py index 9762f73eb..09d80b11a 100644 --- a/novaclient/v1_1/base.py +++ b/novaclient/v1_1/base.py @@ -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 diff --git a/novaclient/v1_1/security_groups.py b/novaclient/v1_1/security_groups.py index ca1a35f8b..f580cf2dc 100644 --- a/novaclient/v1_1/security_groups.py +++ b/novaclient/v1_1/security_groups.py @@ -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') diff --git a/novaclient/v1_1/servers.py b/novaclient/v1_1/servers.py index cac3ec1f5..c6ab9287c 100644 --- a/novaclient/v1_1/servers.py +++ b/novaclient/v1_1/servers.py @@ -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): """