def update_subnet(self, neutron_subnet, params): type = constants.NETWORK_TYPE_L3 new_name = neutron_subnet.get('name') if params['type']: type = constants.NETWORK_TYPE_L2 nuagedhcpoptions = dhcpoptions.NuageDhcpOptions(self.restproxy) nuagedhcpoptions.update_nuage_dhcp(neutron_subnet, parent_id=params['parent_id'], network_type=type) if type == constants.NETWORK_TYPE_L2 and 'dhcp_ip' in params: nuagel2domtemplate = nuagelib.NuageL2DomTemplate() if neutron_subnet.get('enable_dhcp'): # Enable dhcpmanaged on the l2domain template net = params['net'] data = { "DHCPManaged": neutron_subnet['enable_dhcp'], "address": str(net.ip), "netmask": str(net.netmask), "gateway": params['dhcp_ip'], } response = self.restproxy.rest_call( 'PUT', nuagel2domtemplate.put_resource(params['type']), data) else: # Disable dhcpmanaged on the l2domain template response = self.restproxy.rest_call( 'PUT', nuagel2domtemplate.put_resource(params['type']), {'DHCPManaged': False}) if not nuagel2domtemplate.validate(response): raise restproxy.RESTProxyError(nuagel2domtemplate.error_msg) if new_name: # update the description on the VSD for this subnet if required # If a subnet is updated from horizon, we get the name of the # subnet aswell in the subnet dict for update. if type == constants.NETWORK_TYPE_L2: nuagel2domain = nuagelib.NuageL2Domain() l2dom = self.restproxy.rest_call( 'GET', nuagel2domain.get_resource(params['parent_id']), '') if not nuagel2domain.validate(l2dom): raise restproxy.RESTProxyError(nuagel2domain.error_msg) if nuagel2domain.get_description(l2dom) != new_name: response = self.restproxy.rest_call( 'PUT', nuagel2domain.put_resource(params['parent_id']), {'description': neutron_subnet['name']}) if not nuagel2domain.validate(response): raise restproxy.RESTProxyError(nuagel2domain.error_msg) else: nuagesubn = nuagelib.NuageSubnet() l3dom = self.restproxy.rest_call( 'GET', nuagesubn.get_resource(params['parent_id']), '') if not nuagesubn.validate(l3dom): raise restproxy.RESTProxyError(nuagesubn.error_msg) if nuagesubn.get_description(l3dom) != new_name: response = self.restproxy.rest_call( 'PUT', nuagesubn.put_resource(params['parent_id']), {'description': neutron_subnet['name']}) if not nuagesubn.validate(response): raise restproxy.RESTProxyError(nuagesubn.error_msg)
def vms_on_subnet(self, subnet_id): nuagesubnet = nuagelib.NuageSubnet() response = self.restproxy.rest_call( 'GET', nuagesubnet.vm_get_resource(subnet_id), '') return nuagesubnet.vm_exists(response)
def check_if_l2Dom_in_correct_ent(self, nuage_l2dom_id, nuage_netpart): nuagesubn = nuagelib.NuageSubnet() resp_subn = self.restproxy.rest_call( 'GET', nuagesubn.get_resource(nuage_l2dom_id), '') if not nuagesubn.validate(resp_subn): nuagel2dom = nuagelib.NuageL2Domain() response = self.restproxy.rest_call( 'GET', nuagel2dom.get_resource(nuage_l2dom_id), '') if not nuagel2dom.validate(response): raise restproxy.RESTProxyError(nuagel2dom.error_msg) else: if response[3][0]['parentID'] == nuage_netpart['id']: return True return False else: req_params = {'zone_id': resp_subn[3][0]['parentID']} nuagezone = nuagelib.NuageZone(create_params=req_params) resp_zone = self.restproxy.rest_call('GET', nuagezone.get_resource(), '') if not nuagezone.validate(resp_zone): raise restproxy.RESTProxyError(nuagezone.error_msg) req_params = {'domain_id': resp_zone[3][0]['parentID']} nuage_l3domain = nuagelib.NuageL3Domain(create_params=req_params) dom_resp = self.restproxy.rest_call('GET', nuage_l3domain.get_resource(), '') if not nuage_l3domain.validate(dom_resp): raise restproxy.RESTProxyError(nuage_l3domain.error_msg) if dom_resp[3][0]['parentID'] == nuage_netpart['id']: return True return False
def get_nuage_fip_pool_by_id(self, nuage_subnet_id): nuage_fip_pool = nuagelib.NuageSubnet() response = self.restproxy.get( nuage_fip_pool.get_resource(nuage_subnet_id)) if response: ret = {'nuage_fip_pool_id': response[0]['ID']} return ret else: return None
def delete_resources_created_for_domainsubnet_providernet( restproxy_serv, pg_obj, nuage_subn_id, neutron_subn_id): # Get vports on the given nuage domain subnet nuagel3domsub = nuagelib.NuageSubnet() bridge_vports = restproxy_serv.rest_call( 'GET', nuagel3domsub.get_all_vports(nuage_subn_id), '', nuagel3domsub.extra_headers_vport_get()) if not nuagel3domsub.validate(bridge_vports): raise restproxy.RESTProxyError(nuagel3domsub.error_msg) # Delete bridge interface and bridge vport if it is subnet created for # provider net if bridge_vports and bridge_vports[3]: nuage_vport = nuagelib.NuageVPort() vport = bridge_vports[VSD_RESP_OBJ][0] bridge_iface = restproxy_serv.rest_call( 'GET', nuage_vport.post_bridge_interface(vport['ID']), '') if not nuage_vport.validate(bridge_iface): raise restproxy.RESTProxyError(nuage_vport.error_msg) if bridge_iface and bridge_iface[VSD_RESP_OBJ]: bridge_iface_id = \ bridge_iface[constants.VSD_RESP_OBJ][0]['ID'] restproxy_serv.rest_call( 'DELETE', nuage_vport.del_bridge_interface(bridge_iface_id), '') # Delete bridge vport nuage_vport = nuagelib.NuageVPort({'vport_id': vport['ID']}) restproxy_serv.rest_call( 'DELETE', nuage_vport.get_resource(), '') # Delete vlan obj on gateway port delete_vlan_for_gw_port(restproxy_serv, vport) # Get defaultPG on nuage domain and delete if it is subnet created for # providernet if bridge_vports: nuage_dom_id = helper.get_domain_id_by_nuage_subnet_id( restproxy_serv, nuage_subn_id) params = { 'domain_id': nuage_dom_id } nuage_policygroup = nuagelib.NuagePolicygroup(create_params=params) pg_name = 'defaultPG-' + neutron_subn_id nuage_policygroups = restproxy_serv.get( nuage_policygroup.post_resource(), extra_headers=nuage_policygroup.extra_headers_get_name(pg_name)) if nuage_policygroups: nuage_policygroup_id = nuage_policygroups[0]['ID'] if nuage_policygroup_id: pg_obj._delete_policy_group(nuage_policygroup_id)
def _get_nuage_domain_id_from_subnet(restproxy_serv, nuage_subnet_id): nuagesubn = nuagelib.NuageSubnet() l3subnet = restproxy_serv.get(nuagesubn.get_resource(nuage_subnet_id), required=True)[0] nuage_zone_id = l3subnet['parentID'] req_params = {'zone_id': nuage_zone_id} nuagezone = nuagelib.NuageZone(create_params=req_params) zone = restproxy_serv.get(nuagezone.get_resource(), required=True)[0] return zone['parentID']
def update_nuage_subnet(self, nuage_id, params): req_params = {} if params.get('subnet_name'): req_params['description'] = params['subnet_name'] if params.get('gateway_ip'): req_params['gateway'] = params.get('gateway_ip') if not req_params: return nuagel3domsub = nuagelib.NuageSubnet() self.restproxy.put(nuagel3domsub.put_resource(nuage_id), req_params)
def get_nuage_subnet(restproxy_serv, subnet_mapping): if subnet_mapping is None: return None nuage_subnet_id = subnet_mapping["nuage_subnet_id"] if subnet_mapping['nuage_l2dom_tmplt_id']: resource_class = nuagelib.NuageL2Domain() else: resource_class = nuagelib.NuageSubnet() subnets = restproxy_serv.get(resource_class.get_resource(nuage_subnet_id)) return subnets[0] if subnets else None
def _create_subnet(self, req_params, extra_params): nuagel3domsub = nuagelib.NuageSubnet(create_params=req_params, extra_params=extra_params) ignore_error_codes = [constants.RES_EXISTS_INTERNAL_ERR_CODE, constants.SUBNET_NAME_DUPLICATE_ERROR] return self.restproxy.post( nuagel3domsub.post_resource(), nuagel3domsub.post_data(), on_res_exists=self.restproxy.retrieve_by_ext_id_and_cidr, ignore_err_codes=ignore_error_codes)[0]
def delete_domain_subnet(self, nuage_subn_id, neutron_subn_id, pnet_binding): nuagel3domsub = nuagelib.NuageSubnet() if pnet_binding: pnet_helper.delete_resources_created_for_domainsubnet_providernet( self.restproxy, self.policygroups, nuage_subn_id, neutron_subn_id) # Delete domain_subnet self.restproxy.rest_call('DELETE', nuagel3domsub.delete_resource(nuage_subn_id), '')
def _delete_extra_perm_attached(self, tenant, l2dom_id=None, l3dom_id=None): if l2dom_id: create_params = {'l2dom_id': l2dom_id} self._delete_vsd_permission_of_tenant(create_params, tenant) else: nuagesubnet = nuagelib.NuageSubnet() subnet = self.restproxy.get(nuagesubnet.get_resource(l3dom_id), required=True)[0] create_params = {'zone_id': subnet['parentID']} self._delete_vsd_permission_of_tenant(create_params, tenant)
def nuage_vports_on_subnet(self, subnet_id, pnet_binding): nuagesubnet = nuagelib.NuageSubnet() if pnet_binding: response = self.restproxy.rest_call( 'GET', nuagesubnet.get_all_vports(subnet_id), '', extra_headers=( nuagesubnet.extra_headers_host_and_vm_vport_get())) else: response = self.restproxy.rest_call( 'GET', nuagesubnet.get_all_vports(subnet_id), '') return nuagesubnet.get_validate(response)
def get_nuage_cidr(self, nuage_subnetid): nuagesubn = nuagelib.NuageSubnet() response = self.restproxy.rest_call( 'GET', nuagesubn.get_resource(nuage_subnetid), '') if not nuagesubn.validate(response): nuagel2dom = nuagelib.NuageL2Domain() response = self.restproxy.rest_call( 'GET', nuagel2dom.get_resource(nuage_subnetid), '') if not nuagel2dom.validate(response): raise restproxy.RESTProxyError(nuagel2dom.error_msg) return nuagel2dom.get_cidr_info(response) else: return nuagesubn.get_cidr_info(response)
def get_domain_id_by_nuage_subnet_id(restproxy_serv, nuage_subn_id, required=False): nuagel3domsub = nuagelib.NuageSubnet() nuage_subn = restproxy_serv.get( nuagel3domsub.get_resource(nuage_subn_id), required=required) if not nuage_subn: return params = {'zone_id': nuage_subn[0]['parentID']} nuagezone = nuagelib.NuageZone(create_params=params) nuage_zones = restproxy_serv.get(nuagezone.get_resource(), required=required) return nuage_zones[0]['parentID'] if nuage_zones else None
def get_nuage_subnet(restproxy_serv, subnet_mapping): if subnet_mapping is None: return None params = {'externalID': get_vsd_external_id(subnet_mapping["subnet_id"])} nuage_subnet_id = subnet_mapping["nuage_subnet_id"] if subnet_mapping['nuage_l2dom_tmplt_id']: resource_class = nuagelib.NuageL2Domain(create_params=params) else: resource_class = nuagelib.NuageSubnet(create_params=params) try: response = restproxy_serv.get( resource_class.get_resource(nuage_subnet_id)) return response[0] except restproxy.RESTProxyError: return None
def _get_nuage_domain_id_from_subnet(restproxy_serv, nuage_subnet_id): nuagesubn = nuagelib.NuageSubnet() nuage_subnet = restproxy_serv.rest_call( 'GET', nuagesubn.get_resource(nuage_subnet_id), '') if not nuagesubn.validate(nuage_subnet): raise restproxy.RESTProxyError(nuagesubn.error_msg) nuage_zone_id = nuagesubn.get_parentzone(nuage_subnet) req_params = {'zone_id': nuage_zone_id} nuagezone = nuagelib.NuageZone(create_params=req_params) nuage_zone = restproxy_serv.rest_call('GET', nuagezone.get_resource(), '') if not nuagezone.validate(nuage_zone): raise restproxy.RESTProxyError(nuagezone.error_msg) nuage_domain_id = nuagezone.get_response_parentid(nuage_zone) return nuage_domain_id
def _delete_extra_perm_attached(self, tenant, l2dom_id=None, l3dom_id=None): if l2dom_id: create_params = {'l2dom_id': l2dom_id} self._delete_vsd_permission_of_tenant(create_params, tenant) else: nuagesubnet = nuagelib.NuageSubnet() response = self.restproxy.rest_call( 'GET', nuagesubnet.get_resource(l3dom_id), '') if not nuagesubnet.get_validate(response): raise restproxy.RESTProxyError( nuagesubnet.error_msg, nuagesubnet.vsd_error_code) subnet = nuagesubnet.get_response_obj(response) create_params = {'zone_id': subnet['parentID']} self._delete_vsd_permission_of_tenant(create_params, tenant)
def attach_nuage_group_to_nuagenet(self, tenant, nuage_npid, nuage_subnetid, shared): nuage_uid, nuage_gid = helper.create_usergroup(self.restproxy, tenant, nuage_npid) nuagesubn = nuagelib.NuageSubnet() nuagegroup = nuagelib.NuageGroup() if shared: # Get the id for grp 'everybody' params = {'net_partition_id': nuage_npid} nuagegroup = nuagelib.NuageGroup(create_params=params) response = self.restproxy.rest_call( 'GET', nuagegroup.list_resource(), '', nuagegroup.extra_headers_get_for_everybody()) if not nuagegroup.validate(response): raise restproxy.RESTProxyError(nuagegroup.error_msg) nuage_all_groupid = nuagegroup.get_groupid(response) response = self.restproxy. \ rest_call('GET', nuagesubn.get_resource(nuage_subnetid), '') if not nuagesubn.validate(response): nuagel2dom = nuagelib.NuageL2Domain() response = self.restproxy. \ rest_call('GET', nuagel2dom.get_resource(nuage_subnetid), '') if not nuagel2dom.validate(response): raise restproxy.RESTProxyError(nuagel2dom.error_msg) if shared: self.create_permission(nuage_subnetid, nuage_all_groupid, tenant, perm_on='l2domains') else: self.create_permission(nuage_subnetid, nuage_gid, tenant, perm_on='l2domains') return nuage_uid, nuage_gid else: if shared: self.create_permission(nuagesubn.get_parentzone(response), nuage_all_groupid, tenant) else: self.create_permission(nuagesubn.get_parentzone(response), nuage_gid, tenant) return nuage_uid, nuage_gid
def get_domain_subnet_by_ext_id_and_cidr(restproxy_serv, neutron_subnet): params = { 'externalID': get_subnet_external_id(neutron_subnet), 'cidr': netaddr.IPNetwork(neutron_subnet['cidr']), 'ip_type': neutron_subnet['ip_version'] } nuagesubnet = nuagelib.NuageSubnet(create_params=params) subnet = restproxy_serv.get( nuagesubnet.get_all_resources(), extra_headers=nuagesubnet.extra_headers_ext_id_and_cidr_get()) if subnet: return subnet[0] else: msg = ("Cannot find subnet with externalID {} and cidr {}" " in L3domains on VSD").format(params['externalID'], params['cidr']) raise restproxy.ResourceNotFoundException(msg)
def detach_nuage_group_to_nuagenet(self, tenants, nuage_subnetid, shared): nuagesubn = nuagelib.NuageSubnet() response = self.restproxy.rest_call( 'GET', nuagesubn.get_resource(nuage_subnetid), '') if not nuagesubn.validate(response): nuagel2dom = nuagelib.NuageL2Domain() response = self.restproxy.rest_call( 'GET', nuagel2dom.get_resource(nuage_subnetid), '') if not nuagel2dom.validate(response): # This is the case where the VSD-Managed subnet is deleted # from VSD first and then neutron subnet-delete operation # is performed from openstack # for both l2/l3 case we'll return form here return params = {'l2dom_id': nuage_subnetid} nuagepermission = nuagelib.NuagePermission(create_params=params) resource = nuagepermission.get_resource_by_l2dom_id() else: zone_id = nuagesubn.get_parentzone(response) params = {'zone_id': zone_id} nuagepermission = nuagelib.NuagePermission(create_params=params) resource = nuagepermission.get_resource_by_zone_id() nuage_dom = helper.get_nuage_domain_by_zoneid( self.restproxy, zone_id) if nuage_dom['externalID']: # The perm. attached to the zone when the router is deleted # from openstack return response = self.restproxy.rest_call('GET', resource, '') if not nuagepermission.validate(response): if response[0] == constants.RES_NOT_FOUND: return raise restproxy.RESTProxyError(nuagepermission.error_msg, nuagepermission.vsd_error_code) permissions = response[3] if shared: tenants.append("Everybody") for permission in permissions: if permission['permittedEntityName'] in tenants: self.restproxy.delete( nuagepermission.delete_resource(permission['ID']))
def detach_nuage_group_to_nuagenet(self, tenants, nuage_subnetid, shared): nuagesubn = nuagelib.NuageSubnet() try: subnet = self.restproxy.get(nuagesubn.get_resource(nuage_subnetid), required=True)[0] except restproxy.ResourceNotFoundException: nuagel2dom = nuagelib.NuageL2Domain() try: self.restproxy.get(nuagel2dom.get_resource(nuage_subnetid), required=True) except restproxy.ResourceNotFoundException: # This is the case where the VSD-Managed subnet is deleted # from VSD first and then neutron subnet-delete operation # is performed from openstack # for both l2/l3 case we'll return form here return params = {'l2dom_id': nuage_subnetid} nuagepermission = nuagelib.NuagePermission(create_params=params) resource = nuagepermission.get_resource_by_l2dom_id() else: zone_id = subnet['parentID'] params = {'zone_id': zone_id} nuagepermission = nuagelib.NuagePermission(create_params=params) resource = nuagepermission.get_resource_by_zone_id() nuage_dom = helper.get_nuage_domain_by_zoneid( self.restproxy, zone_id) if nuage_dom['externalID']: # The perm. attached to the zone when the router is deleted # from openstack return try: permissions = self.restproxy.get(resource, required=True) except restproxy.ResourceNotFoundException as e: if e.code == constants.RES_NOT_FOUND: return raise nuagepermission.get_rest_proxy_error() if shared: tenants.append("Everybody") for permission in permissions: if permission['permittedEntityName'] in tenants: self.restproxy.delete( nuagepermission.delete_resource(permission['ID']))
def check_if_l2_dom_in_correct_ent(self, nuage_l2dom_id, nuage_netpart): nuagesubn = nuagelib.NuageSubnet() try: subnet = self.restproxy.get(nuagesubn.get_resource(nuage_l2dom_id), required=True)[0] except restproxy.ResourceNotFoundException: nuagel2dom = nuagelib.NuageL2Domain() l2_dom = self.restproxy.get( nuagel2dom.get_resource(nuage_l2dom_id), required=True)[0] return l2_dom['parentID'] == nuage_netpart['id'] else: req_params = {'zone_id': subnet['parentID']} nuagezone = nuagelib.NuageZone(create_params=req_params) zone = self.restproxy.get(nuagezone.get_resource(), required=True)[0] req_params = {'domain_id': zone['parentID']} nuage_l3domain = nuagelib.NuageL3Domain(create_params=req_params) l3_dom = self.restproxy.get(nuage_l3domain.get_resource(), required=True)[0] return l3_dom['parentID'] == nuage_netpart['id']
def create_domain_subnet(self, vsd_zone, os_subnet, pnet_binding): req_params = { 'name': os_subnet['id'], 'net': netaddr.IPNetwork(os_subnet['cidr']), 'zone': vsd_zone['ID'], 'gateway': os_subnet['gateway_ip'], 'externalID': get_vsd_external_id(os_subnet['id']) } extra_params = { 'description': os_subnet.get('name'), 'entityState': 'UNDER_CONSTRUCTION' } nuagel3domsub = nuagelib.NuageSubnet(create_params=req_params, extra_params=extra_params) vsd_subnet = self.restproxy.post(nuagel3domsub.post_resource(), nuagel3domsub.post_data())[0] nuagedhcpoptions = dhcpoptions.NuageDhcpOptions(self.restproxy) nuagedhcpoptions.create_nuage_dhcp( os_subnet, parent_id=vsd_subnet['ID'], network_type=constants.NETWORK_TYPE_L3) if pnet_binding: # Get netpart id needed in process_provider_network to check the # gateway port enterprise permissions req_params = {'domain_id': vsd_zone['parentID']} nuage_l3domain = nuagelib.NuageL3Domain(create_params=req_params) domain = self.restproxy.get(nuage_l3domain.get_resource())[0] np_id = helper.get_l3domain_np_id(self.restproxy, domain['ID']) pnet_params = { 'pnet_binding': pnet_binding, 'nuage_subnet_id': vsd_subnet['ID'], 'netpart_id': np_id, 'neutron_subnet_id': os_subnet['id'] } pnet_helper.process_provider_network(self.restproxy, self.policygroups, pnet_params) return vsd_subnet
def get_subnet_by_externalID(restproxy_serv, subnet_id): req_params = {'externalID': get_vsd_external_id(subnet_id)} nuage_subnet = None nuage_l2_domain = nuagelib.NuageL2Domain(create_params=req_params) response = restproxy_serv.rest_call('GET', nuage_l2_domain.get_all_resources(), '', nuage_l2_domain.extra_headers_get()) if nuage_l2_domain.get_validate(response): nuage_subnet = nuage_l2_domain.get_response_obj(response) nuage_subnet['type'] = constants.L2DOMAIN else: nuage_domainsubn = nuagelib.NuageSubnet(create_params=req_params) response = restproxy_serv.rest_call( 'GET', nuage_domainsubn.get_all_resources(), '', nuage_l2_domain.extra_headers_get()) if nuage_domainsubn.get_validate(response): nuage_subnet = nuage_domainsubn.get_response_obj(response) nuage_subnet['type'] = constants.SUBNET return nuage_subnet
def attach_nuage_group_to_nuagenet(self, tenant, nuage_npid, nuage_subnetid, shared, tenant_name): nuage_uid, nuage_gid = helper.create_usergroup(self.restproxy, tenant, nuage_npid, tenant_name) nuagesubn = nuagelib.NuageSubnet() if shared: # Get the id for grp 'everybody' params = {'net_partition_id': nuage_npid} nuagegroup = nuagelib.NuageGroup(create_params=params) groups = self.restproxy.get( nuagegroup.list_resource(), extra_headers=nuagegroup.extra_headers_get_for_everybody(), required=True) nuage_all_groupid = groups[0]['ID'] if groups else None try: subnet = self.restproxy.get(nuagesubn.get_resource(nuage_subnetid), required=True)[0] except restproxy.ResourceNotFoundException: nuagel2dom = nuagelib.NuageL2Domain() self.restproxy.get(nuagel2dom.get_resource(nuage_subnetid), required=True) if shared: self.create_permission(nuage_subnetid, nuage_all_groupid, tenant, perm_on='l2domains') else: self.create_permission(nuage_subnetid, nuage_gid, tenant, perm_on='l2domains') return nuage_uid, nuage_gid else: if shared: self.create_permission(subnet['parentID'], nuage_all_groupid, tenant) else: self.create_permission(subnet['parentID'], nuage_gid, tenant) return nuage_uid, nuage_gid
def get_nuage_vport_by_neutron_id(restproxy_serv, params, required=True): req_params = {'externalID': get_vsd_external_id(params['neutron_port_id'])} l2domid = params.get('l2dom_id') l3domid = params.get('l3dom_id') vports = '' if l2domid: nuagel2domain = nuagelib.NuageL2Domain(create_params=req_params) vports = restproxy_serv.get( nuagel2domain.get_all_vports(l2domid), extra_headers=nuagel2domain.extra_headers_get()) if not vports and l3domid: nuagel3domsub = nuagelib.NuageSubnet(create_params=req_params) vports = restproxy_serv.get( nuagel3domsub.get_all_vports(l3domid), extra_headers=nuagel3domsub.extra_headers_get()) if not vports and required: raise restproxy.ResourceNotFoundException( "vport for port '%s' not found" % params['neutron_port_id']) return vports[0] if vports else None
def update_domain_subnet(self, nuage_subnet_id, params): updates = {} if params.get('dhcp_enable_changed'): if params.get('ip_type') == constants.IPV4: updates['enableDHCPv4'] = params["subnet_enable_dhcp"] else: updates['enableDHCPv6'] = params["subnet_enable_dhcp"] if params.get('dualstack'): if params.get('network_name'): updates['description'] = params['network_name'] else: if params.get('subnet_name'): updates['description'] = params['subnet_name'] if params.get("subnet_nuage_underlay"): nuage_pat, nuage_underlay = self._calculate_pat_and_underlay( params["subnet_nuage_underlay"]) updates['PATEnabled'] = nuage_pat updates['underlayEnabled'] = nuage_underlay if updates: nuagel3domsub = nuagelib.NuageSubnet() self.restproxy.put(nuagel3domsub.put_resource( nuage_subnet_id), updates)
def get_l3subnet(restproxy_serv, nuage_id, required=False): nuagesubnet = nuagelib.NuageSubnet() subnets = restproxy_serv.get(nuagesubnet.get_resource(nuage_id), required=required) return subnets[0] if subnets else None
def nuage_vports_on_subnet(self, nuage_subnet_id): nuagesubnet = nuagelib.NuageSubnet() vports = self.restproxy.get( nuagesubnet.get_all_vports(nuage_subnet_id)) return len(vports > 0)
def vms_on_subnet(self, nuage_subnet_id): nuagesubnet = nuagelib.NuageSubnet() response = self.restproxy.get( nuagesubnet.vm_get_resource(nuage_subnet_id)) return response