Browse Source

Fix hacking requirements to support py27 in train

And fix some related pep8 issues

Change-Id: If90431416b0cc7ac48e7bc251aa8f64efbf45d1d
changes/71/775071/3
asarfaty 4 months ago
parent
commit
2a58c7b8bc
10 changed files with 32 additions and 20 deletions
  1. +2
    -1
      test-requirements.txt
  2. +3
    -3
      vmware_nsx/plugins/common_v3/plugin.py
  3. +6
    -4
      vmware_nsx/plugins/nsx_p/plugin.py
  4. +1
    -0
      vmware_nsx/plugins/nsx_p/utils.py
  5. +1
    -0
      vmware_nsx/services/lbaas/nsx_p/implementation/lb_utils.py
  6. +3
    -2
      vmware_nsx/services/lbaas/nsx_p/implementation/listener_mgr.py
  7. +1
    -0
      vmware_nsx/shell/admin/plugins/nsxp/resources/migration.py
  8. +1
    -0
      vmware_nsx/shell/admin/plugins/nsxp/resources/utils.py
  9. +13
    -10
      vmware_nsx/shell/admin/plugins/nsxv3/resources/migration.py
  10. +1
    -0
      vmware_nsx/tests/unit/services/lbaas/test_nsxp_driver.py

+ 2
- 1
test-requirements.txt View File

@ -1,7 +1,8 @@
# 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
# process, which may cause wedges in the gate later.
hacking>=1.1.0 # Apache-2.0
hacking>=1.1.0,<1.2.0 # Apache-2.0
coverage!=4.4,>=4.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD
flake8>=2.6.0


+ 3
- 3
vmware_nsx/plugins/common_v3/plugin.py View File

@ -2840,9 +2840,9 @@ class NsxPluginV3Base(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
tags=tags, name=name,
attachment_type=nsxlib_consts.ATTACHMENT_MDPROXY)
except nsx_lib_exc.ResourceNotFound:
err_msg = (_('Logical switch %s or MD proxy %s do '
'not exist') % (nsx_net_id,
az._native_md_proxy_uuid))
err_msg = (_('Logical switch %(net)s or MD proxy %(md)s do '
'not exist') % {'net': nsx_net_id,
'md': az._native_md_proxy_uuid})
LOG.error(err_msg)
raise nsx_exc.NsxPluginException(err_msg=err_msg)


+ 6
- 4
vmware_nsx/plugins/nsx_p/plugin.py View File

@ -1400,13 +1400,15 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
gw_ip = netaddr.IPAddress(raw_gw_ip)
cidr = netaddr.IPNetwork(raw_cidr)
if gw_ip.version != cidr.version:
err_msg = (_("Subnet gateway ip version %s does not match subnet "
"cidr %s") % (gw_ip.version, raw_cidr))
err_msg = (_("Subnet gateway ip version %(ver)s does not match "
"subnet cidr %(cidr)s") %
{'ver': gw_ip.version, 'cidr': raw_cidr})
raise n_exc.InvalidInput(error_message=err_msg)
if gw_ip not in cidr:
err_msg = (_("Subnet gateway ip %s does not belong to subnet "
"cidr %s") % (raw_gw_ip, raw_cidr))
err_msg = (_("Subnet gateway ip %(ip)s does not belong to subnet "
"cidr %(cidr)s") %
{'ip': raw_gw_ip, 'cidr': raw_cidr})
raise n_exc.InvalidInput(error_message=err_msg)
if gw_ip.version == const.IP_VERSION_6:


+ 1
- 0
vmware_nsx/plugins/nsx_p/utils.py View File

@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
def get_edge_cluster_tzs(nsxpolicy, nsxlib, ec_uuid):
ec_nodes = nsxpolicy.edge_cluster.get_edge_node_nsx_ids(ec_uuid)
ec_tzs = []


+ 1
- 0
vmware_nsx/services/lbaas/nsx_p/implementation/lb_utils.py View File

@ -14,6 +14,7 @@
# under the License.
import functools
import netaddr
from neutron_lib import exceptions as n_exc


+ 3
- 2
vmware_nsx/services/lbaas/nsx_p/implementation/listener_mgr.py View File

