Replaces uuid.uuid4 with uuidutils.generate_uuid()

Change-Id: Ib72d9e74c70437678c72cebc31aee60a9e140e23
Closes-Bug: #1082248
This commit is contained in:
Luong Anh Tuan 2016-11-07 13:12:29 +07:00
parent 023c3994de
commit 158bd893b9
30 changed files with 110 additions and 125 deletions

View File

@ -13,9 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import uuid
import six
from oslo_utils import uuidutils
import sqlalchemy as sa
from sqlalchemy.orm import relationship
@ -26,7 +25,7 @@ from sahara.db.sqlalchemy import types as st
# Helpers
def _generate_unicode_uuid():
return six.text_type(uuid.uuid4())
return uuidutils.generate_uuid()
def _id_column():

View File

@ -14,11 +14,11 @@
import copy
import os
import uuid
import jsonschema
from oslo_config import cfg
from oslo_serialization import jsonutils as json
from oslo_utils import uuidutils
import six
from sahara import conductor
@ -169,7 +169,7 @@ def check_cluster_templates_valid(ng_templates, cl_templates):
# passes JSON validation. We don't have the real uuid yet,
# but this will allow the validation test.
if ng_templates:
dummy_uuid = uuid.uuid4()
dummy_uuid = uuidutils.generate_uuid()
ng_ids = {ng["template"]["name"]: dummy_uuid for ng in ng_templates}
else:
ng_ids = {}

View File

@ -13,9 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import uuid
import six
from oslo_utils import uuidutils
from sahara import conductor
from sahara import context
@ -74,7 +73,7 @@ def get_password_from_db(cluster, pwname):
if passwd:
return key_manager.get_secret(passwd, ctx)
passwd = six.text_type(uuid.uuid4())
passwd = uuidutils.generate_uuid()
extra = cluster.extra.to_dict() if cluster.extra else {}
extra[pwname] = key_manager.store_secret(passwd, ctx)
cluster = conductor.cluster_update(ctx, cluster, {'extra': extra})

View File

@ -13,7 +13,7 @@
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import uuidutils as uuid
from oslo_utils import uuidutils
from sahara import conductor as cond
from sahara import context
@ -174,7 +174,7 @@ def deploy_infrastructure(cluster, server=None):
def _execute_script(client, script):
with client.remote() as remote:
script_path = '/tmp/%s' % uuid.generate_uuid()[:8]
script_path = '/tmp/%s' % uuidutils.generate_uuid()[:8]
remote.write_file_to(script_path, script)
remote.execute_command('chmod +x %s' % script_path)
remote.execute_command('bash %s' % script_path)
@ -201,7 +201,8 @@ def _get_krb5_config(cluster, server_fqdn):
def _get_short_uuid():
return "%s%s" % (uuid.generate_uuid()[:8], uuid.generate_uuid()[:8])
return "%s%s" % (uuidutils.generate_uuid()[:8],
uuidutils.generate_uuid()[:8])
def get_server_password(cluster):

View File

@ -13,7 +13,7 @@
# under the License.
import uuid
from oslo_utils import uuidutils
from sahara.conductor import objects
from sahara import context
@ -38,7 +38,8 @@ def _run_as(user, command):
def unique_file_name(base='/tmp'):
return '%(base)s/%(uuid)s' % {'base': base, 'uuid': uuid.uuid4()}
return '%(base)s/%(uuid)s' % {'base': base,
'uuid': uuidutils.generate_uuid()}
def remove(instance, path, recursive=True, run_as=None):
@ -90,7 +91,7 @@ def copy(s_path, s_instance, d_path, d_instance, run_as=None):
def run_script(instance, script, run_as=None, *args, **kwargs):
with instance.remote() as r:
path = '/tmp/%s.sh' % uuid.uuid4()
path = '/tmp/%s.sh' % uuidutils.generate_uuid()
script = files.get_file_text(script) % kwargs
r.write_file_to(path, script, run_as_root=(run_as == 'root'))
r.execute_command(_run_as(run_as, 'chmod +x %s' % path))

View File

