Remove some pylint exclusions (part 2)

Change-Id: I2047f083af01dd0452f61d9fb807098e0514ff36
This commit is contained in:
asarfaty 2020-10-01 10:25:06 +02:00
parent b6bd7e49d1
commit 26f855f9c9
18 changed files with 134 additions and 142 deletions

View File

@ -32,13 +32,10 @@ disable=
expression-not-assigned,
fixme,
global-statement,
literal-comparison,
no-init,
non-parent-init-called,
not-callable,
protected-access,
redefined-builtin,
redefined-outer-name,
signature-differs,
star-args,
super-init-not-called,
@ -52,12 +49,12 @@ disable=
# TODO(dougwig) - disable nonstandard-exception while we have neutron_lib shims
nonstandard-exception,
# "C" Coding convention violations
bad-continuation,
# bad-continuation,
consider-iterating-dictionary,
consider-using-enumerate,
invalid-name,
len-as-condition,
misplaced-comparison-constant,
# misplaced-comparison-constant,
missing-docstring,
singleton-comparison,
superfluous-parens,

View File

@ -162,12 +162,12 @@ class ApiReplayClient(utils.PrepareObjectForMigration):
tenant_name, tenant_domain_id,
password, auth_url)
endpoint = sess.get_endpoint(service_type='load-balancer')
client = octavia.OctaviaAPI(
client_obj = octavia.OctaviaAPI(
session=sess,
service_type='load-balancer',
endpoint=endpoint,
)
return client
return client_obj
def find_subnet_by_id(self, subnet_id, subnets):
for subnet in subnets:

View File

@ -160,8 +160,8 @@ class DhcpMetadataAccess(object):
report = self.migration_manager.report(context, network_id)
return {'network': network_id, 'report': report}
def create_lsn(self, context, lsn):
network_id = lsn['lsn']['network']
def create_lsn(self, context, lsn_data):
network_id = lsn_data['lsn']['network']
subnet = self.migration_manager.validate(context, network_id)
subnet_id = None if not subnet else subnet['id']
self.migration_manager.migrate(context, network_id, subnet)

View File

@ -202,9 +202,9 @@ class DvsManager(VCManagerBase):
self._session.vim,
val, ['name'])
if len(props) and hasattr(props[0], 'propSet'):
for prop in props[0].propSet:
for prop2 in props[0].propSet:
# match name or mor id
if net_id == prop.val or net_id == val.value:
if net_id == prop2.val or net_id == val.value:
# NOTE(garyk): update cache
return val
raise exceptions.NetworkNotFound(net_id=net_id)
@ -377,8 +377,8 @@ class DvsManager(VCManagerBase):
self._session.vim,
pg_moref, ['name'])
if len(props) and hasattr(props[0], 'propSet'):
for prop in props[0].propSet:
if net_id in prop.val and net_moref in prop.val:
for prop2 in props[0].propSet:
if net_id in prop2.val and net_moref in prop2.val:
found = True
self._reconfigure_port_group(
pg_moref,

View File

@ -1279,14 +1279,14 @@ class NsxPluginV3Base(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
def _get_external_attachment_info(self, context, router):
gw_port = router.gw_port
ipaddress = None
ipaddr = None
netmask = None
nexthop = None
if gw_port:
# gw_port may have multiple IPs, only configure the first one
if gw_port.get('fixed_ips'):
ipaddress = gw_port['fixed_ips'][0]['ip_address']
ipaddr = gw_port['fixed_ips'][0]['ip_address']
network_id = gw_port.get('network_id')
if network_id:
@ -1300,7 +1300,7 @@ class NsxPluginV3Base(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
netmask = str(netaddr.IPNetwork(ext_subnet.cidr).netmask)
nexthop = ext_subnet.gateway_ip
return (ipaddress, netmask, nexthop)
return (ipaddr, netmask, nexthop)
def _get_tier0_uuid_by_net_id(self, context, network_id):
if not network_id:

View File

@ -1751,17 +1751,17 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
# and therefore, the spoofguard policy is being removed for this net.
orig_net = self.get_network(context, id)
if not net_attrs[psec.PORTSECURITY]:
sg_policy = nsxv_db.get_spoofguard_policy_id(context.session,
sg_pol = nsxv_db.get_spoofguard_policy_id(context.session,
orig_net['id'])
if sg_policy:
if sg_pol:
try:
self.nsx_v.vcns.delete_spoofguard_policy(sg_policy)
self.nsx_v.vcns.delete_spoofguard_policy(sg_pol)
nsxv_db.del_nsxv_spoofguard_binding(context.session,
sg_policy)
sg_pol)
except Exception as e:
LOG.error('Unable to delete spoofguard policy '
'%(sg_policy)s. Error: %(e)s',
{'sg_policy': sg_policy, 'e': e})
{'sg_policy': sg_pol, 'e': e})
else:
LOG.warning("Could not locate spoofguard policy for "
"network %s", id)
@ -4380,7 +4380,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
context,
securitygroup,
nsx_sg_id):
logging = (cfg.CONF.nsxv.log_security_groups_allowed_traffic or
logged = (cfg.CONF.nsxv.log_security_groups_allowed_traffic or
securitygroup[sg_logging.LOGGING])
action = 'deny' if securitygroup[provider_sg.PROVIDER] else 'allow'
section_name = self.nsx_sg_utils.get_nsx_section_name(securitygroup)
@ -4388,7 +4388,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
# Translate Neutron rules to NSXv fw rules and construct the fw section
for rule in securitygroup['security_group_rules']:
nsx_rule = self._create_nsx_rule(
context, rule, nsx_sg_id, logged=logging, action=action)
context, rule, nsx_sg_id, logged=logged, action=action)
nsx_rules.append(nsx_rule)
section = self.nsx_sg_utils.get_section_with_rules(
section_name, nsx_rules)
@ -4798,7 +4798,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
with locking.LockManager.get_lock('rule-update-%s' % sg_id):
# Querying DB for associated dfw section id
section_uri = self._get_section_uri(context.session, sg_id)
logging = self._is_security_group_logged(context, sg_id)
logged = self._is_security_group_logged(context, sg_id)
provider = self._is_provider_security_group(context, sg_id)
log_all_rules = cfg.CONF.nsxv.log_security_groups_allowed_traffic
@ -4812,7 +4812,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
ruleids.add(rule['id'])
nsx_rules.append(
self._create_nsx_rule(context, rule,
logged=log_all_rules or logging,
logged=log_all_rules or logged,
action='deny' if provider else 'allow')
)

View File

@ -2499,7 +2499,7 @@ def get_loglevel_modifier(module, level):
return wrapper
def update_edge_loglevel(vcns, edge_id, module, level):
def update_edge_loglevel(vcns_obj, edge_id, module, level):
"""Update loglevel on edge for specified module"""
if module not in SUPPORTED_EDGE_LOG_MODULES:
LOG.error("Unrecognized logging module %s - ignored", module)
@ -2509,19 +2509,18 @@ def update_edge_loglevel(vcns, edge_id, module, level):
LOG.error("Unrecognized log level %s - ignored", level)
return
vcns.update_edge_config_with_modifier(edge_id, module,
get_loglevel_modifier(module,
level))
vcns_obj.update_edge_config_with_modifier(
edge_id, module, get_loglevel_modifier(module, level))
def update_edge_host_groups(vcns, edge_id, dvs, availability_zone,
def update_edge_host_groups(vcns_obj, edge_id, dvs_obj, availability_zone,
validate=False):
# Update edge DRS host groups
h, appliances = vcns.get_edge_appliances(edge_id)
h, appliances = vcns_obj.get_edge_appliances(edge_id)
vms = [appliance['vmId']
for appliance in appliances['appliances']]
if validate:
configured_vms = dvs.get_configured_vms(
configured_vms = dvs_obj.get_configured_vms(
availability_zone.resource_pool,
availability_zone.edge_host_groups)
for vm in vms:
@ -2539,7 +2538,7 @@ def update_edge_host_groups(vcns, edge_id, dvs, availability_zone,
len(vms)))
random.shuffle(vms)
try:
dvs.update_cluster_edge_failover(
dvs_obj.update_cluster_edge_failover(
availability_zone.resource_pool,
vms, availability_zone.edge_host_groups)
except Exception as e:
@ -2550,11 +2549,11 @@ def update_edge_host_groups(vcns, edge_id, dvs, availability_zone,
'e': e})
def clean_host_groups(dvs, availability_zone):
def clean_host_groups(dvs_obj, availability_zone):
try:
LOG.info('Cleaning up host groups for AZ %s',
availability_zone.name)
dvs.cluster_host_group_cleanup(
dvs_obj.cluster_host_group_cleanup(
availability_zone.resource_pool,
availability_zone.edge_host_groups)
except Exception as e:

View File

@ -131,16 +131,16 @@ class NsxFwaasCallbacksV2(firewall_l3_agent_v2.L3WithFWaaS):
# since this is a deletion of an illegal port, add this port
# with a dummy router so that the FWaaS plugin will notice the
# change and change the FW status.
router_info = 'Dummy'
rtr_info = 'Dummy'
else:
router_id = port['device_id']
router = self.core_plugin.get_router(context, router_id)
router_info = self._router_dict_to_obj(router)
if router_info:
if router_info in in_ns_ports:
in_ns_ports[router_info].append(port_id)
rtr_info = self._router_dict_to_obj(router)
if rtr_info:
if rtr_info in in_ns_ports:
in_ns_ports[rtr_info].append(port_id)
else:
in_ns_ports[router_info] = [port_id]
in_ns_ports[rtr_info] = [port_id]
return list(in_ns_ports.items())
def delete_firewall_group(self, context, firewall_group, host):

View File

@ -218,11 +218,11 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin):
def _prevent_l2gw_port_delete(self, resource, event,
trigger, payload=None):
context = payload.context
ctx = payload.context
port_id = payload.resource_id
port_check = payload.metadata['port_check']
if port_check:
self.prevent_l2gw_port_deletion(context, port_id)
self.prevent_l2gw_port_deletion(ctx, port_id)
def _validate_device_list(self, devices, check_backend=True):
# In NSXv3, one L2 gateway is mapped to one bridge endpoint profle.
@ -254,35 +254,35 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin):
"gateway driver")
raise n_exc.InvalidInput(error_message=msg)
def create_l2_gateway(self, context, l2_gateway):
def create_l2_gateway(self, ctx, l2_gateway):
"""Create a logical L2 gateway."""
gw = l2_gateway[self.gateway_resource]
devices = gw['devices']
self._validate_device_list(devices)
def create_l2_gateway_precommit(self, context, l2_gateway):
def create_l2_gateway_precommit(self, ctx, l2_gateway):
pass
def create_l2_gateway_postcommit(self, context, l2_gateway):
def create_l2_gateway_postcommit(self, ctx, l2_gateway):
pass
def update_l2_gateway_precommit(self, context, l2_gateway):
def update_l2_gateway_precommit(self, ctx, l2_gateway):
pass
def update_l2_gateway_postcommit(self, context, l2_gateway):
def update_l2_gateway_postcommit(self, ctx, l2_gateway):
pass
def delete_l2_gateway(self, context, l2_gateway_id):
def delete_l2_gateway(self, ctx, l2_gateway_id):
pass
def delete_l2_gateway_precommit(self, context, l2_gateway_id):
def delete_l2_gateway_precommit(self, ctx, l2_gateway_id):
pass
def delete_l2_gateway_postcommit(self, context, l2_gateway_id):
def delete_l2_gateway_postcommit(self, ctx, l2_gateway_id):
pass
def _validate_network(self, context, network_id):
network = self._core_plugin.get_network(context, network_id)
def _validate_network(self, ctx, network_id):
network = self._core_plugin.get_network(ctx, network_id)
network_type = network.get(providernet.NETWORK_TYPE)
# If network is a provider network, verify whether it is of type GENEVE
if network_type and network_type != nsx_utils.NsxV3NetworkTypes.GENEVE:
@ -295,40 +295,40 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin):
raise l2gw_exc.L2GatewaySegmentationRequired
return plugin_utils.is_valid_vlan_tag(seg_id)
def create_l2_gateway_connection(self, context, l2_gateway_connection):
def create_l2_gateway_connection(self, ctx, l2_gateway_connection):
gw_connection = l2_gateway_connection.get(self.connection_resource)
network_id = gw_connection.get(l2gw_const.NETWORK_ID)
self._validate_network(context, network_id)
self._validate_network(ctx, network_id)
def _get_bep(self, context, l2gw_id):
def _get_bep(self, ctx, l2gw_id):
# In NSXv3, there will be only one device configured per L2 gateway.
# The name of the device shall carry the bridge endpoint profile id.
devices = self._get_l2_gateway_devices(context, l2gw_id)
devices = self._get_l2_gateway_devices(ctx, l2gw_id)
return devices[0].get('device_name')
def _get_conn_parameters(self, context, gw_connection):
"""Return interface and segmenantion id for a connection. """
def _get_conn_parameters(self, ctx, gw_connection):
"""Return interface and segmentation id for a connection. """
if not gw_connection:
return
l2gw_id = gw_connection.get(l2gw_const.L2GATEWAY_ID)
seg_id = gw_connection.get(l2gw_const.SEG_ID)
devices = self._get_l2_gateway_devices(context, l2gw_id)
devices = self._get_l2_gateway_devices(ctx, l2gw_id)
# TODO(salv-orlando): support more than a single interface
interface = self._get_l2_gw_interfaces(context, devices[0]['id'])[0]
interface = self._get_l2_gw_interfaces(ctx, devices[0]['id'])[0]
if not seg_id:
# Seg-id was not passed as part of connection-create. Retrieve
# seg-id from L2 gateway's interface.
seg_id = interface.get('segmentation_id')
return interface['interface_name'], seg_id
def create_l2_gateway_connection_precommit(self, context, gw_connection):
def create_l2_gateway_connection_precommit(self, ctx, gw_connection):
"""Validate the L2 gateway connection
Do not allow another connection with the same bride cluster and seg_id
"""
admin_ctx = context.elevated()
admin_ctx = ctx.elevated()
nsxlib = self._core_plugin.nsxlib
l2gw_id = gw_connection.get(l2gw_const.L2GATEWAY_ID)
devices = self._get_l2_gateway_devices(context, l2gw_id)
devices = self._get_l2_gateway_devices(ctx, l2gw_id)
bep_id = devices[0].get('device_name')
# Check for bridge endpoint profile existence
# if bridge endpoint profile is not found, this is likely an old
@ -379,23 +379,23 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin):
'bep_id': bep_id})
raise n_exc.InvalidInput(error_message=msg)
def create_l2_gateway_connection_postcommit(self, context, gw_connection):
def create_l2_gateway_connection_postcommit(self, ctx, gw_connection):
"""Create a L2 gateway connection on the backend"""
nsxlib = self._core_plugin.nsxlib
l2gw_id = gw_connection.get(l2gw_const.L2GATEWAY_ID)
network_id = gw_connection.get(l2gw_const.NETWORK_ID)
device_name = self._get_bep(context, l2gw_id)
device_name = self._get_bep(ctx, l2gw_id)
interface_name, seg_id = self._get_conn_parameters(
context, gw_connection)
ctx, gw_connection)
self._validate_segment_id(seg_id)
tenant_id = gw_connection['tenant_id']
if context.is_admin and not tenant_id:
tenant_id = context.tenant_id
if ctx.is_admin and not tenant_id:
tenant_id = ctx.tenant_id
gw_connection['tenant_id'] = tenant_id
try:
tags = nsxlib.build_v3_tags_payload(
gw_connection, resource_type='os-neutron-l2gw-id',
project_name=context.tenant_name)
project_name=ctx.tenant_name)
bridge_endpoint = nsxlib.bridge_endpoint.create(
device_name=device_name,
vlan_transport_zone_id=interface_name,
@ -420,11 +420,11 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin):
try:
#TODO(abhiraut): Consider adding UT for port check once UTs are
# refactored
port = self._core_plugin.create_port(context, port_dict,
port = self._core_plugin.create_port(ctx, port_dict,
l2gw_port_check=True)
# Deallocate IP address from the port.
for fixed_ip in port.get('fixed_ips', []):
self._core_plugin._delete_ip_allocation(context, network_id,
self._core_plugin._delete_ip_allocation(ctx, network_id,
fixed_ip['subnet_id'],
fixed_ip['ip_address'])
LOG.debug("IP addresses deallocated on port %s", port['id'])
@ -437,14 +437,14 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin):
bridge_endpoint['id'])
super(NsxV3Driver,
self).delete_l2_gateway_connection(
context,
ctx,
gw_connection['id'])
try:
with db_api.CONTEXT_WRITER.using(context):
with db_api.CONTEXT_WRITER.using(ctx):
# Update neutron's database with the mappings.
nsx_db.add_l2gw_connection_mapping(
session=context.session,
session=ctx.session,
connection_id=gw_connection['id'],
bridge_endpoint_id=bridge_endpoint['id'],
port_id=port['id'])
@ -453,7 +453,7 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin):
# from the device spec
if seg_id and not gw_connection.get(l2gw_const.SEG_ID):
conn_db = self._plugin._get_l2_gateway_connection(
context, gw_connection['id'])
ctx, gw_connection['id'])
conn_db['segmentation_id'] = seg_id
# Ensure the object is updated as well so the
# create response returns the segmentation_id
@ -469,20 +469,20 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin):
bridge_endpoint['id'])
super(NsxV3Driver,
self).delete_l2_gateway_connection(
context,
ctx,
gw_connection['id'])
return gw_connection
def delete_l2_gateway_connection_postcommit(self, context, gw_connection):
def delete_l2_gateway_connection_postcommit(self, ctx, gw_connection):
pass
def delete_l2_gateway_connection_precommit(self, context, gw_connection):
def delete_l2_gateway_connection_precommit(self, ctx, gw_connection):
pass
def delete_l2_gateway_connection(self, context, gw_connection):
def delete_l2_gateway_connection(self, ctx, gw_connection):
"""Delete a L2 gateway connection."""
conn_mapping = nsx_db.get_l2gw_connection_mapping(
session=context.session,
session=ctx.session,
connection_id=gw_connection)
if not conn_mapping:
LOG.error("Unable to delete gateway connection %(id)s: mapping "
@ -491,7 +491,7 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin):
return
bridge_endpoint_id = conn_mapping.get('bridge_endpoint_id')
# Delete the logical port from the bridge endpoint.
self._core_plugin.delete_port(context=context,
self._core_plugin.delete_port(context=ctx,
port_id=conn_mapping.get('port_id'),
l2gw_port_check=False)
try:
@ -503,20 +503,18 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin):
raise l2gw_exc.L2GatewayServiceDriverError(
method='delete_l2_gateway_connection')
def prevent_l2gw_port_deletion(self, context, port_id):
def prevent_l2gw_port_deletion(self, ctx, port_id):
"""Prevent core plugin from deleting L2 gateway port."""
try:
port = self._core_plugin.get_port(context, port_id)
port = self._core_plugin.get_port(ctx, port_id)
except n_exc.PortNotFound:
return
if port['device_owner'] == nsx_constants.BRIDGE_ENDPOINT:
reason = _("has device owner %s") % port['device_owner']
raise n_exc.ServicePortInUse(port_id=port_id, reason=reason)
def add_port_mac(self, context, port_dict):
def add_port_mac(self, ctx, port_dict):
"""Process a created Neutron port."""
pass
def delete_port_mac(self, context, port):
def delete_port_mac(self, ctx, port):
"""Process a deleted Neutron port."""
pass

