def create_external_network(mgr_or_client, name=None, shared=True, **kwargs): kwargs['shared'] = shared kwargs['router:external'] = True subnet = kwargs.pop('subnet', None) nobj = Q.net_create(mgr_or_client, name=name, **kwargs) if subnet: Q.subnet_create(mgr_or_client, nobj['id'], **subnet) return Q.net_show(mgr_or_client, nobj['id'])
def create_flat_network(mgr_or_client, name=None, shared=True, **kwargs): subnet = kwargs.pop('subnet', None) kwargs.update({ 'shared': shared, 'provider:network_type': 'flat'}) name = name or Q.data_utils.rand_name('flat-network') nobj = Q.net_create(mgr_or_client, name=name, **kwargs) if subnet: Q.subnet_create(mgr_or_client, nobj['id'], **subnet) return Q.net_show(mgr_or_client, nobj['id'])
def create_vlan_network(mgr_or_client, vlan_id=888, name=None, shared=True, **kwargs): subnet = kwargs.pop('subnet', None) kwargs.update({ 'shared': shared, 'provider:network_type': 'vlan', 'provider:segmentation_id': vlan_id}) name = name or Q.data_utils.rand_name('vlan-%s-network' % vlan_id) nobj = Q.net_create(mgr_or_client, name=name, **kwargs) if subnet: Q.subnet_create(mgr_or_client, nobj['id'], **subnet) return Q.net_show(mgr_or_client, nobj['id'])
def show_or_create_subnet(mgr_or_client, **kwargs): s_args = {} if 'name' in kwargs: s_args['name'] = kwargs.get('name') if 'id' in kwargs: s_args['id'] = kwargs.get('id') sc_list = Q.subnet_list(mgr_or_client, **s_args) if len(sc_list) > 0: return Q.subnet_show(mgr_or_client, sc_list[0]['id']) return Q.subnet_create(mgr_or_client, **kwargs)
def create_subnet(mgr_or_client, network_id, **kwargs): cidr = kwargs.pop('cidr') return Q.subnet_create(mgr_or_client, network_id, cidr, **kwargs)