@ -14,10 +14,8 @@
import os
import uuid
from oslo_utils import uuidutils
import six
import sahara.plugins.mapr.util.general as g
@ -35,7 +33,7 @@ MKDIR_CMD_MAPR3 = 'sudo -u %(user)s hadoop fs -mkdir %(path)s'
def put_file_to_maprfs(r, content, file_name, path, hdfs_user):
tmp_file_name = '/tmp/%s.%s' % (file_name, six.text_type(uuid.uuid4()))
tmp_file_name = '/tmp/%s.%s' % (file_name, uuidutils.generate_uuid())
r.write_file_to(tmp_file_name, content)
target = os.path.join(path, file_name)
move_from_local(r, tmp_file_name, target, hdfs_user)

View File

@ -13,9 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import uuid
import six
from oslo_utils import uuidutils
from sahara import conductor
from sahara import context
@ -59,7 +58,7 @@ def get_password(cluster, pw_name):
if passwd:
return key_manager.get_secret(passwd, ctx)
passwd = six.text_type(uuid.uuid4())
passwd = uuidutils.generate_uuid()
extra = cluster.extra.to_dict() if cluster.extra else {}
extra[pw_name] = key_manager.store_secret(passwd, ctx)
cluster = conductor.cluster_update(ctx, cluster, {'extra': extra})

View File

@ -13,9 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import uuid
import six
from oslo_utils import uuidutils
from sahara.plugins import utils as u
from sahara.service.castellan import utils as castellan
@ -62,5 +61,5 @@ def get_instance_hostname(instance):
def generate_random_password():
password = six.text_type(uuid.uuid4())
password = uuidutils.generate_uuid()
return castellan.store_secret(password)

View File

@ -16,7 +16,6 @@
import random
import re
import string
import uuid
from oslo_config import cfg
from oslo_utils import uuidutils
@ -57,7 +56,7 @@ def get_plugin(cluster):
def create_workflow_dir(where, path, job, use_uuid=None, chmod=""):
if use_uuid is None:
use_uuid = six.text_type(uuid.uuid4())
use_uuid = uuidutils.generate_uuid()
constructed_dir = _append_slash_if_needed(path)
constructed_dir += '%s/%s' % (job.name, use_uuid)

View File

@ -15,10 +15,10 @@
import abc
import os
import uuid
import xml.dom.minidom as xml
from oslo_config import cfg
from oslo_utils import uuidutils
import six
from sahara import conductor as c
@ -377,7 +377,7 @@ class OozieJobEngine(base_engine.JobEngine):
def _create_hdfs_workflow_dir(self, where, job):
constructed_dir = '/user/%s/' % self.get_hdfs_user()
constructed_dir = self._add_postfix(constructed_dir)
constructed_dir += '%s/%s' % (job.name, six.text_type(uuid.uuid4()))
constructed_dir += '%s/%s' % (job.name, uuidutils.generate_uuid())
with remote.get_remote(where) as r:
self.create_hdfs_dir(r, constructed_dir)

View File

@ -15,10 +15,9 @@
# limitations under the License.
import os
import uuid
from oslo_config import cfg
import six
from oslo_utils import uuidutils
from sahara import conductor as c
from sahara import context
@ -156,7 +155,7 @@ class SparkJobEngine(base_engine.JobEngine):
if edp.is_adapt_spark_for_swift_enabled(
job_configs.get('configs', {})):
path = 'service/edp/resources/edp-spark-wrapper.jar'
name = 'builtin-%s.jar' % six.text_type(uuid.uuid4())
name = 'builtin-%s.jar' % uuidutils.generate_uuid()
builtin_libs = [{'raw': files.get_file_text(path),
'name': name}]

View File

@ -16,9 +16,7 @@
import os
from oslo_config import cfg
import six
import uuid
from oslo_utils import uuidutils
from sahara import conductor as c
from sahara import context
@ -78,7 +76,7 @@ class StormJobEngine(base_engine.JobEngine):
return self._generate_topology_name(name)
def _generate_topology_name(self, name):
return name + "_" + six.text_type(uuid.uuid4())
return name + "_" + uuidutils.generate_uuid()
def _get_job_status_from_remote(self, job_execution, retries=3):