View File

@ -25,4 +25,3 @@ class NsxV3QosNotificationDriver(
"""
# The message queue is no longer needed in Pike.
# Keeping this class for a while for existing configurations.
pass

View File

@ -262,10 +262,10 @@ def nsx_delete_orphaned_edges(resource, event, trigger, **kwargs):
LOG.info("NSXv Edge deletion aborted by user")
return
nsxv = utils.get_nsxv_client()
nsxv_c = utils.get_nsxv_client()
for edge in orphaned_edges:
LOG.info("Deleting edge: %s", edge)
nsxv.delete_edge(edge)
nsxv_c.delete_edge(edge)
LOG.info("After delete; Orphaned Edges: \n%s",
pprint.pformat(get_orphaned_edges()))
@ -504,7 +504,7 @@ def change_edge_appliance_reservations(properties):
LOG.error("%s", str(e))
def _update_host_group_for_edge(nsxv, cluster_mng, edge_id, edge):
def _update_host_group_for_edge(nsxv_c, cluster_mng, edge_id, edge):
if edge.get('type') == 'gatewayServices':
try:
az_name, size = _get_edge_az_and_size(edge_id)
@ -513,7 +513,7 @@ def _update_host_group_for_edge(nsxv, cluster_mng, edge_id, edge):
zones = nsx_az.NsxVAvailabilityZones()
az = zones.get_availability_zone(az_name)
if az.edge_ha and az.edge_host_groups:
edge_utils.update_edge_host_groups(nsxv, edge_id,
edge_utils.update_edge_host_groups(nsxv_c, edge_id,
cluster_mng, az,
validate=True)
else:

View File

@ -32,14 +32,13 @@ from vmware_nsx.shell.admin.plugins.nsxv.resources import utils
from vmware_nsx.shell import resources as shell
LOG = logging.getLogger(__name__)
nsxv = utils.get_nsxv_client()
network_types = ['Network', 'VirtualWire', 'DistributedVirtualPortgroup']
PORTGROUP_PREFIX = 'dvportgroup'
def get_networks_from_backend():
nsxv = utils.get_nsxv_client()
so_list = nsxv.get_scoping_objects()
nsxv_c = utils.get_nsxv_client()
so_list = nsxv_c.get_scoping_objects()
return et.fromstring(so_list)
@ -76,7 +75,7 @@ def neutron_list_networks(resource, event, trigger,
@admin_utils.output_header
def nsx_update_switch(resource, event, trigger, **kwargs):
nsxv = utils.get_nsxv_client()
nsxv_c = utils.get_nsxv_client()
if not kwargs.get('property'):
LOG.error("Need to specify dvs-id parameter and "
"attribute to update. Add --property dvs-id=<dvs-id> "
@ -89,7 +88,7 @@ def nsx_update_switch(resource, event, trigger, **kwargs):
"Add --property dvs-id=<dvs-id>")
return
try:
h, switch = nsxv.get_vdn_switch(dvs_id)
h, switch = nsxv_c.get_vdn_switch(dvs_id)
except exceptions.ResourceNotFound:
LOG.error("DVS %s not found", dvs_id)
return
@ -106,7 +105,7 @@ def nsx_update_switch(resource, event, trigger, **kwargs):
"%(policy)s", {'dvs': dvs_id, 'policy': policy})
switch['teamingPolicy'] = policy
try:
switch = nsxv.update_vdn_switch(switch)
switch = nsxv_c.update_vdn_switch(switch)
except exceptions.VcnsApiException as e:
desc = jsonutils.loads(e.response)
details = desc.get('details')
@ -318,7 +317,7 @@ def delete_backend_network(resource, event, trigger, **kwargs):
# Note: in case the backend network is attached to other backend objects,
# like VM, the deleting may fail and through an exception
nsxv = utils.get_nsxv_client()
nsxv_c = utils.get_nsxv_client()
if moref.startswith(PORTGROUP_PREFIX):
# get the dvs id from the backend name:
dvs_id = get_dvs_id_from_backend_name(backend_name)
@ -327,7 +326,7 @@ def delete_backend_network(resource, event, trigger, **kwargs):
"%(moref)s", {'moref': moref})
else:
try:
nsxv.delete_port_group(dvs_id, moref)
nsxv_c.delete_port_group(dvs_id, moref)
except Exception as e:
LOG.error("Failed to delete backend network %(moref)s : "
"%(e)s", {'moref': moref, 'e': e})
@ -337,7 +336,7 @@ def delete_backend_network(resource, event, trigger, **kwargs):
else:
# Virtual wire
try:
nsxv.delete_virtual_wire(moref)
nsxv_c.delete_virtual_wire(moref)
except Exception as e:
LOG.error("Failed to delete backend network %(moref)s : "
"%(e)s", {'moref': moref, 'e': e})

View File

@ -113,8 +113,8 @@ def nsx_recreate_router_edge(old_edge_id):
az_name = _get_router_az_from_plugin_router(router)
# clean up other objects related to this router
if plugin.metadata_proxy_handler:
md_proxy = plugin.get_metadata_proxy_handler(az_name)
md_proxy.cleanup_router_edge(context, router_id)
md_proxy_h = plugin.get_metadata_proxy_handler(az_name)
md_proxy_h.cleanup_router_edge(context, router_id)
# attach the router to a new edge
appliance_size = router.get(routersize.ROUTER_SIZE)

View File

@ -34,13 +34,13 @@ nsxv = utils.get_nsxv_client()
def get_spoofguard_policies():
nsxv = utils.get_nsxv_client()
return nsxv.get_spoofguard_policies()[1].get("policies")
nsxv_c = utils.get_nsxv_client()
return nsxv_c.get_spoofguard_policies()[1].get("policies")
def get_spoofguard_policy_data(policy_id):
nsxv = utils.get_nsxv_client()
return nsxv.get_spoofguard_policy_data(policy_id)[1].get(
nsxv_c = utils.get_nsxv_client()
return nsxv_c.get_spoofguard_policy_data(policy_id)[1].get(
'spoofguardList', [])

View File

@ -1063,11 +1063,11 @@ def migrate_edge_firewalls(nsxlib, nsxpolicy, plugin):
# Make sure fwaas is considered as enabled
self.fwaas_enabled = True
def _get_port_firewall_group_id(self, context, port_id):
def _get_port_firewall_group_id(self, ctx, port_id):
# Override this api because directory.get_plugin does not work from
# admin utils context.
driver_db = firewall_db_v2.FirewallPluginDb()
return driver_db.get_fwg_attached_to_port(context, port_id)
return driver_db.get_fwg_attached_to_port(ctx, port_id)
fwaas_callbacks = MigrationNsxpFwaasCallbacks(False)
plugin.nsxpolicy = nsxpolicy

View File

@ -74,9 +74,9 @@ def list_missing_ports(resource, event, trigger, **kwargs):
admin_cxt = neutron_context.get_admin_context()
filters = v3_utils.get_plugin_filters(admin_cxt)
nsxlib = v3_utils.get_connected_nsxlib()
with v3_utils.NsxV3PluginWrapper() as plugin:
with v3_utils.NsxV3PluginWrapper() as v3_plugin:
problems = plugin_utils.get_mismatch_logical_ports(
admin_cxt, nsxlib, plugin, filters)
admin_cxt, nsxlib, v3_plugin, filters)
if len(problems) > 0:
title = ("Found internal ports misconfiguration on the "
@ -137,8 +137,8 @@ def migrate_compute_ports_vms(resource, event, trigger, **kwargs):
# Go over all the ports from the plugin
admin_cxt = neutron_context.get_admin_context()
with PortsPlugin() as plugin:
neutron_ports = plugin.get_ports(admin_cxt, filters=port_filters)
with PortsPlugin() as v3_plugin:
neutron_ports = v3_plugin.get_ports(admin_cxt, filters=port_filters)
for port in neutron_ports:
# skip non compute ports
@ -202,7 +202,7 @@ def migrate_exclude_ports(resource, event, trigger, **kwargs):
LOG.info("Version is %s", version)
return
admin_cxt = neutron_context.get_admin_context()
plugin = PortsPlugin()
ports_plugin = PortsPlugin()
_port_client = resources.LogicalPort(_nsx_client)
exclude_list = nsxlib.firewall_section.get_excludelist()
for member in exclude_list['members']:
@ -226,7 +226,7 @@ def migrate_exclude_ports(resource, event, trigger, **kwargs):
continue
# Check if this port exists in the DB
try:
plugin.get_port(admin_cxt, neutron_port_id)
ports_plugin.get_port(admin_cxt, neutron_port_id)
except Exception:
LOG.info("Port %s is not defined in DB", neutron_port_id)
continue

View File

@ -85,9 +85,9 @@ def get_connected_nsxlib(nsx_username=None, nsx_password=None,
return _NSXLIB
def get_plugin_filters(context):
def get_plugin_filters(ctx):
return admin_utils.get_plugin_filters(
context, projectpluginmap.NsxPlugins.NSX_T)
ctx, projectpluginmap.NsxPlugins.NSX_T)
class NeutronDbClient(db_base_plugin_v2.NeutronDbPluginV2):
@ -112,15 +112,15 @@ class NeutronDbClient(db_base_plugin_v2.NeutronDbPluginV2):
return super(NeutronDbClient, self).get_networks(
self.context, filters=filters, fields=fields)
def get_network(self, context, network_id):
if not context:
context = self.context
return super(NeutronDbClient, self).get_network(context, network_id)
def get_network(self, ctx, network_id):
if not ctx:
ctx = self.context
return super(NeutronDbClient, self).get_network(ctx, network_id)
def get_subnet(self, context, subnet_id):
if not context:
context = self.context
return super(NeutronDbClient, self).get_subnet(context, subnet_id)
def get_subnet(self, ctx, subnet_id):
if not ctx:
ctx = self.context
return super(NeutronDbClient, self).get_subnet(ctx, subnet_id)
def get_lswitch_and_lport_id(self, port_id):
return nsx_db.get_nsx_switch_and_port_id(self.context.session, port_id)
@ -196,24 +196,24 @@ class NsxV3PluginWrapper(plugin.NsxV3Plugin):
def _init_dhcp_metadata(self):
pass
def _extend_get_network_dict_provider(self, context, net):
self._extend_network_dict_provider(context, net)
def _extend_get_network_dict_provider(self, ctx, net):
self._extend_network_dict_provider(ctx, net)
# skip getting the Qos policy ID because get_object calls
# plugin init again on admin-util environment
def _extend_get_port_dict_binding(self, context, port):
self._extend_port_dict_binding(context, port)
def _extend_get_port_dict_binding(self, ctx, port):
self._extend_port_dict_binding(ctx, port)
# skip getting the Qos policy ID because get_object calls
# plugin init again on admin-util environment
def delete_network(self, context, network_id):
if not context:
context = self.context
def delete_network(self, ctx, network_id):
if not ctx:
ctx = self.context
return super(NsxV3PluginWrapper, self).delete_network(
context, network_id)
ctx, network_id)
def remove_router_interface(self, context, router_id, interface):
if not context:
context = self.context
def remove_router_interface(self, ctx, router_id, interface):
if not ctx:
ctx = self.context
return super(NsxV3PluginWrapper, self).remove_router_interface(
context, router_id, interface)
ctx, router_id, interface)

View File

@ -81,9 +81,9 @@ ops = [op.value for op in Operations]
class Resource(object):
def __init__(self, name, ops):
def __init__(self, name, ops_obj):
self.name = name
self.supported_ops = ops
self.supported_ops = ops_obj
# Add supported NSX-V3 resources in this dictionary