idx
int64
0
63k
question
stringlengths
53
5.28k
target
stringlengths
5
805
37,900
def l3_tenant_id ( cls ) : if cls . _l3_tenant_uuid is None : if hasattr ( cfg . CONF . keystone_authtoken , 'project_domain_id' ) : cls . _l3_tenant_uuid = cls . _get_tenant_id_using_keystone_v3 ( ) else : cls . _l3_tenant_uuid = cls . _get_tenant_id_using_keystone_v2 ( ) return cls . _l3_tenant_uuid
Returns id of tenant owning hosting device resources .
37,901
def mgmt_nw_id ( cls ) : if cls . _mgmt_nw_uuid is None : tenant_id = cls . l3_tenant_id ( ) if not tenant_id : return net = bc . get_plugin ( ) . get_networks ( bc . context . get_admin_context ( ) , { 'tenant_id' : [ tenant_id ] , 'name' : [ cfg . CONF . general . management_network ] } , [ 'id' , 'subnets' ] ) if le...
Returns id of the management network .
37,902
def mgmt_sec_grp_id ( cls ) : if not extensions . is_extension_supported ( bc . get_plugin ( ) , "security-group" ) : return if cls . _mgmt_sec_grp_id is None : tenant_id = cls . l3_tenant_id ( ) res = bc . get_plugin ( ) . get_security_groups ( bc . context . get_admin_context ( ) , { 'tenant_id' : [ tenant_id ] , 'na...
Returns id of security group used by the management network .
37,903
def delete_all_hosting_devices ( self , context , force_delete = False ) : for item in self . _get_collection_query ( context , hd_models . HostingDeviceTemplate ) : self . delete_all_hosting_devices_by_template ( context , template = item , force_delete = force_delete )
Deletes all hosting devices .
37,904
def _process_non_responsive_hosting_device ( self , context , hosting_device ) : if ( hosting_device [ 'template' ] [ 'host_category' ] == VM_CATEGORY and hosting_device [ 'auto_delete' ] ) : self . _delete_dead_service_vm_hosting_device ( context , hosting_device ) return True return False
Host type specific processing of non responsive hosting devices .
37,905
def _create_hosting_device_templates_from_config ( self ) : hdt_dict = config . get_specific_config ( 'cisco_hosting_device_template' ) attr_info = ciscohostingdevicemanager . RESOURCE_ATTRIBUTE_MAP [ ciscohostingdevicemanager . DEVICE_TEMPLATES ] adm_context = bc . context . get_admin_context ( ) for hdt_uuid , kv_dic...
To be called late during plugin initialization so that any hosting device templates defined in the config file is properly inserted in the DB .
37,906
def _create_hosting_devices_from_config ( self ) : hd_dict = config . get_specific_config ( 'cisco_hosting_device' ) attr_info = ciscohostingdevicemanager . RESOURCE_ATTRIBUTE_MAP [ ciscohostingdevicemanager . DEVICES ] adm_context = bc . context . get_admin_context ( ) for hd_uuid , kv_dict in hd_dict . items ( ) : hd...
To be called late during plugin initialization so that any hosting device specified in the config file is properly inserted in the DB .
37,907
def add_router_to_hosting_device ( self , client , hosting_device_id , body ) : res_path = hostingdevice . HostingDevice . resource_path return client . post ( ( res_path + DEVICE_L3_ROUTERS ) % hosting_device_id , body = body )
Adds a router to hosting device .
37,908
def remove_router_from_hosting_device ( self , client , hosting_device_id , router_id ) : res_path = hostingdevice . HostingDevice . resource_path return client . delete ( ( res_path + DEVICE_L3_ROUTERS + "/%s" ) % ( hosting_device_id , router_id ) )
Remove a router from hosting_device .
37,909
def list_routers_on_hosting_device ( self , client , hosting_device_id , ** _params ) : res_path = hostingdevice . HostingDevice . resource_path return client . get ( ( res_path + DEVICE_L3_ROUTERS ) % hosting_device_id , params = _params )
Fetches a list of routers hosted on a hosting device .
37,910
def list_hosting_devices_hosting_routers ( self , client , router_id , ** _params ) : return client . get ( ( client . router_path + L3_ROUTER_DEVICES ) % router_id , params = _params )
Fetches a list of hosting devices hosting a router .
37,911
def setup_client_rpc ( self ) : self . clnt = rpc . DfaRpcClient ( self . _url , constants . DFA_SERVER_QUEUE , exchange = constants . DFA_EXCHANGE )
Setup RPC client for dfa agent .
37,912
def setup_rpc ( self ) : endpoints = RpcCallBacks ( self . _vdpm , self . _iptd ) self . server = rpc . DfaRpcServer ( self . _qn , self . _my_host , self . _url , endpoints , exchange = constants . DFA_EXCHANGE )
Setup RPC server for dfa agent .
37,913
def _add_rid_to_vrf_list ( self , ri ) : if ri . ex_gw_port or ri . router . get ( 'gw_port' ) : driver = self . driver_manager . get_driver ( ri . id ) vrf_name = driver . _get_vrf_name ( ri ) if not vrf_name : return if not self . _router_ids_by_vrf . get ( vrf_name ) : LOG . debug ( "++ CREATING VRF %s" % vrf_name )...
Add router ID to a VRF list .
37,914
def _remove_rid_from_vrf_list ( self , ri ) : if ri . ex_gw_port or ri . router . get ( 'gw_port' ) : driver = self . driver_manager . get_driver ( ri . id ) vrf_name = driver . _get_vrf_name ( ri ) if self . _router_ids_by_vrf . get ( vrf_name ) and ( ri . router [ 'id' ] in self . _router_ids_by_vrf [ vrf_name ] ) : ...
Remove router ID from a VRF list .
37,915
def _internal_network_removed ( self , ri , port , ex_gw_port ) : itfc_deleted = False driver = self . driver_manager . get_driver ( ri . id ) vrf_name = driver . _get_vrf_name ( ri ) network_name = ex_gw_port [ 'hosting_info' ] . get ( 'network_name' ) if self . _router_ids_by_vrf_and_ext_net . get ( vrf_name , { } ) ...
Remove an internal router port
37,916
def do_list_organizations ( self , line ) : org_list = self . dcnm_client . list_organizations ( ) if not org_list : print ( 'No organization found.' ) return org_table = PrettyTable ( [ 'Organization Name' ] ) for org in org_list : org_table . add_row ( [ org [ 'organizationName' ] ] ) print ( org_table )
Get list of organization on DCNM .
37,917
def create_routertype ( self , context , routertype ) : LOG . debug ( "create_routertype() called. Contents %s" , routertype ) rt = routertype [ 'routertype' ] with context . session . begin ( subtransactions = True ) : routertype_db = l3_models . RouterType ( id = self . _get_id ( rt ) , tenant_id = rt [ 'tenant_id' ]...
Creates a router type .
37,918
def associate_hosting_device_with_config_agent ( self , client , config_agent_id , body ) : return client . post ( ( ConfigAgentHandlingHostingDevice . resource_path + CFG_AGENT_HOSTING_DEVICES ) % config_agent_id , body = body )
Associates a hosting_device with a config agent .
37,919
def disassociate_hosting_device_with_config_agent ( self , client , config_agent_id , hosting_device_id ) : return client . delete ( ( ConfigAgentHandlingHostingDevice . resource_path + CFG_AGENT_HOSTING_DEVICES + "/%s" ) % ( config_agent_id , hosting_device_id ) )
Disassociates a hosting_device with a config agent .
37,920
def list_hosting_device_handled_by_config_agent ( self , client , cfg_agent_id , ** _params ) : return client . get ( ( ConfigAgentHandlingHostingDevice . resource_path + CFG_AGENT_HOSTING_DEVICES ) % cfg_agent_id , params = _params )
Fetches a list of hosting devices handled by a config agent .
37,921
def list_config_agents_handling_hosting_device ( self , client , hosting_device_id , ** _params ) : resource_path = '/dev_mgr/hosting_devices/%s' return client . get ( ( resource_path + HOSTING_DEVICE_CFG_AGENTS ) % hosting_device_id , params = _params )
Fetches a list of config agents handling a hosting device .
37,922
def _parse_nexus_vni_range ( self , tunnel_range ) : for ident in tunnel_range : if not self . _is_valid_nexus_vni ( ident ) : raise exc . NetworkTunnelRangeError ( tunnel_range = tunnel_range , error = _ ( "%(id)s is not a valid Nexus VNI value." ) % { 'id' : ident } ) if tunnel_range [ 1 ] < tunnel_range [ 0 ] : rais...
Raise an exception for invalid tunnel range or malformed range .
37,923
def sync_allocations ( self ) : vxlan_vnis = set ( ) for tun_min , tun_max in self . tunnel_ranges : vxlan_vnis |= set ( six . moves . range ( tun_min , tun_max + 1 ) ) session = bc . get_writer_session ( ) with session . begin ( subtransactions = True ) : allocs = ( session . query ( nexus_models_v2 . NexusVxlanAlloca...
Synchronize vxlan_allocations table with configured tunnel ranges .
37,924
def _setup_notification_listener ( self , topic_name , url ) : self . notify_listener = rpc . DfaNotifcationListener ( topic_name , url , rpc . DfaNotificationEndpoints ( self ) )
Setup notification listener for a service .
37,925
def callback ( self , timestamp , event_type , payload ) : try : data = ( event_type , payload ) LOG . debug ( 'RX NOTIFICATION ==>\nevent_type: %(event)s, ' 'payload: %(payload)s\n' , ( { 'event' : event_type , 'payload' : payload } ) ) if 'create' in event_type : pri = self . _create_pri elif 'delete' in event_type :...
Callback method for processing events in notification queue .
37,926
def event_handler ( self ) : if not self . _notify_queue : LOG . error ( 'event_handler: no notification queue for %s' , self . _service_name ) return LOG . debug ( 'calling event handler for %s' , self ) self . start ( ) self . wait ( )
Wait on queue for listening to the events .
37,927
def set_driver ( self , resource ) : try : resource_id = resource [ 'id' ] hosting_device = resource [ 'hosting_device' ] hd_id = hosting_device [ 'id' ] if hd_id in self . _hosting_device_routing_drivers_binding : driver = self . _hosting_device_routing_drivers_binding [ hd_id ] self . _drivers [ resource_id ] = drive...
Set the driver for a neutron resource .
37,928
def _import_ucsmsdk ( self ) : if not CONF . ml2_cisco_ucsm . ucsm_https_verify : LOG . warning ( const . SSL_WARNING ) from networking_cisco . ml2_drivers . ucsm import ucs_ssl ucs_driver = importutils . import_module ( 'ucsmsdk.ucsdriver' ) ucs_driver . ssl = ucs_ssl class ucsmsdk ( object ) : handle = importutils . ...
Imports the ucsmsdk module .
37,929
def ucs_manager_connect ( self , ucsm_ip ) : if not self . ucsmsdk : self . ucsmsdk = self . _import_ucsmsdk ( ) ucsm = CONF . ml2_cisco_ucsm . ucsms . get ( ucsm_ip ) if not ucsm or not ucsm . ucsm_username or not ucsm . ucsm_password : LOG . error ( 'UCS Manager network driver failed to get login ' 'credentials for U...
Connects to a UCS Manager .
37,930
def _create_vlanprofile ( self , handle , vlan_id , ucsm_ip ) : vlan_name = self . make_vlan_name ( vlan_id ) vlan_profile_dest = ( const . VLAN_PATH + const . VLAN_PROFILE_PATH_PREFIX + vlan_name ) try : vp1 = handle . query_dn ( const . VLAN_PATH ) if not vp1 : LOG . warning ( 'UCS Manager network driver Vlan Profile...
Creates VLAN profile to able associated with the Port Profile .
37,931
def nova_services_up ( self ) : required = set ( [ 'nova-conductor' , 'nova-cert' , 'nova-scheduler' , 'nova-compute' ] ) try : services = self . _nclient . services . list ( ) except Exception as e : LOG . error ( 'Failure determining running Nova services: %s' , e ) return False return not bool ( required . differenc...
Checks if required Nova services are up and running .
37,932
def _get_unscheduled_routers ( self , plugin , context ) : if NEUTRON_VERSION . version [ 0 ] <= NEUTRON_NEWTON_VERSION . version [ 0 ] : context , plugin = plugin , context no_agent_binding = ~ sql . exists ( ) . where ( bc . Router . id == bc . rb_model . RouterL3AgentBinding . router_id ) ns_routertype_id = plugin ....
Get routers with no agent binding .
37,933
def _filter_unscheduled_routers ( self , plugin , context , routers ) : if NEUTRON_VERSION . version [ 0 ] <= NEUTRON_NEWTON_VERSION . version [ 0 ] : context , plugin = plugin , context unscheduled_routers = [ ] for router in routers : if ( router [ routertype . TYPE_ATTR ] != plugin . get_namespace_router_type_id ( c...
Filter from list of routers the ones that are not scheduled .
37,934
def _get_underscheduled_routers ( self , plugin , context ) : underscheduled_routers = [ ] max_agents_for_ha = plugin . get_number_of_agents_for_scheduling ( context ) for router , count in plugin . get_routers_l3_agents_count ( context ) : if ( router [ routertype . TYPE_ATTR ] != plugin . get_namespace_router_type_id...
For release > = pike .
37,935
def auto_schedule_hosting_devices ( self , plugin , context , agent_host ) : query = context . session . query ( bc . Agent ) query = query . filter_by ( agent_type = c_constants . AGENT_TYPE_CFG , host = agent_host , admin_state_up = True ) try : cfg_agent_db = query . one ( ) except ( exc . MultipleResultsFound , exc...
Schedules unassociated hosting devices to Cisco cfg agent .
37,936
def _get_external_network_dict ( self , context , port_db ) : if port_db . device_owner == DEVICE_OWNER_ROUTER_GW : network = self . _core_plugin . get_network ( context , port_db . network_id ) else : router = self . l3_plugin . get_router ( context , port_db . device_id ) ext_gw_info = router . get ( EXTERNAL_GW_INFO...
Get external network information
37,937
def apic_driver ( self ) : if not self . _apic_driver : try : self . _apic_driver = ( bc . get_plugin ( 'GROUP_POLICY' ) . policy_driver_manager . policy_drivers [ 'apic' ] . obj ) self . _get_ext_net_name = self . _get_ext_net_name_gbp self . _get_vrf_context = self . _get_vrf_context_gbp except AttributeError : LOG ....
Get APIC driver
37,938
def _snat_subnet_for_ext_net ( self , context , subnet , net ) : if subnet [ 'network_id' ] == net [ 'id' ] : return True network = self . _core_plugin . get_network ( context . elevated ( ) , subnet [ 'network_id' ] ) ext_net_name = network [ 'name' ] if ( APIC_SNAT_NET + '-' ) in ext_net_name : ext_net_name = ext_net...
Determine if an SNAT subnet is for this external network .
37,939
def extend_hosting_port_info ( self , context , port_db , hosting_device , hosting_info ) : if hosting_info . get ( 'segmentation_id' ) is None : LOG . debug ( 'No segmentation ID in hosting_info -- assigning' ) hosting_info [ 'segmentation_id' ] = ( port_db . hosting_info . get ( 'segmentation_id' ) ) is_external = ( ...
Get the segmenetation ID and interface
37,940
def allocate_hosting_port ( self , context , router_id , port_db , network_type , hosting_device_id ) : if port_db . get ( 'device_owner' ) == DEVICE_OWNER_ROUTER_GW : ext_dict , net = self . _get_external_network_dict ( context , port_db ) if net and net . get ( 'provider:network_type' ) == 'opflex' : if ext_dict . ge...
Get the VLAN and port for this hosting device
37,941
def _get_ext_net_name_gbp ( self , network_name ) : prefix = network_name [ : re . search ( UUID_REGEX , network_name ) . start ( ) - 1 ] return prefix . strip ( APIC_OWNED )
Get the external network name
37,942
def is_valid_mac ( addr ) : addrs = addr . split ( ':' ) if len ( addrs ) != 6 : return False for m in addrs : try : if int ( m , 16 ) > 255 : return False except ValueError : return False return True
Check the syntax of a given mac address .
37,943
def make_cidr ( gw , mask ) : try : int_mask = ( 0xFFFFFFFF << ( 32 - int ( mask ) ) ) & 0xFFFFFFFF gw_addr_int = struct . unpack ( '>L' , socket . inet_aton ( gw ) ) [ 0 ] & int_mask return ( socket . inet_ntoa ( struct . pack ( "!I" , gw_addr_int ) ) + '/' + str ( mask ) ) except ( socket . error , struct . error , V...
Create network address in CIDR format .
37,944
def find_agent_host_id ( this_host ) : host_id = this_host try : for root , dirs , files in os . walk ( '/run/resource-agents' ) : for fi in files : if 'neutron-scale-' in fi : host_id = 'neutron-n-' + fi . split ( '-' ) [ 2 ] break return host_id except IndexError : return host_id
Returns the neutron agent host id for RHEL - OSP6 HA setup .
37,945
def _build_credentials ( self , nexus_switches ) : credentials = { } for switch_ip , attrs in nexus_switches . items ( ) : credentials [ switch_ip ] = ( attrs [ const . USERNAME ] , attrs [ const . PASSWORD ] , attrs [ const . HTTPS_VERIFY ] , attrs [ const . HTTPS_CERT ] , None ) if not attrs [ const . HTTPS_VERIFY ] ...
Build credential table for Rest API Client .
37,946
def capture_and_print_timeshot ( self , start_time , which , other = 99 , switch = "x.x.x.x" ) : curr_timeout = time . time ( ) - start_time if which in self . time_stats : self . time_stats [ which ] [ "total_time" ] += curr_timeout self . time_stats [ which ] [ "total_count" ] += 1 if ( curr_timeout < self . time_sta...
Determine delta keep track and print results .
37,947
def get_interface_switch ( self , nexus_host , intf_type , interface ) : if intf_type == "ethernet" : path_interface = "phys-[eth" + interface + "]" else : path_interface = "aggr-[po" + interface + "]" action = snipp . PATH_IF % path_interface starttime = time . time ( ) response = self . client . rest_get ( action , n...
Get the interface data from host .
37,948
def _get_interface_switch_trunk_present ( self , nexus_host , intf_type , interface ) : result = self . get_interface_switch ( nexus_host , intf_type , interface ) if_type = 'l1PhysIf' if intf_type == "ethernet" else 'pcAggrIf' if_info = result [ 'imdata' ] [ 0 ] [ if_type ] try : mode_cfg = if_info [ 'attributes' ] [ ...
Check if switchport trunk configs present .
37,949
def add_ch_grp_to_interface ( self , nexus_host , if_type , port , ch_grp ) : if if_type != "ethernet" : LOG . error ( "Unexpected interface type %(iftype)s when " "adding change group" , { 'iftype' : if_type } ) return starttime = time . time ( ) path_snip = snipp . PATH_ALL path_interface = "phys-[eth" + port + "]" b...
Applies channel - group n to ethernet interface .
37,950
def _apply_user_port_channel_config ( self , nexus_host , vpc_nbr ) : cli_cmds = self . _get_user_port_channel_config ( nexus_host , vpc_nbr ) if cli_cmds : self . _send_cli_conf_string ( nexus_host , cli_cmds ) else : vpc_str = str ( vpc_nbr ) path_snip = snipp . PATH_ALL body_snip = snipp . BODY_ADD_PORT_CH_P2 % ( vp...
Adds STP and no lacp suspend config to port channel .
37,951
def create_port_channel ( self , nexus_host , vpc_nbr ) : starttime = time . time ( ) vpc_str = str ( vpc_nbr ) path_snip = snipp . PATH_ALL body_snip = snipp . BODY_ADD_PORT_CH % ( vpc_str , vpc_str , vpc_str ) self . send_edit_string ( nexus_host , path_snip , body_snip ) self . _apply_user_port_channel_config ( nexu...
Creates port channel n on Nexus switch .
37,952
def delete_port_channel ( self , nexus_host , vpc_nbr ) : starttime = time . time ( ) path_snip = snipp . PATH_ALL body_snip = snipp . BODY_DEL_PORT_CH % ( vpc_nbr ) self . send_edit_string ( nexus_host , path_snip , body_snip ) self . capture_and_print_timeshot ( starttime , "delete_port_channel" , switch = nexus_host...
Deletes delete port channel on Nexus switch .
37,953
def _get_port_channel_group ( self , nexus_host , intf_type , interface ) : ch_grp = 0 if intf_type != 'ethernet' : return ch_grp match_key = "eth" + interface action = snipp . PATH_GET_PC_MEMBERS starttime = time . time ( ) result = self . client . rest_get ( action , nexus_host ) self . capture_and_print_timeshot ( s...
Look for channel - group x config and return x .
37,954
def initialize_baremetal_switch_interfaces ( self , interfaces ) : if not interfaces : return max_ifs = len ( interfaces ) starttime = time . time ( ) learned , nexus_ip_list = self . _build_host_list_and_verify_chgrp ( interfaces ) if not nexus_ip_list : return if max_ifs > 1 : if learned : ch_grp = interfaces [ 0 ] [...
Initialize Nexus interfaces and for initial baremetal event .
37,955
def initialize_all_switch_interfaces ( self , interfaces , switch_ip = None , replay = True ) : if not interfaces : return starttime = time . time ( ) if replay : try : vpcs = nxos_db . get_active_switch_vpc_allocs ( switch_ip ) except cexc . NexusVPCAllocNotFound : vpcs = [ ] for vpc in vpcs : if not vpc . learned : s...
Configure Nexus interface and get port channel number .
37,956
def get_nexus_type ( self , nexus_host ) : starttime = time . time ( ) response = self . client . rest_get ( snipp . PATH_GET_NEXUS_TYPE , nexus_host ) self . capture_and_print_timeshot ( starttime , "gettype" , switch = nexus_host ) if response : try : result = response [ 'imdata' ] [ 0 ] [ "eqptCh" ] [ 'attributes' ]...
Given the nexus host get the type of Nexus switch .
37,957
def get_create_vlan ( self , nexus_host , vlanid , vni , conf_str ) : starttime = time . time ( ) if vni : body_snip = snipp . BODY_VXLAN_ALL_INCR % ( vlanid , vni ) else : body_snip = snipp . BODY_VLAN_ALL_INCR % vlanid conf_str += body_snip + snipp . BODY_VLAN_ALL_CONT self . capture_and_print_timeshot ( starttime , ...
Returns an XML snippet for create VLAN on a Nexus Switch .
37,958
def set_all_vlan_states ( self , nexus_host , vlanid_range ) : starttime = time . time ( ) if not vlanid_range : LOG . warning ( "Exiting set_all_vlan_states: " "No vlans to configure" ) return vlan_id_list = re . sub ( r'\s' , '' , vlanid_range ) . split ( ',' ) if not vlan_id_list or not vlan_id_list [ 0 ] : LOG . wa...
Set the VLAN states to active .
37,959
def create_vlan ( self , nexus_host , vlanid , vni ) : starttime = time . time ( ) path_snip , body_snip = self . start_create_vlan ( ) body_snip = self . get_create_vlan ( nexus_host , vlanid , vni , body_snip ) body_snip = self . end_create_vlan ( body_snip ) self . send_edit_string ( nexus_host , path_snip , body_sn...
Given switch vlanid vni Create a VLAN on Switch .
37,960
def delete_vlan ( self , nexus_host , vlanid ) : starttime = time . time ( ) path_snip = snipp . PATH_VLAN % vlanid self . client . rest_delete ( path_snip , nexus_host ) self . capture_and_print_timeshot ( starttime , "del_vlan" , switch = nexus_host )
Delete a VLAN on Nexus Switch given the VLAN ID .
37,961
def _get_vlan_body_on_trunk_int ( self , nexus_host , vlanid , intf_type , interface , is_native , is_delete , add_mode ) : starttime = time . time ( ) LOG . debug ( "NexusDriver get if body config for host %s: " "if_type %s port %s" , nexus_host , intf_type , interface ) if intf_type == "ethernet" : body_if_type = "l1...
Prepares an XML snippet for VLAN on a trunk interface .
37,962
def disable_vlan_on_trunk_int ( self , nexus_host , vlanid , intf_type , interface , is_native ) : starttime = time . time ( ) path_snip , body_snip = self . _get_vlan_body_on_trunk_int ( nexus_host , vlanid , intf_type , interface , is_native , True , False ) self . send_edit_string ( nexus_host , path_snip , body_sni...
Disable a VLAN on a trunk interface .
37,963
def send_edit_string ( self , nexus_host , path_snip , body_snip , check_to_close_session = True ) : starttime = time . time ( ) LOG . debug ( "NexusDriver edit config for host %s: path: %s body: %s" , nexus_host , path_snip , body_snip ) self . client . rest_post ( path_snip , nexus_host , body_snip ) self . capture_a...
Sends rest Post request to Nexus switch .
37,964
def _send_cli_conf_string ( self , nexus_host , cli_str ) : starttime = time . time ( ) path_snip = snipp . PATH_USER_CMDS body_snip = snipp . BODY_USER_CONF_CMDS % ( '1' , cli_str ) LOG . debug ( "NexusDriver CLI config for host %s: path: %s body: %s" , nexus_host , path_snip , body_snip ) self . nxapi_client . rest_p...
Sends CLI Config commands to Nexus switch using NXAPI .
37,965
def send_enable_vlan_on_trunk_int ( self , nexus_host , vlanid , intf_type , interface , is_native , add_mode = False ) : path_snip , body_snip = self . _get_vlan_body_on_trunk_int ( nexus_host , vlanid , intf_type , interface , is_native , False , add_mode ) self . send_edit_string ( nexus_host , path_snip , body_snip...
Gathers and sends an interface trunk XML snippet .
37,966
def create_and_trunk_vlan ( self , nexus_host , vlan_id , intf_type , nexus_port , vni , is_native ) : starttime = time . time ( ) self . create_vlan ( nexus_host , vlan_id , vni ) LOG . debug ( "NexusDriver created VLAN: %s" , vlan_id ) if nexus_port : self . send_enable_vlan_on_trunk_int ( nexus_host , vlan_id , intf...
Create VLAN and trunk it on the specified ports .
37,967
def enable_vxlan_feature ( self , nexus_host , nve_int_num , src_intf ) : starttime = time . time ( ) self . send_edit_string ( nexus_host , snipp . PATH_VXLAN_STATE , ( snipp . BODY_VXLAN_STATE % "enabled" ) ) self . send_edit_string ( nexus_host , snipp . PATH_VNSEG_STATE , ( snipp . BODY_VNSEG_STATE % "enabled" ) ) ...
Enable VXLAN on the switch .
37,968
def disable_vxlan_feature ( self , nexus_host ) : starttime = time . time ( ) self . send_edit_string ( nexus_host , snipp . PATH_VXLAN_STATE , ( snipp . BODY_VXLAN_STATE % "disabled" ) ) self . send_edit_string ( nexus_host , snipp . PATH_VNSEG_STATE , ( snipp . BODY_VNSEG_STATE % "disabled" ) ) self . capture_and_pri...
Disable VXLAN on the switch .
37,969
def create_nve_member ( self , nexus_host , nve_int_num , vni , mcast_group ) : starttime = time . time ( ) path = snipp . PATH_VNI_UPDATE % ( nve_int_num , vni ) body = snipp . BODY_VNI_UPDATE % ( vni , vni , vni , mcast_group ) self . send_edit_string ( nexus_host , path , body ) self . capture_and_print_timeshot ( s...
Add a member configuration to the NVE interface .
37,970
def delete_nve_member ( self , nexus_host , nve_int_num , vni ) : starttime = time . time ( ) path_snip = snipp . PATH_VNI_UPDATE % ( nve_int_num , vni ) self . client . rest_delete ( path_snip , nexus_host ) self . capture_and_print_timeshot ( starttime , "delete_nve" , switch = nexus_host )
Delete a member configuration on the NVE interface .
37,971
def _get_vrf_name ( self , ri ) : router_id = ri . router_name ( ) [ : self . DEV_NAME_LEN ] is_multi_region_enabled = cfg . CONF . multi_region . enable_multi_region if is_multi_region_enabled : region_id = cfg . CONF . multi_region . region_id vrf_name = "%s-%s" % ( router_id , region_id ) else : vrf_name = router_id...
overloaded method for generating a vrf_name that supports region_id
37,972
def _get_item ( list_containing_dicts_entries , attribute_value , attribute_name = 'subnet_id' ) : for item in list_containing_dicts_entries : if item . get ( attribute_name ) == attribute_value : return item return { }
Searches a list of dicts and returns the first matching entry
37,973
def _nat_rules_for_internet_access ( self , acl_no , network , netmask , inner_itfc , outer_itfc , vrf_name ) : acl_present = self . _check_acl ( acl_no , network , netmask ) if not acl_present : conf_str = snippets . CREATE_ACL % ( acl_no , network , netmask ) self . _edit_running_config ( conf_str , 'CREATE_ACL' ) po...
Configure the NAT rules for an internal network .
37,974
def _remove_internal_nw_nat_rules ( self , ri , ports , ext_port , intf_deleted = False ) : acls = [ ] for port in ports : in_itfc_name = self . _get_interface_name_from_hosting_port ( port ) acls . append ( self . _generate_acl_num_from_port ( port ) ) is_alone = len ( port [ 'change_details' ] [ 'current_ports' ] ) =...
Removes the NAT rules already configured when an internal network is removed .
37,975
def _do_add_floating_ip_asr1k ( self , floating_ip , fixed_ip , vrf , ex_gw_port ) : vlan = ex_gw_port [ 'hosting_info' ] [ 'segmentation_id' ] hsrp_grp = ex_gw_port [ ha . HA_INFO ] [ 'group' ] LOG . debug ( "add floating_ip: %(fip)s, fixed_ip: %(fixed_ip)s, " "vrf: %(vrf)s, ex_gw_port: %(port)s" , { 'fip' : floating_...
To implement a floating ip an ip static nat is configured in the underlying router ex_gw_port contains data to derive the vlan associated with related subnet for the fixed ip . The vlan in turn is applied to the redundancy parameter for setting the IP NAT .
37,976
def report_non_responding_hosting_devices ( self , context , host , hosting_device_ids ) : self . update_hosting_device_status ( context , host , { const . HD_DEAD : hosting_device_ids } )
Report that a hosting device is determined to be dead .
37,977
def update_hosting_device_status ( self , context , host , status_info ) : for status , hd_ids in six . iteritems ( status_info ) : hd_spec = { 'hosting_device' : { 'status' : status } } for hd_id in hd_ids : self . _dmplugin . update_hosting_device ( context , hd_id , hd_spec ) if status == const . HD_DEAD or status =...
Report status changes for hosting devices .
37,978
def get_hosting_devices_for_agent ( self , context , host ) : agent_ids = self . _dmplugin . get_cfg_agents ( context , active = None , filters = { 'host' : [ host ] } ) if agent_ids : return [ self . _dmplugin . get_device_info_for_agent ( context , hd_db ) for hd_db in self . _dmplugin . get_hosting_devices_db ( cont...
Fetches routers that a Cisco cfg agent is managing .
37,979
def remove_router_from_hosting_device ( self , context , hosting_device_id , router_id ) : e_context = context . elevated ( ) r_hd_binding_db = self . _get_router_binding_info ( e_context , router_id ) if r_hd_binding_db . hosting_device_id != hosting_device_id : raise routertypeawarescheduler . RouterNotHostedByHostin...
Remove the router from hosting device .
37,980
def get_number_of_agents_for_scheduling ( self , context ) : num_agents = len ( self . get_l3_agents ( context , active = True , filters = { 'agent_modes' : [ bc . constants . L3_AGENT_MODE_LEGACY , bc . constants . L3_AGENT_MODE_DVR_SNAT ] } ) ) max_agents = cfg . CONF . max_l3_agents_per_router if max_agents : if max...
Return number of agents on which the router will be scheduled .
37,981
def _notify_subnet_create ( resource , event , trigger , ** kwargs ) : context = kwargs [ 'context' ] subnet = kwargs [ 'subnet' ] l3plugin = bc . get_plugin ( L3_ROUTER_NAT ) for router in l3plugin . get_routers ( context ) : if ( router [ 'external_gateway_info' ] and ( router [ 'external_gateway_info' ] [ 'network_i...
Called when a new subnet is created in the external network
37,982
def is_port_profile_created ( self , vlan_id , device_id ) : entry = self . session . query ( ucsm_model . PortProfile ) . filter_by ( vlan_id = vlan_id , device_id = device_id ) . first ( ) return entry and entry . created_on_ucs
Indicates if port profile has been created on UCS Manager .
37,983
def get_port_profile_for_vlan ( self , vlan_id , device_id ) : entry = self . session . query ( ucsm_model . PortProfile ) . filter_by ( vlan_id = vlan_id , device_id = device_id ) . first ( ) return entry . profile_id if entry else None
Returns Vlan id associated with the port profile .
37,984
def add_port_profile ( self , profile_name , vlan_id , device_id ) : if not self . get_port_profile_for_vlan ( vlan_id , device_id ) : port_profile = ucsm_model . PortProfile ( profile_id = profile_name , vlan_id = vlan_id , device_id = device_id , created_on_ucs = False ) with self . session . begin ( subtransactions ...
Adds a port profile and its vlan_id to the table .
37,985
def set_port_profile_created ( self , vlan_id , profile_name , device_id ) : with self . session . begin ( subtransactions = True ) : port_profile = self . session . query ( ucsm_model . PortProfile ) . filter_by ( vlan_id = vlan_id , profile_id = profile_name , device_id = device_id ) . first ( ) if port_profile : por...
Sets created_on_ucs flag to True .
37,986
def delete_vlan_entry ( self , vlan_id ) : with self . session . begin ( subtransactions = True ) : try : self . session . query ( ucsm_model . PortProfile ) . filter_by ( vlan_id = vlan_id ) . delete ( ) except orm . exc . NoResultFound : return
Deletes entry for a vlan_id if it exists .
37,987
def set_sp_template_updated ( self , vlan_id , sp_template , device_id ) : entry = self . get_sp_template_vlan_entry ( vlan_id , sp_template , device_id ) if entry : entry . updated_on_ucs = True self . session . merge ( entry ) return entry else : return False
Sets update_on_ucs flag to True .
37,988
def delete_sp_template_for_vlan ( self , vlan_id ) : with self . session . begin ( subtransactions = True ) : try : self . session . query ( ucsm_model . ServiceProfileTemplate ) . filter_by ( vlan_id = vlan_id ) . delete ( ) except orm . exc . NoResultFound : return
Deletes SP Template for a vlan_id if it exists .
37,989
def set_vnic_template_updated ( self , vlan_id , ucsm_ip , vnic_template , physnet ) : with self . session . begin ( subtransactions = True ) : entry = self . get_vnic_template_vlan_entry ( vlan_id , vnic_template , ucsm_ip , physnet ) if entry : entry . updated_on_ucs = True self . session . merge ( entry ) return ent...
Sets update_on_ucs flag to True for a Vnic Template entry .
37,990
def delete_vnic_template_for_vlan ( self , vlan_id ) : with self . session . begin ( subtransactions = True ) : try : self . session . query ( ucsm_model . VnicTemplate ) . filter_by ( vlan_id = vlan_id ) . delete ( ) except orm . exc . NoResultFound : return
Deletes VNIC Template for a vlan_id and physnet if it exists .
37,991
def has_port_profile_to_delete ( self , profile_name , device_id ) : count = self . session . query ( ucsm_model . PortProfileDelete ) . filter_by ( profile_id = profile_name , device_id = device_id ) . count ( ) return count != 0
Returns True if port profile delete table containes PP .
37,992
def add_port_profile_to_delete_table ( self , profile_name , device_id ) : if not self . has_port_profile_to_delete ( profile_name , device_id ) : port_profile = ucsm_model . PortProfileDelete ( profile_id = profile_name , device_id = device_id ) with self . session . begin ( subtransactions = True ) : self . session ....
Adds a port profile to the delete table .
37,993
def remove_port_profile_to_delete ( self , profile_name , device_id ) : with self . session . begin ( subtransactions = True ) : self . session . query ( ucsm_model . PortProfileDelete ) . filter_by ( profile_id = profile_name , device_id = device_id ) . delete ( )
Removes port profile to be deleted from table .
37,994
def parse ( cls , buf ) : pkt = DhcpPacket ( ) ( pkt . ciaddr , ) = cls . struct ( '4s' ) . unpack_from ( buf , 12 ) ( pkt . giaddr , ) = cls . struct ( '4s' ) . unpack_from ( buf , 24 ) cls . struct ( '4s' ) . pack_into ( buf , 24 , b'' ) pos = 240 while pos < len ( buf ) : ( opttag , ) = cls . struct ( 'B' ) . unpack...
Parse DHCP Packet .
37,995
def register_for_duty ( self , context ) : cctxt = self . client . prepare ( ) return cctxt . call ( context , 'register_for_duty' , host = self . host )
Report that a config agent is ready for duty .
37,996
def get_hosting_devices_for_agent ( self , context ) : cctxt = self . client . prepare ( ) return cctxt . call ( context , 'get_hosting_devices_for_agent' , host = self . host )
Get a list of hosting devices assigned to this agent .
37,997
def process_services ( self , device_ids = None , removed_devices_info = None ) : LOG . debug ( "Processing services started" ) if self . routing_service_helper : self . routing_service_helper . process_service ( device_ids , removed_devices_info ) else : LOG . warning ( "No routing service helper loaded" ) LOG . debug...
Process services managed by this config agent .
37,998
def _process_backlogged_hosting_devices ( self , context ) : driver_mgr = self . get_routing_service_helper ( ) . driver_manager res = self . _dev_status . check_backlogged_hosting_devices ( driver_mgr ) if res [ 'reachable' ] : self . process_services ( device_ids = res [ 'reachable' ] ) if res [ 'revived' ] : LOG . d...
Process currently backlogged devices .
37,999
def agent_updated ( self , context , payload ) : try : if payload [ 'admin_state_up' ] : pass except KeyError as e : LOG . error ( "Invalid payload format for received RPC message " "`agent_updated`. Error is %(error)s. Payload is " "%(payload)s" , { 'error' : e , 'payload' : payload } )
Deal with agent updated RPC message .