code string | signature string | docstring string | loss_without_docstring float64 | loss_with_docstring float64 | factor float64 |
|---|---|---|---|---|---|
LOG.info('Starting process_amqp_msgs...')
while True:
(mtd_fr, hdr_fr, body) = (None, None, None)
try:
if self.consume_channel:
(mtd_fr, hdr_fr, body) = self.consume_channel.basic_get(
self._dcnm_queue_name)
... | def process_amqp_msgs(self) | Process AMQP queue messages.
It connects to AMQP server and calls callbacks to process DCNM events,
i.e. routing key containing '.cisco.dcnm.', once they arrive in the
queue. | 2.740808 | 2.524428 | 1.085715 |
ping_cmd = ['ping',
'-c', '5',
'-W', '1',
'-i', '0.2',
ip]
try:
linux_utils.execute(ping_cmd, check_exit_code=True)
return True
except RuntimeError:
LOG.warning("Cannot ping ip address: %s", ip)
return False | def _is_pingable(ip) | Checks whether an IP address is reachable by pinging.
Use linux utils to execute the ping (ICMP ECHO) command.
Sends 5 packets with an interval of 0.2 seconds and timeout of 1
seconds. Runtime error implies unreachability else IP is pingable.
:param ip: IP to check
:return: bool - True or False dep... | 2.88662 | 2.837688 | 1.017244 |
cs = socket.socket()
try:
cs.connect((ip, port))
cs.close()
return True
except socket.error:
return False | def _can_connect(ip, port) | Checks if a TCP port at IP address is possible to connect to | 2.577896 | 2.479514 | 1.039678 |
res = []
for hd_id in self.hosting_devices_backlog:
hd = self.hosting_devices_backlog[hd_id]['hd']
if hd['hd_state'] == cc.HD_DEAD:
res.append(hd['id'])
return res | def get_dead_hosting_devices_info(self) | Get a list of hosting devices that have been marked dead
:return: List of dead hosting device ids | 4.755941 | 4.195632 | 1.133546 |
wait_time = datetime.timedelta(
seconds=cfg.CONF.cfg_agent.hosting_device_dead_timeout)
resp = []
for hd_id in self.hosting_devices_backlog:
hd = self.hosting_devices_backlog[hd_id]['hd']
display_hd = True
if hd_state_filter is not None:... | def get_monitored_hosting_devices_info(self, hd_state_filter=None) | This function returns a list of all hosting devices monitored
by this agent | 3.221173 | 3.232588 | 0.996469 |
ret_val = False
hd = hosting_device
hd_id = hosting_device['id']
hd_mgmt_ip = hosting_device['management_ip_address']
dead_hd_list = self.get_dead_hosting_devices_info()
if hd_id in dead_hd_list:
LOG.debug("Hosting device: %(hd_id)s@%(ip)s is alread... | def is_hosting_device_reachable(self, hosting_device) | Check the hosting device which hosts this resource is reachable.
If the resource is not reachable, it is added to the backlog.
* heartbeat revision
We want to enqueue all hosting-devices into the backlog for
monitoring purposes
adds key/value pairs to hd (aka hosting_device ... | 2.579023 | 2.386315 | 1.080755 |
return super(CiscoRouterPlugin, self).create_floatingip(
context, floatingip,
initial_status=bc.constants.FLOATINGIP_STATUS_DOWN) | def create_floatingip(self, context, floatingip) | Create floating IP.
:param context: Neutron request context
:param floatingip: data for the floating IP being created
:returns: A floating IP object on success
As the l3 router plugin asynchronously creates floating IPs
leveraging the l3 agent and l3 cfg agent, the initial stat... | 4.814982 | 6.133826 | 0.784988 |
in_sub = self.get_in_subnet_id(tenant_id)
out_sub = self.get_out_subnet_id(tenant_id)
# Modify Hard coded Name fixme
subnet_lst = set()
subnet_lst.add(in_sub)
subnet_lst.add(out_sub)
ret = self.os_helper.add_intf_router(router_id, tenant_id, subnet_lst)
... | def attach_intf_router(self, tenant_id, tenant_name, router_id) | Routine to attach the interface to the router. | 4.002516 | 3.927556 | 1.019086 |
router_id = None
if tenant_id in self.tenant_dict:
router_id = self.tenant_dict.get(tenant_id).get('router_id')
if not router_id:
router_list = self.os_helper.get_rtr_by_name(
'FW_RTR_' + tenant_name)
if len(router_list) > 0:
... | def get_router_id(self, tenant_id, tenant_name) | Retrieve the router ID. | 2.478997 | 2.411476 | 1.028 |
in_sub = self.get_in_subnet_id(tenant_id)
out_sub = self.get_out_subnet_id(tenant_id)
subnet_lst = set()
subnet_lst.add(in_sub)
subnet_lst.add(out_sub)
router_id = self.get_router_id(tenant_id, tenant_name)
if router_id:
ret = self.os_helper.d... | def delete_intf_router(self, tenant_id, tenant_name, router_id) | Routine to delete the router. | 2.702158 | 2.680855 | 1.007946 |
max_get_router_info_retry = True
attempt = 0
while max_get_router_info_retry:
port_data = self.os_helper.get_router_port_subnet(subnet_id)
if port_data is None:
LOG.error("Unable to get router port data")
return None
if... | def prepare_router_vm_msg(self, tenant_id, tenant_name, router_id, net_id,
subnet_id, seg, status) | Prepare the message to be sent to Event queue for VDP trigger.
This is actually called for a subnet add to a router. This function
prepares a VM's VNIC create/delete message. | 2.521791 | 2.507385 | 1.005745 |
data = self.prepare_router_vm_msg(tenant_id, tenant_name, router_id,
net_id, subnet_id, seg, status)
if data is None:
return False
timestamp = time.ctime()
pri = Q_PRIORITY
LOG.info("Sending native FW data into queue ... | def send_router_port_msg(self, tenant_id, tenant_name, router_id, net_id,
subnet_id, seg, status) | Sends the router port message to the queue. | 5.840548 | 5.652194 | 1.033324 |
ip_list = self.os_helper.get_subnet_nwk_excl(tenant_id,
arg_dict.get('excl_list'))
srvc_node_ip = self.get_out_srvc_node_ip_addr(tenant_id)
ret = self.dcnm_obj.update_partition_static_route(
arg_dict.get('tenant_name'), fw... | def update_dcnm_partition_static_route(self, tenant_id, arg_dict) | Add static route in DCNM's partition.
This gets pushed to the relevant leaf switches. | 4.393506 | 4.544832 | 0.966704 |
in_seg, in_vlan = self.get_in_seg_vlan(tenant_id)
out_seg, out_vlan = self.get_out_seg_vlan(tenant_id)
in_ip_dict = self.get_in_ip_addr(tenant_id)
out_ip_dict = self.get_out_ip_addr(tenant_id)
excl_list = [in_ip_dict.get('subnet'), out_ip_dict.get('subnet')]
arg... | def _create_arg_dict(self, tenant_id, data, in_sub, out_sub) | Create the argument dictionary. | 1.712142 | 1.698033 | 1.008309 |
LOG.debug("In creating Native FW data is %s", data)
# TODO(padkrish):
# Check if router is already added and only then add, needed for
# restart cases since native doesn't have a special DB
ret, in_sub, out_sub = self.attach_intf_router(tenant_id,
... | def _create_fw(self, tenant_id, data) | Internal routine that gets called when a FW is created. | 5.303424 | 5.246812 | 1.01079 |
try:
return self._create_fw(tenant_id, data)
except Exception as exc:
LOG.error("Failed to create FW for device native, tenant "
"%(tenant)s data %(data)s Exc %(exc)s",
{'tenant': tenant_id, 'data': data, 'exc': exc})
... | def create_fw(self, tenant_id, data) | Top level routine called when a FW is created. | 3.339134 | 3.34263 | 0.998954 |
LOG.debug("In Delete fw data is %s", data)
in_sub = self.get_in_subnet_id(tenant_id)
out_sub = self.get_out_subnet_id(tenant_id)
arg_dict = self._create_arg_dict(tenant_id, data, in_sub, out_sub)
if arg_dict.get('router_id') is None:
LOG.error("Router ID unk... | def _delete_fw(self, tenant_id, data) | Internal routine called when a FW is deleted. | 3.147162 | 3.10885 | 1.012324 |
try:
ret = self._delete_fw(tenant_id, data)
return ret
except Exception as exc:
LOG.error("Failed to delete FW for device native, tenant "
"%(tenant)s data %(data)s Exc %(exc)s",
{'tenant': tenant_id, 'data': data, ... | def delete_fw(self, tenant_id, data) | Top level routine called when a FW is deleted. | 3.518137 | 3.409197 | 1.031955 |
in_ip_dict = self.get_in_ip_addr(tenant_id)
in_gw = in_ip_dict.get('gateway')
in_ip = in_ip_dict.get('subnet')
if in_gw is None:
LOG.error("No FW service GW present")
return False
out_ip_dict = self.get_out_ip_addr(tenant_id)
out_ip = out_... | def _program_dcnm_static_route(self, tenant_id, tenant_name) | Program DCNM Static Route. | 5.100576 | 5.047732 | 1.010469 |
router_id = self.get_router_id(tenant_id, tenant_name)
if not router_id:
LOG.error("Rout ID not present for tenant")
return False
ret = self._program_dcnm_static_route(tenant_id, tenant_name)
if not ret:
LOG.error("Program DCNM with static rou... | def network_create_notif(self, tenant_id, tenant_name, cidr) | Tenant Network create Notification.
Restart is not supported currently for this. fixme(padkrish). | 4.373846 | 4.346532 | 1.006284 |
router_id = self.get_router_id(tenant_id, tenant_name)
if router_id is None:
LOG.error("Rout ID not present for tenant")
return False
ret = self._program_dcnm_static_route(tenant_id, tenant_name)
if not ret:
LOG.error("Program DCNM with static... | def network_delete_notif(self, tenant_id, tenant_name, network_id) | Tenant Network delete Notification.
Restart is not supported currently for this. fixme(padkrish). | 3.480114 | 3.455637 | 1.007083 |
mgmt_port = None
if mgmt_context and mgmt_context.get('mgmt_nw_id') and tenant_id:
# Create port for mgmt interface
p_spec = {'port': {
'tenant_id': tenant_id,
'admin_state_up': True,
'name': 'mgmt',
'networ... | def create_hosting_device_resources(self, context, complementary_id,
tenant_id, mgmt_context, max_hosted) | Create resources for a hosting device in a plugin specific way. | 3.821724 | 3.816879 | 1.001269 |
mgmt_port = None
# Ports for hosting device may not yet have 'device_id' set to
# Nova assigned uuid of VM instance. However, those ports will still
# have 'device_owner' attribute set to complementary_id. Hence, we
# use both attributes in the query to ensure we find al... | def get_hosting_device_resources(self, context, id, complementary_id,
tenant_id, mgmt_nw_id) | Returns information about all resources for a hosting device. | 4.376646 | 4.486369 | 0.975543 |
if mgmt_port is not None:
try:
self._cleanup_hosting_port(context, mgmt_port['id'])
except n_exc.NeutronException as e:
LOG.error("Unable to delete port:%(port)s after %(tries)d"
" attempts due to exception %(exception)s... | def delete_hosting_device_resources(self, context, tenant_id, mgmt_port,
**kwargs) | Deletes resources for a hosting device in a plugin specific way. | 3.272375 | 3.325789 | 0.983939 |
hosting_port = port_db.hosting_info.hosting_port
if hosting_port:
try:
self._dev_mgr.svc_vm_mgr.interface_attach(hosting_device_id,
hosting_port.id)
LOG.debug("Setup logical port completed for ... | def setup_logical_port_connectivity(self, context, port_db,
hosting_device_id) | Establishes connectivity for a logical port.
This is done by hot plugging the interface(VIF) corresponding to the
port from the VM. | 3.691551 | 3.757545 | 0.982437 |
if port_db is None or port_db.get('id') is None:
LOG.warning("Port id is None! Cannot remove port "
"from hosting_device:%s", hosting_device_id)
return
hosting_port_id = port_db.hosting_info.hosting_port.id
try:
self._dev_mgr.s... | def teardown_logical_port_connectivity(self, context, port_db,
hosting_device_id) | Removes connectivity for a logical port.
Unplugs the corresponding data interface from the VM. | 3.572495 | 3.491239 | 1.023274 |
l3admin_tenant_id = self._dev_mgr.l3_tenant_id()
hostingport_name = 'hostingport_' + port_db['id'][:8]
p_spec = {'port': {
'tenant_id': l3admin_tenant_id,
'admin_state_up': True,
'name': hostingport_name,
'network_i... | def allocate_hosting_port(self, context, router_id, port_db, network_type,
hosting_device_id) | Allocates a hosting port for a logical port.
We create a hosting port for the router port | 3.041393 | 3.044636 | 0.998935 |
self.update_server(disabled=True)
if retain_port:
return
self.update_device(disabled=True)
if self.conf.dhcp_delete_namespaces and self.network.namespace:
ns_ip = ip_lib.IPWrapper(self.root_helper,
self.network.namespa... | def disable(self, retain_port=False) | Teardown DHCP.
Disable DHCP for this network by updating the remote server
and then destroying any local device and namespace. | 3.586576 | 3.062575 | 1.171098 |
if "_devices" in globals():
return
global _devices
confs_dir = os.path.abspath(os.path.normpath(cfg.CONF.dhcp_confs))
for netid in os.listdir(confs_dir):
conf_dir = os.path.join(confs_dir, netid)
intf_filename = os.path.join(conf_dir, 'inter... | def recover_devices(cls) | Track devices.
Creates global dict to track device names across driver invocations
and populates based on current devices configured on the system. | 3.507638 | 3.252175 | 1.078552 |
super(SimpleCpnrDriver, cls).check_version()
model.configure_pnr()
cls.recover_networks()
ver = model.get_version()
if ver < cls.MIN_VERSION:
LOG.warning("CPNR version does not meet minimum requirements, "
"expected: %(ever)f, actual: ... | def check_version(cls) | Checks server version against minimum required version. | 7.663496 | 7.269874 | 1.054144 |
global _networks
sup = super(SimpleCpnrDriver, cls)
superkeys = sup.existing_dhcp_networks(conf)
return set(_networks.keys()) & set(superkeys) | def existing_dhcp_networks(cls, conf) | Return a list of existing networks ids that we have configs for. | 10.701483 | 9.442668 | 1.133311 |
id = self.network.id
net = model.Network.from_neutron(self.network)
if id not in _networks:
if disabled:
return
_networks[id] = net
_networks[id].create()
elif disabled:
_networks[id].delete()
del _netwo... | def _unsafe_update_server(self, disabled=False) | Update server with latest network configuration. | 3.468235 | 3.316906 | 1.045624 |
try:
body = {'network': {'name': name, 'tenant_id': tenant_id,
'admin_state_up': True}}
netw = self.neutronclient.create_network(body=body)
net_dict = netw.get('network')
net_id = net_dict.get('id')
except Exceptio... | def create_network(self, name, tenant_id, subnet, gw=None) | Create the openstack network, including the subnet. | 1.550002 | 1.547555 | 1.001581 |
try:
self.neutronclient.delete_subnet(subnet_id)
except Exception as exc:
LOG.error("Failed to delete subnet %(sub)s exc %(exc)s",
{'sub': subnet_id, 'exc': str(exc)})
return
try:
self.neutronclient.delete_network(net... | def delete_network(self, name, tenant_id, subnet_id, net_id) | Delete the openstack subnet and network. | 1.793198 | 1.819803 | 0.98538 |
try:
body = {'network_id': net_id}
subnet_list = self.neutronclient.list_subnets(body=body)
subnet_list = subnet_list.get('subnets')
for subnet in subnet_list:
if subnet.get('network_id') == net_id:
subnet_id = subnet.g... | def delete_network_all_subnets(self, net_id) | Delete the openstack network including all its subnets. | 1.71004 | 1.752951 | 0.975521 |
try:
subnet_list = self.neutronclient.list_subnets(body={})
subnet_dat = subnet_list.get('subnets')
for sub in subnet_dat:
if sub.get('cidr') == subnet_addr:
return True
return False
except Exception as exc:
... | def is_subnet_present(self, subnet_addr) | Returns if a subnet is present. | 2.792872 | 2.680208 | 1.042035 |
body = {}
subnet_cidrs = []
try:
subnet_list = self.neutronclient.list_subnets(body=body)
subnet_dat = subnet_list.get('subnets')
for sub in subnet_dat:
if no_mask:
subnet_cidrs.append(sub.get('cidr').split('/')[0])... | def get_all_subnets_cidr(self, no_mask=False) | Returns all the subnets. | 2.590806 | 2.528092 | 1.024807 |
try:
subnet_list = self.neutronclient.list_subnets(network_id=net)
subnet_dat = subnet_list.get('subnets')
return subnet_dat
except Exception as exc:
LOG.error("Failed to list subnet net %(net)s, Exc: %(exc)s",
{'net': net, '... | def get_subnets_for_net(self, net) | Returns the subnets in a network. | 3.108608 | 2.965948 | 1.048099 |
try:
subnet_list = self.neutronclient.list_subnets(id=subnet_id)
subnet_dat = subnet_list.get('subnets')[0]
return subnet_dat.get('cidr')
except Exception as exc:
LOG.error("Failed to list subnet for ID %(subnet)s, "
"exc %(e... | def get_subnet_cidr(self, subnet_id) | retrieve the CIDR associated with a subnet, given its ID. | 2.581094 | 2.618152 | 0.985846 |
try:
body = {}
net_list = self.neutronclient.list_networks(body=body)
for net in net_list:
if net.get('name').find(sub_name) != -1:
self.delete_network_all_subnets(net.get('net_id'))
except Exception as exc:
LOG... | def delete_network_subname(self, sub_name) | Delete the network by part of its name, use with caution. | 3.305296 | 3.303701 | 1.000483 |
ret_net_lst = []
try:
body = {}
net_list = self.neutronclient.list_networks(body=body)
net_list = net_list.get('networks')
for net in net_list:
if net.get('name') == nwk_name:
ret_net_lst.append(net)
exc... | def get_network_by_name(self, nwk_name) | Search for a openstack network by name. | 2.289066 | 2.187532 | 1.046415 |
ret_net_lst = []
try:
net_list = self.neutronclient.list_networks(body={})
for net in net_list.get('networks'):
if net.get('tenant_id') == tenant_id:
ret_net_lst.append(net)
except Exception as exc:
LOG.error("Faile... | def get_network_by_tenant(self, tenant_id) | Returns the network of a given tenant. | 2.379848 | 2.407917 | 0.988343 |
upd_rtr_list = []
try:
rtr_list = self.neutronclient.list_routers()
for rtr in rtr_list.get('routers'):
if rtr_name == rtr['name']:
upd_rtr_list.append(rtr)
except Exception as exc:
LOG.error("Failed to get router b... | def get_rtr_by_name(self, rtr_name) | Search a router by its name. | 2.186069 | 2.156796 | 1.013573 |
try:
body = {'router': {'name': name, 'tenant_id': tenant_id,
'admin_state_up': True}}
router = self.neutronclient.create_router(body=body)
rout_dict = router.get('router')
rout_id = rout_dict.get('id')
except Except... | def create_router(self, name, tenant_id, subnet_lst) | Create a openstack router and add the interfaces. | 2.05705 | 2.029892 | 1.013379 |
try:
for subnet_id in subnet_lst:
body = {'subnet_id': subnet_id}
intf = self.neutronclient.add_interface_router(rout_id,
body=body)
intf.get('port_id')
except Exception as... | def add_intf_router(self, rout_id, tenant_id, subnet_lst) | Add the interfaces to a router. | 3.077171 | 3.038785 | 1.012632 |
ret = self.delete_intf_router(name, tenant_id, rout_id, subnet_lst)
if not ret:
return False
try:
ret = self.neutronclient.delete_router(rout_id)
except Exception as exc:
LOG.error("Failed to delete router %(name)s ret %(ret)s "
... | def delete_router(self, name, tenant_id, rout_id, subnet_lst) | Delete the openstack router.
Delete the router and remove the interfaces attached to it. | 2.580622 | 2.58673 | 0.997639 |
try:
for subnet_id in subnet_lst:
body = {'subnet_id': subnet_id}
intf = self.neutronclient.remove_interface_router(rout_id,
body=body)
intf.get('id')
except Exception a... | def delete_intf_router(self, name, tenant_id, rout_id, subnet_lst) | Delete the openstack router and remove the interfaces attached. | 3.030437 | 3.069774 | 0.987185 |
try:
routers = self.neutronclient.list_routers()
rtr_list = routers.get('routers')
for rtr in rtr_list:
if rtr_name == rtr['name']:
self.neutronclient.delete_router(rtr['id'])
except Exception as exc:
LOG.error(... | def delete_router_by_name(self, rtr_name, tenant_id) | Delete the openstack router and its interfaces given its name.
The interfaces should be already removed prior to calling this
function. | 2.128478 | 2.218795 | 0.959295 |
try:
body = {}
self.neutronclient.show_router(router_id, body=body)
except Exception as exc:
LOG.error("Failed to show router interface %(id)s "
"Exc %(exc)s", {'id': router_id, 'exc': str(exc)})
return | def get_router_intf(self, router_id) | Retrieve the router interfaces. Incomplete, TODO(padkrish). | 3.218257 | 3.176955 | 1.013 |
try:
body = {}
router = self.neutronclient.show_router(router_id, body=body)
return router.get('router').get('name')
except Exception as exc:
LOG.error("Failed to show router interface %(id)s "
"Exc %(exc)s", {'id': router_id... | def get_rtr_name(self, router_id) | Retrieve the router name. Incomplete. | 3.252012 | 3.178951 | 1.022983 |
if rout_id is None:
return None
args = ['ip', 'netns', 'list']
try:
ns_list = utils.execute(args, root_helper=self.root_helper)
except Exception as exc:
LOG.error("Unable to find the namespace list Exception %s",
exc)
... | def find_rtr_namespace(self, rout_id) | Find the namespace associated with the router. | 3.132939 | 3.004486 | 1.042754 |
if namespace is None:
namespace = self.find_rtr_namespace(rout_id)
if namespace is None:
LOG.error("Unable to find namespace for router %s", rout_id)
return False
final_args = ['ip', 'netns', 'exec', namespace] + args
try:
utils.ex... | def program_rtr(self, args, rout_id, namespace=None) | Execute the command against the namespace. | 2.255589 | 2.193885 | 1.028125 |
args = ['route', 'add', 'default', 'gw', gw]
ret = self.program_rtr(args, rout_id)
if not ret:
LOG.error("Program router returned error for %s", rout_id)
return False
return True | def program_rtr_default_gw(self, tenant_id, rout_id, gw) | Program the default gateway of a router. | 4.432785 | 4.353201 | 1.018282 |
net_list = self.get_network_by_tenant(tenant_id)
ret_subnet_list = []
for net in net_list:
if excl_part:
name = net.get('name')
part = name.partition('::')[2]
if part:
continue
subnet_lst = self.... | def get_subnet_nwk_excl(self, tenant_id, excl_list, excl_part=False) | Retrieve the subnets of a network.
Get the subnets inside a network after applying the exclusion
list. | 2.463663 | 2.516846 | 0.978869 |
namespace = self.find_rtr_namespace(rout_id)
if namespace is None:
LOG.error("Unable to find namespace for router %s", rout_id)
return False
net_list = self.get_network_by_tenant(tenant_id)
for net in net_list:
subnet_lst = self.get_subnets_f... | def program_rtr_all_nwk_next_hop(self, tenant_id, rout_id, next_hop,
excl_list) | Program the next hop for all networks of a tenant. | 2.803023 | 2.741034 | 1.022615 |
namespace = self.find_rtr_namespace(rout_id)
if namespace is None:
LOG.error("Unable to find namespace for router %s", rout_id)
return False
args = ['route', 'add', '-net', cidr, 'gw', next_hop]
ret = self.program_rtr(args, rout_id, namespace=namespace)
... | def program_rtr_nwk_next_hop(self, rout_id, next_hop, cidr) | Program the next hop for all networks of a tenant. | 3.128213 | 3.227878 | 0.969124 |
namespace = self.find_rtr_namespace(rout_id)
if namespace is None:
LOG.error("Unable to find namespace for router %s", rout_id)
return False
args = ['ip', 'route']
ret = self.program_rtr_return(args, rout_id, namespace=namespace)
if ret is None:
... | def remove_rtr_nwk_next_hop(self, rout_id, next_hop, subnet_lst,
excl_list) | Remove the next hop for all networks of a tenant. | 2.903955 | 2.853769 | 1.017586 |
fw = None
try:
fw = self.neutronclient.show_firewall(fw_id)
except Exception as exc:
LOG.error("Failed to get firewall list for id %(id)s, "
"Exc %(exc)s", {'id': fw_id, 'exc': str(exc)})
return fw | def get_fw(self, fw_id) | Return the Firewall given its ID. | 2.997152 | 2.839656 | 1.055463 |
rule = None
try:
rule = self.neutronclient.show_firewall_rule(rule_id)
except Exception as exc:
LOG.error("Failed to get firewall rule for id %(id)s "
"Exc %(exc)s", {'id': rule_id, 'exc': str(exc)})
return rule | def get_fw_rule(self, rule_id) | Return the firewall rule, given its ID. | 2.594782 | 2.446025 | 1.060816 |
policy = None
try:
policy = self.neutronclient.show_firewall_policy(policy_id)
except Exception as exc:
LOG.error("Failed to get firewall plcy for id %(id)s "
"Exc %(exc)s",
{'id': policy_id, 'exc': str(exc)})
r... | def get_fw_policy(self, policy_id) | Return the firewall policy, given its ID. | 2.990584 | 2.814512 | 1.062558 |
details = router.pop(ha.DETAILS, {})
if details == ATTR_NOT_SPECIFIED:
details = {}
res = {ha.ENABLED: router.pop(ha.ENABLED, ATTR_NOT_SPECIFIED),
ha.DETAILS: details}
if not is_attr_set(res[ha.ENABLED]):
res[ha.ENABLED] = router_type['ha_... | def _ensure_create_ha_compliant(self, router, router_type) | To be called in create_router() BEFORE router is created in DB. | 2.162066 | 2.133575 | 1.013353 |
if (ha.ENABLED not in ha_settings or
not ha_settings[ha.ENABLED]):
new_router[ha.HA] = {ha.ENABLED: False}
return
ha_spec = ha_settings[ha.DETAILS]
priority = ha_spec.get(ha.PRIORITY, DEFAULT_MASTER_PRIORITY)
with context.session.begin(sub... | def _create_redundancy_routers(self, context, new_router, ha_settings,
new_router_db, ports=None, expire_db=False) | To be called in create_router() AFTER router has been
created in DB. | 2.942595 | 2.93345 | 1.003117 |
if r_hd_binding_db.role == ROUTER_ROLE_HA_REDUNDANCY:
return {ha.ENABLED: False}
auto_enable_ha = r_hd_binding_db.router_type.ha_enabled_by_default
requested_ha_details = router.pop(ha.DETAILS, {})
# If ha_details are given then ha is assumed to be enabled even if
... | def _ensure_update_ha_compliant(self, router, current_router,
r_hd_binding_db) | To be called in update_router() BEFORE router has been
updated in DB. | 3.684659 | 3.713123 | 0.992334 |
if not router[ha.ENABLED]:
# No HA currently enabled so we're done
return
e_context = context.elevated()
# since gateway is about to change the ha group for the current gateway
# is removed, a new one will be created later
self._delete_ha_group(e_... | def _teardown_redundancy_router_gw_connectivity(self, context, router,
router_db,
plugging_driver) | To be called in update_router() if the router gateway is to change
BEFORE router has been updated in DB . | 4.458307 | 4.309701 | 1.034482 |
priority = (DEFAULT_MASTER_PRIORITY +
(start_index - 1) * PRIORITY_INCREASE_STEP)
r = copy.deepcopy(user_visible_router)
# No tenant_id so redundancy routers are hidden from user
r['tenant_id'] = ''
name = r['name']
redundancy_r_ids = []
... | def _add_redundancy_routers(self, context, start_index, stop_index,
user_visible_router, ports=None,
ha_settings_db=None, create_ha_group=True) | Creates a redundancy router and its interfaces on
the specified subnets. | 3.98582 | 4.002322 | 0.995877 |
subnets_info = [{'subnet_id': port['fixed_ips'][0]['subnet_id']}
for port in ports]
for r_id in router_ids:
for i in range(len(subnets_info)):
self.remove_router_interface(context, r_id, subnets_info[i])
LOG.debug("Removed inte... | def _remove_redundancy_routers(self, context, router_ids, ports,
delete_ha_groups=False) | Deletes all interfaces of the specified redundancy routers
and then the redundancy routers themselves. | 2.538098 | 2.467406 | 1.02865 |
e_context = context.elevated()
for binding in router_db.redundancy_bindings:
self.delete_router(e_context, binding.redundancy_router_id)
LOG.debug("Deleted redundancy router %s",
binding.redundancy_router_id)
if router_db.gw_port_id:
... | def _delete_redundancy_routers(self, context, router_db) | To be called in delete_router() BEFORE router has been
deleted in DB. The router should have not interfaces. | 3.4351 | 3.553553 | 0.966666 |
router_id = router['id']
if ha_settings_db is None:
ha_settings_db = self._get_ha_settings_by_router_id(context,
router_id)
if ha_settings_db is None:
return
e_context = context.elevated()
... | def _update_redundancy_router_interfaces(self, context, router,
port, modified_port_data,
redundancy_router_ids=None,
ha_settings_db=None) | To be called when the router interfaces are updated,
like in the case of change in port admin_state_up status | 2.206857 | 2.225875 | 0.991456 |
ha_settings = self._get_ha_settings_by_router_id(context, router_id)
if ha_settings is None or old_port is None:
return
e_context = context.elevated()
rr_ids = self._get_redundancy_router_ids(e_context, router_id)
port_info_list = self._core_plugin.get_ports(... | def _remove_redundancy_router_interfaces(self, context, router_id,
old_port) | To be called in delete_router_interface() BEFORE interface has been
removed from router in DB. | 2.10622 | 2.082833 | 1.011229 |
if ha_settings_db is None:
ha_settings_db = self._get_ha_settings_by_router_id(context,
router_id)
if ha_settings_db is None:
return
e_context = context.elevated()
router_ids = []
fo... | def _redundancy_routers_for_floatingip(
self, context, router_id, redundancy_router_ids=None,
ha_settings_db=None) | To be called in update_floatingip() to get the
redundant router ids. | 2.202019 | 2.097862 | 1.049649 |
r_r_b = self._get_redundancy_router_bindings(
context, redundancy_router_id=router['id'])
if not r_r_b:
if router[ha.ENABLED]:
# The router is a user visible router with HA enabled.
user_router_id = router['id']
fips = []
... | def _populate_ha_information(self, context, router) | To be called when router information, including router interface
list, (for the l3_cfg_agent) has been collected so it is extended
with ha information. | 3.484005 | 3.411952 | 1.021118 |
port = {'port': {
'tenant_id': '', # intentionally not set
'network_id': network_id,
'mac_address': ATTR_NOT_SPECIFIED,
'fixed_ips': fixed_ips,
'device_id': device_id,
'device_owner': port_type,
'admin_state_up': True,... | def _create_hidden_port(self, context, network_id, device_id, fixed_ips,
port_type=DEVICE_OWNER_ROUTER_INTF) | Creates port used specially for HA purposes. | 2.9082 | 2.864727 | 1.015176 |
gw_port = orm.aliased(models_v2.Port, name="gw_port")
routerport_qry = context.session.query(
RouterPort.router_id, models_v2.IPAllocation.ip_address).join(
models_v2.Port, models_v2.IPAllocation).filter(
models_v2.Port.network_id == internal_port['network_id... | def get_router_for_floatingip(self, context, internal_port,
internal_subnet, external_network_id) | We need to over-load this function so that we only return the
user visible router and never its redundancy routers (as they never
have floatingips associated with them). | 2.687536 | 2.495017 | 1.077161 |
for cnt in self.res:
used = self.res.get(cnt).get('used')
if used < self.res.get(cnt).get('quota'):
self.res[cnt]['used'] = used + 1
self.res[cnt]['fw_id_lst'].append(fw_id)
return self.res[cnt].get('obj_dict'), (
... | def allocate_fw_dev(self, fw_id) | Allocate firewall device.
Allocate the first Firewall device which has resources available. | 3.916985 | 3.782016 | 1.035687 |
for cnt in self.res:
used = self.res.get(cnt).get('used')
if mgmt_ip == self.res[cnt].get('mgmt_ip'):
if new:
self.res[cnt]['used'] = used + 1
self.res[cnt]['fw_id_lst'].append(fw_id)
return self.res[cnt].get('o... | def populate_fw_dev(self, fw_id, mgmt_ip, new) | Populate the class after a restart. | 3.668563 | 3.568398 | 1.02807 |
for cnt in self.res:
if fw_id in self.res.get(cnt).get('fw_id_lst'):
return self.res[cnt].get('obj_dict'), (
self.res[cnt].get('mgmt_ip'))
return None, None | def get_fw_dev_map(self, fw_id) | Return the object dict and mgmt ip for a firewall. | 5.600667 | 3.661863 | 1.529459 |
for cnt in self.res:
if fw_id in self.res.get(cnt).get('fw_id_lst'):
self.res[cnt]['used'] = self.res[cnt]['used'] - 1
self.res.get(cnt).get('fw_id_lst').remove(fw_id)
return | def deallocate_fw_dev(self, fw_id) | Release the firewall resource. | 3.008141 | 2.854995 | 1.053642 |
for fw_id in fw_dict:
fw_data = fw_dict.get(fw_id)
mgmt_ip = fw_data.get('fw_mgmt_ip')
dev_status = fw_data.get('device_status')
if dev_status == 'SUCCESS':
new = True
else:
new = False
if mgmt_ip is... | def populate_local_sch_cache(self, fw_dict) | Populate the local cache from FW DB after restart. | 3.81791 | 3.685677 | 1.035878 |
cnt = 0
for ip in self.obj_dict:
cfg_dict = {}
drvr_obj = self.obj_dict.get(ip).get('drvr_obj')
cfg_dict['mgmt_ip_addr'] = ip
if self.user_list is not None:
cfg_dict['user'] = self.user_list[cnt]
if self.pwd_list is not... | def drvr_initialize(self, cfg) | Initialize the driver routines. | 2.171919 | 2.185774 | 0.993661 |
for ip in self.obj_dict:
drvr_obj = self.obj_dict.get(ip).get('drvr_obj')
drvr_obj.populate_event_que(que_obj) | def populate_event_que(self, que_obj) | Populates the event queue object.
This is for sending router events to event handler. | 4.402802 | 4.447738 | 0.989897 |
for ip in self.obj_dict:
drvr_obj = self.obj_dict.get(ip).get('drvr_obj')
drvr_obj.populate_dcnm_obj(dcnm_obj) | def populate_dcnm_obj(self, dcnm_obj) | Populates the DCNM object. | 3.833513 | 3.786177 | 1.012502 |
for ip in self.obj_dict:
drvr_obj = self.obj_dict.get(ip).get('drvr_obj')
ret = drvr_obj.is_device_virtual()
# No way to pin a device as of now, so return the first
# TODO(padkrish)
return ret | def is_device_virtual(self) | Returns if the device is physical or virtual. | 8.706341 | 7.798263 | 1.116446 |
drvr_dict, mgmt_ip = self.sched_obj.allocate_fw_dev(fw_id)
if drvr_dict is not None and mgmt_ip is not None:
self.update_fw_db_mgmt_ip(fw_id, mgmt_ip)
ret = drvr_dict.get('drvr_obj').create_fw(tenant_id, data)
if not ret:
self.sched_obj.deallo... | def create_fw_device(self, tenant_id, fw_id, data) | Creates the Firewall. | 3.353672 | 3.278456 | 1.022942 |
drvr_dict, mgmt_ip = self.sched_obj.get_fw_dev_map(fw_id)
ret = drvr_dict.get('drvr_obj').delete_fw(tenant_id, data)
# FW DB gets deleted, so no need to remove the MGMT IP
if ret:
self.sched_obj.deallocate_fw_dev(fw_id)
return ret | def delete_fw_device(self, tenant_id, fw_id, data) | Deletes the Firewall. | 6.456001 | 6.534622 | 0.987968 |
drvr_dict, mgmt_ip = self.sched_obj.get_fw_dev_map(fw_id)
return drvr_dict.get('drvr_obj').modify_fw(tenant_id, data) | def modify_fw_device(self, tenant_id, fw_id, data) | Modifies the firewall cfg. | 7.860921 | 7.851231 | 1.001234 |
for ip in self.obj_dict:
drvr_obj = self.obj_dict.get(ip).get('drvr_obj')
ret = drvr_obj.network_create_notif(tenant_id, tenant_name, cidr)
LOG.info("Driver with IP %(ip)s return %(ret)s",
{'ip': ip, 'ret': ret}) | def network_create_notif(self, tenant_id, tenant_name, cidr) | Notification for Network create.
Since FW ID not present, it's not possible to know which FW instance
to call. So, calling everyone, each instance will figure out if it
applies to them. | 3.406245 | 3.585423 | 0.950026 |
for ip in self.obj_dict:
drvr_obj = self.obj_dict.get(ip).get('drvr_obj')
ret = drvr_obj.network_delete_notif(tenant_id, tenant_name,
net_id)
LOG.info("Driver with IP %(ip)s return %(ret)s for network "
... | def network_delete_notif(self, tenant_id, tenant_name, net_id) | Notification for Network delete.
Since FW ID not present, it's not possible to know which FW instance
to call. So, calling everyone, each instance will figure out if it
applies to them. | 3.371755 | 3.541698 | 0.952016 |
return self._l3plugin.cfg_list_router_ids_on_host(context, host,
router_ids,
hosting_device_ids) | def get_cfg_router_ids(self, context, host, router_ids=None,
hosting_device_ids=None) | Returns IDs of routers scheduled to l3 agent on <host> | 5.293848 | 4.909015 | 1.078393 |
adm_context = bc.context.get_admin_context()
try:
routers = (
self._l3plugin.list_active_sync_routers_on_hosting_devices(
adm_context, host, router_ids, hosting_device_ids))
except AttributeError:
routers = []
LOG.debug... | def cfg_sync_routers(self, context, host, router_ids=None,
hosting_device_ids=None) | Sync routers according to filters to a specific Cisco cfg agent.
:param context: contains user information
:param host: originator of callback
:param router_ids: list of router ids to return information about
:param hosting_device_ids: list of hosting device ids to get
route... | 4.30846 | 4.29711 | 1.002641 |
with context.session.begin(subtransactions=True):
for (floatingip_id, status) in six.iteritems(fip_statuses):
LOG.debug("New status for floating IP %(floatingip_id)s: "
"%(status)s", {'floatingip_id': floatingip_id,
... | def update_floatingip_statuses_cfg(self, context, router_id, fip_statuses) | Update operational status for one or several floating IPs.
This is called by Cisco cfg agent to update the status of one or
several floatingips.
:param context: contains user information
:param router_id: id of router associated with the floatingips
:param router_id: dict with ... | 3.420755 | 3.606984 | 0.94837 |
self._l3plugin.update_router_port_statuses(context, port_ids,
status) | def update_port_statuses_cfg(self, context, port_ids, status) | Update the operational statuses of a list of router ports.
This is called by the Cisco cfg agent to update the status of a list
of ports.
:param context: contains user information
:param port_ids: list of ids of all the ports for the given status
:param status: PORT_STATUS_ACTI... | 5.063385 | 5.448362 | 0.929341 |
try:
parser = ConfigParser.ConfigParser()
cfg_fp = open(cfg_file)
parser.readfp(cfg_fp)
cfg_fp.close()
except ConfigParser.NoOptionError:
cfg_fp.close()
print('Failed to find mysql connections credentials.')
sys.exit(1)
except IOError:
pr... | def get_mysql_credentials(cfg_file) | Get the credentials and database name from options in config file. | 2.899332 | 2.861894 | 1.013081 |
if not cfgfile or not outfn:
print('ERROR: There is no config file.')
sys.exit(0)
options = service_options[service_name]
with open(cfgfile, 'r') as cf:
lines = cf.readlines()
for opt in options:
op = opt.get('option')
res = [line for line in lines if line... | def modify_conf(cfgfile, service_name, outfn) | Modify config file neutron and keystone to include enabler options. | 2.709267 | 2.708077 | 1.00044 |
cctxt = self.client.prepare()
return cctxt.call(context,
'get_all_hosting_devices',
host=self.host) | def get_all_hosting_devices(self, context) | Get a list of all hosting devices. | 2.718031 | 2.361391 | 1.15103 |
cctxt = self.client.prepare()
return cctxt.call(context, 'cfg_sync_all_hosted_routers',
host=self.host) | def get_all_hosted_routers(self, context) | Make a remote process call to retrieve the sync data for
routers that have been scheduled to a hosting device.
:param context: session context | 4.5016 | 4.601696 | 0.978248 |
cctxt = self.client.prepare()
return cctxt.call(context,
'get_hardware_router_type_id',
host=self.host) | def get_hardware_router_type_id(self, context) | Get the ID for the ASR1k hardware router type. | 2.678913 | 2.473252 | 1.083154 |
args = jsonutils.loads(msg)
when = args.get('when')
agent = args.get('agent')
# The configurations in here, only used once when creating entry
# for an agent in DB for the first time.
configurations = {'uplink': ''}
LOG.debug('heartbeat received: %(time)... | def heartbeat(self, context, msg) | Process heartbeat message from agents on compute nodes. | 7.119282 | 7.037612 | 1.011605 |
LOG.debug('request_uplink_info from %(agent)s', {'agent': agent})
# Add the request into queue for processing.
event_type = 'agent.request.uplink'
payload = {'agent': agent}
timestamp = time.ctime()
data = (event_type, payload)
pri = self.obj.PRI_LOW_ST... | def request_uplink_info(self, context, agent) | Process uplink message from an agent. | 5.580308 | 5.43975 | 1.025839 |
args = jsonutils.loads(msg)
macaddr = args.get('mac')
ipaddr = args.get('ip')
LOG.debug('set_static_ip_address received: %(mac)s %(ip)s', (
{'mac': macaddr, 'ip': ipaddr}))
# Add the request into queue for processing.
event_type = 'cli.static_i... | def set_static_ip_address(self, context, msg) | Process request for setting rules in iptables.
In cases that static ip address is assigned for a VM, it is needed
to update the iptables rule for that address. | 4.853479 | 5.033251 | 0.964283 |
args = jsonutils.loads(msg)
agent = context.get('agent')
port_id = args.get('port_uuid')
result = args.get('result')
LOG.debug('update_vm_result received from %(agent)s: '
'%(port_id)s %(result)s', {'agent': agent,
... | def update_vm_result(self, context, msg) | Update VM's result field in the DB.
The result reflects the success of failure of operation when an
agent processes the vm info. | 5.169995 | 5.129924 | 1.007811 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.