diff options
author | spisarski <s.pisarski@cablelabs.com> | 2017-08-09 14:17:26 -0600 |
---|---|---|
committer | spisarski <s.pisarski@cablelabs.com> | 2017-08-09 14:37:41 -0600 |
commit | 2b9b2d64c5be98405aaaf98db58f06b35b8af983 (patch) | |
tree | 7eac6cb5a5182371b5602e53bb613234c5eff11c /snaps/openstack/utils/neutron_utils.py | |
parent | 430905e7f76e4a074167a49ca2bfbf727eebcefd (diff) |
SNAPS Stack creators can now return SNAPS network creators.
As Heat Stacks are responsible for spawning objects in OpenStack,
the class OpenStackHeatStack which is responsible for applying and
managing the state of a stack now can retrieve OpenStackNetwork
objects for the networks created in the stack for clients who would
like to query the networks and subnets or update them outside of
Heat.
JIRA: SNAPS-171
Change-Id: I9bf0b81d4f7bfeb1b6392f345022c7d9a57d0415
Signed-off-by: spisarski <s.pisarski@cablelabs.com>
Diffstat (limited to 'snaps/openstack/utils/neutron_utils.py')
-rw-r--r-- | snaps/openstack/utils/neutron_utils.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/snaps/openstack/utils/neutron_utils.py b/snaps/openstack/utils/neutron_utils.py index e7b002a..076557b 100644 --- a/snaps/openstack/utils/neutron_utils.py +++ b/snaps/openstack/utils/neutron_utils.py @@ -187,6 +187,35 @@ def get_subnet(neutron, subnet_settings=None, subnet_name=None): return Subnet(**subnet) +def get_subnet_by_id(neutron, subnet_id): + """ + Returns a SNAPS-OO Subnet domain object for a given ID + :param neutron: the OpenStack neutron client + :param subnet_id: the subnet ID + :return: a Subnet object + """ + os_subnet = neutron.show_subnet(subnet_id) + if os_subnet and 'subnet' in os_subnet: + return Subnet(**os_subnet['subnet']) + + +def get_subnets_by_network(neutron, network): + """ + Returns a list of SNAPS-OO Subnet domain objects + :param neutron: the OpenStack neutron client + :param network: the SNAPS-OO Network domain object + :return: a list of Subnet objects + """ + out = list() + + os_subnets = neutron.list_subnets(network_id=network.id) + + for os_subnet in os_subnets['subnets']: + out.append(Subnet(**os_subnet)) + + return out + + def create_router(neutron, os_creds, router_settings): """ Creates a router for OpenStack |