:return: the client object
"""
return Client(api_version=os_creds.network_api_version,
- session=keystone_utils.keystone_session(os_creds))
+ session=keystone_utils.keystone_session(os_creds),
+ region_name=os_creds.region_name)
def create_network(neutron, os_creds, network_settings):
for network, netInsts in networks.items():
for inst in netInsts:
if inst.get('name') == network_name:
- if project_id and inst.get('project_id') == project_id:
- return {'network': inst}
- else:
- return Network(**inst)
+ return Network(**inst)
return None
Removes an OpenStack port
:param neutron: the client
:param port: the SNAPS-OO Port domain object
- :return:
"""
logger.info('Deleting port with name ' + port.name)
neutron.delete_port(port.id)
Returns the first port object (dictionary) found with a given name
:param neutron: the client
:param port_name: the name of the port to retrieve
- :return:
+ :return: a SNAPS-OO Port domain object
"""
ports = neutron.list_ports(**{'name': port_name})
for port in ports['ports']:
:param neutron: the Neutron client
:param keystone: the Keystone client
:param sec_grp_settings: the security group settings
- :return: the security group object
+ :return: a SNAPS-OO SecurityGroup domain object
"""
logger.info('Creating security group with name - %s',
sec_grp_settings.name)
Returns the first security group object of the given name else None
:param neutron: the client
:param name: the name of security group object to retrieve
+ :return: a SNAPS-OO SecurityGroup domain object or None if not found
"""
logger.info('Retrieving security group with name - ' + name)
Returns the first security group object of the given name else None
:param neutron: the client
:param sec_grp_id: the id of the security group to retrieve
+ :return: a SNAPS-OO SecurityGroup domain object or None if not found
"""
logger.info('Retrieving security group with ID - ' + sec_grp_id)
Creates a security group object in OpenStack
:param neutron: the client
:param sec_grp_rule_settings: the security group rule settings
- :return: the security group object
+ :return: a SNAPS-OO SecurityGroupRule domain object
"""
logger.info('Creating security group to security group - %s',
sec_grp_rule_settings.sec_grp_name)
"""
Retrieves all of the rules for a given security group
:param neutron: the client
- :param sec_grp: the SNAPS SecurityGroup object
+ :param sec_grp: a list of SNAPS SecurityGroupRule domain objects
"""
logger.info('Retrieving security group rules associate with the '
'security group - %s', sec_grp.name)
:param neutron: the client
:param sec_grp: the SNAPS SecurityGroup domain object
:param rule_id: the rule's ID
+ :param sec_grp: a SNAPS SecurityGroupRule domain object
"""
rules = neutron.list_security_group_rules(
**{'security_group_id': sec_grp.id})
Returns a list of external OpenStack network object/dict for all external
networks
:param neutron: the client
- :return: a list of external networks (empty list if none configured)
+ :return: a list of external networks of Type SNAPS-OO domain class Network
"""
out = list()
for network in neutron.list_networks(
**{'router:external': True})['networks']:
- out.append({'network': network})
+ out.append(Network(**network))
return out