Replace uuid.uuid4() with uuidutils.generate_uuid()
Since oslo.utils provide the ability to generate the uuid string, and some others use oslo.utils[0] too. For consistency, this ps replaces uuid.uuid4() with uuidutils.generate_uuid(). Change-Id: I9b3ebff137d0ffaed8c54031c8587c3bfc1acdce
This commit is contained in:
parent
dc1d46dca2
commit
e427c8fe39
@ -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', '<unknown>'))
|
||||
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)
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user