blob: 783f99786b0230a7a7a38c7ea56171897ef13fe0 [file] [log] [blame]
import base_section
from runtest import conditions
MICROVERSION_RELEASE_MAPPING = {
'queens':
{
'min_microversion': '2.1',
'max_microversion': '2.60'
},
'pike':
{
'min_microversion': '2.1',
'max_microversion': '2.53'
},
'ocata':
{
'min_microversion': '2.1',
'max_microversion': '2.42'
},
'newton':
{
'min_microversion': '2.1',
'max_microversion': '2.42'
},
'mitaka':
{
'min_microversion': '2.1',
'max_microversion': '2.42'
}
}
class Compute(base_section.BaseSection):
name = "compute"
options = [
'build_interval',
'build_timeout',
'catalog_type',
'endpoint_type',
'fixed_network_name',
'flavor_ref',
'flavor_ref_alt',
'hypervisor_type',
'image_ref',
'image_ref_alt',
'max_microversion',
'min_compute_nodes',
'min_microversion',
'ready_wait',
'region',
'shelved_offload_time',
'volume_device_name',
]
@property
def build_interval(self):
pass
@property
def build_timeout(self):
pass
@property
def catalog_type(self):
pass
@property
def endpoint_type(self):
pass
@property
def fixed_network_name(self):
pass
@property
def flavor_ref(self):
c = conditions.BaseRule(field='keystone.client.enabled', op='eq',
val=True)
nodes = self.get_nodes_where_condition_match(c)
flavor_name = self.runtest_opts.get('convert_to_uuid', {}).get(
'compute', {}).get('flavor_ref')
if not flavor_name:
return
keystone_profile_admin = self.runtest_opts.get('keystone_profile_admin', {})
res = self.authenticated_openstack_module_call(
nodes[0], 'novang.flavor_list', profile=keystone_profile_admin)[nodes[0]]
if flavor_name in res:
return res[flavor_name]['id']
@property
def flavor_ref_alt(self):
c = conditions.BaseRule(field='keystone.client.enabled', op='eq',
val=True)
nodes = self.get_nodes_where_condition_match(c)
flavor_name = self.runtest_opts.get('convert_to_uuid', {}).get(
'compute', {}).get('flavor_ref_alt')
if not flavor_name:
return
keystone_profile_admin = self.runtest_opts.get('keystone_profile_admin', {})
res = self.authenticated_openstack_module_call(
nodes[0], 'novang.flavor_list', profile=keystone_profile_admin)[nodes[0]]
if flavor_name in res:
return res[flavor_name]['id']
@property
def hypervisor_type(self):
pass
@property
def image_ref(self):
c = conditions.BaseRule(field='keystone.client.enabled', op='eq',
val=True)
nodes = self.get_nodes_where_condition_match(c)
image_name = self.runtest_opts.get('convert_to_uuid', {}).get(
'compute', {}).get('image_ref')
if not image_name:
return
keystone_profile_admin = self.runtest_opts.get('keystone_profile_admin', {})
res = self.authenticated_openstack_module_call(
nodes[0], 'glanceng.image_list', profile=keystone_profile_admin)[nodes[0]]
images = [n['id'] for n in res if n['name'] == image_name]
if len(images) != 1:
raise Exception("Error getting images: {}".format(images))
return images[0]
@property
def image_ref_alt(self):
c = conditions.BaseRule(field='keystone.client.enabled', op='eq',
val=True)
nodes = self.get_nodes_where_condition_match(c)
image_name = self.runtest_opts.get('convert_to_uuid', {}).get(
'compute', {}).get('image_ref_alt')
if not image_name:
return
keystone_profile_admin = self.runtest_opts.get('keystone_profile_admin', {})
res = self.authenticated_openstack_module_call(
nodes[0], 'glanceng.image_list', profile=keystone_profile_admin)[nodes[0]]
images = [n['id'] for n in res if n['name'] == image_name]
if len(images) != 1:
raise Exception("Error getting images: {}".format(images))
return images[0]
@property
def max_microversion(self):
c = conditions.BaseRule('nova.controller.enabled', 'eq', True)
nova_version = self.get_item_when_condition_match('nova.controller.version', c)
if nova_version and nova_version in MICROVERSION_RELEASE_MAPPING:
return MICROVERSION_RELEASE_MAPPING[nova_version]['max_microversion']
@property
def min_compute_nodes(self):
c = conditions.BaseRule(field='nova.compute.enabled', op='eq',
val=True)
nodes = self.get_nodes_where_condition_match(c)
return len(nodes)
@property
def min_microversion(self):
c = conditions.BaseRule('nova.controller.enabled', 'eq', True)
nova_version = self.get_item_when_condition_match('nova.controller.version', c)
if nova_version and nova_version in MICROVERSION_RELEASE_MAPPING:
return MICROVERSION_RELEASE_MAPPING[nova_version]['min_microversion']
@property
def ready_wait(self):
pass
@property
def region(self):
pass
@property
def shelved_offload_time(self):
pass
@property
def volume_device_name(self):
c = conditions.BaseRule('nova.compute.enabled', 'eq', True)
force = self.get_item_when_condition_match('nova.compute.config_drive.forced', c)
# NOTE(mshalamov): implicit default in nova-compute.conf template in nova salt formula
# for nova.compute.config_drive.forced is 'true'
if force is None or force is True:
return 'vdc'