@ -158,8 +158,9 @@ class EdgeListenerManagerFromDict(base_mgr.NsxpLoadbalancerBaseManager):
pool_id = p_utils.path_to_id(vs.get('pool_path', ''))
if pool_id == def_pool_id:
completor(success=False)
msg = (_('Default pool %s is already used by another '
'listener %s') % (def_pool_id, vs.get('id')))
msg = (_("Default pool %(pool)s is already used by "
"another listener %(listener)s") %
{'pool': def_pool_id, 'listener': vs.get('id')})
raise n_exc.BadRequest(resource='lbaas-pool', msg=msg)
lb_common.validate_session_persistence(


+ 1
- 0
vmware_nsx/shell/admin/plugins/nsxp/resources/migration.py View File

@ -13,6 +13,7 @@
# under the License.
import copy
import netaddr
from neutron_lib.callbacks import registry


+ 1
- 0
vmware_nsx/shell/admin/plugins/nsxp/resources/utils.py View File

@ -13,6 +13,7 @@
# under the License.
import logging
from oslo_config import cfg
from neutron.db import l3_dvr_db # noqa


+ 13
- 10
vmware_nsx/shell/admin/plugins/nsxv3/resources/migration.py View File

@ -16,6 +16,7 @@ import copy
import time
import logging
import paramiko
import tenacity
@ -164,8 +165,8 @@ def change_migration_service_status(start=True, nsxlib=None):
try:
get_migration_status_with_retry(nsxlib)
except Exception:
raise Exception("The migration service did not get up after %s "
"retries" % SERVICE_UP_RETRIES)
raise Exception(_("The migration service did not get up after %s "
"retries") % SERVICE_UP_RETRIES)
elapsed_time = time.time() - start_time
LOG.info("The service is up (waited %s seconds)", elapsed_time)
@ -204,8 +205,8 @@ def verify_component_status(nsxlib, component_number):
# Success that indicates resource migration is already done
return COMPONENT_STATUS_ALREADY_MIGRATED
# bad state. abort, mark as fail, and go to next request
raise Exception("The migration server returned with FAILURE status. "
"Details: %s", status)
raise Exception(_("The migration server returned with FAILURE status. "
"Details: %s"), status)
# Success
return COMPONENT_STATUS_OK
@ -298,11 +299,12 @@ def get_resource_migration_data(nsxlib_resource, neutron_id_tags,
# Make sure not to migrate multiple resources to the same policy-id
if policy_id:
if policy_id in policy_ids:
msg = (_("Cannot migrate %s %s to policy-id %s: Another %s "
msg = (_("Cannot migrate %(res)s %(name)s to policy-id "
"%(id)s: Another %(res)s "
"has the same designated policy-id. One of those is "
"probably a neutron orphaned. Please delete it and "
"try migration again.") % (printable_name,
name_and_id, policy_id, printable_name))
"try migration again.") % {'res': printable_name,
'name': name_and_id, 'id': policy_id})
raise Exception(msg)
policy_ids.append(policy_id)
@ -319,7 +321,7 @@ def get_resource_migration_data(nsxlib_resource, neutron_id_tags,
def migrate_objects(nsxlib, data, use_admin=False):
if not ensure_migration_state_ready(nsxlib):
raise Exception("The migration server is not ready")
raise Exception(_("The migration server is not ready"))
migration_body = {"migration_data": [data]}
@ -395,8 +397,9 @@ def migrate_resource(nsxlib, resource_type, entries,
addition_size = 1 + len(entries[index].get('linked_ids', []))
if addition_size > limit:
# Unsupported size of resource
raise Exception("%s size is over the allowed limit of "
"%s" % (resource_type, limit))
raise Exception(_("%(res)s size is over the allowed limit "
"of %(lim)s") % {'res': resource_type,
'lim': limit})
if counter + addition_size > limit:
# Migrate what was accumulated so far
migrate_objects(nsxlib,


+ 1
- 0
vmware_nsx/tests/unit/services/lbaas/test_nsxp_driver.py View File

@ -14,6 +14,7 @@
# limitations under the License.
import copy
import mock
from neutron.tests import base


Loading…
Cancel
Save