diff --git a/vmware_nsx/plugins/dvs/plugin.py b/vmware_nsx/plugins/dvs/plugin.py index 2b7e74d74f..581f5176b7 100644 --- a/vmware_nsx/plugins/dvs/plugin.py +++ b/vmware_nsx/plugins/dvs/plugin.py @@ -13,8 +13,6 @@ # License for the specific language governing permissions and limitations # under the License. -import uuid - from neutron_lib.api.definitions import allowedaddresspairs as addr_apidef from neutron_lib.api.definitions import port_security as psec from neutron_lib.exceptions import allowedaddresspairs as addr_exc @@ -22,6 +20,7 @@ from neutron_lib.exceptions import port_security as psec_exc from oslo_config import cfg from oslo_log import log as logging from oslo_utils import excutils +from oslo_utils import uuidutils from neutron.api import extensions as neutron_extensions from neutron.db import _resource_extend as resource_extend @@ -183,7 +182,7 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin, LOG.warning("Network with admin_state_up=False are not yet " "supported by this plugin. Ignoring setting for " "network %s", net_data.get('name', '')) - net_data['id'] = str(uuid.uuid4()) + net_data['id'] = uuidutils.generate_uuid() vlan_tag = 0 if net_data.get(pnet.NETWORK_TYPE) == c_utils.NetworkTypes.VLAN: vlan_tag = net_data.get(pnet.SEGMENTATION_ID, 0) diff --git a/vmware_nsx/plugins/nsx_mh/plugin.py b/vmware_nsx/plugins/nsx_mh/plugin.py index c67433d3e1..40cb1afe7c 100644 --- a/vmware_nsx/plugins/nsx_mh/plugin.py +++ b/vmware_nsx/plugins/nsx_mh/plugin.py @@ -13,8 +13,6 @@ # License for the specific language governing permissions and limitations # under the License. -import uuid - from neutron_lib.api.definitions import allowedaddresspairs as addr_apidef from neutron_lib.api.definitions import external_net as extnet_apidef from neutron_lib.api.definitions import port_security as psec @@ -31,6 +29,7 @@ from oslo_config import cfg from oslo_db import exception as db_exc from oslo_log import log as logging from oslo_utils import excutils +from oslo_utils import uuidutils import six from sqlalchemy import exc as sql_exc from sqlalchemy.orm import exc as sa_exc @@ -955,7 +954,7 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin, # NOTE(salv-orlando): Pre-generating uuid for Neutron # network. This will be removed once the network create operation # becomes an asynchronous task - net_data['id'] = str(uuid.uuid4()) + net_data['id'] = str(uuidutils.generate_uuid()) if (not validators.is_attr_set(external) or validators.is_attr_set(external) and not external): lswitch = switchlib.create_lswitch( @@ -1480,7 +1479,7 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin, # NOTE(salv-orlando): Pre-generating uuid for Neutron # router. This will be removed once the router create operation # becomes an asynchronous task - neutron_router_id = str(uuid.uuid4()) + neutron_router_id = str(uuidutils.generate_uuid()) r['id'] = neutron_router_id # Populate distributed attribute in order to ensure the appropriate # type of router is created in the NSX backend @@ -2362,7 +2361,7 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin, if not default_sg: self._ensure_default_security_group(context, tenant_id) # NOTE(salv-orlando): Pre-generating Neutron ID for security group. - neutron_id = str(uuid.uuid4()) + neutron_id = str(uuidutils.generate_uuid()) nsx_secgroup = secgrouplib.create_security_profile( self.cluster, tenant_id, neutron_id, s) with db_api.context_manager.writer.using(context): diff --git a/vmware_nsx/plugins/nsx_v/plugin.py b/vmware_nsx/plugins/nsx_v/plugin.py index 3dbe025ac5..8e5c97f361 100644 --- a/vmware_nsx/plugins/nsx_v/plugin.py +++ b/vmware_nsx/plugins/nsx_v/plugin.py @@ -14,7 +14,6 @@ # under the License. from distutils import version -import uuid import netaddr @@ -1135,7 +1134,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin, provider_type = self._convert_to_transport_zones_dict(net_data) self._validate_provider_create(context, net_data) self._validate_availability_zones_in_obj(context, 'network', net_data) - net_data['id'] = str(uuid.uuid4()) + net_data['id'] = str(uuidutils.generate_uuid()) external = net_data.get(extnet_apidef.EXTERNAL) backend_network = (not validators.is_attr_set(external) or @@ -4190,7 +4189,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin, def create_security_group(self, context, security_group, default_sg=False): """Create a security group.""" sg_data = security_group['security_group'] - sg_id = sg_data["id"] = str(uuid.uuid4()) + sg_id = sg_data["id"] = str(uuidutils.generate_uuid()) self._validate_security_group(context, sg_data, default_sg) with db_api.context_manager.writer.using(context): diff --git a/vmware_nsx/tests/unit/nsx_mh/test_plugin.py b/vmware_nsx/tests/unit/nsx_mh/test_plugin.py index 34edca498a..639862bef8 100644 --- a/vmware_nsx/tests/unit/nsx_mh/test_plugin.py +++ b/vmware_nsx/tests/unit/nsx_mh/test_plugin.py @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. import copy -import uuid import mock from neutron.extensions import l3 @@ -1091,7 +1090,8 @@ class NeutronNsxOutOfSync(NsxPluginV2TestCase, # duplicate every entry in the nat rule dict tmp = copy.deepcopy(self.fc._fake_lrouter_nat_dict) for (_rule_id, rule) in tmp.items(): - self.fc._fake_lrouter_nat_dict[uuid.uuid4()] = rule + _uuid = uuidutils.generate_uuid() + self.fc._fake_lrouter_nat_dict[_uuid] = rule self._test_remove_router_interface_nsx_out_of_sync(unsync_action)