Update secgroup API for new get/list/search API

Security group API now conforms to the new get/list/search
interface. Instead of a Nova object being returned, we now return
a dict (or list of dicts).

Change-Id: I0b84ef6065101948ffb2a0f56235bda7a071ad17
This commit is contained in:
David Shrewsbury 2015-04-29 15:02:59 -04:00
parent 746a1a84d7
commit a540167587

View File

@ -824,6 +824,10 @@ class OpenStackCloud(object):
flavors = self.list_flavors()
return self._filter_list(flavors, name_or_id, filters)
def search_security_groups(self, name_or_id=None, filters=None):
groups = self.list_security_groups()
return self._filter_list(groups, name_or_id, filters)
def list_networks(self):
return self.manager.submitTask(_tasks.NetworkList())['networks']
@ -848,6 +852,11 @@ class OpenStackCloud(object):
self.manager.submitTask(_tasks.FlavorList())
)
def list_security_groups(self):
return meta.obj_list_to_dict(
self.manager.submitTask(_tasks.SecurityGroupList())
)
def get_network(self, name_or_id, filters=None):
return self._get_entity(self.search_networks, name_or_id, filters)
@ -863,6 +872,10 @@ class OpenStackCloud(object):
def get_flavor(self, name_or_id, filters=None):
return self._get_entity(self.search_flavors, name_or_id, filters)
def get_security_group(self, name_or_id, filters=None):
return self._get_entity(self.search_security_groups,
name_or_id, filters)
# TODO(Shrews): This will eventually need to support tenant ID and
# provider networks, which are admin-level params.
def create_network(self, name, shared=False, admin_state_up=True):
@ -1492,12 +1505,6 @@ class OpenStackCloud(object):
groups = meta.get_groups_from_server(self, server, server_vars)
return dict(server_vars=server_vars, groups=groups)
def get_security_group(self, name_or_id):
for secgroup in self.manager.submitTask(_tasks.SecurityGroupList()):
if name_or_id in (secgroup.name, secgroup.id):
return secgroup
return None
def get_openstack_vars(self, server):
return meta.get_hostvars_from_server(self, server)