sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
def _adjust_router_list_for_global_router(self, routers):
"""
Pushes 'Global' routers to the end of the router list, so that
deleting default route occurs before deletion of external nw subintf
"""
#ToDo(Hareesh): Simplify if possible
for r in routers:
if r[RO... | Pushes 'Global' routers to the end of the router list, so that
deleting default route occurs before deletion of external nw subintf | entailment |
def _process_routers(self, routers, removed_routers,
device_id=None, all_routers=False):
"""Process the set of routers.
Iterating on the set of routers received and comparing it with the
set of routers already in the routing service helper, new routers
which are... | Process the set of routers.
Iterating on the set of routers received and comparing it with the
set of routers already in the routing service helper, new routers
which are added are identified. Before processing check the
reachability (via ping) of hosting device where the router is host... | entailment |
def _send_update_port_statuses(self, port_ids, status):
"""Sends update notifications to set the operational status of the
list of router ports provided. To make each notification doesn't exceed
the RPC length, each message contains a maximum of MAX_PORTS_IN_BATCH
port ids.
:par... | Sends update notifications to set the operational status of the
list of router ports provided. To make each notification doesn't exceed
the RPC length, each message contains a maximum of MAX_PORTS_IN_BATCH
port ids.
:param port_ids: List of ports to update the status
:param stat... | entailment |
def _process_router(self, ri):
"""Process a router, apply latest configuration and update router_info.
Get the router dict from RouterInfo and proceed to detect changes
from the last known state. When new ports or deleted ports are
detected, `internal_network_added()` or `internal_netw... | Process a router, apply latest configuration and update router_info.
Get the router dict from RouterInfo and proceed to detect changes
from the last known state. When new ports or deleted ports are
detected, `internal_network_added()` or `internal_networks_removed()`
are called accordi... | entailment |
def _process_router_floating_ips(self, ri, ex_gw_port):
"""Process a router's floating ips.
Compare floatingips configured in device (i.e., those fips in
the ri.floating_ips "cache") with the router's updated floating ips
(in ri.router.floating_ips) and determine floating_ips which were... | Process a router's floating ips.
Compare floatingips configured in device (i.e., those fips in
the ri.floating_ips "cache") with the router's updated floating ips
(in ri.router.floating_ips) and determine floating_ips which were
added or removed. Notify driver of the change via
... | entailment |
def _router_added(self, router_id, router):
"""Operations when a router is added.
Create a new RouterInfo object for this router and add it to the
service helpers router_info dictionary. Then `router_added()` is
called on the device driver.
:param router_id: id of the router
... | Operations when a router is added.
Create a new RouterInfo object for this router and add it to the
service helpers router_info dictionary. Then `router_added()` is
called on the device driver.
:param router_id: id of the router
:param router: router dict
:return: None | entailment |
def _router_removed(self, router_id, deconfigure=True):
"""Operations when a router is removed.
Get the RouterInfo object corresponding to the router in the service
helpers's router_info dict. If deconfigure is set to True,
remove this router's configuration from the hosting device.
... | Operations when a router is removed.
Get the RouterInfo object corresponding to the router in the service
helpers's router_info dict. If deconfigure is set to True,
remove this router's configuration from the hosting device.
:param router_id: id of the router
:param deconfigure:... | entailment |
def _routes_updated(self, ri):
"""Update the state of routes in the router.
Compares the current routes with the (configured) existing routes
and detect what was removed or added. Then configure the
logical router in the hosting device accordingly.
:param ri: RouterInfo correspo... | Update the state of routes in the router.
Compares the current routes with the (configured) existing routes
and detect what was removed or added. Then configure the
logical router in the hosting device accordingly.
:param ri: RouterInfo corresponding to the router.
:return: None... | entailment |
def get_running_config(self, conn):
"""Get the ASR1k's current running config.
:return: Current IOS running config as multiline string
"""
config = conn.get_config(source="running")
if config:
root = ET.fromstring(config._raw)
running_config = root[0][0]
... | Get the ASR1k's current running config.
:return: Current IOS running config as multiline string | entailment |
def subintf_real_ip_check_gw_port(self, gw_port, ip_addr, netmask):
"""
checks running-cfg derived ip_addr and netmask against neutron-db
gw_port
"""
if gw_port is not None:
found = False
for i in range(len(gw_port['fixed_ips'])):
target_ip... | checks running-cfg derived ip_addr and netmask against neutron-db
gw_port | entailment |
def retry(ExceptionToCheck, tries=4, delay=3, backoff=2):
"""Retry calling the decorated function using an exponential backoff.
Reference: http://www.saltycrane.com/blog/2009/11/trying-out-retry
-decorator-python/
:param ExceptionToCheck: the exception to check. may be a tuple of
exceptions to... | Retry calling the decorated function using an exponential backoff.
Reference: http://www.saltycrane.com/blog/2009/11/trying-out-retry
-decorator-python/
:param ExceptionToCheck: the exception to check. may be a tuple of
exceptions to check
:param tries: number of times to try (not retry) befor... | entailment |
def _get_connection(self):
"""Make SSH connection to the IOS XE device.
The external ncclient library is used for creating this connection.
This method keeps state of any existing connections and reuses them if
already connected. Also interfaces (except management) are typically
... | Make SSH connection to the IOS XE device.
The external ncclient library is used for creating this connection.
This method keeps state of any existing connections and reuses them if
already connected. Also interfaces (except management) are typically
disabled by default when it is booted... | entailment |
def _get_interfaces(self):
"""Get a list of interfaces on this hosting device.
:return: List of the interfaces
"""
ios_cfg = self._get_running_config()
parse = HTParser(ios_cfg)
itfcs_raw = parse.find_lines("^interface GigabitEthernet")
itfcs = [raw_if.strip().sp... | Get a list of interfaces on this hosting device.
:return: List of the interfaces | entailment |
def _get_interface_ip(self, interface_name):
"""Get the ip address for an interface.
:param interface_name: interface_name as a string
:return: ip address of interface as a string
"""
ios_cfg = self._get_running_config()
parse = HTParser(ios_cfg)
children = parse... | Get the ip address for an interface.
:param interface_name: interface_name as a string
:return: ip address of interface as a string | entailment |
def _interface_exists(self, interface):
"""Check whether interface exists."""
ios_cfg = self._get_running_config()
parse = HTParser(ios_cfg)
itfcs_raw = parse.find_lines("^interface " + interface)
return len(itfcs_raw) > 0 | Check whether interface exists. | entailment |
def _get_vrfs(self):
"""Get the current VRFs configured in the device.
:return: A list of vrf names as string
"""
vrfs = []
ios_cfg = self._get_running_config()
parse = HTParser(ios_cfg)
vrfs_raw = parse.find_lines("^vrf definition")
for line in vrfs_raw:... | Get the current VRFs configured in the device.
:return: A list of vrf names as string | entailment |
def _get_capabilities(self):
"""Get the servers NETCONF capabilities.
:return: List of server capabilities.
"""
conn = self._get_connection()
capabilities = []
for c in conn.server_capabilities:
capabilities.append(c)
LOG.debug("Server capabilities: %... | Get the servers NETCONF capabilities.
:return: List of server capabilities. | entailment |
def _get_running_config(self, split=True):
"""Get the IOS XE device's current running config.
:return: Current IOS running config as multiline string
"""
conn = self._get_connection()
config = conn.get_config(source="running")
if config:
root = ET.fromstring(... | Get the IOS XE device's current running config.
:return: Current IOS running config as multiline string | entailment |
def _check_acl(self, acl_no, network, netmask):
"""Check a ACL config exists in the running config.
:param acl_no: access control list (ACL) number
:param network: network which this ACL permits
:param netmask: netmask of the network
:return:
"""
exp_cfg_lines = ... | Check a ACL config exists in the running config.
:param acl_no: access control list (ACL) number
:param network: network which this ACL permits
:param netmask: netmask of the network
:return: | entailment |
def _cfg_exists(self, cfg_str):
"""Check a partial config string exists in the running config.
:param cfg_str: config string to check
:return : True or False
"""
ios_cfg = self._get_running_config()
parse = HTParser(ios_cfg)
cfg_raw = parse.find_lines("^" + cfg_s... | Check a partial config string exists in the running config.
:param cfg_str: config string to check
:return : True or False | entailment |
def caller_name(self, skip=2):
"""
Get a name of a caller in the format module.class.method
`skip` specifies how many levels of stack to skip while getting caller
name. skip=1 means "who calls me", skip=2 "who calls my caller" etc.
An empty string is returned if skipped levels exc... | Get a name of a caller in the format module.class.method
`skip` specifies how many levels of stack to skip while getting caller
name. skip=1 means "who calls me", skip=2 "who calls my caller" etc.
An empty string is returned if skipped levels exceed stack height | entailment |
def _check_response(self, rpc_obj, snippet_name, conf_str=None):
"""This function checks the rpc response object for status.
This function takes as input the response rpc_obj and the snippet name
that was executed. It parses it to see, if the last edit operation was
a success or not.
... | This function checks the rpc response object for status.
This function takes as input the response rpc_obj and the snippet name
that was executed. It parses it to see, if the last edit operation was
a success or not.
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply mess... | entailment |
def _get_instances_for_project(self, project_id):
"""Return all instances for a given project.
:project_id: UUID of project (tenant)
"""
search_opts = {'marker': None,
'all_tenants': True,
'project_id': project_id}
try:
s... | Return all instances for a given project.
:project_id: UUID of project (tenant) | entailment |
def get_instance_for_uuid(self, uuid, project_id):
"""Return instance name for given uuid of an instance and project.
:uuid: Instance's UUID
:project_id: UUID of project (tenant)
"""
instance_name = self._inst_info_cache.get((uuid, project_id))
if instance_name:
... | Return instance name for given uuid of an instance and project.
:uuid: Instance's UUID
:project_id: UUID of project (tenant) | entailment |
def l3_tenant_id(cls):
"""Returns id of tenant owning hosting device resources."""
if cls._l3_tenant_uuid is None:
if hasattr(cfg.CONF.keystone_authtoken, 'project_domain_id'):
# TODO(sridar): hack for now to determing if keystone v3
# API is to be used.
... | Returns id of tenant owning hosting device resources. | entailment |
def mgmt_nw_id(cls):
"""Returns id of the management network."""
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(),
{... | Returns id of the management network. | entailment |
def mgmt_sec_grp_id(cls):
"""Returns id of security group used by the management network."""
if not extensions.is_extension_supported(bc.get_plugin(),
"security-group"):
return
if cls._mgmt_sec_grp_id is None:
# Get the id ... | Returns id of security group used by the management network. | entailment |
def get_hosting_device_driver(self, context, id):
"""Returns device driver for hosting device template with <id>."""
if id is None:
return
try:
return self._hosting_device_drivers[id]
except KeyError:
try:
template = self._get_hosting_d... | Returns device driver for hosting device template with <id>. | entailment |
def get_hosting_device_plugging_driver(self, context, id):
"""Returns plugging driver for hosting device template with <id>."""
if id is None:
return
try:
return self._plugging_drivers[id]
except KeyError:
try:
template = self._get_hos... | Returns plugging driver for hosting device template with <id>. | entailment |
def acquire_hosting_device_slots(self, context, hosting_device, resource,
resource_type, resource_service, num,
exclusive=False):
"""Assign <num> slots in <hosting_device> to logical <resource>.
If exclusive is True the hosting d... | Assign <num> slots in <hosting_device> to logical <resource>.
If exclusive is True the hosting device is bound to the resource's
tenant. Otherwise it is not bound to any tenant.
Returns True if allocation was granted, False otherwise. | entailment |
def release_hosting_device_slots(self, context, hosting_device, resource,
num):
"""Free <num> slots in <hosting_device> from logical resource <id>.
Returns True if deallocation was successful. False otherwise.
"""
with context.session.begin(subtransa... | Free <num> slots in <hosting_device> from logical resource <id>.
Returns True if deallocation was successful. False otherwise. | entailment |
def get_hosting_devices_qry(self, context, hosting_device_ids,
load_agent=True):
"""Returns hosting devices with <hosting_device_ids>."""
query = context.session.query(hd_models.HostingDevice)
if load_agent:
query = query.options(joinedload('cfg_agent'... | Returns hosting devices with <hosting_device_ids>. | entailment |
def delete_all_hosting_devices(self, context, force_delete=False):
"""Deletes all hosting devices."""
for item in self._get_collection_query(
context, hd_models.HostingDeviceTemplate):
self.delete_all_hosting_devices_by_template(
context, template=item, force_... | Deletes all hosting devices. | entailment |
def delete_all_hosting_devices_by_template(self, context, template,
force_delete=False):
"""Deletes all hosting devices based on <template>."""
plugging_drv = self.get_hosting_device_plugging_driver(
context, template['id'])
hosting_devi... | Deletes all hosting devices based on <template>. | entailment |
def get_device_info_for_agent(self, context, hosting_device_db):
"""Returns information about <hosting_device> needed by config agent.
Convenience function that service plugins can use to populate
their resources with information about the device hosting their
logical resource.... | Returns information about <hosting_device> needed by config agent.
Convenience function that service plugins can use to populate
their resources with information about the device hosting their
logical resource. | entailment |
def _process_non_responsive_hosting_device(self, context, hosting_device):
"""Host type specific processing of non responsive hosting devices.
:param hosting_device: db object for hosting device
:return: True if hosting_device has been deleted, otherwise False
"""
if (hosting_de... | Host type specific processing of non responsive hosting devices.
:param hosting_device: db object for hosting device
:return: True if hosting_device has been deleted, otherwise False | entailment |
def _maintain_hosting_device_pool(self, context, template):
"""Maintains the pool of hosting devices that are based on <template>.
Ensures that the number of standby hosting devices (essentially
service VMs) is kept at a suitable level so that resource creation is
not slowed down by boo... | Maintains the pool of hosting devices that are based on <template>.
Ensures that the number of standby hosting devices (essentially
service VMs) is kept at a suitable level so that resource creation is
not slowed down by booting of the hosting device.
:param context: context for this o... | entailment |
def _create_svc_vm_hosting_devices(self, context, num, template):
"""Creates <num> or less service VM instances based on <template>.
These hosting devices can be bound to a certain tenant or for shared
use. A list with the created hosting device VMs is returned.
"""
hosting_devi... | Creates <num> or less service VM instances based on <template>.
These hosting devices can be bound to a certain tenant or for shared
use. A list with the created hosting device VMs is returned. | entailment |
def _delete_idle_service_vm_hosting_devices(self, context, num, template):
"""Deletes <num> or less unused <template>-based service VM instances.
The number of deleted service vm instances is returned.
"""
# Delete the "youngest" hosting devices since they are more likely
# not ... | Deletes <num> or less unused <template>-based service VM instances.
The number of deleted service vm instances is returned. | entailment |
def _delete_dead_service_vm_hosting_device(self, context, hosting_device):
"""Deletes a presumably dead <hosting_device> service VM.
This will indirectly make all of its hosted resources unscheduled.
"""
if hosting_device is None:
return
plugging_drv = self.get_hosti... | Deletes a presumably dead <hosting_device> service VM.
This will indirectly make all of its hosted resources unscheduled. | entailment |
def _get_total_available_slots(self, context, template_id, capacity):
"""Returns available slots in idle devices based on <template_id>.
Only slots in tenant unbound hosting devices are counted to ensure
there is always hosting device slots available regardless of tenant.
"""
qu... | Returns available slots in idle devices based on <template_id>.
Only slots in tenant unbound hosting devices are counted to ensure
there is always hosting device slots available regardless of tenant. | entailment |
def _exclusively_used(self, context, hosting_device, tenant_id):
"""Checks if only <tenant_id>'s resources use <hosting_device>."""
return (context.session.query(hd_models.SlotAllocation).filter(
hd_models.SlotAllocation.hosting_device_id == hosting_device['id'],
hd_models.SlotAl... | Checks if only <tenant_id>'s resources use <hosting_device>. | entailment |
def _update_hosting_device_exclusivity(self, context, hosting_device,
tenant_id):
"""Make <hosting device> bound or unbound to <tenant_id>.
If <tenant_id> is None the device is unbound, otherwise it gets bound
to that <tenant_id>
"""
wi... | Make <hosting device> bound or unbound to <tenant_id>.
If <tenant_id> is None the device is unbound, otherwise it gets bound
to that <tenant_id> | entailment |
def _get_template_pool_lock(self, id):
"""Returns lock object for hosting device template with <id>."""
try:
return self._hosting_device_locks[id]
except KeyError:
self._hosting_device_locks[id] = threading.Lock()
return self._hosting_device_locks.get(id) | Returns lock object for hosting device template with <id>. | entailment |
def _create_hosting_device_templates_from_config(self):
"""To be called late during plugin initialization so that any hosting
device templates defined in the config file is properly inserted in
the DB.
"""
hdt_dict = config.get_specific_config('cisco_hosting_device_template')
... | To be called late during plugin initialization so that any hosting
device templates defined in the config file is properly inserted in
the DB. | entailment |
def _create_hosting_devices_from_config(self):
"""To be called late during plugin initialization so that any hosting
device specified in the config file is properly inserted in the DB.
"""
hd_dict = config.get_specific_config('cisco_hosting_device')
attr_info = ciscohostingdevice... | To be called late during plugin initialization so that any hosting
device specified in the config file is properly inserted in the DB. | entailment |
def add_router_to_hosting_device(self, client, hosting_device_id, body):
"""Adds a router to hosting device."""
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. | entailment |
def remove_router_from_hosting_device(self, client, hosting_device_id,
router_id):
"""Remove a router from hosting_device."""
res_path = hostingdevice.HostingDevice.resource_path
return client.delete((res_path + DEVICE_L3_ROUTERS + "/%s") % (
... | Remove a router from hosting_device. | entailment |
def list_routers_on_hosting_device(self, client, hosting_device_id,
**_params):
"""Fetches a list of routers hosted on a hosting device."""
res_path = hostingdevice.HostingDevice.resource_path
return client.get((res_path + DEVICE_L3_ROUTERS) %
... | Fetches a list of routers hosted on a hosting device. | entailment |
def list_hosting_devices_hosting_routers(self, client, router_id,
**_params):
"""Fetches a list of hosting devices hosting a router."""
return client.get((client.router_path + L3_ROUTER_DEVICES) %
router_id, params=_params) | Fetches a list of hosting devices hosting a router. | entailment |
def setup_client_rpc(self):
"""Setup RPC client for dfa agent."""
# Setup RPC client.
self.clnt = rpc.DfaRpcClient(self._url, constants.DFA_SERVER_QUEUE,
exchange=constants.DFA_EXCHANGE) | Setup RPC client for dfa agent. | entailment |
def setup_rpc(self):
"""Setup RPC server for dfa agent."""
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. | entailment |
def _add_rid_to_vrf_list(self, ri):
"""Add router ID to a VRF list.
In order to properly manage VRFs in the ASR, their
usage has to be tracked. VRFs are provided with neutron
router objects in their hosting_info fields of the gateway ports.
This means that the VRF is only availa... | Add router ID to a VRF list.
In order to properly manage VRFs in the ASR, their
usage has to be tracked. VRFs are provided with neutron
router objects in their hosting_info fields of the gateway ports.
This means that the VRF is only available when the gateway port
of the router... | entailment |
def _remove_rid_from_vrf_list(self, ri):
"""Remove router ID from a VRF list.
This removes a router from the list of routers that's kept
in a map, using a VRF ID as the key. If the VRF exists, the
router is removed from the list if it's present. If the last
router in the list is... | Remove router ID from a VRF list.
This removes a router from the list of routers that's kept
in a map, using a VRF ID as the key. If the VRF exists, the
router is removed from the list if it's present. If the last
router in the list is removed, then the driver's method to
remove... | entailment |
def _internal_network_removed(self, ri, port, ex_gw_port):
"""Remove an internal router port
Check to see if this is the last port to be removed for
a given network scoped by a VRF (note: there can be
different mappings between VRFs and networks -- 1-to-1,
1-to-n, n-to-1, n-to-n... | Remove an internal router port
Check to see if this is the last port to be removed for
a given network scoped by a VRF (note: there can be
different mappings between VRFs and networks -- 1-to-1,
1-to-n, n-to-1, n-to-n -- depending on the configuration
and workflow used). If it i... | entailment |
def do_list_organizations(self, line):
'''Get list of organization on DCNM.'''
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:
... | Get list of organization on DCNM. | entailment |
def create_routertype(self, context, routertype):
"""Creates a router type.
Also binds it to the specified hosting device template.
"""
LOG.debug("create_routertype() called. Contents %s", routertype)
rt = routertype['routertype']
with context.session.begin(subtransactio... | Creates a router type.
Also binds it to the specified hosting device template. | entailment |
def associate_hosting_device_with_config_agent(
self, client, config_agent_id, body):
"""Associates a hosting_device with a config agent."""
return client.post((ConfigAgentHandlingHostingDevice.resource_path +
CFG_AGENT_HOSTING_DEVICES) % config_agent_id,
... | Associates a hosting_device with a config agent. | entailment |
def disassociate_hosting_device_with_config_agent(
self, client, config_agent_id, hosting_device_id):
"""Disassociates a hosting_device with a config agent."""
return client.delete((ConfigAgentHandlingHostingDevice.resource_path +
CFG_AGENT_HOSTING_DEVICES + "/%... | Disassociates a hosting_device with a config agent. | entailment |
def list_hosting_device_handled_by_config_agent(
self, client, cfg_agent_id, **_params):
"""Fetches a list of hosting devices handled by a config agent."""
return client.get((ConfigAgentHandlingHostingDevice.resource_path +
CFG_AGENT_HOSTING_DEVICES) % cfg_agent_id... | Fetches a list of hosting devices handled by a config agent. | entailment |
def list_config_agents_handling_hosting_device(
self, client, hosting_device_id, **_params):
"""Fetches a list of config agents handling a hosting device."""
resource_path = '/dev_mgr/hosting_devices/%s'
return client.get((resource_path + HOSTING_DEVICE_CFG_AGENTS) %
... | Fetches a list of config agents handling a hosting device. | entailment |
def _parse_nexus_vni_range(self, tunnel_range):
"""Raise an exception for invalid tunnel range or malformed range."""
for ident in tunnel_range:
if not self._is_valid_nexus_vni(ident):
raise exc.NetworkTunnelRangeError(
tunnel_range=tunnel_range,
... | Raise an exception for invalid tunnel range or malformed range. | entailment |
def sync_allocations(self):
"""
Synchronize vxlan_allocations table with configured tunnel ranges.
"""
# determine current configured allocatable vnis
vxlan_vnis = set()
for tun_min, tun_max in self.tunnel_ranges:
vxlan_vnis |= set(six.moves.range(tun_min, tu... | Synchronize vxlan_allocations table with configured tunnel ranges. | entailment |
def _setup_notification_listener(self, topic_name, url):
"""Setup notification listener for a service."""
self.notify_listener = rpc.DfaNotifcationListener(
topic_name, url, rpc.DfaNotificationEndpoints(self)) | Setup notification listener for a service. | entailment |
def callback(self, timestamp, event_type, payload):
"""Callback method for processing events in notification queue.
:param timestamp: time the message is received.
:param event_type: event type in the notification queue such as
identity.project.created, identity.proje... | Callback method for processing events in notification queue.
:param timestamp: time the message is received.
:param event_type: event type in the notification queue such as
identity.project.created, identity.project.deleted.
:param payload: Contains information of an ... | entailment |
def event_handler(self):
"""Wait on queue for listening to the events."""
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.st... | Wait on queue for listening to the events. | entailment |
def set_driver(self, resource):
"""Set the driver for a neutron resource.
:param resource: Neutron resource in dict format.
Expected keys::
{
'id': <value>,
'hosting_device': { 'id': <value>, },
'router_type': {'cf... | Set the driver for a neutron resource.
:param resource: Neutron resource in dict format.
Expected keys::
{
'id': <value>,
'hosting_device': { 'id': <value>, },
'router_type': {'cfg_agent_driver': <value>, }
... | entailment |
def _import_ucsmsdk(self):
"""Imports the ucsmsdk module.
This module is not installed as part of the normal Neutron
distributions. It is imported dynamically in this module so that
the import can be mocked, allowing unit testing without requiring
the installation of ucsmsdk.
... | Imports the ucsmsdk module.
This module is not installed as part of the normal Neutron
distributions. It is imported dynamically in this module so that
the import can be mocked, allowing unit testing without requiring
the installation of ucsmsdk. | entailment |
def ucs_manager_connect(self, ucsm_ip):
"""Connects to a UCS Manager."""
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 Mana... | Connects to a UCS Manager. | entailment |
def _create_ucsm_host_to_service_profile_mapping(self):
"""Reads list of Service profiles and finds associated Server."""
# Get list of UCSMs without host list given in the config
ucsm_ips = [ip for ip, ucsm in CONF.ml2_cisco_ucsm.ucsms.items()
if not ucsm.ucsm_host_list]
... | Reads list of Service profiles and finds associated Server. | entailment |
def _create_vlanprofile(self, handle, vlan_id, ucsm_ip):
"""Creates VLAN profile to able associated with the Port Profile."""
vlan_name = self.make_vlan_name(vlan_id)
vlan_profile_dest = (const.VLAN_PATH + const.VLAN_PROFILE_PATH_PREFIX +
vlan_name)
try:
... | Creates VLAN profile to able associated with the Port Profile. | entailment |
def _create_port_profile(self, handle, profile_name, vlan_id,
vnic_type, ucsm_ip, trunk_vlans, qos_policy):
"""Creates a Port Profile on the UCS Manager.
Significant parameters set in the port profile are:
1. Port profile name - Should match what was set in vif_deta... | Creates a Port Profile on the UCS Manager.
Significant parameters set in the port profile are:
1. Port profile name - Should match what was set in vif_details
2. High performance mode - For VM-FEX to be enabled/configured on
the port using this port profile, this mode should be enabled.... | entailment |
def _update_service_profile(self, handle, service_profile,
vlan_id, ucsm_ip):
"""Updates Service Profile on the UCS Manager.
Each of the ethernet ports on the Service Profile representing
the UCS Server, is updated with the VLAN profile corresponding
to t... | Updates Service Profile on the UCS Manager.
Each of the ethernet ports on the Service Profile representing
the UCS Server, is updated with the VLAN profile corresponding
to the vlan_id passed in. | entailment |
def update_vnic_template(self, host_id, vlan_id, physnet,
vnic_template_path, vnic_template):
"""Updates VNIC Template with the vlan_id."""
ucsm_ip = self.get_ucsm_ip_for_host(host_id)
if not ucsm_ip:
LOG.info('UCS Manager network driver does not have UCSM IP '
... | Updates VNIC Template with the vlan_id. | entailment |
def _delete_vlan_profile(self, handle, vlan_id, ucsm_ip):
"""Deletes VLAN Profile from UCS Manager."""
vlan_name = self.make_vlan_name(vlan_id)
vlan_profile_dest = (const.VLAN_PATH + const.VLAN_PROFILE_PATH_PREFIX +
vlan_name)
try:
obj = handle.qu... | Deletes VLAN Profile from UCS Manager. | entailment |
def _delete_port_profile_from_ucsm(self, handle, port_profile, ucsm_ip):
"""Deletes Port Profile from UCS Manager."""
port_profile_dest = (const.PORT_PROFILESETDN + const.VNIC_PATH_PREFIX +
port_profile)
# Find port profile on the UCS Manager
p_profile = han... | Deletes Port Profile from UCS Manager. | entailment |
def _remove_vlan_from_all_service_profiles(self, handle, vlan_id, ucsm_ip):
"""Deletes VLAN Profile config from server's ethernet ports."""
service_profile_list = []
for key, value in six.iteritems(self.ucsm_sp_dict):
if (ucsm_ip in key) and value:
service_profile_lis... | Deletes VLAN Profile config from server's ethernet ports. | entailment |
def _remove_vlan_from_all_sp_templates(self, handle, vlan_id, ucsm_ip):
"""Deletes VLAN config from all SP Templates that have it."""
sp_template_info_list = (
CONF.ml2_cisco_ucsm.ucsms[ucsm_ip].sp_template_list.values())
vlan_name = self.make_vlan_name(vlan_id)
virtio_port_... | Deletes VLAN config from all SP Templates that have it. | entailment |
def _remove_vlan_from_vnic_templates(self, handle, vlan_id, ucsm_ip):
"""Removes VLAN from all VNIC templates that have it enabled."""
ucsm = CONF.ml2_cisco_ucsm.ucsms[ucsm_ip]
vnic_template_info = ucsm.vnic_template_list.values()
vlan_name = self.make_vlan_name(vlan_id)
if not... | Removes VLAN from all VNIC templates that have it enabled. | entailment |
def nova_services_up(self):
"""Checks if required Nova services are up and running.
returns: True if all needed Nova services are up, False otherwise
"""
required = set(['nova-conductor', 'nova-cert', 'nova-scheduler',
'nova-compute'])
try:
ser... | Checks if required Nova services are up and running.
returns: True if all needed Nova services are up, False otherwise | entailment |
def _get_unscheduled_routers(self, plugin, context):
"""Get routers with no agent binding."""
if NEUTRON_VERSION.version[0] <= NEUTRON_NEWTON_VERSION.version[0]:
context, plugin = plugin, context
# TODO(gongysh) consider the disabled agent's router
no_agent_binding = ~sql.exi... | Get routers with no agent binding. | entailment |
def _filter_unscheduled_routers(self, plugin, context, routers):
"""Filter from list of routers the ones that are not scheduled.
Only for release < pike.
"""
if NEUTRON_VERSION.version[0] <= NEUTRON_NEWTON_VERSION.version[0]:
context, plugin = plugin, context
unsc... | Filter from list of routers the ones that are not scheduled.
Only for release < pike. | entailment |
def _get_underscheduled_routers(self, plugin, context):
"""For release >= pike."""
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... | For release >= pike. | entailment |
def auto_schedule_hosting_devices(self, plugin, context, agent_host):
"""Schedules unassociated hosting devices to Cisco cfg agent.
Schedules hosting devices to agent running on <agent_host>.
"""
query = context.session.query(bc.Agent)
query = query.filter_by(agent_type=c_consta... | Schedules unassociated hosting devices to Cisco cfg agent.
Schedules hosting devices to agent running on <agent_host>. | entailment |
def schedule_hosting_device(self, plugin, context, hosting_device):
"""Selects Cisco cfg agent that will configure <hosting_device>."""
active_cfg_agents = plugin.get_cfg_agents(context, active=True)
if not active_cfg_agents:
LOG.warning('There are no active Cisco cfg agents')
... | Selects Cisco cfg agent that will configure <hosting_device>. | entailment |
def _get_external_network_dict(self, context, port_db):
"""Get external network information
Get the information about the external network,
so that it can be used to create the hidden port,
subnet, and network.
"""
if port_db.device_owner == DEVICE_OWNER_ROUTER_GW:
... | Get external network information
Get the information about the external network,
so that it can be used to create the hidden port,
subnet, and network. | entailment |
def apic_driver(self):
"""Get APIC driver
There are different drivers for the GBP workflow
and Neutron workflow for APIC. First see if the GBP
workflow is active, and if so get the APIC driver for it.
If the GBP service isn't installed, try to get the driver
from the Neu... | Get APIC driver
There are different drivers for the GBP workflow
and Neutron workflow for APIC. First see if the GBP
workflow is active, and if so get the APIC driver for it.
If the GBP service isn't installed, try to get the driver
from the Neutron (APIC ML2) workflow. | entailment |
def _snat_subnet_for_ext_net(self, context, subnet, net):
"""Determine if an SNAT subnet is for this external network.
This method determines if a given SNAT subnet is intended for
the passed external network.
For APIC ML2/Neutron workflow, SNAT subnets are created on
a separat... | Determine if an SNAT subnet is for this external network.
This method determines if a given SNAT subnet is intended for
the passed external network.
For APIC ML2/Neutron workflow, SNAT subnets are created on
a separate network from the external network. The association
with an ... | entailment |
def extend_hosting_port_info(self, context, port_db, hosting_device,
hosting_info):
"""Get the segmenetation ID and interface
This extends the hosting info attribute with the segmentation ID
and physical interface used on the external router to connect to
... | Get the segmenetation ID and interface
This extends the hosting info attribute with the segmentation ID
and physical interface used on the external router to connect to
the ACI fabric. The segmentation ID should have been set already
by the call to allocate_hosting_port, but if it's not... | entailment |
def allocate_hosting_port(self, context, router_id, port_db, network_type,
hosting_device_id):
"""Get the VLAN and port for this hosting device
The VLAN used between the APIC and the external router is stored
by the APIC driver. This calls into the APIC driver to ... | Get the VLAN and port for this hosting device
The VLAN used between the APIC and the external router is stored
by the APIC driver. This calls into the APIC driver to first get
the ACI VRF information associated with this port, then uses that
to look up the VLAN to use for this port to ... | entailment |
def _get_ext_net_name_gbp(self, network_name):
"""Get the external network name
The name of the external network used in the APIC
configuration file can be different from the name
of the external network in Neutron, especially using
the GBP workflow
"""
prefix = ... | Get the external network name
The name of the external network used in the APIC
configuration file can be different from the name
of the external network in Neutron, especially using
the GBP workflow | entailment |
def is_valid_mac(addr):
"""Check the syntax of a given mac address.
The acceptable format is xx:xx:xx:xx:xx:xx
"""
addrs = addr.split(':')
if len(addrs) != 6:
return False
for m in addrs:
try:
if int(m, 16) > 255:
return False
except ValueErro... | Check the syntax of a given mac address.
The acceptable format is xx:xx:xx:xx:xx:xx | entailment |
def make_cidr(gw, mask):
"""Create network address in CIDR format.
Return network address for a given gateway address and netmask.
"""
try:
int_mask = (0xFFFFFFFF << (32 - int(mask))) & 0xFFFFFFFF
gw_addr_int = struct.unpack('>L', socket.inet_aton(gw))[0] & int_mask
return (sock... | Create network address in CIDR format.
Return network address for a given gateway address and netmask. | entailment |
def find_agent_host_id(this_host):
"""Returns the neutron agent host id for RHEL-OSP6 HA setup."""
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-' + ... | Returns the neutron agent host id for RHEL-OSP6 HA setup. | entailment |
def _build_credentials(self, nexus_switches):
"""Build credential table for Rest API Client.
:param nexus_switches: switch config
:returns credentials: switch credentials list
"""
credentials = {}
for switch_ip, attrs in nexus_switches.items():
credentials[sw... | Build credential table for Rest API Client.
:param nexus_switches: switch config
:returns credentials: switch credentials list | entailment |
def capture_and_print_timeshot(self, start_time, which,
other=99, switch="x.x.x.x"):
"""Determine delta, keep track, and print results."""
curr_timeout = time.time() - start_time
if which in self.time_stats:
self.time_stats[which]["total_time"] += ... | Determine delta, keep track, and print results. | entailment |
def get_interface_switch(self, nexus_host,
intf_type, interface):
"""Get the interface data from host.
:param nexus_host: IP address of Nexus switch
:param intf_type: String which specifies interface type.
example: ethernet
:param... | Get the interface data from host.
:param nexus_host: IP address of Nexus switch
:param intf_type: String which specifies interface type.
example: ethernet
:param interface: String indicating which interface.
example: 1/19
:returns ... | entailment |
def _get_interface_switch_trunk_present(
self, nexus_host, intf_type, interface):
"""Check if 'switchport trunk' configs present.
:param nexus_host: IP address of Nexus switch
:param intf_type: String which specifies interface type.
example: ethernet
... | Check if 'switchport trunk' configs present.
:param nexus_host: IP address of Nexus switch
:param intf_type: String which specifies interface type.
example: ethernet
:param interface: String indicating which interface.
example: 1... | entailment |
def add_ch_grp_to_interface(
self, nexus_host, if_type, port, ch_grp):
"""Applies channel-group n to ethernet interface."""
if if_type != "ethernet":
LOG.error("Unexpected interface type %(iftype)s when "
"adding change group", {'iftype': if_type})
... | Applies channel-group n to ethernet interface. | entailment |
def _apply_user_port_channel_config(self, nexus_host, vpc_nbr):
"""Adds STP and no lacp suspend config to port channel. """
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_... | Adds STP and no lacp suspend config to port channel. | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.