X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=snaps%2Fopenstack%2Futils%2Fheat_utils.py;h=e319229f8bb34149764f9a482626f772a21bb3d9;hb=4cad4f7d1f53189900f9024fa5478e98a64d3760;hp=15c3533b0eeea0798de3914c2a1b3718ccda482a;hpb=76c96d0c7095978e5d51ead79f1a85eff46b4143;p=snaps.git diff --git a/snaps/openstack/utils/heat_utils.py b/snaps/openstack/utils/heat_utils.py index 15c3533..e319229 100644 --- a/snaps/openstack/utils/heat_utils.py +++ b/snaps/openstack/utils/heat_utils.py @@ -37,7 +37,7 @@ def heat_client(os_creds): :param os_creds: the OpenStack credentials :return: the client """ - logger.debug('Retrieving Nova Client') + logger.debug('Retrieving Heat Client') return Client(os_creds.heat_api_version, session=keystone_utils.keystone_session(os_creds), region_name=os_creds.region_name) @@ -155,7 +155,7 @@ def get_resources(heat_cli, stack, res_type=None): out = list() for os_resource in os_resources: if ((res_type and os_resource.resource_type == res_type) - or not res_type): + or not res_type): out.append(Resource( name=os_resource.resource_name, resource_type=os_resource.resource_type, @@ -207,6 +207,45 @@ def get_stack_networks(heat_cli, neutron, stack): return out +def get_stack_routers(heat_cli, neutron, stack): + """ + Returns a list of Network domain objects deployed by this stack + :param heat_cli: the OpenStack heat client object + :param neutron: the OpenStack neutron client object + :param stack: the SNAPS-OO Stack domain object + :return: a list of Network objects + """ + + out = list() + resources = get_resources(heat_cli, stack, 'OS::Neutron::Router') + for resource in resources: + router = neutron_utils.get_router_by_id(neutron, resource.id) + if router: + out.append(router) + + return out + + +def get_stack_security_groups(heat_cli, neutron, stack): + """ + Returns a list of SecurityGroup domain objects deployed by this stack + :param heat_cli: the OpenStack heat client object + :param neutron: the OpenStack neutron client object + :param stack: the SNAPS-OO Stack domain object + :return: a list of SecurityGroup objects + """ + + out = list() + resources = get_resources(heat_cli, stack, 'OS::Neutron::SecurityGroup') + for resource in resources: + security_group = neutron_utils.get_security_group_by_id( + neutron, resource.id) + if security_group: + out.append(security_group) + + return out + + def get_stack_servers(heat_cli, nova, stack): """ Returns a list of VMInst domain objects associated with a Stack