Mesos-Ubuntu bay driver implementation
Moves templates and template_definitions to the new directory structure. Change-Id: I42e4d2bd056f3d8082ef51ef599d917f2fe82960 Paritially-Implements: blueprint bay-drivers
This commit is contained in:
parent
cb99c64614
commit
242cbe00da
@ -40,11 +40,6 @@ template_def_opts = [
|
||||
cfg.StrOpt('etcd_discovery_service_endpoint_format',
|
||||
default='https://discovery.etcd.io/new?size=%(size)d',
|
||||
help=_('Url for etcd public discovery endpoint.')),
|
||||
cfg.StrOpt('mesos_ubuntu_template_path',
|
||||
default=paths.basedir_def('templates/mesos/'
|
||||
'mesoscluster.yaml'),
|
||||
help=_('Location of template to build a Mesos cluster '
|
||||
'on Ubuntu.')),
|
||||
cfg.ListOpt('enabled_definitions',
|
||||
default=['magnum_vm_atomic_k8s', 'magnum_vm_coreos_k8s',
|
||||
'magnum_vm_atomic_swarm', 'magnum_vm_ubuntu_mesos'],
|
||||
@ -206,73 +201,3 @@ class CoreOSK8sTemplateDefinition(K8sTemplateDefinition):
|
||||
@property
|
||||
def template_path(self):
|
||||
return cfg.CONF.bay.k8s_coreos_template_path
|
||||
|
||||
|
||||
class UbuntuMesosTemplateDefinition(template_def.BaseTemplateDefinition):
|
||||
"""Mesos template for Ubuntu VM."""
|
||||
|
||||
provides = [
|
||||
{'server_type': 'vm', 'os': 'ubuntu', 'coe': 'mesos'},
|
||||
]
|
||||
|
||||
def __init__(self):
|
||||
super(UbuntuMesosTemplateDefinition, self).__init__()
|
||||
self.add_parameter('external_network',
|
||||
baymodel_attr='external_network_id',
|
||||
required=True)
|
||||
self.add_parameter('number_of_slaves',
|
||||
bay_attr='node_count')
|
||||
self.add_parameter('master_flavor',
|
||||
baymodel_attr='master_flavor_id')
|
||||
self.add_parameter('slave_flavor',
|
||||
baymodel_attr='flavor_id')
|
||||
self.add_parameter('cluster_name',
|
||||
bay_attr='name')
|
||||
self.add_parameter('volume_driver',
|
||||
baymodel_attr='volume_driver')
|
||||
|
||||
self.add_output('api_address',
|
||||
bay_attr='api_address')
|
||||
self.add_output('mesos_master_private',
|
||||
bay_attr=None)
|
||||
self.add_output('mesos_master',
|
||||
bay_attr='master_addresses')
|
||||
self.add_output('mesos_slaves_private',
|
||||
bay_attr=None)
|
||||
self.add_output('mesos_slaves',
|
||||
bay_attr='node_addresses')
|
||||
|
||||
def get_params(self, context, baymodel, bay, **kwargs):
|
||||
extra_params = kwargs.pop('extra_params', {})
|
||||
# HACK(apmelton) - This uses the user's bearer token, ideally
|
||||
# it should be replaced with an actual trust token with only
|
||||
# access to do what the template needs it to do.
|
||||
osc = self.get_osc(context)
|
||||
extra_params['auth_url'] = context.auth_url
|
||||
extra_params['username'] = context.user_name
|
||||
extra_params['tenant_name'] = context.tenant
|
||||
extra_params['domain_name'] = context.domain_name
|
||||
extra_params['region_name'] = osc.cinder_region_name()
|
||||
|
||||
label_list = ['rexray_preempt', 'mesos_slave_isolation',
|
||||
'mesos_slave_image_providers',
|
||||
'mesos_slave_work_dir',
|
||||
'mesos_slave_executor_env_variables']
|
||||
|
||||
for label in label_list:
|
||||
extra_params[label] = baymodel.labels.get(label)
|
||||
|
||||
scale_mgr = kwargs.pop('scale_manager', None)
|
||||
if scale_mgr:
|
||||
hosts = self.get_output('mesos_slaves_private')
|
||||
extra_params['slaves_to_remove'] = (
|
||||
scale_mgr.get_removal_nodes(hosts))
|
||||
|
||||
return super(UbuntuMesosTemplateDefinition,
|
||||
self).get_params(context, baymodel, bay,
|
||||
extra_params=extra_params,
|
||||
**kwargs)
|
||||
|
||||
@property
|
||||
def template_path(self):
|
||||
return cfg.CONF.bay.mesos_ubuntu_template_path
|
||||
|
@ -48,11 +48,6 @@ template_def_opts = [
|
||||
cfg.StrOpt('etcd_discovery_service_endpoint_format',
|
||||
default='https://discovery.etcd.io/new?size=%(size)d',
|
||||
help=_('Url for etcd public discovery endpoint.')),
|
||||
cfg.StrOpt('mesos_ubuntu_template_path',
|
||||
default=paths.basedir_def('templates/mesos/'
|
||||
'mesoscluster.yaml'),
|
||||
help=_('Location of template to build a Mesos cluster '
|
||||
'on Ubuntu.')),
|
||||
cfg.ListOpt('enabled_definitions',
|
||||
default=['magnum_vm_atomic_k8s', 'magnum_vm_coreos_k8s',
|
||||
'magnum_vm_atomic_swarm', 'magnum_vm_ubuntu_mesos'],
|
||||
|
0
magnum/drivers/mesos_ubuntu_v1/__init__.py
Normal file
0
magnum/drivers/mesos_ubuntu_v1/__init__.py
Normal file
87
magnum/drivers/mesos_ubuntu_v1/template_def.py
Normal file
87
magnum/drivers/mesos_ubuntu_v1/template_def.py
Normal file
@ -0,0 +1,87 @@
|
||||
# Copyright 2016 Rackspace Inc. All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
import os
|
||||
|
||||
from magnum.drivers.common import template_def
|
||||
|
||||
|
||||
class UbuntuMesosTemplateDefinition(template_def.BaseTemplateDefinition):
|
||||
"""Mesos template for Ubuntu VM."""
|
||||
|
||||
provides = [
|
||||
{'server_type': 'vm', 'os': 'ubuntu', 'coe': 'mesos'},
|
||||
]
|
||||
|
||||
def __init__(self):
|
||||
super(UbuntuMesosTemplateDefinition, self).__init__()
|
||||
self.add_parameter('external_network',
|
||||
baymodel_attr='external_network_id',
|
||||
required=True)
|
||||
self.add_parameter('number_of_slaves',
|
||||
bay_attr='node_count')
|
||||
self.add_parameter('master_flavor',
|
||||
baymodel_attr='master_flavor_id')
|
||||
self.add_parameter('slave_flavor',
|
||||
baymodel_attr='flavor_id')
|
||||
self.add_parameter('cluster_name',
|
||||
bay_attr='name')
|
||||
self.add_parameter('volume_driver',
|
||||
baymodel_attr='volume_driver')
|
||||
|
||||
self.add_output('api_address',
|
||||
bay_attr='api_address')
|
||||
self.add_output('mesos_master_private',
|
||||
bay_attr=None)
|
||||
self.add_output('mesos_master',
|
||||
bay_attr='master_addresses')
|
||||
self.add_output('mesos_slaves_private',
|
||||
bay_attr=None)
|
||||
self.add_output('mesos_slaves',
|
||||
bay_attr='node_addresses')
|
||||
|
||||
def get_params(self, context, baymodel, bay, **kwargs):
|
||||
extra_params = kwargs.pop('extra_params', {})
|
||||
# HACK(apmelton) - This uses the user's bearer token, ideally
|
||||
# it should be replaced with an actual trust token with only
|
||||
# access to do what the template needs it to do.
|
||||
osc = self.get_osc(context)
|
||||
extra_params['auth_url'] = context.auth_url
|
||||
extra_params['username'] = context.user_name
|
||||
extra_params['tenant_name'] = context.tenant
|
||||
extra_params['domain_name'] = context.domain_name
|
||||
extra_params['region_name'] = osc.cinder_region_name()
|
||||
|
||||
label_list = ['rexray_preempt', 'mesos_slave_isolation',
|
||||
'mesos_slave_image_providers',
|
||||
'mesos_slave_work_dir',
|
||||
'mesos_slave_executor_env_variables']
|
||||
|
||||
for label in label_list:
|
||||
extra_params[label] = baymodel.labels.get(label)
|
||||
|
||||
scale_mgr = kwargs.pop('scale_manager', None)
|
||||
if scale_mgr:
|
||||
hosts = self.get_output('mesos_slaves_private')
|
||||
extra_params['slaves_to_remove'] = (
|
||||
scale_mgr.get_removal_nodes(hosts))
|
||||
|
||||
return super(UbuntuMesosTemplateDefinition,
|
||||
self).get_params(context, baymodel, bay,
|
||||
extra_params=extra_params,
|
||||
**kwargs)
|
||||
|
||||
@property
|
||||
def template_path(self):
|
||||
return os.path.join(os.path.dirname(os.path.realpath(__file__)),
|
||||
'templates/mesoscluster.yaml')
|
@ -18,6 +18,7 @@ from oslo_config import cfg
|
||||
from magnum.common import exception
|
||||
from magnum.conductor import template_definition as tdef
|
||||
from magnum.drivers.common import template_def as cmn_tdef
|
||||
from magnum.drivers.mesos_ubuntu_v1 import template_def as mesos_tdef
|
||||
from magnum.drivers.swarm_fedora_atomic_v1 import template_def as swarm_tdef
|
||||
from magnum.tests import base
|
||||
|
||||
@ -87,7 +88,7 @@ class TemplateDefinitionTestCase(base.TestCase):
|
||||
'mesos')
|
||||
|
||||
self.assertIsInstance(definition,
|
||||
tdef.UbuntuMesosTemplateDefinition)
|
||||
mesos_tdef.UbuntuMesosTemplateDefinition)
|
||||
|
||||
def test_get_definition_not_supported(self):
|
||||
self.assertRaises(exception.BayTypeNotSupported,
|
||||
@ -680,7 +681,7 @@ class UbuntuMesosTemplateDefinitionTestCase(base.TestCase):
|
||||
mock_scale_manager = mock.MagicMock()
|
||||
mock_scale_manager.get_removal_nodes.return_value = removal_nodes
|
||||
|
||||
mesos_def = tdef.UbuntuMesosTemplateDefinition()
|
||||
mesos_def = mesos_tdef.UbuntuMesosTemplateDefinition()
|
||||
|
||||
mesos_def.get_params(mock_context, mock_baymodel, mock_bay,
|
||||
scale_manager=mock_scale_manager)
|
||||
@ -702,7 +703,7 @@ class UbuntuMesosTemplateDefinitionTestCase(base.TestCase):
|
||||
mock_bay, **expected_kwargs)
|
||||
|
||||
def test_mesos_get_heat_param(self):
|
||||
mesos_def = tdef.UbuntuMesosTemplateDefinition()
|
||||
mesos_def = mesos_tdef.UbuntuMesosTemplateDefinition()
|
||||
|
||||
heat_param = mesos_def.get_heat_param(bay_attr='node_count')
|
||||
self.assertEqual('number_of_slaves', heat_param)
|
||||
@ -711,7 +712,7 @@ class UbuntuMesosTemplateDefinitionTestCase(base.TestCase):
|
||||
self.assertEqual('number_of_masters', heat_param)
|
||||
|
||||
def test_update_outputs(self):
|
||||
mesos_def = tdef.UbuntuMesosTemplateDefinition()
|
||||
mesos_def = mesos_tdef.UbuntuMesosTemplateDefinition()
|
||||
|
||||
expected_api_address = 'updated_address'
|
||||
expected_node_addresses = ['ex_slave', 'address']
|
||||
|
@ -59,7 +59,7 @@ magnum.template_definitions =
|
||||
magnum_vm_atomic_k8s = magnum.conductor.template_definition:AtomicK8sTemplateDefinition
|
||||
magnum_vm_coreos_k8s = magnum.conductor.template_definition:CoreOSK8sTemplateDefinition
|
||||
magnum_vm_atomic_swarm = magnum.drivers.swarm_fedora_atomic_v1.template_def:AtomicSwarmTemplateDefinition
|
||||
magnum_vm_ubuntu_mesos = magnum.conductor.template_definition:UbuntuMesosTemplateDefinition
|
||||
magnum_vm_ubuntu_mesos = magnum.drivers.mesos_ubuntu_v1.template_def:UbuntuMesosTemplateDefinition
|
||||
|
||||
magnum.database.migration_backend =
|
||||
sqlalchemy = magnum.db.sqlalchemy.migration
|
||||
|
Loading…
Reference in New Issue
Block a user