Fix the wrong platform usage
As 'vm' is not proper for platform, we now used server_type to replace platfrom. As server_type can be vm or baremetal(bm) etc. Closes-Bug: #1473257 Change-Id: I9e769e73ba3ea48069f0e69c4a93240bb1fe6c63
This commit is contained in:
parent
fe0c382bfa
commit
8ec20a29f1
@ -93,13 +93,13 @@ Enabling a template is as simple as adding it's Entry Point to the
|
||||
(.venv)$ magnum-template-manage list-templates --details
|
||||
Enabled Templates
|
||||
example_template: /home/example/.venv/local/lib/python2.7/site-packages/ExampleTemplate-0.1-py2.7.egg/example_template/example.yaml
|
||||
Platform OS CoE
|
||||
vm example example_coe
|
||||
Server_Type OS CoE
|
||||
vm example example_coe
|
||||
magnum_vm_atomic_k8s: /home/example/.venv/local/lib/python2.7/site-packages/magnum/templates/heat-kubernetes/kubecluster.yaml
|
||||
Platform OS CoE
|
||||
Server_Type OS CoE
|
||||
vm fedora-atomic kubernetes
|
||||
magnum_vm_coreos_k8s: /home/example/.venv/local/lib/python2.7/site-packages/magnum/templates/heat-kubernetes/kubecluster-coreos.yaml
|
||||
Platform OS CoE
|
||||
vm coreos kubernetes
|
||||
Server_Type OS CoE
|
||||
vm coreos kubernetes
|
||||
Disabled Templates
|
||||
|
||||
|
@ -20,8 +20,8 @@ from magnum.conductor import template_definition
|
||||
|
||||
class ExampleTemplate(template_definition.BaseTemplateDefinition):
|
||||
provides = [
|
||||
{'platform': 'vm', 'os': 'example', 'coe': 'example_coe'},
|
||||
{'platform': 'vm', 'os': 'example2', 'coe': 'example_coe'},
|
||||
{'server_type': 'vm', 'os': 'example', 'coe': 'example_coe'},
|
||||
{'server_type': 'vm', 'os': 'example2', 'coe': 'example_coe'},
|
||||
]
|
||||
|
||||
def __init__(self):
|
||||
|
@ -33,8 +33,8 @@ def print_rows(rows):
|
||||
field_labels = ['Name', 'Enabled']
|
||||
|
||||
if CONF.command.details:
|
||||
fields.extend(['platform', 'os', 'coe'])
|
||||
field_labels.extend(['Platform', 'OS', 'COE'])
|
||||
fields.extend(['server_type', 'os', 'coe'])
|
||||
field_labels.extend(['Server_Type', 'OS', 'COE'])
|
||||
if CONF.command.paths:
|
||||
fields.append('path')
|
||||
field_labels.append('Template Path')
|
||||
|
@ -425,11 +425,13 @@ class NotSupported(MagnumException):
|
||||
|
||||
|
||||
class BayTypeNotSupported(MagnumException):
|
||||
message = _("Bay type (%(platform)s, %(os)s, %(coe)s) not supported.")
|
||||
message = _("Bay type (%(server_type)s, %(os)s, %(coe)s)"
|
||||
" not supported.")
|
||||
|
||||
|
||||
class BayTypeNotEnabled(MagnumException):
|
||||
message = _("Bay type (%(platform)s, %(os)s, %(coe)s) not enabled.")
|
||||
message = _("Bay type (%(server_type)s, %(os)s, %(coe)s)"
|
||||
" not enabled.")
|
||||
|
||||
|
||||
class RequiredParameterNotProvided(MagnumException):
|
||||
|
@ -172,12 +172,12 @@ class TemplateDefinition(object):
|
||||
With the following classes:
|
||||
class TemplateDefinition1(TemplateDefinition):
|
||||
provides = [
|
||||
('platform1', 'os1', 'coe1')
|
||||
('server_type1', 'os1', 'coe1')
|
||||
]
|
||||
|
||||
class TemplateDefinition2(TemplateDefinition):
|
||||
provides = [
|
||||
('platform2', 'os2', 'coe2')
|
||||
('server_type2', 'os2', 'coe2')
|
||||
]
|
||||
|
||||
And the following entry_points:
|
||||
@ -188,9 +188,9 @@ class TemplateDefinition(object):
|
||||
|
||||
get_template_definitions will return:
|
||||
{
|
||||
(platform1, os1, coe1):
|
||||
(server_type1, os1, coe1):
|
||||
{'template_name_1': TemplateDefinition1},
|
||||
(platform2, os2, coe2):
|
||||
(server_type2, os2, coe2):
|
||||
{'template_name_2': TemplateDefinition2}
|
||||
}
|
||||
|
||||
@ -201,7 +201,7 @@ class TemplateDefinition(object):
|
||||
cls.definitions = dict()
|
||||
for entry_point, def_class in cls.load_entry_points():
|
||||
for bay_type in def_class.provides:
|
||||
bay_type_tuple = (bay_type['platform'],
|
||||
bay_type_tuple = (bay_type['server_type'],
|
||||
bay_type['os'],
|
||||
bay_type['coe'])
|
||||
providers = cls.definitions.setdefault(bay_type_tuple,
|
||||
@ -211,19 +211,19 @@ class TemplateDefinition(object):
|
||||
return cls.definitions
|
||||
|
||||
@classmethod
|
||||
def get_template_definition(cls, platform, os, coe):
|
||||
def get_template_definition(cls, server_type, os, coe):
|
||||
'''Returns the enabled TemplateDefinition class for the provided
|
||||
bay_type.
|
||||
|
||||
With the following classes:
|
||||
class TemplateDefinition1(TemplateDefinition):
|
||||
provides = [
|
||||
('platform1', 'os1', 'coe1')
|
||||
('server_type1', 'os1', 'coe1')
|
||||
]
|
||||
|
||||
class TemplateDefinition2(TemplateDefinition):
|
||||
provides = [
|
||||
('platform2', 'os2', 'coe2')
|
||||
('server_type2', 'os2', 'coe2')
|
||||
]
|
||||
|
||||
And the following entry_points:
|
||||
@ -232,10 +232,11 @@ class TemplateDefinition(object):
|
||||
template_name_1 = some.python.path:TemplateDefinition1
|
||||
template_name_2 = some.python.path:TemplateDefinition2
|
||||
|
||||
get_template_name_1_definition('platform2', 'os2', 'coe2')
|
||||
get_template_name_1_definition('server_type2', 'os2', 'coe2')
|
||||
will return: TemplateDefinition2
|
||||
|
||||
:param platform: The platform the bay definition will build on
|
||||
:param server_type: The server_type the bay definition
|
||||
will build on
|
||||
:param os: The operation system the bay definition will build on
|
||||
:param coe: The Container Orchestration Environment the bay will
|
||||
produce
|
||||
@ -244,18 +245,21 @@ class TemplateDefinition(object):
|
||||
'''
|
||||
|
||||
definition_map = cls.get_template_definitions()
|
||||
bay_type = (platform, os, coe)
|
||||
bay_type = (server_type, os, coe)
|
||||
|
||||
if bay_type not in definition_map:
|
||||
raise exception.BayTypeNotSupported(platform=platform, os=os,
|
||||
coe=coe)
|
||||
raise exception.BayTypeNotSupported(
|
||||
server_type=server_type,
|
||||
os=os,
|
||||
coe=coe)
|
||||
type_definitions = definition_map[bay_type]
|
||||
|
||||
for name in cfg.CONF.bay.enabled_definitions:
|
||||
if name in type_definitions:
|
||||
return type_definitions[name]()
|
||||
|
||||
raise exception.BayTypeNotEnabled(platform=platform, os=os, coe=coe)
|
||||
raise exception.BayTypeNotEnabled(
|
||||
server_type=server_type, os=os, coe=coe)
|
||||
|
||||
def add_parameter(self, *args, **kwargs):
|
||||
param = ParameterMapping(*args, **kwargs)
|
||||
@ -323,7 +327,9 @@ class BaseTemplateDefinition(TemplateDefinition):
|
||||
|
||||
class AtomicK8sTemplateDefinition(BaseTemplateDefinition):
|
||||
provides = [
|
||||
{'platform': 'vm', 'os': 'fedora-atomic', 'coe': 'kubernetes'},
|
||||
{'server_type': 'vm',
|
||||
'os': 'fedora-atomic',
|
||||
'coe': 'kubernetes'},
|
||||
]
|
||||
|
||||
def __init__(self):
|
||||
@ -371,7 +377,7 @@ class AtomicK8sTemplateDefinition(BaseTemplateDefinition):
|
||||
|
||||
class CoreOSK8sTemplateDefinition(AtomicK8sTemplateDefinition):
|
||||
provides = [
|
||||
{'platform': 'vm', 'os': 'coreos', 'coe': 'kubernetes'},
|
||||
{'server_type': 'vm', 'os': 'coreos', 'coe': 'kubernetes'},
|
||||
]
|
||||
|
||||
def __init__(self):
|
||||
@ -404,7 +410,7 @@ class CoreOSK8sTemplateDefinition(AtomicK8sTemplateDefinition):
|
||||
|
||||
class AtomicSwarmTemplateDefinition(BaseTemplateDefinition):
|
||||
provides = [
|
||||
{'platform': 'vm', 'os': 'fedora-atomic', 'coe': 'swarm'},
|
||||
{'server_type': 'vm', 'os': 'fedora-atomic', 'coe': 'swarm'},
|
||||
]
|
||||
|
||||
def __init__(self):
|
||||
@ -460,7 +466,7 @@ class AtomicSwarmTemplateDefinition(BaseTemplateDefinition):
|
||||
|
||||
class UbuntuMesosTemplateDefinition(BaseTemplateDefinition):
|
||||
provides = [
|
||||
{'platform': 'vm', 'os': 'ubuntu', 'coe': 'mesos'},
|
||||
{'server_type': 'vm', 'os': 'ubuntu', 'coe': 'mesos'},
|
||||
]
|
||||
|
||||
def __init__(self):
|
||||
|
Loading…
Reference in New Issue
Block a user