Remove old random name generator

Kill the old random name generator in favor of the fancy new one.

Implements blueprint: consistent-resource-names
Change-Id: Ia612ebb3ed3af27c6aaa1e35f459b7980b7a24b9
This commit is contained in:
Chris St. Pierre 2015-09-22 09:19:37 -05:00 committed by Andrey Kurilin
parent dde6a8cfad
commit cfbd4c8be6
2 changed files with 11 additions and 7 deletions

View File

@ -189,10 +189,14 @@ class MuranoScenario(scenario.OpenStackScenario):
def _zip_package(self, package_path):
"""Call _prepare_package method that returns path to zip archive."""
return MuranoPackageManager()._prepare_package(package_path)
return MuranoPackageManager(self.task)._prepare_package(package_path)
class MuranoPackageManager(object):
class MuranoPackageManager(common_utils.RandomNameGeneratorMixin):
RESOURCE_NAME_FORMAT = "app.rally_XXXXXXXX_XXXXXXXX"
def __init__(self, task):
self.task = task
@staticmethod
def _read_from_file(filename):
@ -228,7 +232,7 @@ class MuranoPackageManager(object):
:param app_dir: path to directory with Murano application context
"""
new_fullname = common_utils.generate_random_name("app.")
new_fullname = self.generate_random_name()
manifest_file = os.path.join(app_dir, "manifest.yaml")
manifest = self._read_from_file(manifest_file)

View File

@ -106,7 +106,7 @@ class MuranoScenarioTestCase(test.ScenarioTestCase):
side_effect=mock.mock_open(read_data="Key: value"),
create=True)
def test_read_from_file(self, mock_open):
utility = utils.MuranoPackageManager()
utility = utils.MuranoPackageManager({"uuid": "fake_task_id"})
data = utility._read_from_file("filename")
expected_data = {"Key": "value"}
self.assertEqual(expected_data, data)
@ -120,7 +120,7 @@ class MuranoScenarioTestCase(test.ScenarioTestCase):
"Classes": {"app.name_abc": "app_class.yaml"}}
mock_murano_package_manager__read_from_file.side_effect = (
[manifest])
utility = utils.MuranoPackageManager()
utility = utils.MuranoPackageManager({"uuid": "fake_task_id"})
utility._change_app_fullname("tmp/tmpfile/")
mock_murano_package_manager__read_from_file.assert_has_calls(
[mock.call("tmp/tmpfile/manifest.yaml")]
@ -140,7 +140,7 @@ class MuranoScenarioTestCase(test.ScenarioTestCase):
mock_murano_package_manager__change_app_fullname,
mock_shutil_copytree, mock_tempfile_mkdtemp,
mock_zipfile_is_zipfile):
utility = utils.MuranoPackageManager()
utility = utils.MuranoPackageManager({"uuid": "fake_task_id"})
package_path = "tmp/tmpfile"
mock_zipfile_is_zipfile.return_value = False
@ -161,7 +161,7 @@ class MuranoScenarioTestCase(test.ScenarioTestCase):
@mock.patch("zipfile.is_zipfile")
def test_prepare_zip_if_zip(self, mock_zipfile_is_zipfile):
utility = utils.MuranoPackageManager()
utility = utils.MuranoPackageManager({"uuid": "fake_task_id"})
package_path = "tmp/tmpfile.zip"
mock_zipfile_is_zipfile.return_value = True
zip_file = utility._prepare_package(package_path)