View File

@ -14,11 +14,11 @@
# limitations under the License.
import functools
import uuid
from oslo_config import cfg
from oslo_log import log as logging
import oslo_messaging as messaging
from oslo_utils import uuidutils
import six
from sahara import conductor as c
@ -134,7 +134,8 @@ def request_context(func):
class OpsServer(rpc_utils.RPCServer):
def __init__(self):
target = messaging.Target(topic='sahara-ops', server=uuid.uuid4(),
target = messaging.Target(topic='sahara-ops',
server=uuidutils.generate_uuid(),
version='1.0')
super(OpsServer, self).__init__(target)

View File

@ -14,9 +14,9 @@
# limitations under the License.
import copy
import uuid
import mock
from oslo_utils import uuidutils
import six
from sqlalchemy import exc as sa_ex
import testtools
@ -37,7 +37,7 @@ SAMPLE_NGT = {
"plugin_name": "test_plugin",
"hadoop_version": "test_version",
"node_processes": ["p1", "p2"],
"image_id": str(uuid.uuid4()),
"image_id": uuidutils.generate_uuid(),
"node_configs": {
"service_1": {
"config_1": "value_1"
@ -67,7 +67,7 @@ SAMPLE_CLT = {
"name": "clt_test",
"plugin_name": "test_plugin",
"hadoop_version": "test_version",
"default_image_id": str(uuid.uuid4()),
"default_image_id": uuidutils.generate_uuid(),
"cluster_configs": {
"service_1": {
"config_1": "value_1"
@ -103,7 +103,7 @@ SAMPLE_CLT = {
],
"anti_affinity": ["datanode"],
"description": "my template",
"neutron_management_network": str(uuid.uuid4()),
"neutron_management_network": uuidutils.generate_uuid(),
"shares": None,
"is_public": False,
"is_protected": False

View File

@ -14,7 +14,6 @@
import copy
import tempfile
import uuid
import jsonschema
import mock
@ -217,7 +216,7 @@ class TemplateUpdateTestCase(base.ConductorManagerTestCase):
clt["neutron_management_network"] = "{neutron_management_network}"
clt["default_image_id"] = "{default_image_id}"
netid = str(uuid.uuid4())
netid = uuidutils.generate_uuid()
configs = {"neutron_management_network": netid,
"default_image_id": None}
template_api.substitute_config_values(configs, clt, "/path")
@ -619,7 +618,7 @@ class TemplateUpdateTestCase(base.ConductorManagerTestCase):
get_configs.return_value = {
"flavor_id": '2',
"neutron_management_network": str(uuid.uuid4()),
"neutron_management_network": uuidutils.generate_uuid(),
'auto_security_group': True,
'security_groups': [],
}
@ -656,7 +655,7 @@ class TemplateUpdateTestCase(base.ConductorManagerTestCase):
get_configs.return_value = {
"flavor_id": '2',
"neutron_management_network": str(uuid.uuid4())
"neutron_management_network": uuidutils.generate_uuid()
}
option_values = {"tenant_id": ctx.tenant_id,
@ -694,7 +693,7 @@ class TemplateUpdateTestCase(base.ConductorManagerTestCase):
get_configs.return_value = {
"flavor_id": '2',
"neutron_management_network": str(uuid.uuid4())
"neutron_management_network": uuidutils.generate_uuid()
}
option_values = {"tenant_id": ctx.tenant_id,
"directory": tempdir,
@ -731,7 +730,7 @@ class TemplateUpdateTestCase(base.ConductorManagerTestCase):
get_configs.return_value = {
"flavor_id": '2',
"neutron_management_network": str(uuid.uuid4())
"neutron_management_network": uuidutils.generate_uuid()
}
option_values = {"tenant_id": ctx.tenant_id,
@ -775,7 +774,7 @@ class TemplateUpdateTestCase(base.ConductorManagerTestCase):
get_configs.return_value = {
"flavor_id": '2',
"neutron_management_network": str(uuid.uuid4())
"neutron_management_network": uuidutils.generate_uuid()
}
option_values = {"tenant_id": ctx.tenant_id,

View File

@ -13,10 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import uuid
import mock
import six
from oslo_utils import uuidutils
from sahara import conductor as cond
from sahara.utils import edp
@ -89,7 +88,7 @@ def create_data_source(url, name=None, id=None):
def _create_job_exec(job_id, type, configs=None, info=None):
j_exec = mock.Mock()
j_exec.id = six.text_type(uuid.uuid4())
j_exec.id = uuidutils.generate_uuid()
j_exec.job_id = job_id
j_exec.job_configs = configs
j_exec.info = info

View File

@ -13,10 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import uuid
import mock
import six
from oslo_utils import uuidutils
import testtools
from sahara import conductor as cond
@ -64,7 +63,7 @@ class JobUtilsTestCase(testtools.TestCase):
self.assertFalse(by_uuid)
def test_find_possible_data_source_refs_by_name(self):
id = six.text_type(uuid.uuid4())
id = uuidutils.generate_uuid()
job_configs = {}
self.assertEqual([],
job_utils.find_possible_data_source_refs_by_name(
@ -117,7 +116,7 @@ class JobUtilsTestCase(testtools.TestCase):
job_utils.find_possible_data_source_refs_by_uuid(
job_configs))
id = six.text_type(uuid.uuid4())
id = uuidutils.generate_uuid()
job_configs = {'args': ['first', name_ref],
'configs': {'config': 'value'},
'params': {'param': 'value'}}
@ -146,7 +145,7 @@ class JobUtilsTestCase(testtools.TestCase):
[id],
job_utils.find_possible_data_source_refs_by_uuid(job_configs))
id2 = six.text_type(uuid.uuid4())
id2 = uuidutils.generate_uuid()
job_configs = {'args': [id, id2, name_ref],
'configs': {'config': id},
'params': {'param': id}}
@ -161,16 +160,16 @@ class JobUtilsTestCase(testtools.TestCase):
ctx.return_value = 'dummy'
name_ref = job_utils.DATA_SOURCE_PREFIX+'input'
job_exec_id = six.text_type(uuid.uuid4())
job_exec_id = uuidutils.generate_uuid()
input_url = "swift://container/input"
input = u.create_data_source(input_url,
name="input",
id=six.text_type(uuid.uuid4()))
id=uuidutils.generate_uuid())
output = u.create_data_source("swift://container/output.%JOB_EXEC_ID%",
name="output",
id=six.text_type(uuid.uuid4()))
id=uuidutils.generate_uuid())
output_url = "swift://container/output." + job_exec_id
by_name = {'input': input,
@ -273,7 +272,7 @@ class JobUtilsTestCase(testtools.TestCase):
def test_construct_data_source_url_no_placeholders(self):
base_url = "swift://container/input"
job_exec_id = six.text_type(uuid.uuid4())
job_exec_id = uuidutils.generate_uuid()
url = job_utils._construct_data_source_url(base_url, job_exec_id)
@ -281,7 +280,7 @@ class JobUtilsTestCase(testtools.TestCase):
def test_construct_data_source_url_job_exec_id_placeholder(self):
base_url = "swift://container/input.%JOB_EXEC_ID%.out"
job_exec_id = six.text_type(uuid.uuid4())
job_exec_id = uuidutils.generate_uuid()
url = job_utils._construct_data_source_url(base_url, job_exec_id)
@ -290,7 +289,7 @@ class JobUtilsTestCase(testtools.TestCase):
def test_construct_data_source_url_randstr_placeholder(self):
base_url = "swift://container/input.%RANDSTR(4)%.%RANDSTR(7)%.out"
job_exec_id = six.text_type(uuid.uuid4())
job_exec_id = uuidutils.generate_uuid()
url = job_utils._construct_data_source_url(base_url, job_exec_id)

View File

@ -15,9 +15,9 @@
import itertools
import os
import uuid
from oslo_serialization import jsonutils as json
from oslo_utils import uuidutils
import testtools
from sahara.service.validations.edp import data_source_schema
@ -76,4 +76,4 @@ class TestJSONApiExamplesV11(testtools.TestCase):
return itertools.chain(*all_files)
def _formatter(self, *variables):
return {variable: str(uuid.uuid4()) for variable in variables}
return {variable: uuidutils.generate_uuid() for variable in variables}

View File

@ -13,9 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import uuid
import mock
from oslo_utils import uuidutils
import testtools
from sahara import exceptions as exc
@ -108,7 +108,7 @@ class FakeNodeGroup(object):
self.floating_ip_pool = pool
self.flavor_id = flavor_id
self.open_ports = ports
self.id = uuid.uuid4()
self.id = uuidutils.generate_uuid()
nova_limits = {
'absolute': {

View File

@ -13,10 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import uuid
from manilaclient.openstack.common.apiclient import exceptions as manila_ex
import mock
from oslo_utils import uuidutils
import testtools
from sahara import exceptions
@ -46,7 +46,7 @@ def _mock_node_group(ips, share_list):
# execute_command functions for its instances.
execute_mocks = [mock.Mock(return_value="centos") for ip in ips]
get_id = mock.Mock(return_value=uuid.uuid4())
get_id = mock.Mock(return_value=uuidutils.generate_uuid())
instances = [
mock.Mock(
internal_ip=ip,

View File

@ -13,9 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import uuid
import mock
from oslo_utils import uuidutils
import testtools
import sahara.exceptions as ex
@ -283,7 +283,7 @@ class TestDataSourceCreateValidation(u.ValidationTestCase):
check_ds_unique_name.return_value = True
data = {
"name": "test_data_data_source",
"url": "man://%s" % uuid.uuid4(),
"url": "man://%s" % uuidutils.generate_uuid(),
"type": "manila",
"description": ("incorrect url schema for")
}
@ -322,7 +322,7 @@ class TestDataSourceCreateValidation(u.ValidationTestCase):
check_ds_unique_name.return_value = True
data = {
"name": "test_data_data_source",
"url": "manila://%s" % uuid.uuid4(),
"url": "manila://%s" % uuidutils.generate_uuid(),
"type": "manila",
"description": ("netloc is not a uuid")
}
@ -335,7 +335,7 @@ class TestDataSourceCreateValidation(u.ValidationTestCase):
check_ds_unique_name.return_value = True
data = {
"name": "test_data_data_source",
"url": "manila://%s/foo" % uuid.uuid4(),
"url": "manila://%s/foo" % uuidutils.generate_uuid(),
"type": "manila",
"description": ("correct url")
}
@ -384,11 +384,12 @@ class TestDataSourceUpdateValidation(u.ValidationTestCase):
with testtools.ExpectedException(ex.InvalidDataException):
ds.check_data_source_update(
{"url": "manila://%s/foo" % uuid.uuid4()}, 'ds_id')
{"url": "manila://%s/foo" % uuidutils.generate_uuid()},
'ds_id')
ds.check_data_source_update(
{'type': 'manila',
'url': 'manila://%s/foo' % uuid.uuid4()}, 'ds_id')
'url': 'manila://%s/foo' % uuidutils.generate_uuid()}, 'ds_id')
@mock.patch('sahara.conductor.API.job_execution_get_all')
def test_update_referenced_data_source(self, je_all):
@ -464,12 +465,12 @@ class TestDataSourceUpdateValidation(u.ValidationTestCase):
@mock.patch('sahara.conductor.API.data_source_get')
def test_update_data_source_manila(self, ds_get, je_all):
old_ds = mock.Mock(id='ds_id', type='manila',
url='manila://%s/foo' % uuid.uuid4(),
url='manila://%s/foo' % uuidutils.generate_uuid(),
credentials={})
ds_get.return_value = old_ds
ds.check_data_source_update(
{'url': 'manila://%s/foo' % uuid.uuid4()}, 'ds_id')
{'url': 'manila://%s/foo' % uuidutils.generate_uuid()}, 'ds_id')
self._update_swift()
self._update_hdfs()

View File

@ -14,11 +14,10 @@
# limitations under the License.
import time
import uuid
import mock
from oslo_utils import timeutils
import six
from oslo_utils import uuidutils
import testtools
from sahara import exceptions as ex
@ -54,8 +53,8 @@ class TestJobExecCreateValidation(u.ValidationTestCase):
get_job.return_value = mock.Mock(
type=edp.JOB_TYPE_MAPREDUCE_STREAMING, libs=[], interface=[])
ds1_id = six.text_type(uuid.uuid4())
ds2_id = six.text_type(uuid.uuid4())
ds1_id = uuidutils.generate_uuid()
ds2_id = uuidutils.generate_uuid()
data_sources = {
ds1_id: mock.Mock(type="swift", url="http://swift/test"),
@ -71,7 +70,7 @@ class TestJobExecCreateValidation(u.ValidationTestCase):
self._assert_create_object_validation(
data={
"cluster_id": six.text_type(uuid.uuid4()),
"cluster_id": uuidutils.generate_uuid(),
"input_id": ds1_id,
"output_id": ds2_id,
"job_configs": {"configs": {},
@ -86,7 +85,7 @@ class TestJobExecCreateValidation(u.ValidationTestCase):
self._assert_create_object_validation(
data={
"cluster_id": six.text_type(uuid.uuid4()),
"cluster_id": uuidutils.generate_uuid(),
"input_id": ds1_id,
"output_id": ds2_id,
"job_configs": {
@ -105,8 +104,8 @@ class TestJobExecCreateValidation(u.ValidationTestCase):
get_job.return_value = mock.Mock(
type=edp.JOB_TYPE_MAPREDUCE_STREAMING, libs=[], interface=[])
ds1_id = six.text_type(uuid.uuid4())
ds2_id = six.text_type(uuid.uuid4())
ds1_id = uuidutils.generate_uuid()
ds2_id = uuidutils.generate_uuid()
data_sources = {
ds1_id: mock.Mock(type="swift", url="http://swift/test"),
@ -122,7 +121,7 @@ class TestJobExecCreateValidation(u.ValidationTestCase):
self._assert_create_object_validation(
data={
"cluster_id": six.text_type(uuid.uuid4()),
"cluster_id": uuidutils.generate_uuid(),
"input_id": ds1_id,
"output_id": ds2_id,
"job_configs": {
@ -141,7 +140,7 @@ class TestJobExecCreateValidation(u.ValidationTestCase):
self._assert_create_object_validation(
data={
"cluster_id": six.text_type(uuid.uuid4()),
"cluster_id": uuidutils.generate_uuid(),
"input_id": ds1_id,
"output_id": ds2_id,
"job_configs": {
@ -167,9 +166,9 @@ class TestJobExecCreateValidation(u.ValidationTestCase):
self._assert_create_object_validation(
data={
"cluster_id": six.text_type(uuid.uuid4()),
"input_id": six.text_type(uuid.uuid4()),
"output_id": six.text_type(uuid.uuid4())
"cluster_id": uuidutils.generate_uuid(),
"input_id": uuidutils.generate_uuid(),
"output_id": uuidutils.generate_uuid()
},
bad_req_i=(1, "INVALID_COMPONENT_COUNT",
"Hadoop cluster should contain 1 oozie component(s). "
@ -193,7 +192,7 @@ class TestJobExecCreateValidation(u.ValidationTestCase):
# Everything is okay, spark cluster supports EDP by default
# because cluster requires a master and slaves >= 1
wrap_it(data={"cluster_id": six.text_type(uuid.uuid4()),
wrap_it(data={"cluster_id": uuidutils.generate_uuid(),
"job_configs": {
"configs": {
"edp.java.main_class": "org.me.class"}}})
@ -210,7 +209,7 @@ class TestJobExecCreateValidation(u.ValidationTestCase):
self._assert_create_object_validation(
data={
"cluster_id": six.text_type(uuid.uuid4()),
"cluster_id": uuidutils.generate_uuid(),
"job_configs": {"configs": {},
"params": {},
"args": [],
@ -222,7 +221,7 @@ class TestJobExecCreateValidation(u.ValidationTestCase):
self._assert_create_object_validation(
data={
"cluster_id": six.text_type(uuid.uuid4()),
"cluster_id": uuidutils.generate_uuid(),
"job_configs": {
"configs": {
"edp.java.main_class": ""},
@ -236,7 +235,7 @@ class TestJobExecCreateValidation(u.ValidationTestCase):
self._assert_create_object_validation(
data={
"cluster_id": six.text_type(uuid.uuid4()),
"cluster_id": uuidutils.generate_uuid(),
"job_configs": {
"configs": {
"edp.java.main_class": "org.me.myclass"},
@ -257,7 +256,7 @@ class TestJobExecCreateValidation(u.ValidationTestCase):
self._assert_create_object_validation(
data={
"cluster_id": six.text_type(uuid.uuid4()),
"cluster_id": uuidutils.generate_uuid(),
"job_configs": {"configs": {},
"params": {},
"args": [],
@ -269,7 +268,7 @@ class TestJobExecCreateValidation(u.ValidationTestCase):
self._assert_create_object_validation(
data={
"cluster_id": six.text_type(uuid.uuid4()),
"cluster_id": uuidutils.generate_uuid(),
"job_configs": {
"configs": {
"edp.java.main_class": ""},
@ -283,7 +282,7 @@ class TestJobExecCreateValidation(u.ValidationTestCase):
self._assert_create_object_validation(
data={
"cluster_id": six.text_type(uuid.uuid4()),
"cluster_id": uuidutils.generate_uuid(),
"job_configs": {
"configs": {
"edp.java.main_class": "org.me.myclass"},

View File

@ -13,9 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import uuid
import mock
from oslo_utils import uuidutils
from sahara.service.api import v10 as api
from sahara.service.validations import cluster_template_schema as ct_schema
@ -211,7 +211,7 @@ class TestClusterTemplateCreateValidation(u.ValidationTestCase):
'name': 'testname',
'plugin_name': 'fake',
'hadoop_version': '0.1',
'default_image_id': str(uuid.uuid4()),
'default_image_id': uuidutils.generate_uuid(),
'cluster_configs': {
"service_1": {
"config_1": "value_1"
@ -227,7 +227,7 @@ class TestClusterTemplateCreateValidation(u.ValidationTestCase):
],
'anti_affinity': ['datanode'],
'description': 'my template',
'neutron_management_network': str(uuid.uuid4()),
'neutron_management_network': uuidutils.generate_uuid(),
'domain_name': 'domain.org.'
})

View File

@ -14,15 +14,13 @@
# limitations under the License.
import uuid
import six
from oslo_utils import uuidutils
from sahara.conductor import resource as r
def create_cluster(name, tenant, plugin, version, node_groups, **kwargs):
dct = {'id': six.text_type(uuid.uuid4()), 'name': name,
dct = {'id': uuidutils.generate_uuid(), 'name': name,
'tenant_id': tenant, 'plugin_name': plugin,
'hadoop_version': version, 'node_groups': node_groups,
'cluster_configs': {}, "sahara_info": {}, 'is_protected': False}

View File

@ -13,10 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import uuid
import jsonschema
import six
from oslo_utils import uuidutils
import testtools
from sahara.utils import api_validator
@ -151,7 +150,7 @@ class ApiValidatorTest(testtools.TestCase):
"format": "uuid",
}
id = six.text_type(uuid.uuid4())
id = uuidutils.generate_uuid()
self._validate_success(schema, id)
self._validate_success(schema, id.replace("-", ""))
@ -338,7 +337,7 @@ class ApiValidatorTest(testtools.TestCase):
self._validate_success(schema, 1)
self._validate_success(schema, "0")
self._validate_success(schema, "1")
self._validate_success(schema, six.text_type(uuid.uuid4()))
self._validate_success(schema, uuidutils.generate_uuid())
self._validate_failure(schema, True)
self._validate_failure(schema, 0.1)
self._validate_failure(schema, "0.1")

View File

@ -13,9 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import uuid
import mock
from oslo_utils import uuidutils
from sahara import conductor
from sahara import context
@ -26,12 +26,12 @@ from sahara.utils import cluster_progress_ops as cpo
class FakeInstance(object):
def __init__(self):
self.id = uuid.uuid4()
self.name = uuid.uuid4()
self.cluster_id = uuid.uuid4()
self.node_group_id = uuid.uuid4()
self.instance_id = uuid.uuid4()
self.instance_name = uuid.uuid4()
self.id = uuidutils.generate_uuid()
self.name = uuidutils.generate_uuid()
self.cluster_id = uuidutils.generate_uuid()
self.node_group_id = uuidutils.generate_uuid()
self.instance_id = uuidutils.generate_uuid()
self.instance_name = uuidutils.generate_uuid()
class ClusterProgressOpsTest(base.SaharaWithDbTestCase):

View File

@ -13,10 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import uuid
import mock
import six
from oslo_utils import uuidutils
from sahara.service.edp import job_utils
from sahara.tests.unit import base
@ -88,7 +87,7 @@ class TestProxyUtils(base.SaharaWithDbTestCase):
url='swift://%')
data_source_count.reset_mock()
data_source_count.return_value = 1
myid = six.text_type(uuid.uuid4())
myid = uuidutils.generate_uuid()
job_execution.job_configs = {
'configs': {job_utils.DATA_SOURCE_SUBST_UUID: True},
'args': [myid]}

View File

@ -13,9 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import uuid
import six
from oslo_utils import uuidutils
from sahara.utils import files
@ -152,7 +151,7 @@ def get_builtin_binaries(job, configs):
if job.type == JOB_TYPE_JAVA:
if is_adapt_for_oozie_enabled(configs):
path = 'service/edp/resources/edp-main-wrapper.jar'
name = 'builtin-%s.jar' % six.text_type(uuid.uuid4())
name = 'builtin-%s.jar' % uuidutils.generate_uuid()
return [{'raw': files.get_file_binary(path),
'name': name}]
return []

View File

@ -13,10 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import uuid
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import uuidutils
import six
from sahara import conductor as c
@ -267,7 +267,7 @@ def proxy_user_create(username):
'''
admin = k.client_for_admin()
domain = domain_for_proxy()
password = six.text_type(uuid.uuid4())
password = uuidutils.generate_uuid()
b.execute_with_retries(
admin.users.create, name=username, password=password, domain=domain.id)
LOG.debug('Created proxy user {username}'.format(username=username))

View File

@ -37,7 +37,6 @@ import shlex
import sys
import threading
import time
import uuid
from eventlet.green import subprocess as e_subprocess
from eventlet import semaphore
@ -45,6 +44,7 @@ from eventlet import timeout as e_timeout
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import excutils
from oslo_utils import uuidutils
import paramiko
import requests
from requests import adapters
@ -278,7 +278,7 @@ def _append_fl(sftp, remote_file, data):
def _write_file(sftp, remote_file, data, run_as_root):
if run_as_root:
temp_file = 'temp-file-%s' % six.text_type(uuid.uuid4())
temp_file = 'temp-file-%s' % uuidutils.generate_uuid()
_write_fl(sftp, temp_file, data)
_execute_command(
'mv %s %s' % (temp_file, remote_file), run_as_root=True)
@ -288,7 +288,7 @@ def _write_file(sftp, remote_file, data, run_as_root):
def _append_file(sftp, remote_file, data, run_as_root):
if run_as_root:
temp_file = 'temp-file-%s' % six.text_type(uuid.uuid4())
temp_file = 'temp-file-%s' % uuidutils.generate_uuid()
_write_fl(sftp, temp_file, data)
_execute_command(
'cat %s >> %s' % (temp_file, remote_file), run_as_root=True)
@ -339,7 +339,7 @@ def _read_file_from(remote_file, run_as_root=False):
fl = remote_file
if run_as_root:
fl = 'temp-file-%s' % (six.text_type(uuid.uuid4()))
fl = 'temp-file-%s' % (uuidutils.generate_uuid())
_execute_command('cp %s %s' % (remote_file, fl), run_as_root=True)
try: