update bandit, hacking and flake8 requirements
This patch bumps the hacking, bandit and flake8 requirements to match suit with similar work (ex [1]). It also updates the code to fix a few new pep8 errors as well as adds a local tox target for requirements-check-dev. [1] https://review.opendev.org/#/c/658245/ Change-Id: I6caeb52dc1a5842338ec989a742ae5989608e0da
This commit is contained in:
parent
2d68de6ce4
commit
5362c65416
@ -175,7 +175,7 @@ class NSXClient(object):
|
|||||||
self.cleanup_tier1_nat_rules(rtr['id'])
|
self.cleanup_tier1_nat_rules(rtr['id'])
|
||||||
try:
|
try:
|
||||||
self.nsxpolicy.tier1.delete_locale_service(rtr['id'])
|
self.nsxpolicy.tier1.delete_locale_service(rtr['id'])
|
||||||
except exceptions.ManagerError as e:
|
except exceptions.ManagerError:
|
||||||
# Not always exists
|
# Not always exists
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
|
@ -253,7 +253,7 @@ class VSMClient(object):
|
|||||||
# Query all firewall sections
|
# Query all firewall sections
|
||||||
response = self.get()
|
response = self.get()
|
||||||
# Get layer3 sections related to security group
|
# Get layer3 sections related to security group
|
||||||
if response.status_code is 200:
|
if response.status_code == 200:
|
||||||
l3_sections = response.json()['layer3Sections']['layer3Sections']
|
l3_sections = response.json()['layer3Sections']['layer3Sections']
|
||||||
# do not delete the default section, or sections created by the
|
# do not delete the default section, or sections created by the
|
||||||
# service composer
|
# service composer
|
||||||
@ -289,7 +289,7 @@ class VSMClient(object):
|
|||||||
self.__set_endpoint("/services/securitygroup/scope/globalroot-0")
|
self.__set_endpoint("/services/securitygroup/scope/globalroot-0")
|
||||||
# Query all security groups
|
# Query all security groups
|
||||||
response = self.get()
|
response = self.get()
|
||||||
if response.status_code is 200:
|
if response.status_code == 200:
|
||||||
sg_all = response.json()
|
sg_all = response.json()
|
||||||
else:
|
else:
|
||||||
print("ERROR: wrong response status code! Exiting...")
|
print("ERROR: wrong response status code! Exiting...")
|
||||||
@ -323,7 +323,7 @@ class VSMClient(object):
|
|||||||
self.__set_endpoint("/services/spoofguard/policies/")
|
self.__set_endpoint("/services/spoofguard/policies/")
|
||||||
# Query all spoofguard policies
|
# Query all spoofguard policies
|
||||||
response = self.get()
|
response = self.get()
|
||||||
if response.status_code is not 200:
|
if response.status_code != 200:
|
||||||
print("ERROR: Faield to get spoofguard policies")
|
print("ERROR: Faield to get spoofguard policies")
|
||||||
return
|
return
|
||||||
sgp_all = response.json()
|
sgp_all = response.json()
|
||||||
@ -395,7 +395,7 @@ def ceil(a, b):
|
|||||||
if b == 0:
|
if b == 0:
|
||||||
return 0
|
return 0
|
||||||
div = a / b
|
div = a / b
|
||||||
mod = 0 if a % b is 0 else 1
|
mod = 0 if a % b == 0 else 1
|
||||||
return int(div + mod)
|
return int(div + mod)
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,9 +3,9 @@ coverage==4.0
|
|||||||
decorator==4.3.0
|
decorator==4.3.0
|
||||||
eventlet==0.24.1
|
eventlet==0.24.1
|
||||||
fixtures==3.0.0
|
fixtures==3.0.0
|
||||||
flake8==2.5.5
|
|
||||||
flake8-import-order==0.12
|
flake8-import-order==0.12
|
||||||
hacking==0.12.0
|
flake8==2.6.2
|
||||||
|
hacking==1.1.0
|
||||||
httplib2==0.9.1
|
httplib2==0.9.1
|
||||||
mock==2.0.0
|
mock==2.0.0
|
||||||
netaddr==0.7.18
|
netaddr==0.7.18
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
# The order of packages is significant, because pip processes them in the order
|
# The order of packages is significant, because pip processes them in the order
|
||||||
# of appearance. Changing the order has an impact on the overall integration
|
# of appearance. Changing the order has an impact on the overall integration
|
||||||
# process, which may cause wedges in the gate later.
|
# process, which may cause wedges in the gate later.
|
||||||
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
|
hacking>=1.1.0 # Apache-2.0
|
||||||
|
bandit!=1.6.0,>=1.1.0 # Apache-2.0
|
||||||
coverage!=4.4,>=4.0 # Apache-2.0
|
coverage!=4.4,>=4.0 # Apache-2.0
|
||||||
fixtures>=3.0.0 # Apache-2.0/BSD
|
fixtures>=3.0.0 # Apache-2.0/BSD
|
||||||
|
flake8>=2.6.0
|
||||||
flake8-import-order==0.12 # LGPLv3
|
flake8-import-order==0.12 # LGPLv3
|
||||||
mock>=2.0.0 # BSD
|
mock>=2.0.0 # BSD
|
||||||
|
|
||||||
psycopg2>=2.7 # LGPL/ZPL
|
psycopg2>=2.7 # LGPL/ZPL
|
||||||
PyMySQL>=0.7.6 # MIT License
|
PyMySQL>=0.7.6 # MIT License
|
||||||
oslotest>=3.2.0 # Apache-2.0
|
oslotest>=3.2.0 # Apache-2.0
|
||||||
@ -18,7 +18,6 @@ testresources>=2.0.0 # Apache-2.0/BSD
|
|||||||
testtools>=2.2.0 # MIT
|
testtools>=2.2.0 # MIT
|
||||||
testscenarios>=0.4 # Apache-2.0/BSD
|
testscenarios>=0.4 # Apache-2.0/BSD
|
||||||
WebTest>=2.0.27 # MIT
|
WebTest>=2.0.27 # MIT
|
||||||
bandit>=1.1.0 # Apache-2.0
|
|
||||||
tempest>=17.1.0 # Apache-2.0
|
tempest>=17.1.0 # Apache-2.0
|
||||||
pylint==1.7.6 # GPLv2
|
pylint==1.7.6 # GPLv2
|
||||||
python-openstackclient>=3.16.0 # Apache-2.0
|
python-openstackclient>=3.16.0 # Apache-2.0
|
||||||
|
18
tox.ini
18
tox.ini
@ -126,7 +126,7 @@ commands =
|
|||||||
# If it is easier to add a check via a shell script, consider adding it in this file
|
# If it is easier to add a check via a shell script, consider adding it in this file
|
||||||
sh ./tools/misc-sanity-checks.sh
|
sh ./tools/misc-sanity-checks.sh
|
||||||
# Checks for coding and style guidelines
|
# Checks for coding and style guidelines
|
||||||
flake8 {toxinidir}/vmware_nsx
|
flake8
|
||||||
sh ./tools/coding-checks.sh --pylint '{posargs}'
|
sh ./tools/coding-checks.sh --pylint '{posargs}'
|
||||||
neutron-db-manage --subproject vmware-nsx check_migration
|
neutron-db-manage --subproject vmware-nsx check_migration
|
||||||
{[testenv:genconfig]commands}
|
{[testenv:genconfig]commands}
|
||||||
@ -163,7 +163,8 @@ commands = sphinx-build -b html doc/source doc/build/html
|
|||||||
# TODO(dougwig) -- uncomment this to test for remaining linkages
|
# TODO(dougwig) -- uncomment this to test for remaining linkages
|
||||||
# N530 direct neutron imports not allowed
|
# N530 direct neutron imports not allowed
|
||||||
# N531 translations hints
|
# N531 translations hints
|
||||||
ignore = E125,E126,E128,E129,E265,H305,H307,H404,H405,H904,N530,N531
|
# W504 line break after binary operator
|
||||||
|
ignore = E125,E126,E128,E129,E265,H305,H307,H404,H405,H904,N530,N531,W504
|
||||||
show-source = true
|
show-source = true
|
||||||
builtins = _
|
builtins = _
|
||||||
exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,.ropeproject
|
exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,.ropeproject
|
||||||
@ -205,3 +206,16 @@ deps =
|
|||||||
|
|
||||||
[testenv:venv]
|
[testenv:venv]
|
||||||
commands = {posargs}
|
commands = {posargs}
|
||||||
|
|
||||||
|
[testenv:requirements-check-dev]
|
||||||
|
basepython = python3
|
||||||
|
commands =
|
||||||
|
pip install -q -e "git+https://opendev.org/openstack/requirements#egg=requirements"
|
||||||
|
pip freeze
|
||||||
|
# must have openstack/requirements on latest src/master in ../requirements
|
||||||
|
{toxinidir}/../requirements/playbooks/files/project-requirements-change.py --reqs={toxinidir}/../requirements {toxinidir}
|
||||||
|
deps =
|
||||||
|
-c{toxinidir}/lower-constraints.txt
|
||||||
|
-r{toxinidir}/test-requirements.txt
|
||||||
|
-r{toxinidir}/doc/requirements.txt
|
||||||
|
-r{toxinidir}/requirements.txt
|
||||||
|
@ -152,5 +152,6 @@ class EventletApiClient(base.ApiClientBase):
|
|||||||
|
|
||||||
return cookie
|
return cookie
|
||||||
|
|
||||||
|
|
||||||
# Register as subclass.
|
# Register as subclass.
|
||||||
base.ApiClientBase.register(EventletApiClient)
|
base.ApiClientBase.register(EventletApiClient)
|
||||||
|
@ -45,13 +45,14 @@ class DhcpAgentNotifyAPI(dhcp_rpc_agent_api.DhcpAgentNotifyAPI):
|
|||||||
if lsn_exists:
|
if lsn_exists:
|
||||||
# if lsn exists, the network is one created with the new model
|
# if lsn exists, the network is one created with the new model
|
||||||
if (resource == 'subnet' and action == 'create' and
|
if (resource == 'subnet' and action == 'create' and
|
||||||
const.DEVICE_OWNER_DHCP not in plugin.port_special_owners):
|
const.DEVICE_OWNER_DHCP not in
|
||||||
|
plugin.port_special_owners):
|
||||||
# network/subnet provisioned in the new model have a plain
|
# network/subnet provisioned in the new model have a plain
|
||||||
# nsx lswitch port, no vif attachment
|
# nsx lswitch port, no vif attachment
|
||||||
plugin.port_special_owners.append(const.DEVICE_OWNER_DHCP)
|
plugin.port_special_owners.append(const.DEVICE_OWNER_DHCP)
|
||||||
treat_dhcp_owner_specially = True
|
treat_dhcp_owner_specially = True
|
||||||
if (resource == 'port' and action == 'update' or
|
if (resource == 'port' and action == 'update' or
|
||||||
resource == 'subnet'):
|
resource == 'subnet'):
|
||||||
self.agentless_notifier.notify(context, data, methodname)
|
self.agentless_notifier.notify(context, data, methodname)
|
||||||
elif not lsn_exists and resource in ['port', 'subnet']:
|
elif not lsn_exists and resource in ['port', 'subnet']:
|
||||||
# call notifier for the agent-based mode
|
# call notifier for the agent-based mode
|
||||||
|
@ -84,9 +84,9 @@ def format_exception(etype, e, exception_locals):
|
|||||||
"""
|
"""
|
||||||
msg = [_("Error. %(type)s exception: %(exc)s.") %
|
msg = [_("Error. %(type)s exception: %(exc)s.") %
|
||||||
{'type': etype, 'exc': e}]
|
{'type': etype, 'exc': e}]
|
||||||
l = dict((k, v) for k, v in six.iteritems(exception_locals)
|
lcls = dict((k, v) for k, v in six.iteritems(exception_locals)
|
||||||
if k != 'request')
|
if k != 'request')
|
||||||
msg.append(_("locals=[%s]") % str(l))
|
msg.append(_("locals=[%s]") % str(lcls))
|
||||||
return ' '.join(msg)
|
return ' '.join(msg)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1555,6 +1555,7 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
|
|||||||
if (actions['remove_router_link_port'] or
|
if (actions['remove_router_link_port'] or
|
||||||
actions['add_router_link_port']):
|
actions['add_router_link_port']):
|
||||||
# GW was changed. update GW and route advertisement
|
# GW was changed. update GW and route advertisement
|
||||||
|
# pylint: disable=unexpected-keyword-arg
|
||||||
self.nsxpolicy.tier1.update_route_advertisement(
|
self.nsxpolicy.tier1.update_route_advertisement(
|
||||||
router_id,
|
router_id,
|
||||||
nat=actions['advertise_route_nat_flag'],
|
nat=actions['advertise_route_nat_flag'],
|
||||||
|
@ -296,14 +296,14 @@ class ErrorDhcpEdgeJob(base_job.BaseJob):
|
|||||||
|
|
||||||
if vnic['type'] != 'trunk':
|
if vnic['type'] != 'trunk':
|
||||||
# reinitialize the interface as it is missing config
|
# reinitialize the interface as it is missing config
|
||||||
vnic['name'] = (vcns_const.INTERNAL_VNIC_NAME +
|
vnic['name'] = (vcns_const.INTERNAL_VNIC_NAME +
|
||||||
str(vnic['index']))
|
str(vnic['index']))
|
||||||
vnic['type'] = 'trunk'
|
vnic['type'] = 'trunk'
|
||||||
vnic['portgroupId'] = port_group_id
|
vnic['portgroupId'] = port_group_id
|
||||||
vnic['mtu'] = 1500
|
vnic['mtu'] = 1500
|
||||||
vnic['enableProxyArp'] = False
|
vnic['enableProxyArp'] = False
|
||||||
vnic['enableSendRedirects'] = True
|
vnic['enableSendRedirects'] = True
|
||||||
vnic['isConnected'] = True
|
vnic['isConnected'] = True
|
||||||
|
|
||||||
def _update_router_bindings(self, context, edge_id):
|
def _update_router_bindings(self, context, edge_id):
|
||||||
edge_router_binds = nsxv_db.get_nsxv_router_bindings_by_edge(
|
edge_router_binds = nsxv_db.get_nsxv_router_bindings_by_edge(
|
||||||
|
@ -1000,7 +1000,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
if self._vcm:
|
if self._vcm:
|
||||||
try:
|
try:
|
||||||
h, switch = self.nsx_v.vcns.get_vdn_switch(dvs_id)
|
h, switch = self.nsx_v.vcns.get_vdn_switch(dvs_id)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
LOG.warning('DVS %s not registered on NSX. Unable to '
|
LOG.warning('DVS %s not registered on NSX. Unable to '
|
||||||
'update teaming for network %s',
|
'update teaming for network %s',
|
||||||
dvs_id, net_id)
|
dvs_id, net_id)
|
||||||
@ -1362,9 +1362,9 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
# requires allowing multiple or cidr-based allowed address pairs
|
# requires allowing multiple or cidr-based allowed address pairs
|
||||||
# defined per port but doesn't want to disable spoofguard globally
|
# defined per port but doesn't want to disable spoofguard globally
|
||||||
sg_policy_id = None
|
sg_policy_id = None
|
||||||
allow_multiple_addresses = (not net_data[psec.PORTSECURITY]
|
allow_multiple_addresses = (not net_data[psec.PORTSECURITY] and
|
||||||
and cfg.CONF.nsxv.
|
cfg.CONF.
|
||||||
allow_multiple_ip_addresses)
|
nsxv.allow_multiple_ip_addresses)
|
||||||
if (cfg.CONF.nsxv.spoofguard_enabled and backend_network and not
|
if (cfg.CONF.nsxv.spoofguard_enabled and backend_network and not
|
||||||
allow_multiple_addresses):
|
allow_multiple_addresses):
|
||||||
# This variable is set as the method below may result in a
|
# This variable is set as the method below may result in a
|
||||||
@ -1816,10 +1816,10 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
self._update_vnic_assigned_addresses(context.session, port,
|
self._update_vnic_assigned_addresses(context.session, port,
|
||||||
vnic_id)
|
vnic_id)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg = _('Unable to add port to spoofguard policy error '
|
msg = _('Unable to add port to spoofguard policy error '
|
||||||
'%s') % e
|
'%s') % e
|
||||||
raise n_exc.BadRequest(resource='spoofguard policy',
|
raise n_exc.BadRequest(resource='spoofguard policy',
|
||||||
msg=msg)
|
msg=msg)
|
||||||
|
|
||||||
def update_network(self, context, id, network):
|
def update_network(self, context, id, network):
|
||||||
net_attrs = network['network']
|
net_attrs = network['network']
|
||||||
@ -2005,17 +2005,17 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
not network_port_security):
|
not network_port_security):
|
||||||
for ap in attrs[addr_apidef.ADDRESS_PAIRS]:
|
for ap in attrs[addr_apidef.ADDRESS_PAIRS]:
|
||||||
# Check that the IP address is a subnet
|
# Check that the IP address is a subnet
|
||||||
if len(ap['ip_address'].split('/')) > 1:
|
if len(ap['ip_address'].split('/')) > 1:
|
||||||
msg = _('NSXv does not support CIDR as address pairs')
|
msg = _('NSXv does not support CIDR as address pairs')
|
||||||
raise n_exc.BadRequest(resource='address_pairs',
|
raise n_exc.BadRequest(resource='address_pairs',
|
||||||
msg=msg)
|
msg=msg)
|
||||||
# Check that the MAC address is the same as the port
|
# Check that the MAC address is the same as the port
|
||||||
for ap in attrs[addr_apidef.ADDRESS_PAIRS]:
|
for ap in attrs[addr_apidef.ADDRESS_PAIRS]:
|
||||||
if ('mac_address' in ap and
|
if ('mac_address' in ap and
|
||||||
ap['mac_address'] != db_port['mac_address']):
|
ap['mac_address'] != db_port['mac_address']):
|
||||||
msg = _('Address pairs should have same MAC as the '
|
msg = _('Address pairs should have same MAC as the '
|
||||||
'port')
|
'port')
|
||||||
raise n_exc.BadRequest(resource='address_pairs', msg=msg)
|
raise n_exc.BadRequest(resource='address_pairs', msg=msg)
|
||||||
|
|
||||||
def _is_mac_in_use(self, context, network_id, mac_address):
|
def _is_mac_in_use(self, context, network_id, mac_address):
|
||||||
# Override this method as the backed doesn't support using the same
|
# Override this method as the backed doesn't support using the same
|
||||||
|
@ -660,6 +660,7 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
|
|||||||
def _init_mac_learning_profiles(self):
|
def _init_mac_learning_profiles(self):
|
||||||
with locking.LockManager.get_lock('nsxv3_mac_learning_profile_init'):
|
with locking.LockManager.get_lock('nsxv3_mac_learning_profile_init'):
|
||||||
if not self._get_mac_learning_profile():
|
if not self._get_mac_learning_profile():
|
||||||
|
# pylint: disable=unexpected-keyword-arg
|
||||||
self.nsxlib.switching_profile.create_mac_learning_profile(
|
self.nsxlib.switching_profile.create_mac_learning_profile(
|
||||||
NSX_V3_MAC_LEARNING_PROFILE_NAME,
|
NSX_V3_MAC_LEARNING_PROFILE_NAME,
|
||||||
'Neutron MAC Learning Profile',
|
'Neutron MAC Learning Profile',
|
||||||
@ -667,6 +668,7 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
|
|||||||
tags=self.nsxlib.build_v3_api_version_tag())
|
tags=self.nsxlib.build_v3_api_version_tag())
|
||||||
self._get_mac_learning_profile()
|
self._get_mac_learning_profile()
|
||||||
if not self._get_mac_learning_disabled_profile():
|
if not self._get_mac_learning_disabled_profile():
|
||||||
|
# pylint: disable=unexpected-keyword-arg
|
||||||
self.nsxlib.switching_profile.create_mac_learning_profile(
|
self.nsxlib.switching_profile.create_mac_learning_profile(
|
||||||
NSX_V3_MAC_DISABLED_PROFILE_NAME,
|
NSX_V3_MAC_DISABLED_PROFILE_NAME,
|
||||||
'Neutron MAC Learning Disabled Profile',
|
'Neutron MAC Learning Disabled Profile',
|
||||||
@ -3139,10 +3141,10 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
|
|||||||
name = self.nsxlib.ns_group.get_name(secgroup)
|
name = self.nsxlib.ns_group.get_name(secgroup)
|
||||||
|
|
||||||
if self.nsxlib.feature_supported(
|
if self.nsxlib.feature_supported(
|
||||||
nsxlib_consts.FEATURE_DYNAMIC_CRITERIA):
|
nsxlib_consts.FEATURE_DYNAMIC_CRITERIA):
|
||||||
tag_expression = (
|
tag_expression = (
|
||||||
self.nsxlib.ns_group.get_port_tag_expression(
|
self.nsxlib.ns_group.get_port_tag_expression(
|
||||||
security.PORT_SG_SCOPE, secgroup['id']))
|
security.PORT_SG_SCOPE, secgroup['id']))
|
||||||
else:
|
else:
|
||||||
tag_expression = None
|
tag_expression = None
|
||||||
|
|
||||||
|
@ -104,8 +104,9 @@ class EdgeListenerManagerFromDict(base_mgr.NsxpLoadbalancerBaseManager):
|
|||||||
ssl_profile_binding = self._upload_certificate(
|
ssl_profile_binding = self._upload_certificate(
|
||||||
listener['id'], listener['default_tls_container_id'], tags,
|
listener['id'], listener['default_tls_container_id'], tags,
|
||||||
certificate=certificate)
|
certificate=certificate)
|
||||||
if (listener['protocol'] == lb_const.LB_PROTOCOL_TERMINATED_HTTPS
|
if (listener['protocol'] ==
|
||||||
and ssl_profile_binding):
|
lb_const.LB_PROTOCOL_TERMINATED_HTTPS and
|
||||||
|
ssl_profile_binding):
|
||||||
kwargs.update(ssl_profile_binding)
|
kwargs.update(ssl_profile_binding)
|
||||||
|
|
||||||
waf_profile, mode = self.core_plugin.get_waf_profile_path_and_mode()
|
waf_profile, mode = self.core_plugin.get_waf_profile_path_and_mode()
|
||||||
|
@ -291,7 +291,7 @@ class EdgeListenerManagerFromDict(base_mgr.EdgeLoadbalancerBaseManager):
|
|||||||
with locking.LockManager.get_lock(edge_id):
|
with locking.LockManager.get_lock(edge_id):
|
||||||
self.vcns.delete_app_profile(edge_id, app_profile_id)
|
self.vcns.delete_app_profile(edge_id, app_profile_id)
|
||||||
except (vcns_exc.ResourceNotFound, vcns_exc.RequestBad):
|
except (vcns_exc.ResourceNotFound, vcns_exc.RequestBad):
|
||||||
LOG.error('app profile not found on edge: %s', edge_id)
|
LOG.error('app profile not found on edge: %s', edge_id)
|
||||||
except vcns_exc.VcnsApiException:
|
except vcns_exc.VcnsApiException:
|
||||||
LOG.error('Failed to delete app profile on Edge: %s', edge_id)
|
LOG.error('Failed to delete app profile on Edge: %s', edge_id)
|
||||||
|
|
||||||
|
@ -343,6 +343,7 @@ def nsx_fix_name_mismatch(resource, event, trigger, **kwargs):
|
|||||||
'Edge %s has no backup prefix on NSX', edge_id)
|
'Edge %s has no backup prefix on NSX', edge_id)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
registry.subscribe(nsx_list_backup_edges,
|
registry.subscribe(nsx_list_backup_edges,
|
||||||
constants.BACKUP_EDGES,
|
constants.BACKUP_EDGES,
|
||||||
shell.Operations.LIST.value)
|
shell.Operations.LIST.value)
|
||||||
|
@ -327,7 +327,7 @@ def change_edge_ha(ha, edge_id):
|
|||||||
'enabled': ha}
|
'enabled': ha}
|
||||||
try:
|
try:
|
||||||
nsxv.enable_ha(edge_id, request)
|
nsxv.enable_ha(edge_id, request)
|
||||||
except nsxv_exceptions.ResourceNotFound as e:
|
except nsxv_exceptions.ResourceNotFound:
|
||||||
LOG.error("Edge %s not found", edge_id)
|
LOG.error("Edge %s not found", edge_id)
|
||||||
except exceptions.NeutronException as e:
|
except exceptions.NeutronException as e:
|
||||||
LOG.error("%s", str(e))
|
LOG.error("%s", str(e))
|
||||||
@ -353,7 +353,7 @@ def change_edge_syslog(properties):
|
|||||||
edge_id = properties.get('edge-id')
|
edge_id = properties.get('edge-id')
|
||||||
try:
|
try:
|
||||||
nsxv.update_edge_syslog(edge_id, request)
|
nsxv.update_edge_syslog(edge_id, request)
|
||||||
except nsxv_exceptions.ResourceNotFound as e:
|
except nsxv_exceptions.ResourceNotFound:
|
||||||
LOG.error("Edge %s not found", edge_id)
|
LOG.error("Edge %s not found", edge_id)
|
||||||
except exceptions.NeutronException as e:
|
except exceptions.NeutronException as e:
|
||||||
LOG.error("%s", str(e))
|
LOG.error("%s", str(e))
|
||||||
@ -362,7 +362,7 @@ def change_edge_syslog(properties):
|
|||||||
def delete_edge_syslog(edge_id):
|
def delete_edge_syslog(edge_id):
|
||||||
try:
|
try:
|
||||||
nsxv.delete_edge_syslog(edge_id)
|
nsxv.delete_edge_syslog(edge_id)
|
||||||
except nsxv_exceptions.ResourceNotFound as e:
|
except nsxv_exceptions.ResourceNotFound:
|
||||||
LOG.error("Edge %s not found", edge_id)
|
LOG.error("Edge %s not found", edge_id)
|
||||||
except exceptions.NeutronException as e:
|
except exceptions.NeutronException as e:
|
||||||
LOG.error("%s", str(e))
|
LOG.error("%s", str(e))
|
||||||
@ -404,7 +404,7 @@ def change_edge_loglevel(properties):
|
|||||||
try:
|
try:
|
||||||
edge_utils.update_edge_loglevel(nsxv, edge_id, module, level)
|
edge_utils.update_edge_loglevel(nsxv, edge_id, module, level)
|
||||||
|
|
||||||
except nsxv_exceptions.ResourceNotFound as e:
|
except nsxv_exceptions.ResourceNotFound:
|
||||||
LOG.error("Edge %s not found", edge_id)
|
LOG.error("Edge %s not found", edge_id)
|
||||||
except exceptions.NeutronException as e:
|
except exceptions.NeutronException as e:
|
||||||
LOG.error("%s", str(e))
|
LOG.error("%s", str(e))
|
||||||
@ -422,7 +422,7 @@ def change_edge_appliance_size(properties):
|
|||||||
try:
|
try:
|
||||||
nsxv.change_edge_appliance_size(
|
nsxv.change_edge_appliance_size(
|
||||||
properties.get('edge-id'), size)
|
properties.get('edge-id'), size)
|
||||||
except nsxv_exceptions.ResourceNotFound as e:
|
except nsxv_exceptions.ResourceNotFound:
|
||||||
LOG.error("Edge %s not found", properties.get('edge-id'))
|
LOG.error("Edge %s not found", properties.get('edge-id'))
|
||||||
except exceptions.NeutronException as e:
|
except exceptions.NeutronException as e:
|
||||||
LOG.error("%s", str(e))
|
LOG.error("%s", str(e))
|
||||||
@ -462,7 +462,7 @@ def change_edge_appliance(edge_id):
|
|||||||
request = {'appliances': appliances, 'applianceSize': size}
|
request = {'appliances': appliances, 'applianceSize': size}
|
||||||
try:
|
try:
|
||||||
nsxv.change_edge_appliance(edge_id, request)
|
nsxv.change_edge_appliance(edge_id, request)
|
||||||
except nsxv_exceptions.ResourceNotFound as e:
|
except nsxv_exceptions.ResourceNotFound:
|
||||||
LOG.error("Edge %s not found", edge_id)
|
LOG.error("Edge %s not found", edge_id)
|
||||||
except exceptions.NeutronException as e:
|
except exceptions.NeutronException as e:
|
||||||
LOG.error("%s", str(e))
|
LOG.error("%s", str(e))
|
||||||
@ -503,7 +503,7 @@ def change_edge_appliance_reservations(properties):
|
|||||||
request = {'appliances': appliances}
|
request = {'appliances': appliances}
|
||||||
try:
|
try:
|
||||||
nsxv.change_edge_appliance(edge_id, request)
|
nsxv.change_edge_appliance(edge_id, request)
|
||||||
except nsxv_exceptions.ResourceNotFound as e:
|
except nsxv_exceptions.ResourceNotFound:
|
||||||
LOG.error("Edge %s not found", edge_id)
|
LOG.error("Edge %s not found", edge_id)
|
||||||
except exceptions.NeutronException as e:
|
except exceptions.NeutronException as e:
|
||||||
LOG.error("%s", str(e))
|
LOG.error("%s", str(e))
|
||||||
|
@ -71,6 +71,7 @@ class Operations(enum.Enum):
|
|||||||
VALIDATE = 'validate'
|
VALIDATE = 'validate'
|
||||||
REUSE = 'reuse'
|
REUSE = 'reuse'
|
||||||
|
|
||||||
|
|
||||||
ops = [op.value for op in Operations]
|
ops = [op.value for op in Operations]
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ class PortSecurityTestCaseNSXv2(psec.PortSecurityDBTestCase,
|
|||||||
|
|
||||||
|
|
||||||
class TestPortSecurityNSXv2(PortSecurityTestCaseNSXv2, psec.TestPortSecurity):
|
class TestPortSecurityNSXv2(PortSecurityTestCaseNSXv2, psec.TestPortSecurity):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class TestPortSecurityNSXv3(psec.TestPortSecurity,
|
class TestPortSecurityNSXv3(psec.TestPortSecurity,
|
||||||
|
@ -552,11 +552,11 @@ class NsxPTestNetworks(test_db_base_plugin_v2.TestNetworksV2,
|
|||||||
'provider:physical_network': 'xxx',
|
'provider:physical_network': 'xxx',
|
||||||
'qos_policy_id': policy_id,
|
'qos_policy_id': policy_id,
|
||||||
'port_security_enabled': False}}
|
'port_security_enabled': False}}
|
||||||
with mock_ens, mock_tz, mock_tt,\
|
with mock_ens, mock_tz, mock_tt, mock.patch.object(
|
||||||
mock.patch.object(self.plugin, '_validate_qos_policy_id'):
|
self.plugin, '_validate_qos_policy_id'):
|
||||||
self.assertRaises(n_exc.InvalidInput,
|
self.assertRaises(n_exc.InvalidInput,
|
||||||
self.plugin.create_network,
|
self.plugin.create_network,
|
||||||
context.get_admin_context(), data)
|
context.get_admin_context(), data)
|
||||||
|
|
||||||
def test_update_ens_network_with_qos(self):
|
def test_update_ens_network_with_qos(self):
|
||||||
cfg.CONF.set_override('ens_support', True, 'nsx_v3')
|
cfg.CONF.set_override('ens_support', True, 'nsx_v3')
|
||||||
@ -1660,38 +1660,38 @@ class NsxPTestL3NatTestCase(NsxPTestL3NatTest,
|
|||||||
"NsxPolicySegmentApi.update") as seg_update:
|
"NsxPolicySegmentApi.update") as seg_update:
|
||||||
|
|
||||||
with self.router() as r, self.network() as n:
|
with self.router() as r, self.network() as n:
|
||||||
with self.subnet(network=n, cidr='fd00::0/64',
|
with self.subnet(
|
||||||
gateway_ip='fd00::1', ip_version=6,
|
network=n, cidr='fd00::0/64', gateway_ip='fd00::1',
|
||||||
enable_dhcp=False) as s6, \
|
ip_version=6, enable_dhcp=False) as s6, self.subnet(
|
||||||
self.subnet(network=n, cidr='2.0.0.0/24',
|
network=n, cidr='2.0.0.0/24',
|
||||||
gateway_ip='2.0.0.1') as s4:
|
gateway_ip='2.0.0.1') as s4:
|
||||||
|
|
||||||
subnets = []
|
|
||||||
if s6_first:
|
|
||||||
self._router_interface_action('add',
|
|
||||||
r['router']['id'],
|
|
||||||
s6['subnet']['id'],
|
|
||||||
None)
|
|
||||||
subnets.append(s6['subnet']['cidr'])
|
|
||||||
|
|
||||||
|
subnets = []
|
||||||
|
if s6_first:
|
||||||
self._router_interface_action('add',
|
self._router_interface_action('add',
|
||||||
r['router']['id'],
|
r['router']['id'],
|
||||||
s4['subnet']['id'],
|
s6['subnet']['id'],
|
||||||
None)
|
None)
|
||||||
subnets.append(s4['subnet']['cidr'])
|
subnets.append(s6['subnet']['cidr'])
|
||||||
|
|
||||||
if not s6_first:
|
self._router_interface_action('add',
|
||||||
self._router_interface_action('add',
|
r['router']['id'],
|
||||||
r['router']['id'],
|
s4['subnet']['id'],
|
||||||
s6['subnet']['id'],
|
None)
|
||||||
None)
|
subnets.append(s4['subnet']['cidr'])
|
||||||
subnets.append(s6['subnet']['cidr'])
|
|
||||||
|
|
||||||
# We expect two subnet objects on segment
|
if not s6_first:
|
||||||
seg_update.assert_called_with(
|
self._router_interface_action('add',
|
||||||
n['network']['id'],
|
r['router']['id'],
|
||||||
subnets=[mock.ANY, mock.ANY],
|
s6['subnet']['id'],
|
||||||
tier1_id=r['router']['id'])
|
None)
|
||||||
|
subnets.append(s6['subnet']['cidr'])
|
||||||
|
|
||||||
|
# We expect two subnet objects on segment
|
||||||
|
seg_update.assert_called_with(
|
||||||
|
n['network']['id'],
|
||||||
|
subnets=[mock.ANY, mock.ANY],
|
||||||
|
tier1_id=r['router']['id'])
|
||||||
|
|
||||||
def test_router_add_v4_v6_subnets(self):
|
def test_router_add_v4_v6_subnets(self):
|
||||||
self._test_router_add_dual_stack_subnets()
|
self._test_router_add_dual_stack_subnets()
|
||||||
@ -2031,21 +2031,20 @@ class NsxPTestL3NatTestCase(NsxPTestL3NatTest,
|
|||||||
path_prefix = ("/infra/sites/default/enforcement-points/default/"
|
path_prefix = ("/infra/sites/default/enforcement-points/default/"
|
||||||
"edge-clusters/")
|
"edge-clusters/")
|
||||||
# create a router and external network
|
# create a router and external network
|
||||||
with self.router() as r,\
|
with self.router() as r, self._create_l3_ext_network() as ext_net, \
|
||||||
self._create_l3_ext_network() as ext_net,\
|
self.subnet(
|
||||||
self.subnet(network=ext_net, cidr='10.0.1.0/24',
|
network=ext_net, cidr='10.0.1.0/24',
|
||||||
enable_dhcp=False) as s,\
|
enable_dhcp=False) as s, mock.patch(
|
||||||
mock.patch("vmware_nsxlib.v3.policy.core_resources."
|
"vmware_nsxlib.v3.policy.core_resources."
|
||||||
"NsxPolicyTier1Api.get_edge_cluster_path",
|
"NsxPolicyTier1Api.get_edge_cluster_path",
|
||||||
return_value=False),\
|
return_value=False), mock.patch(
|
||||||
mock.patch("vmware_nsxlib.v3.policy.core_resources."
|
"vmware_nsxlib.v3.policy.core_resources."
|
||||||
"NsxPolicyTier1Api.set_edge_cluster_path"
|
"NsxPolicyTier1Api.set_edge_cluster_path") as add_srv_router:
|
||||||
) as add_srv_router:
|
self._add_external_gateway_to_router(
|
||||||
self._add_external_gateway_to_router(
|
r['router']['id'],
|
||||||
r['router']['id'],
|
s['subnet']['network_id'])
|
||||||
s['subnet']['network_id'])
|
add_srv_router.assert_called_once_with(
|
||||||
add_srv_router.assert_called_once_with(
|
mock.ANY, '%s%s' % (path_prefix, edge_cluster))
|
||||||
mock.ANY, '%s%s' % (path_prefix, edge_cluster))
|
|
||||||
|
|
||||||
def test_router_add_interface_cidr_overlapped_with_gateway(self):
|
def test_router_add_interface_cidr_overlapped_with_gateway(self):
|
||||||
with self.router() as r,\
|
with self.router() as r,\
|
||||||
@ -2127,22 +2126,22 @@ class NsxPTestL3NatTestCase(NsxPTestL3NatTest,
|
|||||||
|
|
||||||
with self.subnet(cidr='30.0.0.0/24', gateway_ip=None) as private_sub:
|
with self.subnet(cidr='30.0.0.0/24', gateway_ip=None) as private_sub:
|
||||||
with self.port(
|
with self.port(
|
||||||
subnet=private_sub,
|
subnet=private_sub,
|
||||||
device_owner=constants.DEVICE_OWNER_ROUTER_INTF) as p:
|
device_owner=constants.DEVICE_OWNER_ROUTER_INTF) as p:
|
||||||
port_id = p['port']['id']
|
port_id = p['port']['id']
|
||||||
with self.router() as r:
|
with self.router() as r:
|
||||||
self._router_interface_action('add', r['router']['id'],
|
self._router_interface_action('add', r['router']['id'],
|
||||||
None, port_id)
|
None, port_id)
|
||||||
with self.external_network() as public_net,\
|
with self.external_network() as public_net, self.subnet(
|
||||||
self.subnet(network=public_net, cidr='12.0.0.0/24',
|
network=public_net, cidr='12.0.0.0/24',
|
||||||
enable_dhcp=False) as public_sub:
|
enable_dhcp=False) as public_sub:
|
||||||
self._add_external_gateway_to_router(
|
self._add_external_gateway_to_router(
|
||||||
r['router']['id'],
|
r['router']['id'],
|
||||||
public_sub['subnet']['network_id'])
|
public_sub['subnet']['network_id'])
|
||||||
self._make_floatingip(
|
self._make_floatingip(
|
||||||
self.fmt, public_sub['subnet']['network_id'],
|
self.fmt, public_sub['subnet']['network_id'],
|
||||||
port_id=port_id,
|
port_id=port_id,
|
||||||
http_status=exc.HTTPBadRequest.code)
|
http_status=exc.HTTPBadRequest.code)
|
||||||
|
|
||||||
def test_assign_floatingip_to_router_interface_device_owner_fail(self):
|
def test_assign_floatingip_to_router_interface_device_owner_fail(self):
|
||||||
# This tests that an error is raised when trying to assign a router
|
# This tests that an error is raised when trying to assign a router
|
||||||
@ -2150,20 +2149,20 @@ class NsxPTestL3NatTestCase(NsxPTestL3NatTest,
|
|||||||
|
|
||||||
with self.subnet(cidr='30.0.0.0/24', gateway_ip=None) as private_sub:
|
with self.subnet(cidr='30.0.0.0/24', gateway_ip=None) as private_sub:
|
||||||
with self.port(
|
with self.port(
|
||||||
subnet=private_sub,
|
subnet=private_sub,
|
||||||
device_owner=constants.DEVICE_OWNER_ROUTER_INTF) as p:
|
device_owner=constants.DEVICE_OWNER_ROUTER_INTF) as p:
|
||||||
port_id = p['port']['id']
|
port_id = p['port']['id']
|
||||||
with self.router() as r:
|
with self.router() as r:
|
||||||
self._router_interface_action('add', r['router']['id'],
|
self._router_interface_action('add', r['router']['id'],
|
||||||
None, port_id)
|
None, port_id)
|
||||||
with self.external_network() as public_net,\
|
with self.external_network() as public_net, self.subnet(
|
||||||
self.subnet(network=public_net, cidr='12.0.0.0/24',
|
network=public_net, cidr='12.0.0.0/24',
|
||||||
enable_dhcp=False) as public_sub:
|
enable_dhcp=False) as public_sub:
|
||||||
self._add_external_gateway_to_router(
|
self._add_external_gateway_to_router(
|
||||||
r['router']['id'],
|
r['router']['id'],
|
||||||
public_sub['subnet']['network_id'])
|
public_sub['subnet']['network_id'])
|
||||||
fip = self._make_floatingip(self.fmt, public_sub[
|
fip = self._make_floatingip(self.fmt, public_sub[
|
||||||
'subnet']['network_id'])
|
'subnet']['network_id'])
|
||||||
self._update('floatingips', fip['floatingip'][
|
self._update('floatingips', fip['floatingip'][
|
||||||
'id'], {'floatingip': {'port_id': port_id}},
|
'id'], {'floatingip': {'port_id': port_id}},
|
||||||
expected_code=exc.HTTPBadRequest.code)
|
expected_code=exc.HTTPBadRequest.code)
|
||||||
|
@ -2697,31 +2697,33 @@ class L3NatTestCaseBase(test_l3_plugin.L3NatTestCaseMixin):
|
|||||||
to a router places them all on the same router interface.
|
to a router places them all on the same router interface.
|
||||||
"""
|
"""
|
||||||
with self.router() as r, self.network() as n:
|
with self.router() as r, self.network() as n:
|
||||||
with (self.subnet(network=n, cidr='fd00::1/64',
|
with self.subnet(
|
||||||
enable_dhcp=False, ip_version=6)
|
network=n, cidr='fd00::1/64',
|
||||||
) as s1, self.subnet(network=n, cidr='fd01::1/64',
|
enable_dhcp=False, ip_version=6) as s1, self.subnet(
|
||||||
ip_version=6, enable_dhcp=False) as s2:
|
network=n, cidr='fd01::1/64',
|
||||||
body = self._router_interface_action('add',
|
ip_version=6, enable_dhcp=False) as s2:
|
||||||
r['router']['id'],
|
|
||||||
s1['subnet']['id'],
|
body = self._router_interface_action('add',
|
||||||
None)
|
r['router']['id'],
|
||||||
pid1 = body['port_id']
|
s1['subnet']['id'],
|
||||||
body = self._router_interface_action('add',
|
None)
|
||||||
r['router']['id'],
|
pid1 = body['port_id']
|
||||||
s2['subnet']['id'],
|
body = self._router_interface_action('add',
|
||||||
None)
|
r['router']['id'],
|
||||||
pid2 = body['port_id']
|
s2['subnet']['id'],
|
||||||
self.assertEqual(pid1, pid2)
|
None)
|
||||||
port = self._show('ports', pid1)
|
pid2 = body['port_id']
|
||||||
self.assertEqual(2, len(port['port']['fixed_ips']))
|
self.assertEqual(pid1, pid2)
|
||||||
port_subnet_ids = [fip['subnet_id'] for fip in
|
port = self._show('ports', pid1)
|
||||||
port['port']['fixed_ips']]
|
self.assertEqual(2, len(port['port']['fixed_ips']))
|
||||||
self.assertIn(s1['subnet']['id'], port_subnet_ids)
|
port_subnet_ids = [fip['subnet_id'] for fip in
|
||||||
self.assertIn(s2['subnet']['id'], port_subnet_ids)
|
port['port']['fixed_ips']]
|
||||||
self._router_interface_action('remove', r['router']['id'],
|
self.assertIn(s1['subnet']['id'], port_subnet_ids)
|
||||||
s1['subnet']['id'], None)
|
self.assertIn(s2['subnet']['id'], port_subnet_ids)
|
||||||
self._router_interface_action('remove', r['router']['id'],
|
self._router_interface_action('remove', r['router']['id'],
|
||||||
s2['subnet']['id'], None)
|
s1['subnet']['id'], None)
|
||||||
|
self._router_interface_action('remove', r['router']['id'],
|
||||||
|
s2['subnet']['id'], None)
|
||||||
|
|
||||||
def test_router_add_interface_ipv6_port_existing_network_returns_400(self):
|
def test_router_add_interface_ipv6_port_existing_network_returns_400(self):
|
||||||
"""Ensure unique IPv6 router ports per network id.
|
"""Ensure unique IPv6 router ports per network id.
|
||||||
@ -5379,36 +5381,36 @@ class TestSharedRouterTestCase(L3NatTest, L3NatTestCaseBase,
|
|||||||
ext_subnet['subnet']['network_id'])
|
ext_subnet['subnet']['network_id'])
|
||||||
|
|
||||||
def test_routers_with_interface_on_same_edge(self):
|
def test_routers_with_interface_on_same_edge(self):
|
||||||
with self.router() as r1, self.router() as r2,\
|
with self.router() as r1, self.router() as r2,\
|
||||||
self.subnet(cidr='11.0.0.0/24') as s11,\
|
self.subnet(cidr='11.0.0.0/24') as s11,\
|
||||||
self.subnet(cidr='12.0.0.0/24') as s12:
|
self.subnet(cidr='12.0.0.0/24') as s12:
|
||||||
self._router_interface_action('add',
|
self._router_interface_action('add',
|
||||||
r1['router']['id'],
|
r1['router']['id'],
|
||||||
s11['subnet']['id'],
|
s11['subnet']['id'],
|
||||||
None)
|
None)
|
||||||
self._router_interface_action('add',
|
self._router_interface_action('add',
|
||||||
r2['router']['id'],
|
r2['router']['id'],
|
||||||
s12['subnet']['id'],
|
s12['subnet']['id'],
|
||||||
None)
|
None)
|
||||||
routers_expected = [r1['router']['id'], r2['router']['id']]
|
routers_expected = [r1['router']['id'], r2['router']['id']]
|
||||||
routers_1 = (self.plugin_instance.edge_manager.
|
routers_1 = (self.plugin_instance.edge_manager.
|
||||||
get_routers_on_same_edge(
|
get_routers_on_same_edge(
|
||||||
context.get_admin_context(),
|
context.get_admin_context(),
|
||||||
r1['router']['id']))
|
r1['router']['id']))
|
||||||
self.assertEqual(set(routers_expected), set(routers_1))
|
self.assertEqual(set(routers_expected), set(routers_1))
|
||||||
routers_2 = (self.plugin_instance.edge_manager.
|
routers_2 = (self.plugin_instance.edge_manager.
|
||||||
get_routers_on_same_edge(
|
get_routers_on_same_edge(
|
||||||
context.get_admin_context(),
|
context.get_admin_context(),
|
||||||
r2['router']['id']))
|
r2['router']['id']))
|
||||||
self.assertEqual(set(routers_expected), set(routers_2))
|
self.assertEqual(set(routers_expected), set(routers_2))
|
||||||
self._router_interface_action('remove',
|
self._router_interface_action('remove',
|
||||||
r1['router']['id'],
|
r1['router']['id'],
|
||||||
s11['subnet']['id'],
|
s11['subnet']['id'],
|
||||||
None)
|
None)
|
||||||
self._router_interface_action('remove',
|
self._router_interface_action('remove',
|
||||||
r2['router']['id'],
|
r2['router']['id'],
|
||||||
s12['subnet']['id'],
|
s12['subnet']['id'],
|
||||||
None)
|
None)
|
||||||
|
|
||||||
def test_routers_with_overlap_interfaces(self):
|
def test_routers_with_overlap_interfaces(self):
|
||||||
with self.router() as r1, self.router() as r2,\
|
with self.router() as r1, self.router() as r2,\
|
||||||
|
@ -995,9 +995,9 @@ class FakeVcns(object):
|
|||||||
return self._section_not_found(section_id)
|
return self._section_not_found(section_id)
|
||||||
_section = self._sections[section_id]
|
_section = self._sections[section_id]
|
||||||
if (_section['name'] != section_name and
|
if (_section['name'] != section_name and
|
||||||
section_name in self._sections['names']):
|
section_name in self._sections['names']):
|
||||||
# Theres a section with this name already
|
# There's a section with this name already
|
||||||
headers, response = self._unknown_error()
|
headers, response = self._unknown_error()
|
||||||
else:
|
else:
|
||||||
# Different Etag every successful update
|
# Different Etag every successful update
|
||||||
_section['etag'] = ('Etag-1' if _section['etag'] == 'Etag-0'
|
_section['etag'] = ('Etag-1' if _section['etag'] == 'Etag-0'
|
||||||
|
@ -569,7 +569,7 @@ class TestNetworksV2(test_plugin.TestNetworksV2, NsxV3PluginTestCaseMixin):
|
|||||||
'provider:physical_network': 'xxx',
|
'provider:physical_network': 'xxx',
|
||||||
'port_security_enabled': True}}
|
'port_security_enabled': True}}
|
||||||
with mock_ens, mock_tz, mock_tt:
|
with mock_ens, mock_tz, mock_tt:
|
||||||
self.plugin.create_network(context.get_admin_context(), data)
|
self.plugin.create_network(context.get_admin_context(), data)
|
||||||
|
|
||||||
def test_create_ens_network_with_qos(self):
|
def test_create_ens_network_with_qos(self):
|
||||||
cfg.CONF.set_override('ens_support', True, 'nsx_v3')
|
cfg.CONF.set_override('ens_support', True, 'nsx_v3')
|
||||||
@ -590,11 +590,11 @@ class TestNetworksV2(test_plugin.TestNetworksV2, NsxV3PluginTestCaseMixin):
|
|||||||
'provider:physical_network': 'xxx',
|
'provider:physical_network': 'xxx',
|
||||||
'qos_policy_id': policy_id,
|
'qos_policy_id': policy_id,
|
||||||
'port_security_enabled': False}}
|
'port_security_enabled': False}}
|
||||||
with mock_ens, mock_tz, mock_tt,\
|
with mock_ens, mock_tz, mock_tt, mock.patch.object(
|
||||||
mock.patch.object(self.plugin, '_validate_qos_policy_id'):
|
self.plugin, '_validate_qos_policy_id'):
|
||||||
self.assertRaises(n_exc.InvalidInput,
|
self.assertRaises(n_exc.InvalidInput,
|
||||||
self.plugin.create_network,
|
self.plugin.create_network,
|
||||||
context.get_admin_context(), data)
|
context.get_admin_context(), data)
|
||||||
|
|
||||||
def test_update_ens_network_with_qos(self):
|
def test_update_ens_network_with_qos(self):
|
||||||
cfg.CONF.set_override('ens_support', True, 'nsx_v3')
|
cfg.CONF.set_override('ens_support', True, 'nsx_v3')
|
||||||
@ -720,13 +720,14 @@ class TestNetworksV2(test_plugin.TestNetworksV2, NsxV3PluginTestCaseMixin):
|
|||||||
pnet.PHYSICAL_NETWORK:
|
pnet.PHYSICAL_NETWORK:
|
||||||
'fb69d878-958e-4f32-84e4-50286f26226b'}
|
'fb69d878-958e-4f32-84e4-50286f26226b'}
|
||||||
|
|
||||||
with mock.patch('vmware_nsxlib.v3.core_resources.NsxLibTransportZone.'
|
gtt_path = "vmware_nsxlib.v3.core_resources." \
|
||||||
'get_transport_type', return_value='VLAN'):
|
"NsxLibTransportZone.get_transport_type"
|
||||||
|
with mock.patch(gtt_path, return_value='VLAN'):
|
||||||
with self.network(name=name, providernet_args=providernet_args,
|
with self.network(name=name, providernet_args=providernet_args,
|
||||||
arg_list=(pnet.NETWORK_TYPE,
|
arg_list=(pnet.NETWORK_TYPE,
|
||||||
pnet.PHYSICAL_NETWORK)) as net:
|
pnet.PHYSICAL_NETWORK)) as net:
|
||||||
for k, v in expected:
|
for k, v in expected:
|
||||||
self.assertEqual(net['network'][k], v)
|
self.assertEqual(net['network'][k], v)
|
||||||
|
|
||||||
def test_create_phys_vlan_generate(self):
|
def test_create_phys_vlan_generate(self):
|
||||||
cfg.CONF.set_override('network_vlan_ranges',
|
cfg.CONF.set_override('network_vlan_ranges',
|
||||||
@ -1069,27 +1070,27 @@ class TestPortsV2(common_v3.NsxV3SubnetMixin,
|
|||||||
self.plugin.update_port, self.ctx, port['id'], data)
|
self.plugin.update_port, self.ctx, port['id'], data)
|
||||||
|
|
||||||
def test_fail_create_allowed_address_pairs_over_limit(self):
|
def test_fail_create_allowed_address_pairs_over_limit(self):
|
||||||
with self.network() as network,\
|
with self.network() as network, self.subnet(
|
||||||
self.subnet(network=network, enable_dhcp=True) as s1:
|
network=network, enable_dhcp=True) as s1:
|
||||||
data = {'port': {
|
data = {
|
||||||
'network_id': network['network']['id'],
|
'port': {
|
||||||
'tenant_id': self._tenant_id,
|
'network_id': network['network']['id'],
|
||||||
'name': 'pair_port',
|
'tenant_id': self._tenant_id,
|
||||||
'admin_state_up': True,
|
'name': 'pair_port',
|
||||||
'device_id': 'fake_device',
|
'admin_state_up': True,
|
||||||
'device_owner': 'fake_owner',
|
'device_id': 'fake_device',
|
||||||
'fixed_ips': [{'subnet_id': s1['subnet']['id']}]
|
'device_owner': 'fake_owner',
|
||||||
}
|
'fixed_ips': [{'subnet_id': s1['subnet']['id']}]
|
||||||
}
|
}
|
||||||
count = 1
|
}
|
||||||
address_pairs = []
|
count = 1
|
||||||
while count < 129:
|
address_pairs = []
|
||||||
address_pairs.append({'ip_address': '10.0.0.%s' %
|
while count < 129:
|
||||||
count})
|
address_pairs.append({'ip_address': '10.0.0.%s' % count})
|
||||||
count += 1
|
count += 1
|
||||||
data['port']['allowed_address_pairs'] = address_pairs
|
data['port']['allowed_address_pairs'] = address_pairs
|
||||||
self.assertRaises(n_exc.InvalidInput,
|
self.assertRaises(n_exc.InvalidInput,
|
||||||
self.plugin.create_port, self.ctx, data)
|
self.plugin.create_port, self.ctx, data)
|
||||||
|
|
||||||
def test_fail_update_lb_port_with_fixed_ip(self):
|
def test_fail_update_lb_port_with_fixed_ip(self):
|
||||||
with self.network() as network:
|
with self.network() as network:
|
||||||
@ -3171,21 +3172,20 @@ class TestL3NatTestCase(L3NatTest,
|
|||||||
with self.subnet(cidr='30.0.0.0/24', gateway_ip=None) as private_sub:
|
with self.subnet(cidr='30.0.0.0/24', gateway_ip=None) as private_sub:
|
||||||
with self.port(
|
with self.port(
|
||||||
subnet=private_sub,
|
subnet=private_sub,
|
||||||
device_owner=constants.DEVICE_OWNER_ROUTER_INTF) as p:
|
device_owner=constants.DEVICE_OWNER_ROUTER_INTF) as p:
|
||||||
port_id = p['port']['id']
|
port_id = p['port']['id']
|
||||||
with self.router() as r:
|
with self.router() as r:
|
||||||
self._router_interface_action('add', r['router']['id'],
|
self._router_interface_action('add', r['router']['id'],
|
||||||
None, port_id)
|
None, port_id)
|
||||||
with self.external_network() as public_net,\
|
with self.external_network() as public_net, self.subnet(
|
||||||
self.subnet(
|
|
||||||
network=public_net, cidr='12.0.0.0/24') as public_sub:
|
network=public_net, cidr='12.0.0.0/24') as public_sub:
|
||||||
self._add_external_gateway_to_router(
|
self._add_external_gateway_to_router(
|
||||||
r['router']['id'],
|
r['router']['id'],
|
||||||
public_sub['subnet']['network_id'])
|
public_sub['subnet']['network_id'])
|
||||||
self._make_floatingip(
|
self._make_floatingip(
|
||||||
self.fmt, public_sub['subnet']['network_id'],
|
self.fmt, public_sub['subnet']['network_id'],
|
||||||
port_id=port_id,
|
port_id=port_id,
|
||||||
http_status=exc.HTTPBadRequest.code)
|
http_status=exc.HTTPBadRequest.code)
|
||||||
|
|
||||||
def test_assign_floatingip_to_router_interface_device_owner_fail(self):
|
def test_assign_floatingip_to_router_interface_device_owner_fail(self):
|
||||||
# This tests that an error is raised when trying to assign a router
|
# This tests that an error is raised when trying to assign a router
|
||||||
@ -3194,22 +3194,21 @@ class TestL3NatTestCase(L3NatTest,
|
|||||||
with self.subnet(cidr='30.0.0.0/24', gateway_ip=None) as private_sub:
|
with self.subnet(cidr='30.0.0.0/24', gateway_ip=None) as private_sub:
|
||||||
with self.port(
|
with self.port(
|
||||||
subnet=private_sub,
|
subnet=private_sub,
|
||||||
device_owner=constants.DEVICE_OWNER_ROUTER_INTF) as p:
|
device_owner=constants.DEVICE_OWNER_ROUTER_INTF) as p:
|
||||||
port_id = p['port']['id']
|
port_id = p['port']['id']
|
||||||
with self.router() as r:
|
with self.router() as r:
|
||||||
self._router_interface_action('add', r['router']['id'],
|
self._router_interface_action('add', r['router']['id'],
|
||||||
None, port_id)
|
None, port_id)
|
||||||
with self.external_network() as public_net,\
|
with self.external_network() as public_net, self.subnet(
|
||||||
self.subnet(
|
|
||||||
network=public_net, cidr='12.0.0.0/24') as public_sub:
|
network=public_net, cidr='12.0.0.0/24') as public_sub:
|
||||||
self._add_external_gateway_to_router(
|
self._add_external_gateway_to_router(
|
||||||
r['router']['id'],
|
r['router']['id'],
|
||||||
public_sub['subnet']['network_id'])
|
public_sub['subnet']['network_id'])
|
||||||
fip = self._make_floatingip(self.fmt, public_sub[
|
fip = self._make_floatingip(self.fmt, public_sub[
|
||||||
'subnet']['network_id'])
|
'subnet']['network_id'])
|
||||||
self._update('floatingips', fip['floatingip'][
|
self._update('floatingips', fip['floatingip'][
|
||||||
'id'], {'floatingip': {'port_id': port_id}},
|
'id'], {'floatingip': {'port_id': port_id}},
|
||||||
expected_code=exc.HTTPBadRequest.code)
|
expected_code=exc.HTTPBadRequest.code)
|
||||||
|
|
||||||
|
|
||||||
class ExtGwModeTestCase(test_ext_gw_mode.ExtGwModeIntTestCase,
|
class ExtGwModeTestCase(test_ext_gw_mode.ExtGwModeIntTestCase,
|
||||||
|
@ -297,11 +297,11 @@ class TestNSXvBgpPlugin(test_plugin.NsxVPluginV2TestCase,
|
|||||||
self.skipTest('No SNAT with floating ips not supported')
|
self.skipTest('No SNAT with floating ips not supported')
|
||||||
|
|
||||||
def test_add_bgp_peer_with_bad_id(self):
|
def test_add_bgp_peer_with_bad_id(self):
|
||||||
with self.subnetpool_with_address_scope(
|
with self.subnetpool_with_address_scope(
|
||||||
4, prefixes=['8.0.0.0/8']) as sp:
|
4, prefixes=['8.0.0.0/8']) as sp:
|
||||||
with self.bgp_speaker(sp['ip_version'], 1234) as speaker:
|
with self.bgp_speaker(sp['ip_version'], 1234) as speaker:
|
||||||
self.assertRaises(ext_bgp.BgpPeerNotFound,
|
self.assertRaises(ext_bgp.BgpPeerNotFound,
|
||||||
self.bgp_plugin.add_bgp_peer,
|
self.bgp_plugin.add_bgp_peer,
|
||||||
self.context,
|
self.context,
|
||||||
speaker['id'],
|
speaker['id'],
|
||||||
{'bgp_peer_id': 'aaa'})
|
{'bgp_peer_id': 'aaa'})
|
||||||
|
@ -252,14 +252,14 @@ class TestQosNsxPNotification(base.BaseQosTestCase,
|
|||||||
self.ctxt, **self.policy_data['policy'])
|
self.ctxt, **self.policy_data['policy'])
|
||||||
# add a rule to the policy
|
# add a rule to the policy
|
||||||
setattr(_policy, "rules", [rule])
|
setattr(_policy, "rules", [rule])
|
||||||
with mock.patch.object(QoSPolicy, 'get_object',
|
with mock.patch.object(
|
||||||
return_value=_policy),\
|
QoSPolicy, 'get_object', return_value=_policy), mock.patch(
|
||||||
mock.patch('neutron.objects.db.api.update_object',
|
'neutron.objects.db.api.update_object',
|
||||||
return_value=rule_data):
|
return_value=rule_data):
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exceptions.DriverCallError,
|
exceptions.DriverCallError,
|
||||||
self.qos_plugin.update_policy_bandwidth_limit_rule,
|
self.qos_plugin.update_policy_bandwidth_limit_rule,
|
||||||
self.ctxt, rule.id, _policy.id, rule_data)
|
self.ctxt, rule.id, _policy.id, rule_data)
|
||||||
|
|
||||||
@mock.patch.object(QoSPolicy, '_reload_rules')
|
@mock.patch.object(QoSPolicy, '_reload_rules')
|
||||||
def test_dscp_rule_create_profile(self, *mocks):
|
def test_dscp_rule_create_profile(self, *mocks):
|
||||||
|
@ -266,14 +266,14 @@ class TestQosNsxV3Notification(base.BaseQosTestCase,
|
|||||||
self.ctxt, **self.policy_data['policy'])
|
self.ctxt, **self.policy_data['policy'])
|
||||||
# add a rule to the policy
|
# add a rule to the policy
|
||||||
setattr(_policy, "rules", [rule])
|
setattr(_policy, "rules", [rule])
|
||||||
with mock.patch.object(QoSPolicy, 'get_object',
|
with mock.patch.object(
|
||||||
return_value=_policy),\
|
QoSPolicy, 'get_object', return_value=_policy), mock.patch(
|
||||||
mock.patch('neutron.objects.db.api.update_object',
|
'neutron.objects.db.api.update_object',
|
||||||
return_value=rule_data):
|
return_value=rule_data):
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exceptions.DriverCallError,
|
exceptions.DriverCallError,
|
||||||
self.qos_plugin.update_policy_bandwidth_limit_rule,
|
self.qos_plugin.update_policy_bandwidth_limit_rule,
|
||||||
self.ctxt, rule.id, _policy.id, rule_data)
|
self.ctxt, rule.id, _policy.id, rule_data)
|
||||||
|
|
||||||
@mock.patch.object(QoSPolicy, '_reload_rules')
|
@mock.patch.object(QoSPolicy, '_reload_rules')
|
||||||
def test_dscp_rule_create_profile(self, *mocks):
|
def test_dscp_rule_create_profile(self, *mocks):
|
||||||
@ -325,9 +325,9 @@ class TestQosNsxV3Notification(base.BaseQosTestCase,
|
|||||||
# add a rule to the policy
|
# add a rule to the policy
|
||||||
setattr(policy, "rules", [min_bw_rule])
|
setattr(policy, "rules", [min_bw_rule])
|
||||||
with mock.patch.object(
|
with mock.patch.object(
|
||||||
QoSPolicy, 'get_object', return_value=policy),\
|
QoSPolicy, 'get_object', return_value=policy), mock.patch(
|
||||||
mock.patch('neutron.objects.db.api.'
|
'neutron.objects.db.api.update_object',
|
||||||
'update_object', return_value=self.dscp_rule_data):
|
return_value=self.dscp_rule_data):
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exceptions.DriverCallError,
|
exceptions.DriverCallError,
|
||||||
self.qos_plugin.update_policy_minimum_bandwidth_rule,
|
self.qos_plugin.update_policy_minimum_bandwidth_rule,
|
||||||
|
@ -315,31 +315,31 @@ class TestDriverValidation(base.BaseTestCase):
|
|||||||
else:
|
else:
|
||||||
return connections
|
return connections
|
||||||
|
|
||||||
with mock.patch.object(self.validator.vpn_plugin, '_get_vpnservice',
|
with mock.patch.object(
|
||||||
side_effect=mock_get_service),\
|
self.validator.vpn_plugin, '_get_vpnservice',
|
||||||
mock.patch.object(self.validator._core_plugin, 'get_routers',
|
side_effect=mock_get_service), mock.patch.object(
|
||||||
side_effect=mock_get_routers),\
|
self.validator._core_plugin, 'get_routers',
|
||||||
mock.patch.object(self.validator._core_plugin,
|
side_effect=mock_get_routers), mock.patch.object(
|
||||||
'_find_router_subnets_cidrs',
|
self.validator._core_plugin, '_find_router_subnets_cidrs',
|
||||||
return_value=router_subnets),\
|
return_value=router_subnets), mock.patch.object(
|
||||||
mock.patch.object(self.validator.vpn_plugin,
|
self.validator.vpn_plugin, 'get_ipsec_site_connections',
|
||||||
'get_ipsec_site_connections',
|
side_effect=mock_get_connections):
|
||||||
side_effect=mock_get_connections):
|
|
||||||
ipsec_sitecon = {'id': '1',
|
ipsec_sitecon = {'id': '1',
|
||||||
'vpnservice_id': '1',
|
'vpnservice_id': '1',
|
||||||
'mtu': 1500,
|
'mtu': 1500,
|
||||||
'peer_address': self.peer_address,
|
'peer_address': self.peer_address,
|
||||||
'peer_cidrs': [self.peer_cidr]}
|
'peer_cidrs': [self.peer_cidr]}
|
||||||
if conn_params:
|
if conn_params:
|
||||||
ipsec_sitecon.update(conn_params)
|
ipsec_sitecon.update(conn_params)
|
||||||
if success:
|
if success:
|
||||||
self.validator.validate_ipsec_site_connection(
|
self.validator.validate_ipsec_site_connection(
|
||||||
self.context, ipsec_sitecon)
|
self.context, ipsec_sitecon)
|
||||||
else:
|
else:
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
nsx_exc.NsxVpnValidationError,
|
nsx_exc.NsxVpnValidationError,
|
||||||
self.validator.validate_ipsec_site_connection,
|
self.validator.validate_ipsec_site_connection,
|
||||||
self.context, ipsec_sitecon)
|
self.context, ipsec_sitecon)
|
||||||
|
|
||||||
def test_dpd_validation(self):
|
def test_dpd_validation(self):
|
||||||
params = {'dpd': {'action': 'hold',
|
params = {'dpd': {'action': 'hold',
|
||||||
@ -705,8 +705,9 @@ class TestVpnaasDriver(test_plugin.NsxV3PluginTestCaseMixin):
|
|||||||
with mock.patch.object(
|
with mock.patch.object(
|
||||||
self.nsxlib_vpn.service, 'list',
|
self.nsxlib_vpn.service, 'list',
|
||||||
return_value={'results': nsx_services}),\
|
return_value={'results': nsx_services}),\
|
||||||
mock.patch.object(self.service_plugin, 'get_vpnservices',
|
mock.patch.object(
|
||||||
return_value=[{'id': 'dummy', 'router_id': 'dummy'}]),\
|
self.service_plugin, 'get_vpnservices',
|
||||||
|
return_value=[{'id': 'dummy', 'router_id': 'dummy'}]),\
|
||||||
mock.patch.object(self.nsxlib_vpn.service,
|
mock.patch.object(self.nsxlib_vpn.service,
|
||||||
'delete') as delete_service:
|
'delete') as delete_service:
|
||||||
self.driver.delete_vpnservice(
|
self.driver.delete_vpnservice(
|
||||||
|
Loading…
Reference in New Issue
Block a user