Rally: get the correct IMAGE_NAME from cirros_img_url
Current the statement which retrieves IMAGE_NAME from cirros_img_url is located in global place. So it's done before loading the configuration file. Closes-Bug: #1530075 Change-Id: Ida75010fd3bf2cb6286390736ecd56567340de74
This commit is contained in:
parent
31c066464a
commit
fb49811bbf
|
@ -68,8 +68,6 @@ CONF = cfg.CONF
|
|||
CONF.register_opts(IMAGE_OPTS, "image")
|
||||
CONF.register_opts(ROLE_OPTS, "role")
|
||||
|
||||
IMAGE_NAME = parse.urlparse(CONF.image.cirros_img_url).path.split("/")[-1]
|
||||
|
||||
|
||||
def _create_or_get_data_dir():
|
||||
data_dir = os.path.join(
|
||||
|
@ -100,11 +98,13 @@ class TempestConfig(utils.RandomNameGeneratorMixin):
|
|||
|
||||
self.conf = configparser.ConfigParser()
|
||||
self.conf.read(os.path.join(os.path.dirname(__file__), "config.ini"))
|
||||
self.image_name = parse.urlparse(
|
||||
CONF.image.cirros_img_url).path.split("/")[-1]
|
||||
|
||||
self._download_cirros_image()
|
||||
|
||||
def _download_cirros_image(self):
|
||||
img_path = os.path.join(self.data_dir, IMAGE_NAME)
|
||||
img_path = os.path.join(self.data_dir, self.image_name)
|
||||
if os.path.isfile(img_path):
|
||||
return
|
||||
|
||||
|
@ -242,7 +242,7 @@ class TempestConfig(utils.RandomNameGeneratorMixin):
|
|||
|
||||
def _configure_scenario(self, section_name="scenario"):
|
||||
self.conf.set(section_name, "img_dir", self.data_dir)
|
||||
self.conf.set(section_name, "img_file", IMAGE_NAME)
|
||||
self.conf.set(section_name, "img_file", self.image_name)
|
||||
|
||||
def _configure_service_available(self, section_name="service_available"):
|
||||
services = ["ceilometer", "cinder", "glance",
|
||||
|
@ -299,6 +299,8 @@ class TempestResourcesContext(object):
|
|||
self.conf_path = conf_path
|
||||
self.conf = configparser.ConfigParser()
|
||||
self.conf.read(conf_path)
|
||||
self.image_name = parse.urlparse(
|
||||
CONF.image.cirros_img_url).path.split("/")[-1]
|
||||
|
||||
self._created_roles = []
|
||||
self._created_images = []
|
||||
|
@ -389,7 +391,7 @@ class TempestResourcesContext(object):
|
|||
image = glanceclient.images.create(**params)
|
||||
self._created_images.append(image)
|
||||
image.update(data=open(
|
||||
os.path.join(_create_or_get_data_dir(), IMAGE_NAME), "rb"))
|
||||
os.path.join(_create_or_get_data_dir(), self.image_name), "rb"))
|
||||
|
||||
return image
|
||||
|
||||
|
|
|
@ -242,8 +242,10 @@ class TempestConfigTestCase(test.TestCase):
|
|||
def test__configure_scenario(self):
|
||||
self.tempest_conf._configure_scenario()
|
||||
|
||||
image_name = parse.urlparse(
|
||||
config.CONF.image.cirros_img_url).path.split("/")[-1]
|
||||
expected = (("img_dir", self.tempest_conf.data_dir),
|
||||
("img_file", config.IMAGE_NAME))
|
||||
("img_file", image_name))
|
||||
result = self.tempest_conf.conf.items("scenario")
|
||||
for item in expected:
|
||||
self.assertIn(item, result)
|
||||
|
|
Loading…
Reference in New Issue