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,7 +45,8 @@ 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)
|
||||||
|
@ -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'],
|
||||||
|
@ -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
|
||||||
|
@ -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',
|
||||||
|
@ -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()
|
||||||
|
@ -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]
|
||||||
|
|
||||||
|
|
||||||
|
@ -552,8 +552,8 @@ 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)
|
||||||
@ -1660,10 +1660,10 @@ 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 = []
|
subnets = []
|
||||||
@ -2031,16 +2031,15 @@ 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'])
|
||||||
@ -2133,8 +2132,8 @@ class NsxPTestL3NatTestCase(NsxPTestL3NatTest,
|
|||||||
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'],
|
||||||
@ -2156,8 +2155,8 @@ class NsxPTestL3NatTestCase(NsxPTestL3NatTest,
|
|||||||
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'],
|
||||||
|
@ -2697,10 +2697,12 @@ 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(
|
||||||
|
network=n, cidr='fd01::1/64',
|
||||||
ip_version=6, enable_dhcp=False) as s2:
|
ip_version=6, enable_dhcp=False) as s2:
|
||||||
|
|
||||||
body = self._router_interface_action('add',
|
body = self._router_interface_action('add',
|
||||||
r['router']['id'],
|
r['router']['id'],
|
||||||
s1['subnet']['id'],
|
s1['subnet']['id'],
|
||||||
|
@ -996,7 +996,7 @@ class FakeVcns(object):
|
|||||||
_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
|
||||||
|
@ -590,8 +590,8 @@ 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)
|
||||||
@ -720,8 +720,9 @@ 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:
|
||||||
@ -1069,9 +1070,10 @@ 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 = {
|
||||||
|
'port': {
|
||||||
'network_id': network['network']['id'],
|
'network_id': network['network']['id'],
|
||||||
'tenant_id': self._tenant_id,
|
'tenant_id': self._tenant_id,
|
||||||
'name': 'pair_port',
|
'name': 'pair_port',
|
||||||
@ -1084,8 +1086,7 @@ class TestPortsV2(common_v3.NsxV3SubnetMixin,
|
|||||||
count = 1
|
count = 1
|
||||||
address_pairs = []
|
address_pairs = []
|
||||||
while count < 129:
|
while count < 129:
|
||||||
address_pairs.append({'ip_address': '10.0.0.%s' %
|
address_pairs.append({'ip_address': '10.0.0.%s' % count})
|
||||||
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,
|
||||||
@ -3176,8 +3177,7 @@ class TestL3NatTestCase(L3NatTest,
|
|||||||
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'],
|
||||||
@ -3199,8 +3199,7 @@ class TestL3NatTestCase(L3NatTest,
|
|||||||
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'],
|
||||||
|
@ -252,9 +252,9 @@ 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,
|
||||||
|
@ -266,9 +266,9 @@ 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,
|
||||||
@ -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,16 +315,16 @@ 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,
|
||||||
@ -705,7 +705,8 @@ 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(
|
||||||
|
self.service_plugin, 'get_vpnservices',
|
||||||
return_value=[{'id': 'dummy', 'router_id': 'dummy'}]),\
|
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:
|
||||||
|
Loading…
Reference in New Issue
Block a user