# under the License.
# @author: Rohit Agarwalla, Cisco Systems, Inc.
-import uuid
-
from sqlalchemy import Column, Integer, String, ForeignKey, Boolean
from sqlalchemy.orm import relation, object_mapper
+from quantum.openstack.common import uuidutils
from quantum.plugins.cisco.db import models
from quantum.plugins.cisco.db.models import BASE
qos = Column(String(255))
def __init__(self, name, vlan_id, qos=None):
- self.uuid = uuid.uuid4()
- self.name = name
- self.vlan_id = vlan_id
- self.qos = qos
+ self.uuid = uuidutils.generate_uuid()
+ self.name = name
+ self.vlan_id = vlan_id
+ self.qos = qos
def __repr__(self):
return "<PortProfile(%s,%s,%d,%s)>" % (self.uuid,
qos_desc = Column(String(255))
def __init__(self, tenant_id, qos_name, qos_desc):
- self.qos_id = str(uuid.uuid4())
+ self.qos_id = uuidutils.generate_uuid()
self.tenant_id = tenant_id
self.qos_name = qos_name
self.qos_desc = qos_desc
password = Column(String(255))
def __init__(self, tenant_id, credential_name, user_name, password):
- self.credential_id = str(uuid.uuid4())
+ self.credential_id = uuidutils.generate_uuid()
self.tenant_id = tenant_id
self.credential_name = credential_name
self.user_name = user_name
# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
# Copyright 2011 Nicira Networks, Inc.
# All Rights Reserved.
#
# @author: Brad Hall, Nicira Networks, Inc.
# @author: Dan Wendlandt, Nicira Networks, Inc.
-import uuid
-
from sqlalchemy import Column, String, ForeignKey
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relation, object_mapper
+from quantum.openstack.common import uuidutils
+
+
BASE = declarative_base()
state = Column(String(8))
def __init__(self, network_id):
- self.uuid = str(uuid.uuid4())
+ self.uuid = uuidutils.generate_uuid()
self.network_id = network_id
self.state = "DOWN"
ports = relation(Port, order_by=Port.uuid, backref="network")
def __init__(self, tenant_id, name):
- self.uuid = str(uuid.uuid4())
+ self.uuid = uuidutils.generate_uuid()
self.tenant_id = tenant_id
self.name = name
# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
+
# Copyright 2012, Cisco Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
#
# @author: Rohit Agarwalla, Cisco Systems, Inc.
-import uuid
-
from sqlalchemy import Column, Integer, String, ForeignKey, Boolean
from sqlalchemy.orm import relation, object_mapper
from quantum.db import model_base
from quantum.db import models_v2 as models
+from quantum.openstack.common import uuidutils
class L2NetworkBase(object):
qos = Column(String(255))
def __init__(self, name, vlan_id, qos=None):
- self.uuid = uuid.uuid4()
- self.name = name
- self.vlan_id = vlan_id
- self.qos = qos
+ self.uuid = uuidutils.generate_uuid()
+ self.name = name
+ self.vlan_id = vlan_id
+ self.qos = qos
def __repr__(self):
return "<PortProfile(%s,%s,%d,%s)>" % (self.uuid,
qos_desc = Column(String(255))
def __init__(self, tenant_id, qos_name, qos_desc):
- self.qos_id = str(uuid.uuid4())
+ self.qos_id = uuidutils.generate_uuid()
self.tenant_id = tenant_id
self.qos_name = qos_name
self.qos_desc = qos_desc
password = Column(String(255))
def __init__(self, tenant_id, credential_name, user_name, password):
- self.credential_id = str(uuid.uuid4())
+ self.credential_id = uuidutils.generate_uuid()
self.tenant_id = tenant_id
self.credential_name = credential_name
self.user_name = user_name
# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
+
# Copyright 2012 Cisco Systems, Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
import logging
import unittest
-import uuid
from quantum.common import exceptions as exc
+from quantum.openstack.common import uuidutils
from quantum.plugins.cisco.common import cisco_constants as const
from quantum.plugins.cisco.common import cisco_credentials_v2 as creds
from quantum.plugins.cisco.db import network_db_v2 as cdb
def _test_with_port_creation(self, cmd, params=None):
"""Tests commands that requires a port to exist"""
LOG.debug("test_%s - START", cmd)
- net_uuid = str(uuid.uuid4())
+ net_uuid = uuidutils.generate_uuid()
device_params = self._ucs_inventory.create_port(tenant, net_uuid,
port_state,
state=port_state)
# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
+
# Copyright 2012 NEC Corporation. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# under the License.
# @author: Ryota MIBU
-import uuid
-
+from quantum.openstack.common import uuidutils
from quantum.plugins.nec.common import ofc_client
from quantum.plugins.nec import ofc_driver_base
port=conf_ofc.port)
def create_tenant(self, description, tenant_id=None):
- return tenant_id or str(uuid.uuid4())
+ return tenant_id or uuidutils.generate_uuid()
def update_tenant(self, ofc_tenant_id, description):
pass
pass
def create_network(self, ofc_tenant_id, description, network_id=None):
- ofc_network_id = network_id or str(uuid.uuid4())
+ ofc_network_id = network_id or uuidutils.generate_uuid()
body = {'id': ofc_network_id, 'description': description}
self.client.post(self.networks_path, body=body)
return ofc_network_id
else:
ofp_wildcards.append("tp_dst")
- ofc_filter_id = filter_id or str(uuid.uuid4())
+ ofc_filter_id = filter_id or uuidutils.generate_uuid()
body['id'] = ofc_filter_id
body['ofp_wildcards'] = ','.join(ofp_wildcards)
def create_port(self, ofc_tenant_id, ofc_network_id, portinfo,
port_id=None):
- ofc_port_id = port_id or str(uuid.uuid4())
+ ofc_port_id = port_id or uuidutils.generate_uuid()
path = self.ports_path % ofc_network_id
body = {'id': ofc_port_id,
'datapath_id': portinfo.datapath_id,
#NOTE: This Driver create slices with Port-MAC Based bindings on Trema
# Sliceable. It's REST API requires Port Based binding before you
# define Port-MAC Based binding.
- ofc_port_id = port_id or str(uuid.uuid4())
+ ofc_port_id = port_id or uuidutils.generate_uuid()
dummy_port_id = "dummy-%s" % ofc_port_id
path = self.ports_path % ofc_network_id
def create_port(self, ofc_tenant_id, ofc_network_id, portinfo,
port_id=None):
- ofc_port_id = port_id or str(uuid.uuid4())
+ ofc_port_id = port_id or uuidutils.generate_uuid()
path = self.attachments_path % ofc_network_id
body = {'id': ofc_port_id, 'mac': portinfo.mac}
self.client.post(path, body=body)
# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
+
# Copyright 2012, Nachi Ueno, NTT MCL, Inc.
# All Rights Reserved.
#
# under the License.
import os
-import uuid
import mock
import mox
from quantum.extensions.flavor import (FLAVOR_NETWORK, FLAVOR_ROUTER)
from quantum.extensions import l3
from quantum.openstack.common import cfg
+from quantum.openstack.common import uuidutils
from quantum.plugins.metaplugin.meta_quantum_plugin import MetaPluginV2
from quantum.plugins.metaplugin.proxy_quantum_plugin import ProxyPluginV2
from quantum.tests.unit.metaplugin import fake_plugin
super(MetaQuantumPluginV2Test, self).setUp()
db._ENGINE = None
db._MAKER = None
- self.fake_tenant_id = str(uuid.uuid4())
+ self.fake_tenant_id = uuidutils.generate_uuid()
self.context = context.get_admin_context()
sql_connection = 'sqlite:///:memory:'
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
# Copyright 2012 Nicira Networks, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
-#
import json
import logging
import urlparse
-import uuid
+
+from quantum.openstack.common import uuidutils
+
LOG = logging.getLogger("fake_nvpapiclient")
LOG.setLevel(logging.DEBUG)
def _add_lswitch(self, body):
fake_lswitch = json.loads(body)
- fake_lswitch['uuid'] = str(uuid.uuid4())
+ fake_lswitch['uuid'] = uuidutils.generate_uuid()
self._fake_lswitch_dict[fake_lswitch['uuid']] = fake_lswitch
# put the tenant_id and the zone_uuid in the main dict
# for simplyfying templating
def _add_lport(self, body, ls_uuid):
fake_lport = json.loads(body)
- fake_lport['uuid'] = str(uuid.uuid4())
+ fake_lport['uuid'] = uuidutils.generate_uuid()
# put the tenant_id and the ls_uuid in the main dict
# for simplyfying templating
fake_lport['ls_uuid'] = ls_uuid
# under the License.
# @author: Dan Wendlandt, Nicira, Inc.
-import uuid
-
import mox
import unittest2 as unittest
from quantum.agent.linux import ovs_lib, utils
+from quantum.openstack.common import uuidutils
class OVS_Lib_Test(unittest.TestCase):
pname = "vif1.0"
ofport = 5
- vif_id = str(uuid.uuid4())
+ vif_id = uuidutils.generate_uuid()
mac = "ca:fe:de:ad:be:ef"
# test __init__
def _test_get_vif_ports(self, is_xen=False):
pname = "tap99"
ofport = "6"
- vif_id = str(uuid.uuid4())
+ vif_id = uuidutils.generate_uuid()
mac = "ca:fe:de:ad:be:ef"
utils.execute(["ovs-vsctl", self.TO, "list-ports", self.BR_NAME],
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
# Copyright 2012 OpenStack LLC.
# All Rights Reserved.
#
import logging
import os
import unittest
-import uuid
import mock
-import webtest
-
from webob import exc
+import webtest
from quantum.api.extensions import PluginAwareExtensionManager
from quantum.api.v2 import attributes
from quantum.manager import QuantumManager
from quantum.openstack.common import cfg
from quantum.openstack.common.notifier import api as notifer_api
+from quantum.openstack.common import uuidutils
LOG = logging.getLogger(__name__)
def _uuid():
- return str(uuid.uuid4())
+ return uuidutils.generate_uuid()
ROOTDIR = os.path.dirname(os.path.dirname(__file__))
ETCDIR = os.path.join(ROOTDIR, 'etc')
env = {}
if req_tenant_id:
env = {'quantum.context': context.Context('', req_tenant_id)}
- input_dict = {'id': str(uuid.uuid4()),
+ input_dict = {'id': uuidutils.generate_uuid(),
'name': 'net1',
'admin_state_up': True,
'status': "ACTIVE",
instance = self.plugin.return_value
instance.get_network.return_value = return_value
- self.api.get(_get_path('networks', id=str(uuid.uuid4())))
+ self.api.get(_get_path('networks', id=uuidutils.generate_uuid()))
def _test_delete(self, req_tenant_id, real_tenant_id, expected_code,
expect_errors=False):
'shared': False}
instance.delete_network.return_value = None
- res = self.api.delete(_get_path('networks', id=str(uuid.uuid4())),
- extra_environ=env, expect_errors=expect_errors)
+ res = self.api.delete(_get_path('networks',
+ id=uuidutils.generate_uuid()),
+ extra_environ=env,
+ expect_errors=expect_errors)
self.assertEqual(res.status_int, expected_code)
def test_delete_noauth(self):
instance.get_network.return_value = data
res = self.api.get(_get_path('networks',
- id=str(uuid.uuid4())),
+ id=uuidutils.generate_uuid()),
extra_environ=env,
expect_errors=expect_errors)
self.assertEqual(res.status_int, expected_code)
instance.update_network.return_value = return_value
res = self.api.put_json(_get_path('networks',
- id=str(uuid.uuid4())),
+ id=uuidutils.generate_uuid()),
data,
extra_environ=env,
expect_errors=expect_errors)