9d037f7d19
At present various users of instance.image_meta expect it to be a fully populated ImageMeta object. However when the instance is pulled from the database the ImageMeta object is only partially populated via instance.system_metadata with a limited set of attributes such as min_ram, min_disk, disk_format and container_format. This can result in NotImplementedErrors being raised by o.vo as seen in bug #1928063 when an attempt is made to access common attributes such as id or name. To avoid this the id is now provided by instance.image_ref when available. The majority of the change is test fallout and ensuring that valid UUIDs are provided as instance.image_ref and used by instance.image_meta. Related-Bug: #1928063 Change-Id: I55d66c3a6cbd50da90065f4a58f77b5cd29ce9ea
87 lines
2.5 KiB
Python
87 lines
2.5 KiB
Python
# Copyright 2014 IBM Corp.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
from nova import objects
|
|
from nova import test
|
|
from nova.virt import configdrive
|
|
|
|
|
|
class ConfigDriveTestCase(test.NoDBTestCase):
|
|
def test_instance_force(self):
|
|
self.flags(force_config_drive=False)
|
|
|
|
instance = objects.Instance(
|
|
config_drive="yes",
|
|
image_ref='',
|
|
system_metadata={
|
|
"image_img_config_drive": "mandatory",
|
|
}
|
|
)
|
|
|
|
self.assertTrue(configdrive.required_by(instance))
|
|
|
|
def test_image_meta_force(self):
|
|
self.flags(force_config_drive=False)
|
|
|
|
instance = objects.Instance(
|
|
image_ref='',
|
|
config_drive=None,
|
|
system_metadata={
|
|
"image_img_config_drive": "mandatory",
|
|
}
|
|
)
|
|
|
|
self.assertTrue(configdrive.required_by(instance))
|
|
|
|
def test_config_flag_force_for_new_vms(self):
|
|
self.flags(force_config_drive=True)
|
|
|
|
instance = objects.Instance(
|
|
image_ref='',
|
|
config_drive=None,
|
|
launched_at=None,
|
|
system_metadata={
|
|
"image_img_config_drive": "optional",
|
|
}
|
|
)
|
|
|
|
self.assertTrue(configdrive.required_by(instance))
|
|
|
|
def test_config_flag_force_for_existing_vms(self):
|
|
self.flags(force_config_drive=True)
|
|
|
|
instance = objects.Instance(
|
|
image_ref='',
|
|
config_drive=None,
|
|
launched_at='2019-05-17T00:00:00.000000',
|
|
system_metadata={
|
|
"image_img_config_drive": "optional",
|
|
}
|
|
)
|
|
|
|
self.assertFalse(configdrive.required_by(instance))
|
|
|
|
def test_no_config_drive(self):
|
|
self.flags(force_config_drive=False)
|
|
|
|
instance = objects.Instance(
|
|
image_ref='',
|
|
config_drive=None,
|
|
system_metadata={
|
|
"image_img_config_drive": "optional",
|
|
}
|
|
)
|
|
|
|
self.assertFalse(configdrive.required_by(instance))
|