Remove some pylint exclusions (part 2)
Change-Id: I2047f083af01dd0452f61d9fb807098e0514ff36
This commit is contained in:
parent
b6bd7e49d1
commit
26f855f9c9
@ -32,13 +32,10 @@ disable=
|
|||||||
expression-not-assigned,
|
expression-not-assigned,
|
||||||
fixme,
|
fixme,
|
||||||
global-statement,
|
global-statement,
|
||||||
literal-comparison,
|
|
||||||
no-init,
|
no-init,
|
||||||
non-parent-init-called,
|
non-parent-init-called,
|
||||||
not-callable,
|
|
||||||
protected-access,
|
protected-access,
|
||||||
redefined-builtin,
|
redefined-builtin,
|
||||||
redefined-outer-name,
|
|
||||||
signature-differs,
|
signature-differs,
|
||||||
star-args,
|
star-args,
|
||||||
super-init-not-called,
|
super-init-not-called,
|
||||||
@ -52,12 +49,12 @@ disable=
|
|||||||
# TODO(dougwig) - disable nonstandard-exception while we have neutron_lib shims
|
# TODO(dougwig) - disable nonstandard-exception while we have neutron_lib shims
|
||||||
nonstandard-exception,
|
nonstandard-exception,
|
||||||
# "C" Coding convention violations
|
# "C" Coding convention violations
|
||||||
bad-continuation,
|
# bad-continuation,
|
||||||
consider-iterating-dictionary,
|
consider-iterating-dictionary,
|
||||||
consider-using-enumerate,
|
consider-using-enumerate,
|
||||||
invalid-name,
|
invalid-name,
|
||||||
len-as-condition,
|
len-as-condition,
|
||||||
misplaced-comparison-constant,
|
# misplaced-comparison-constant,
|
||||||
missing-docstring,
|
missing-docstring,
|
||||||
singleton-comparison,
|
singleton-comparison,
|
||||||
superfluous-parens,
|
superfluous-parens,
|
||||||
|
@ -162,12 +162,12 @@ class ApiReplayClient(utils.PrepareObjectForMigration):
|
|||||||
tenant_name, tenant_domain_id,
|
tenant_name, tenant_domain_id,
|
||||||
password, auth_url)
|
password, auth_url)
|
||||||
endpoint = sess.get_endpoint(service_type='load-balancer')
|
endpoint = sess.get_endpoint(service_type='load-balancer')
|
||||||
client = octavia.OctaviaAPI(
|
client_obj = octavia.OctaviaAPI(
|
||||||
session=sess,
|
session=sess,
|
||||||
service_type='load-balancer',
|
service_type='load-balancer',
|
||||||
endpoint=endpoint,
|
endpoint=endpoint,
|
||||||
)
|
)
|
||||||
return client
|
return client_obj
|
||||||
|
|
||||||
def find_subnet_by_id(self, subnet_id, subnets):
|
def find_subnet_by_id(self, subnet_id, subnets):
|
||||||
for subnet in subnets:
|
for subnet in subnets:
|
||||||
|
@ -160,8 +160,8 @@ class DhcpMetadataAccess(object):
|
|||||||
report = self.migration_manager.report(context, network_id)
|
report = self.migration_manager.report(context, network_id)
|
||||||
return {'network': network_id, 'report': report}
|
return {'network': network_id, 'report': report}
|
||||||
|
|
||||||
def create_lsn(self, context, lsn):
|
def create_lsn(self, context, lsn_data):
|
||||||
network_id = lsn['lsn']['network']
|
network_id = lsn_data['lsn']['network']
|
||||||
subnet = self.migration_manager.validate(context, network_id)
|
subnet = self.migration_manager.validate(context, network_id)
|
||||||
subnet_id = None if not subnet else subnet['id']
|
subnet_id = None if not subnet else subnet['id']
|
||||||
self.migration_manager.migrate(context, network_id, subnet)
|
self.migration_manager.migrate(context, network_id, subnet)
|
||||||
|
@ -202,9 +202,9 @@ class DvsManager(VCManagerBase):
|
|||||||
self._session.vim,
|
self._session.vim,
|
||||||
val, ['name'])
|
val, ['name'])
|
||||||
if len(props) and hasattr(props[0], 'propSet'):
|
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
|
# 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
|
# NOTE(garyk): update cache
|
||||||
return val
|
return val
|
||||||
raise exceptions.NetworkNotFound(net_id=net_id)
|
raise exceptions.NetworkNotFound(net_id=net_id)
|
||||||
@ -377,8 +377,8 @@ class DvsManager(VCManagerBase):
|
|||||||
self._session.vim,
|
self._session.vim,
|
||||||
pg_moref, ['name'])
|
pg_moref, ['name'])
|
||||||
if len(props) and hasattr(props[0], 'propSet'):
|
if len(props) and hasattr(props[0], 'propSet'):
|
||||||
for prop in props[0].propSet:
|
for prop2 in props[0].propSet:
|
||||||
if net_id in prop.val and net_moref in prop.val:
|
if net_id in prop2.val and net_moref in prop2.val:
|
||||||
found = True
|
found = True
|
||||||
self._reconfigure_port_group(
|
self._reconfigure_port_group(
|
||||||
pg_moref,
|
pg_moref,
|
||||||
|
@ -1279,14 +1279,14 @@ class NsxPluginV3Base(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
|||||||
|
|
||||||
def _get_external_attachment_info(self, context, router):
|
def _get_external_attachment_info(self, context, router):
|
||||||
gw_port = router.gw_port
|
gw_port = router.gw_port
|
||||||
ipaddress = None
|
ipaddr = None
|
||||||
netmask = None
|
netmask = None
|
||||||
nexthop = None
|
nexthop = None
|
||||||
|
|
||||||
if gw_port:
|
if gw_port:
|
||||||
# gw_port may have multiple IPs, only configure the first one
|
# gw_port may have multiple IPs, only configure the first one
|
||||||
if gw_port.get('fixed_ips'):
|
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')
|
network_id = gw_port.get('network_id')
|
||||||
if network_id:
|
if network_id:
|
||||||
@ -1300,7 +1300,7 @@ class NsxPluginV3Base(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
|||||||
netmask = str(netaddr.IPNetwork(ext_subnet.cidr).netmask)
|
netmask = str(netaddr.IPNetwork(ext_subnet.cidr).netmask)
|
||||||
nexthop = ext_subnet.gateway_ip
|
nexthop = ext_subnet.gateway_ip
|
||||||
|
|
||||||
return (ipaddress, netmask, nexthop)
|
return (ipaddr, netmask, nexthop)
|
||||||
|
|
||||||
def _get_tier0_uuid_by_net_id(self, context, network_id):
|
def _get_tier0_uuid_by_net_id(self, context, network_id):
|
||||||
if not network_id:
|
if not network_id:
|
||||||
|
@ -1751,17 +1751,17 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
# and therefore, the spoofguard policy is being removed for this net.
|
# and therefore, the spoofguard policy is being removed for this net.
|
||||||
orig_net = self.get_network(context, id)
|
orig_net = self.get_network(context, id)
|
||||||
if not net_attrs[psec.PORTSECURITY]:
|
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'])
|
orig_net['id'])
|
||||||
if sg_policy:
|
if sg_pol:
|
||||||
try:
|
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,
|
nsxv_db.del_nsxv_spoofguard_binding(context.session,
|
||||||
sg_policy)
|
sg_pol)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.error('Unable to delete spoofguard policy '
|
LOG.error('Unable to delete spoofguard policy '
|
||||||
'%(sg_policy)s. Error: %(e)s',
|
'%(sg_policy)s. Error: %(e)s',
|
||||||
{'sg_policy': sg_policy, 'e': e})
|
{'sg_policy': sg_pol, 'e': e})
|
||||||
else:
|
else:
|
||||||
LOG.warning("Could not locate spoofguard policy for "
|
LOG.warning("Could not locate spoofguard policy for "
|
||||||
"network %s", id)
|
"network %s", id)
|
||||||
@ -4380,7 +4380,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
context,
|
context,
|
||||||
securitygroup,
|
securitygroup,
|
||||||
nsx_sg_id):
|
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])
|
securitygroup[sg_logging.LOGGING])
|
||||||
action = 'deny' if securitygroup[provider_sg.PROVIDER] else 'allow'
|
action = 'deny' if securitygroup[provider_sg.PROVIDER] else 'allow'
|
||||||
section_name = self.nsx_sg_utils.get_nsx_section_name(securitygroup)
|
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
|
# Translate Neutron rules to NSXv fw rules and construct the fw section
|
||||||
for rule in securitygroup['security_group_rules']:
|
for rule in securitygroup['security_group_rules']:
|
||||||
nsx_rule = self._create_nsx_rule(
|
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)
|
nsx_rules.append(nsx_rule)
|
||||||
section = self.nsx_sg_utils.get_section_with_rules(
|
section = self.nsx_sg_utils.get_section_with_rules(
|
||||||
section_name, nsx_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):
|
with locking.LockManager.get_lock('rule-update-%s' % sg_id):
|
||||||
# Querying DB for associated dfw section id
|
# Querying DB for associated dfw section id
|
||||||
section_uri = self._get_section_uri(context.session, sg_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)
|
provider = self._is_provider_security_group(context, sg_id)
|
||||||
log_all_rules = cfg.CONF.nsxv.log_security_groups_allowed_traffic
|
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'])
|
ruleids.add(rule['id'])
|
||||||
nsx_rules.append(
|
nsx_rules.append(
|
||||||
self._create_nsx_rule(context, rule,
|
self._create_nsx_rule(context, rule,
|
||||||
logged=log_all_rules or logging,
|
logged=log_all_rules or logged,
|
||||||
action='deny' if provider else 'allow')
|
action='deny' if provider else 'allow')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -2499,7 +2499,7 @@ def get_loglevel_modifier(module, level):
|
|||||||
return wrapper
|
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"""
|
"""Update loglevel on edge for specified module"""
|
||||||
if module not in SUPPORTED_EDGE_LOG_MODULES:
|
if module not in SUPPORTED_EDGE_LOG_MODULES:
|
||||||
LOG.error("Unrecognized logging module %s - ignored", module)
|
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)
|
LOG.error("Unrecognized log level %s - ignored", level)
|
||||||
return
|
return
|
||||||
|
|
||||||
vcns.update_edge_config_with_modifier(edge_id, module,
|
vcns_obj.update_edge_config_with_modifier(
|
||||||
get_loglevel_modifier(module,
|
edge_id, module, get_loglevel_modifier(module, level))
|
||||||
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):
|
validate=False):
|
||||||
# Update edge DRS host groups
|
# 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']
|
vms = [appliance['vmId']
|
||||||
for appliance in appliances['appliances']]
|
for appliance in appliances['appliances']]
|
||||||
if validate:
|
if validate:
|
||||||
configured_vms = dvs.get_configured_vms(
|
configured_vms = dvs_obj.get_configured_vms(
|
||||||
availability_zone.resource_pool,
|
availability_zone.resource_pool,
|
||||||
availability_zone.edge_host_groups)
|
availability_zone.edge_host_groups)
|
||||||
for vm in vms:
|
for vm in vms:
|
||||||
@ -2539,7 +2538,7 @@ def update_edge_host_groups(vcns, edge_id, dvs, availability_zone,
|
|||||||
len(vms)))
|
len(vms)))
|
||||||
random.shuffle(vms)
|
random.shuffle(vms)
|
||||||
try:
|
try:
|
||||||
dvs.update_cluster_edge_failover(
|
dvs_obj.update_cluster_edge_failover(
|
||||||
availability_zone.resource_pool,
|
availability_zone.resource_pool,
|
||||||
vms, availability_zone.edge_host_groups)
|
vms, availability_zone.edge_host_groups)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -2550,11 +2549,11 @@ def update_edge_host_groups(vcns, edge_id, dvs, availability_zone,
|
|||||||
'e': e})
|
'e': e})
|
||||||
|
|
||||||
|
|
||||||
def clean_host_groups(dvs, availability_zone):
|
def clean_host_groups(dvs_obj, availability_zone):
|
||||||
try:
|
try:
|
||||||
LOG.info('Cleaning up host groups for AZ %s',
|
LOG.info('Cleaning up host groups for AZ %s',
|
||||||
availability_zone.name)
|
availability_zone.name)
|
||||||
dvs.cluster_host_group_cleanup(
|
dvs_obj.cluster_host_group_cleanup(
|
||||||
availability_zone.resource_pool,
|
availability_zone.resource_pool,
|
||||||
availability_zone.edge_host_groups)
|
availability_zone.edge_host_groups)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -131,16 +131,16 @@ class NsxFwaasCallbacksV2(firewall_l3_agent_v2.L3WithFWaaS):
|
|||||||
# since this is a deletion of an illegal port, add this port
|
# since this is a deletion of an illegal port, add this port
|
||||||
# with a dummy router so that the FWaaS plugin will notice the
|
# with a dummy router so that the FWaaS plugin will notice the
|
||||||
# change and change the FW status.
|
# change and change the FW status.
|
||||||
router_info = 'Dummy'
|
rtr_info = 'Dummy'
|
||||||
else:
|
else:
|
||||||
router_id = port['device_id']
|
router_id = port['device_id']
|
||||||
router = self.core_plugin.get_router(context, router_id)
|
router = self.core_plugin.get_router(context, router_id)
|
||||||
router_info = self._router_dict_to_obj(router)
|
rtr_info = self._router_dict_to_obj(router)
|
||||||
if router_info:
|
if rtr_info:
|
||||||
if router_info in in_ns_ports:
|
if rtr_info in in_ns_ports:
|
||||||
in_ns_ports[router_info].append(port_id)
|
in_ns_ports[rtr_info].append(port_id)
|
||||||
else:
|
else:
|
||||||
in_ns_ports[router_info] = [port_id]
|
in_ns_ports[rtr_info] = [port_id]
|
||||||
return list(in_ns_ports.items())
|
return list(in_ns_ports.items())
|
||||||
|
|
||||||
def delete_firewall_group(self, context, firewall_group, host):
|
def delete_firewall_group(self, context, firewall_group, host):
|
||||||
|
@ -218,11 +218,11 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin):
|
|||||||
|
|
||||||
def _prevent_l2gw_port_delete(self, resource, event,
|
def _prevent_l2gw_port_delete(self, resource, event,
|
||||||
trigger, payload=None):
|
trigger, payload=None):
|
||||||
context = payload.context
|
ctx = payload.context
|
||||||
port_id = payload.resource_id
|
port_id = payload.resource_id
|
||||||
port_check = payload.metadata['port_check']
|
port_check = payload.metadata['port_check']
|
||||||
if 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):
|
def _validate_device_list(self, devices, check_backend=True):
|
||||||
# In NSXv3, one L2 gateway is mapped to one bridge endpoint profle.
|
# In NSXv3, one L2 gateway is mapped to one bridge endpoint profle.
|
||||||
@ -254,35 +254,35 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin):
|
|||||||
"gateway driver")
|
"gateway driver")
|
||||||
raise n_exc.InvalidInput(error_message=msg)
|
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."""
|
"""Create a logical L2 gateway."""
|
||||||
gw = l2_gateway[self.gateway_resource]
|
gw = l2_gateway[self.gateway_resource]
|
||||||
devices = gw['devices']
|
devices = gw['devices']
|
||||||
self._validate_device_list(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
|
pass
|
||||||
|
|
||||||
def create_l2_gateway_postcommit(self, context, l2_gateway):
|
def create_l2_gateway_postcommit(self, ctx, l2_gateway):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def update_l2_gateway_precommit(self, context, l2_gateway):
|
def update_l2_gateway_precommit(self, ctx, l2_gateway):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def update_l2_gateway_postcommit(self, context, l2_gateway):
|
def update_l2_gateway_postcommit(self, ctx, l2_gateway):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def delete_l2_gateway(self, context, l2_gateway_id):
|
def delete_l2_gateway(self, ctx, l2_gateway_id):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def delete_l2_gateway_precommit(self, context, l2_gateway_id):
|
def delete_l2_gateway_precommit(self, ctx, l2_gateway_id):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def delete_l2_gateway_postcommit(self, context, l2_gateway_id):
|
def delete_l2_gateway_postcommit(self, ctx, l2_gateway_id):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _validate_network(self, context, network_id):
|
def _validate_network(self, ctx, network_id):
|
||||||
network = self._core_plugin.get_network(context, network_id)
|
network = self._core_plugin.get_network(ctx, network_id)
|
||||||
network_type = network.get(providernet.NETWORK_TYPE)
|
network_type = network.get(providernet.NETWORK_TYPE)
|
||||||
# If network is a provider network, verify whether it is of type GENEVE
|
# If network is a provider network, verify whether it is of type GENEVE
|
||||||
if network_type and network_type != nsx_utils.NsxV3NetworkTypes.GENEVE:
|
if network_type and network_type != nsx_utils.NsxV3NetworkTypes.GENEVE:
|
||||||
@ -295,40 +295,40 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin):
|
|||||||
raise l2gw_exc.L2GatewaySegmentationRequired
|
raise l2gw_exc.L2GatewaySegmentationRequired
|
||||||
return plugin_utils.is_valid_vlan_tag(seg_id)
|
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)
|
gw_connection = l2_gateway_connection.get(self.connection_resource)
|
||||||
network_id = gw_connection.get(l2gw_const.NETWORK_ID)
|
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.
|
# In NSXv3, there will be only one device configured per L2 gateway.
|
||||||
# The name of the device shall carry the bridge endpoint profile id.
|
# 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')
|
return devices[0].get('device_name')
|
||||||
|
|
||||||
def _get_conn_parameters(self, context, gw_connection):
|
def _get_conn_parameters(self, ctx, gw_connection):
|
||||||
"""Return interface and segmenantion id for a connection. """
|
"""Return interface and segmentation id for a connection. """
|
||||||
if not gw_connection:
|
if not gw_connection:
|
||||||
return
|
return
|
||||||
l2gw_id = gw_connection.get(l2gw_const.L2GATEWAY_ID)
|
l2gw_id = gw_connection.get(l2gw_const.L2GATEWAY_ID)
|
||||||
seg_id = gw_connection.get(l2gw_const.SEG_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
|
# 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:
|
if not seg_id:
|
||||||
# Seg-id was not passed as part of connection-create. Retrieve
|
# Seg-id was not passed as part of connection-create. Retrieve
|
||||||
# seg-id from L2 gateway's interface.
|
# seg-id from L2 gateway's interface.
|
||||||
seg_id = interface.get('segmentation_id')
|
seg_id = interface.get('segmentation_id')
|
||||||
return interface['interface_name'], seg_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
|
"""Validate the L2 gateway connection
|
||||||
Do not allow another connection with the same bride cluster and seg_id
|
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
|
nsxlib = self._core_plugin.nsxlib
|
||||||
l2gw_id = gw_connection.get(l2gw_const.L2GATEWAY_ID)
|
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')
|
bep_id = devices[0].get('device_name')
|
||||||
# Check for bridge endpoint profile existence
|
# Check for bridge endpoint profile existence
|
||||||
# if bridge endpoint profile is not found, this is likely an old
|
# 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})
|
'bep_id': bep_id})
|
||||||
raise n_exc.InvalidInput(error_message=msg)
|
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"""
|
"""Create a L2 gateway connection on the backend"""
|
||||||
nsxlib = self._core_plugin.nsxlib
|
nsxlib = self._core_plugin.nsxlib
|
||||||
l2gw_id = gw_connection.get(l2gw_const.L2GATEWAY_ID)
|
l2gw_id = gw_connection.get(l2gw_const.L2GATEWAY_ID)
|
||||||
network_id = gw_connection.get(l2gw_const.NETWORK_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(
|
interface_name, seg_id = self._get_conn_parameters(
|
||||||
context, gw_connection)
|
ctx, gw_connection)
|
||||||
self._validate_segment_id(seg_id)
|
self._validate_segment_id(seg_id)
|
||||||
tenant_id = gw_connection['tenant_id']
|
tenant_id = gw_connection['tenant_id']
|
||||||
if context.is_admin and not tenant_id:
|
if ctx.is_admin and not tenant_id:
|
||||||
tenant_id = context.tenant_id
|
tenant_id = ctx.tenant_id
|
||||||
gw_connection['tenant_id'] = tenant_id
|
gw_connection['tenant_id'] = tenant_id
|
||||||
try:
|
try:
|
||||||
tags = nsxlib.build_v3_tags_payload(
|
tags = nsxlib.build_v3_tags_payload(
|
||||||
gw_connection, resource_type='os-neutron-l2gw-id',
|
gw_connection, resource_type='os-neutron-l2gw-id',
|
||||||
project_name=context.tenant_name)
|
project_name=ctx.tenant_name)
|
||||||
bridge_endpoint = nsxlib.bridge_endpoint.create(
|
bridge_endpoint = nsxlib.bridge_endpoint.create(
|
||||||
device_name=device_name,
|
device_name=device_name,
|
||||||
vlan_transport_zone_id=interface_name,
|
vlan_transport_zone_id=interface_name,
|
||||||
@ -420,11 +420,11 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin):
|
|||||||
try:
|
try:
|
||||||
#TODO(abhiraut): Consider adding UT for port check once UTs are
|
#TODO(abhiraut): Consider adding UT for port check once UTs are
|
||||||
# refactored
|
# refactored
|
||||||
port = self._core_plugin.create_port(context, port_dict,
|
port = self._core_plugin.create_port(ctx, port_dict,
|
||||||
l2gw_port_check=True)
|
l2gw_port_check=True)
|
||||||
# Deallocate IP address from the port.
|
# Deallocate IP address from the port.
|
||||||
for fixed_ip in port.get('fixed_ips', []):
|
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['subnet_id'],
|
||||||
fixed_ip['ip_address'])
|
fixed_ip['ip_address'])
|
||||||
LOG.debug("IP addresses deallocated on port %s", port['id'])
|
LOG.debug("IP addresses deallocated on port %s", port['id'])
|
||||||
@ -437,14 +437,14 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin):
|
|||||||
bridge_endpoint['id'])
|
bridge_endpoint['id'])
|
||||||
super(NsxV3Driver,
|
super(NsxV3Driver,
|
||||||
self).delete_l2_gateway_connection(
|
self).delete_l2_gateway_connection(
|
||||||
context,
|
ctx,
|
||||||
gw_connection['id'])
|
gw_connection['id'])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with db_api.CONTEXT_WRITER.using(context):
|
with db_api.CONTEXT_WRITER.using(ctx):
|
||||||
# Update neutron's database with the mappings.
|
# Update neutron's database with the mappings.
|
||||||
nsx_db.add_l2gw_connection_mapping(
|
nsx_db.add_l2gw_connection_mapping(
|
||||||
session=context.session,
|
session=ctx.session,
|
||||||
connection_id=gw_connection['id'],
|
connection_id=gw_connection['id'],
|
||||||
bridge_endpoint_id=bridge_endpoint['id'],
|
bridge_endpoint_id=bridge_endpoint['id'],
|
||||||
port_id=port['id'])
|
port_id=port['id'])
|
||||||
@ -453,7 +453,7 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin):
|
|||||||
# from the device spec
|
# from the device spec
|
||||||
if seg_id and not gw_connection.get(l2gw_const.SEG_ID):
|
if seg_id and not gw_connection.get(l2gw_const.SEG_ID):
|
||||||
conn_db = self._plugin._get_l2_gateway_connection(
|
conn_db = self._plugin._get_l2_gateway_connection(
|
||||||
context, gw_connection['id'])
|
ctx, gw_connection['id'])
|
||||||
conn_db['segmentation_id'] = seg_id
|
conn_db['segmentation_id'] = seg_id
|
||||||
# Ensure the object is updated as well so the
|
# Ensure the object is updated as well so the
|
||||||
# create response returns the segmentation_id
|
# create response returns the segmentation_id
|
||||||
@ -469,20 +469,20 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin):
|
|||||||
bridge_endpoint['id'])
|
bridge_endpoint['id'])
|
||||||
super(NsxV3Driver,
|
super(NsxV3Driver,
|
||||||
self).delete_l2_gateway_connection(
|
self).delete_l2_gateway_connection(
|
||||||
context,
|
ctx,
|
||||||
gw_connection['id'])
|
gw_connection['id'])
|
||||||
return gw_connection
|
return gw_connection
|
||||||
|
|
||||||
def delete_l2_gateway_connection_postcommit(self, context, gw_connection):
|
def delete_l2_gateway_connection_postcommit(self, ctx, gw_connection):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def delete_l2_gateway_connection_precommit(self, context, gw_connection):
|
def delete_l2_gateway_connection_precommit(self, ctx, gw_connection):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def delete_l2_gateway_connection(self, context, gw_connection):
|
def delete_l2_gateway_connection(self, ctx, gw_connection):
|
||||||
"""Delete a L2 gateway connection."""
|
"""Delete a L2 gateway connection."""
|
||||||
conn_mapping = nsx_db.get_l2gw_connection_mapping(
|
conn_mapping = nsx_db.get_l2gw_connection_mapping(
|
||||||
session=context.session,
|
session=ctx.session,
|
||||||
connection_id=gw_connection)
|
connection_id=gw_connection)
|
||||||
if not conn_mapping:
|
if not conn_mapping:
|
||||||
LOG.error("Unable to delete gateway connection %(id)s: mapping "
|
LOG.error("Unable to delete gateway connection %(id)s: mapping "
|
||||||
@ -491,7 +491,7 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin):
|
|||||||
return
|
return
|
||||||
bridge_endpoint_id = conn_mapping.get('bridge_endpoint_id')
|
bridge_endpoint_id = conn_mapping.get('bridge_endpoint_id')
|
||||||
# Delete the logical port from the bridge endpoint.
|
# 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'),
|
port_id=conn_mapping.get('port_id'),
|
||||||
l2gw_port_check=False)
|
l2gw_port_check=False)
|
||||||
try:
|
try:
|
||||||
@ -503,20 +503,18 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin):
|
|||||||
raise l2gw_exc.L2GatewayServiceDriverError(
|
raise l2gw_exc.L2GatewayServiceDriverError(
|
||||||
method='delete_l2_gateway_connection')
|
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."""
|
"""Prevent core plugin from deleting L2 gateway port."""
|
||||||
try:
|
try:
|
||||||
port = self._core_plugin.get_port(context, port_id)
|
port = self._core_plugin.get_port(ctx, port_id)
|
||||||
except n_exc.PortNotFound:
|
except n_exc.PortNotFound:
|
||||||
return
|
return
|
||||||
if port['device_owner'] == nsx_constants.BRIDGE_ENDPOINT:
|
if port['device_owner'] == nsx_constants.BRIDGE_ENDPOINT:
|
||||||
reason = _("has device owner %s") % port['device_owner']
|
reason = _("has device owner %s") % port['device_owner']
|
||||||
raise n_exc.ServicePortInUse(port_id=port_id, reason=reason)
|
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."""
|
"""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."""
|
"""Process a deleted Neutron port."""
|
||||||
pass
|
|
||||||
|
@ -25,4 +25,3 @@ class NsxV3QosNotificationDriver(
|
|||||||
"""
|
"""
|
||||||
# The message queue is no longer needed in Pike.
|
# The message queue is no longer needed in Pike.
|
||||||
# Keeping this class for a while for existing configurations.
|
# Keeping this class for a while for existing configurations.
|
||||||
pass
|
|
||||||
|
@ -262,10 +262,10 @@ def nsx_delete_orphaned_edges(resource, event, trigger, **kwargs):
|
|||||||
LOG.info("NSXv Edge deletion aborted by user")
|
LOG.info("NSXv Edge deletion aborted by user")
|
||||||
return
|
return
|
||||||
|
|
||||||
nsxv = utils.get_nsxv_client()
|
nsxv_c = utils.get_nsxv_client()
|
||||||
for edge in orphaned_edges:
|
for edge in orphaned_edges:
|
||||||
LOG.info("Deleting edge: %s", edge)
|
LOG.info("Deleting edge: %s", edge)
|
||||||
nsxv.delete_edge(edge)
|
nsxv_c.delete_edge(edge)
|
||||||
|
|
||||||
LOG.info("After delete; Orphaned Edges: \n%s",
|
LOG.info("After delete; Orphaned Edges: \n%s",
|
||||||
pprint.pformat(get_orphaned_edges()))
|
pprint.pformat(get_orphaned_edges()))
|
||||||
@ -504,7 +504,7 @@ def change_edge_appliance_reservations(properties):
|
|||||||
LOG.error("%s", str(e))
|
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':
|
if edge.get('type') == 'gatewayServices':
|
||||||
try:
|
try:
|
||||||
az_name, size = _get_edge_az_and_size(edge_id)
|
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()
|
zones = nsx_az.NsxVAvailabilityZones()
|
||||||
az = zones.get_availability_zone(az_name)
|
az = zones.get_availability_zone(az_name)
|
||||||
if az.edge_ha and az.edge_host_groups:
|
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,
|
cluster_mng, az,
|
||||||
validate=True)
|
validate=True)
|
||||||
else:
|
else:
|
||||||
|
@ -32,14 +32,13 @@ from vmware_nsx.shell.admin.plugins.nsxv.resources import utils
|
|||||||
from vmware_nsx.shell import resources as shell
|
from vmware_nsx.shell import resources as shell
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
nsxv = utils.get_nsxv_client()
|
|
||||||
network_types = ['Network', 'VirtualWire', 'DistributedVirtualPortgroup']
|
network_types = ['Network', 'VirtualWire', 'DistributedVirtualPortgroup']
|
||||||
PORTGROUP_PREFIX = 'dvportgroup'
|
PORTGROUP_PREFIX = 'dvportgroup'
|
||||||
|
|
||||||
|
|
||||||
def get_networks_from_backend():
|
def get_networks_from_backend():
|
||||||
nsxv = utils.get_nsxv_client()
|
nsxv_c = utils.get_nsxv_client()
|
||||||
so_list = nsxv.get_scoping_objects()
|
so_list = nsxv_c.get_scoping_objects()
|
||||||
return et.fromstring(so_list)
|
return et.fromstring(so_list)
|
||||||
|
|
||||||
|
|
||||||
@ -76,7 +75,7 @@ def neutron_list_networks(resource, event, trigger,
|
|||||||
|
|
||||||
@admin_utils.output_header
|
@admin_utils.output_header
|
||||||
def nsx_update_switch(resource, event, trigger, **kwargs):
|
def nsx_update_switch(resource, event, trigger, **kwargs):
|
||||||
nsxv = utils.get_nsxv_client()
|
nsxv_c = utils.get_nsxv_client()
|
||||||
if not kwargs.get('property'):
|
if not kwargs.get('property'):
|
||||||
LOG.error("Need to specify dvs-id parameter and "
|
LOG.error("Need to specify dvs-id parameter and "
|
||||||
"attribute to update. Add --property dvs-id=<dvs-id> "
|
"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>")
|
"Add --property dvs-id=<dvs-id>")
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
h, switch = nsxv.get_vdn_switch(dvs_id)
|
h, switch = nsxv_c.get_vdn_switch(dvs_id)
|
||||||
except exceptions.ResourceNotFound:
|
except exceptions.ResourceNotFound:
|
||||||
LOG.error("DVS %s not found", dvs_id)
|
LOG.error("DVS %s not found", dvs_id)
|
||||||
return
|
return
|
||||||
@ -106,7 +105,7 @@ def nsx_update_switch(resource, event, trigger, **kwargs):
|
|||||||
"%(policy)s", {'dvs': dvs_id, 'policy': policy})
|
"%(policy)s", {'dvs': dvs_id, 'policy': policy})
|
||||||
switch['teamingPolicy'] = policy
|
switch['teamingPolicy'] = policy
|
||||||
try:
|
try:
|
||||||
switch = nsxv.update_vdn_switch(switch)
|
switch = nsxv_c.update_vdn_switch(switch)
|
||||||
except exceptions.VcnsApiException as e:
|
except exceptions.VcnsApiException as e:
|
||||||
desc = jsonutils.loads(e.response)
|
desc = jsonutils.loads(e.response)
|
||||||
details = desc.get('details')
|
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,
|
# Note: in case the backend network is attached to other backend objects,
|
||||||
# like VM, the deleting may fail and through an exception
|
# 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):
|
if moref.startswith(PORTGROUP_PREFIX):
|
||||||
# get the dvs id from the backend name:
|
# get the dvs id from the backend name:
|
||||||
dvs_id = get_dvs_id_from_backend_name(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})
|
"%(moref)s", {'moref': moref})
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
nsxv.delete_port_group(dvs_id, moref)
|
nsxv_c.delete_port_group(dvs_id, moref)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.error("Failed to delete backend network %(moref)s : "
|
LOG.error("Failed to delete backend network %(moref)s : "
|
||||||
"%(e)s", {'moref': moref, 'e': e})
|
"%(e)s", {'moref': moref, 'e': e})
|
||||||
@ -337,7 +336,7 @@ def delete_backend_network(resource, event, trigger, **kwargs):
|
|||||||
else:
|
else:
|
||||||
# Virtual wire
|
# Virtual wire
|
||||||
try:
|
try:
|
||||||
nsxv.delete_virtual_wire(moref)
|
nsxv_c.delete_virtual_wire(moref)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.error("Failed to delete backend network %(moref)s : "
|
LOG.error("Failed to delete backend network %(moref)s : "
|
||||||
"%(e)s", {'moref': moref, 'e': e})
|
"%(e)s", {'moref': moref, 'e': e})
|
||||||
|
@ -113,8 +113,8 @@ def nsx_recreate_router_edge(old_edge_id):
|
|||||||
az_name = _get_router_az_from_plugin_router(router)
|
az_name = _get_router_az_from_plugin_router(router)
|
||||||
# clean up other objects related to this router
|
# clean up other objects related to this router
|
||||||
if plugin.metadata_proxy_handler:
|
if plugin.metadata_proxy_handler:
|
||||||
md_proxy = plugin.get_metadata_proxy_handler(az_name)
|
md_proxy_h = plugin.get_metadata_proxy_handler(az_name)
|
||||||
md_proxy.cleanup_router_edge(context, router_id)
|
md_proxy_h.cleanup_router_edge(context, router_id)
|
||||||
|
|
||||||
# attach the router to a new edge
|
# attach the router to a new edge
|
||||||
appliance_size = router.get(routersize.ROUTER_SIZE)
|
appliance_size = router.get(routersize.ROUTER_SIZE)
|
||||||
|
@ -34,13 +34,13 @@ nsxv = utils.get_nsxv_client()
|
|||||||
|
|
||||||
|
|
||||||
def get_spoofguard_policies():
|
def get_spoofguard_policies():
|
||||||
nsxv = utils.get_nsxv_client()
|
nsxv_c = utils.get_nsxv_client()
|
||||||
return nsxv.get_spoofguard_policies()[1].get("policies")
|
return nsxv_c.get_spoofguard_policies()[1].get("policies")
|
||||||
|
|
||||||
|
|
||||||
def get_spoofguard_policy_data(policy_id):
|
def get_spoofguard_policy_data(policy_id):
|
||||||
nsxv = utils.get_nsxv_client()
|
nsxv_c = utils.get_nsxv_client()
|
||||||
return nsxv.get_spoofguard_policy_data(policy_id)[1].get(
|
return nsxv_c.get_spoofguard_policy_data(policy_id)[1].get(
|
||||||
'spoofguardList', [])
|
'spoofguardList', [])
|
||||||
|
|
||||||
|
|
||||||
|
@ -1063,11 +1063,11 @@ def migrate_edge_firewalls(nsxlib, nsxpolicy, plugin):
|
|||||||
# Make sure fwaas is considered as enabled
|
# Make sure fwaas is considered as enabled
|
||||||
self.fwaas_enabled = True
|
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
|
# Override this api because directory.get_plugin does not work from
|
||||||
# admin utils context.
|
# admin utils context.
|
||||||
driver_db = firewall_db_v2.FirewallPluginDb()
|
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)
|
fwaas_callbacks = MigrationNsxpFwaasCallbacks(False)
|
||||||
plugin.nsxpolicy = nsxpolicy
|
plugin.nsxpolicy = nsxpolicy
|
||||||
|
@ -74,9 +74,9 @@ def list_missing_ports(resource, event, trigger, **kwargs):
|
|||||||
admin_cxt = neutron_context.get_admin_context()
|
admin_cxt = neutron_context.get_admin_context()
|
||||||
filters = v3_utils.get_plugin_filters(admin_cxt)
|
filters = v3_utils.get_plugin_filters(admin_cxt)
|
||||||
nsxlib = v3_utils.get_connected_nsxlib()
|
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(
|
problems = plugin_utils.get_mismatch_logical_ports(
|
||||||
admin_cxt, nsxlib, plugin, filters)
|
admin_cxt, nsxlib, v3_plugin, filters)
|
||||||
|
|
||||||
if len(problems) > 0:
|
if len(problems) > 0:
|
||||||
title = ("Found internal ports misconfiguration on the "
|
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
|
# Go over all the ports from the plugin
|
||||||
admin_cxt = neutron_context.get_admin_context()
|
admin_cxt = neutron_context.get_admin_context()
|
||||||
with PortsPlugin() as plugin:
|
with PortsPlugin() as v3_plugin:
|
||||||
neutron_ports = plugin.get_ports(admin_cxt, filters=port_filters)
|
neutron_ports = v3_plugin.get_ports(admin_cxt, filters=port_filters)
|
||||||
|
|
||||||
for port in neutron_ports:
|
for port in neutron_ports:
|
||||||
# skip non compute ports
|
# skip non compute ports
|
||||||
@ -202,7 +202,7 @@ def migrate_exclude_ports(resource, event, trigger, **kwargs):
|
|||||||
LOG.info("Version is %s", version)
|
LOG.info("Version is %s", version)
|
||||||
return
|
return
|
||||||
admin_cxt = neutron_context.get_admin_context()
|
admin_cxt = neutron_context.get_admin_context()
|
||||||
plugin = PortsPlugin()
|
ports_plugin = PortsPlugin()
|
||||||
_port_client = resources.LogicalPort(_nsx_client)
|
_port_client = resources.LogicalPort(_nsx_client)
|
||||||
exclude_list = nsxlib.firewall_section.get_excludelist()
|
exclude_list = nsxlib.firewall_section.get_excludelist()
|
||||||
for member in exclude_list['members']:
|
for member in exclude_list['members']:
|
||||||
@ -226,7 +226,7 @@ def migrate_exclude_ports(resource, event, trigger, **kwargs):
|
|||||||
continue
|
continue
|
||||||
# Check if this port exists in the DB
|
# Check if this port exists in the DB
|
||||||
try:
|
try:
|
||||||
plugin.get_port(admin_cxt, neutron_port_id)
|
ports_plugin.get_port(admin_cxt, neutron_port_id)
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.info("Port %s is not defined in DB", neutron_port_id)
|
LOG.info("Port %s is not defined in DB", neutron_port_id)
|
||||||
continue
|
continue
|
||||||
|
@ -85,9 +85,9 @@ def get_connected_nsxlib(nsx_username=None, nsx_password=None,
|
|||||||
return _NSXLIB
|
return _NSXLIB
|
||||||
|
|
||||||
|
|
||||||
def get_plugin_filters(context):
|
def get_plugin_filters(ctx):
|
||||||
return admin_utils.get_plugin_filters(
|
return admin_utils.get_plugin_filters(
|
||||||
context, projectpluginmap.NsxPlugins.NSX_T)
|
ctx, projectpluginmap.NsxPlugins.NSX_T)
|
||||||
|
|
||||||
|
|
||||||
class NeutronDbClient(db_base_plugin_v2.NeutronDbPluginV2):
|
class NeutronDbClient(db_base_plugin_v2.NeutronDbPluginV2):
|
||||||
@ -112,15 +112,15 @@ class NeutronDbClient(db_base_plugin_v2.NeutronDbPluginV2):
|
|||||||
return super(NeutronDbClient, self).get_networks(
|
return super(NeutronDbClient, self).get_networks(
|
||||||
self.context, filters=filters, fields=fields)
|
self.context, filters=filters, fields=fields)
|
||||||
|
|
||||||
def get_network(self, context, network_id):
|
def get_network(self, ctx, network_id):
|
||||||
if not context:
|
if not ctx:
|
||||||
context = self.context
|
ctx = self.context
|
||||||
return super(NeutronDbClient, self).get_network(context, network_id)
|
return super(NeutronDbClient, self).get_network(ctx, network_id)
|
||||||
|
|
||||||
def get_subnet(self, context, subnet_id):
|
def get_subnet(self, ctx, subnet_id):
|
||||||
if not context:
|
if not ctx:
|
||||||
context = self.context
|
ctx = self.context
|
||||||
return super(NeutronDbClient, self).get_subnet(context, subnet_id)
|
return super(NeutronDbClient, self).get_subnet(ctx, subnet_id)
|
||||||
|
|
||||||
def get_lswitch_and_lport_id(self, port_id):
|
def get_lswitch_and_lport_id(self, port_id):
|
||||||
return nsx_db.get_nsx_switch_and_port_id(self.context.session, 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):
|
def _init_dhcp_metadata(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _extend_get_network_dict_provider(self, context, net):
|
def _extend_get_network_dict_provider(self, ctx, net):
|
||||||
self._extend_network_dict_provider(context, net)
|
self._extend_network_dict_provider(ctx, net)
|
||||||
# skip getting the Qos policy ID because get_object calls
|
# skip getting the Qos policy ID because get_object calls
|
||||||
# plugin init again on admin-util environment
|
# plugin init again on admin-util environment
|
||||||
|
|
||||||
def _extend_get_port_dict_binding(self, context, port):
|
def _extend_get_port_dict_binding(self, ctx, port):
|
||||||
self._extend_port_dict_binding(context, port)
|
self._extend_port_dict_binding(ctx, port)
|
||||||
# skip getting the Qos policy ID because get_object calls
|
# skip getting the Qos policy ID because get_object calls
|
||||||
# plugin init again on admin-util environment
|
# plugin init again on admin-util environment
|
||||||
|
|
||||||
def delete_network(self, context, network_id):
|
def delete_network(self, ctx, network_id):
|
||||||
if not context:
|
if not ctx:
|
||||||
context = self.context
|
ctx = self.context
|
||||||
return super(NsxV3PluginWrapper, self).delete_network(
|
return super(NsxV3PluginWrapper, self).delete_network(
|
||||||
context, network_id)
|
ctx, network_id)
|
||||||
|
|
||||||
def remove_router_interface(self, context, router_id, interface):
|
def remove_router_interface(self, ctx, router_id, interface):
|
||||||
if not context:
|
if not ctx:
|
||||||
context = self.context
|
ctx = self.context
|
||||||
return super(NsxV3PluginWrapper, self).remove_router_interface(
|
return super(NsxV3PluginWrapper, self).remove_router_interface(
|
||||||
context, router_id, interface)
|
ctx, router_id, interface)
|
||||||
|
@ -81,9 +81,9 @@ ops = [op.value for op in Operations]
|
|||||||
|
|
||||||
|
|
||||||
class Resource(object):
|
class Resource(object):
|
||||||
def __init__(self, name, ops):
|
def __init__(self, name, ops_obj):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.supported_ops = ops
|
self.supported_ops = ops_obj
|
||||||
|
|
||||||
|
|
||||||
# Add supported NSX-V3 resources in this dictionary
|
# Add supported NSX-V3 resources in this dictionary
|
||||||
|
Loading…
Reference in New Issue
Block a user