def create_network(os_creds, network_settings, cleanup=False): """ Creates a network on which the CMTSs can attach :param os_creds: The OpenStack credentials object :param network_settings: The network settings object :param cleanup: Denotes whether or not this is being called for cleanup :return: A reference to the network creator objects for each network from which network elements such as the subnet, router, interface router, and network objects can be accessed. """ # Check for OS for network existence # If exists return network instance data # Else, create network and return instance data logger.info('Attempting to create network with name - %s', network_settings.name) network_creator = OpenStackNetwork(os_creds, network_settings) if cleanup: network_creator.initialize() else: network_creator.create() logger.info('Created network ') return network_creator
def get_network_creators(self): """ Returns a list of network creator objects as configured by the heat template :return: list() of OpenStackNetwork objects """ out = list() stack_networks = heat_utils.get_stack_networks(self.__heat_cli, self.__neutron, self.__stack) for stack_network in stack_networks: net_settings = settings_utils.create_network_config( self.__neutron, stack_network) net_creator = OpenStackNetwork(self._os_creds, net_settings) out.append(net_creator) net_creator.initialize() return out