Browse Source

Mesos-Ubuntu bay driver implementation

Moves templates and template_definitions to the new
directory structure.

Change-Id: I42e4d2bd056f3d8082ef51ef599d917f2fe82960
Paritially-Implements: blueprint bay-drivers
tags/3.0.0
Spyros Trigazis 2 years ago
parent
commit
242cbe00da
29 changed files with 93 additions and 85 deletions
  1. 0
    75
      magnum/conductor/template_definition.py
  2. 0
    5
      magnum/drivers/common/template_def.py
  3. 0
    0
      magnum/drivers/mesos_ubuntu_v1/COPYING
  4. 0
    0
      magnum/drivers/mesos_ubuntu_v1/README.md
  5. 0
    0
      magnum/drivers/mesos_ubuntu_v1/__init__.py
  6. 0
    0
      magnum/drivers/mesos_ubuntu_v1/image/Dockerfile
  7. 0
    0
      magnum/drivers/mesos_ubuntu_v1/image/README.md
  8. 0
    0
      magnum/drivers/mesos_ubuntu_v1/image/docker/elements-deps
  9. 0
    0
      magnum/drivers/mesos_ubuntu_v1/image/docker/package-installs.yaml
  10. 0
    0
      magnum/drivers/mesos_ubuntu_v1/image/docker/post-install.d/60-disable-docker-service
  11. 0
    0
      magnum/drivers/mesos_ubuntu_v1/image/docker/pre-install.d/10-add-docker-repo
  12. 0
    0
      magnum/drivers/mesos_ubuntu_v1/image/mesos/elements-deps
  13. 0
    0
      magnum/drivers/mesos_ubuntu_v1/image/mesos/package-installs.yaml
  14. 0
    0
      magnum/drivers/mesos_ubuntu_v1/image/mesos/post-install.d/60-disable-upstart
  15. 0
    0
      magnum/drivers/mesos_ubuntu_v1/image/mesos/pre-install.d/10-apt-repo
  16. 87
    0
      magnum/drivers/mesos_ubuntu_v1/template_def.py
  17. 0
    0
      magnum/drivers/mesos_ubuntu_v1/templates/fragments/add-proxy.sh
  18. 0
    0
      magnum/drivers/mesos_ubuntu_v1/templates/fragments/configure-mesos-master.sh
  19. 0
    0
      magnum/drivers/mesos_ubuntu_v1/templates/fragments/configure-mesos-slave.sh
  20. 0
    0
      magnum/drivers/mesos_ubuntu_v1/templates/fragments/start-services-master.sh
  21. 0
    0
      magnum/drivers/mesos_ubuntu_v1/templates/fragments/start-services-slave.sh
  22. 0
    0
      magnum/drivers/mesos_ubuntu_v1/templates/fragments/volume-service.sh
  23. 0
    0
      magnum/drivers/mesos_ubuntu_v1/templates/fragments/write-heat-params-master.sh
  24. 0
    0
      magnum/drivers/mesos_ubuntu_v1/templates/fragments/write-heat-params.yaml
  25. 0
    0
      magnum/drivers/mesos_ubuntu_v1/templates/mesoscluster.yaml
  26. 0
    0
      magnum/drivers/mesos_ubuntu_v1/templates/mesosmaster.yaml
  27. 0
    0
      magnum/drivers/mesos_ubuntu_v1/templates/mesosslave.yaml
  28. 5
    4
      magnum/tests/unit/conductor/test_template_definition.py
  29. 1
    1
      setup.cfg

+ 0
- 75
magnum/conductor/template_definition.py View File

@@ -40,11 +40,6 @@ template_def_opts = [
40 40
     cfg.StrOpt('etcd_discovery_service_endpoint_format',
41 41
                default='https://discovery.etcd.io/new?size=%(size)d',
42 42
                help=_('Url for etcd public discovery endpoint.')),
43
-    cfg.StrOpt('mesos_ubuntu_template_path',
44
-               default=paths.basedir_def('templates/mesos/'
45
-                                         'mesoscluster.yaml'),
46
-               help=_('Location of template to build a Mesos cluster '
47
-                      'on Ubuntu.')),
48 43
     cfg.ListOpt('enabled_definitions',
49 44
                 default=['magnum_vm_atomic_k8s', 'magnum_vm_coreos_k8s',
50 45
                          'magnum_vm_atomic_swarm', 'magnum_vm_ubuntu_mesos'],
@@ -206,73 +201,3 @@ class CoreOSK8sTemplateDefinition(K8sTemplateDefinition):
206 201
     @property
207 202
     def template_path(self):
208 203
         return cfg.CONF.bay.k8s_coreos_template_path
209
-
210
-
211
-class UbuntuMesosTemplateDefinition(template_def.BaseTemplateDefinition):
212
-    """Mesos template for Ubuntu VM."""
213
-
214
-    provides = [
215
-        {'server_type': 'vm', 'os': 'ubuntu', 'coe': 'mesos'},
216
-    ]
217
-
218
-    def __init__(self):
219
-        super(UbuntuMesosTemplateDefinition, self).__init__()
220
-        self.add_parameter('external_network',
221
-                           baymodel_attr='external_network_id',
222
-                           required=True)
223
-        self.add_parameter('number_of_slaves',
224
-                           bay_attr='node_count')
225
-        self.add_parameter('master_flavor',
226
-                           baymodel_attr='master_flavor_id')
227
-        self.add_parameter('slave_flavor',
228
-                           baymodel_attr='flavor_id')
229
-        self.add_parameter('cluster_name',
230
-                           bay_attr='name')
231
-        self.add_parameter('volume_driver',
232
-                           baymodel_attr='volume_driver')
233
-
234
-        self.add_output('api_address',
235
-                        bay_attr='api_address')
236
-        self.add_output('mesos_master_private',
237
-                        bay_attr=None)
238
-        self.add_output('mesos_master',
239
-                        bay_attr='master_addresses')
240
-        self.add_output('mesos_slaves_private',
241
-                        bay_attr=None)
242
-        self.add_output('mesos_slaves',
243
-                        bay_attr='node_addresses')
244
-
245
-    def get_params(self, context, baymodel, bay, **kwargs):
246
-        extra_params = kwargs.pop('extra_params', {})
247
-        # HACK(apmelton) - This uses the user's bearer token, ideally
248
-        # it should be replaced with an actual trust token with only
249
-        # access to do what the template needs it to do.
250
-        osc = self.get_osc(context)
251
-        extra_params['auth_url'] = context.auth_url
252
-        extra_params['username'] = context.user_name
253
-        extra_params['tenant_name'] = context.tenant
254
-        extra_params['domain_name'] = context.domain_name
255
-        extra_params['region_name'] = osc.cinder_region_name()
256
-
257
-        label_list = ['rexray_preempt', 'mesos_slave_isolation',
258
-                      'mesos_slave_image_providers',
259
-                      'mesos_slave_work_dir',
260
-                      'mesos_slave_executor_env_variables']
261
-
262
-        for label in label_list:
263
-            extra_params[label] = baymodel.labels.get(label)
264
-
265
-        scale_mgr = kwargs.pop('scale_manager', None)
266
-        if scale_mgr:
267
-            hosts = self.get_output('mesos_slaves_private')
268
-            extra_params['slaves_to_remove'] = (
269
-                scale_mgr.get_removal_nodes(hosts))
270
-
271
-        return super(UbuntuMesosTemplateDefinition,
272
-                     self).get_params(context, baymodel, bay,
273
-                                      extra_params=extra_params,
274
-                                      **kwargs)
275
-
276
-    @property
277
-    def template_path(self):
278
-        return cfg.CONF.bay.mesos_ubuntu_template_path

+ 0
- 5
magnum/drivers/common/template_def.py View File

@@ -48,11 +48,6 @@ template_def_opts = [
48 48
     cfg.StrOpt('etcd_discovery_service_endpoint_format',
49 49
                default='https://discovery.etcd.io/new?size=%(size)d',
50 50
                help=_('Url for etcd public discovery endpoint.')),
51
-    cfg.StrOpt('mesos_ubuntu_template_path',
52
-               default=paths.basedir_def('templates/mesos/'
53
-                                         'mesoscluster.yaml'),
54
-               help=_('Location of template to build a Mesos cluster '
55
-                      'on Ubuntu.')),
56 51
     cfg.ListOpt('enabled_definitions',
57 52
                 default=['magnum_vm_atomic_k8s', 'magnum_vm_coreos_k8s',
58 53
                          'magnum_vm_atomic_swarm', 'magnum_vm_ubuntu_mesos'],

magnum/templates/mesos/COPYING → magnum/drivers/mesos_ubuntu_v1/COPYING View File


magnum/templates/mesos/README.md → magnum/drivers/mesos_ubuntu_v1/README.md View File


+ 0
- 0
magnum/drivers/mesos_ubuntu_v1/__init__.py View File


magnum/templates/mesos/Dockerfile → magnum/drivers/mesos_ubuntu_v1/image/Dockerfile View File


magnum/templates/mesos/elements/README.md → magnum/drivers/mesos_ubuntu_v1/image/README.md View File


magnum/templates/mesos/elements/docker/elements-deps → magnum/drivers/mesos_ubuntu_v1/image/docker/elements-deps View File


magnum/templates/mesos/elements/docker/package-installs.yaml → magnum/drivers/mesos_ubuntu_v1/image/docker/package-installs.yaml View File


magnum/templates/mesos/elements/docker/post-install.d/60-disable-docker-service → magnum/drivers/mesos_ubuntu_v1/image/docker/post-install.d/60-disable-docker-service View File


magnum/templates/mesos/elements/docker/pre-install.d/10-add-docker-repo → magnum/drivers/mesos_ubuntu_v1/image/docker/pre-install.d/10-add-docker-repo View File


magnum/templates/mesos/elements/mesos/elements-deps → magnum/drivers/mesos_ubuntu_v1/image/mesos/elements-deps View File


magnum/templates/mesos/elements/mesos/package-installs.yaml → magnum/drivers/mesos_ubuntu_v1/image/mesos/package-installs.yaml View File


magnum/templates/mesos/elements/mesos/post-install.d/60-disable-upstart → magnum/drivers/mesos_ubuntu_v1/image/mesos/post-install.d/60-disable-upstart View File


magnum/templates/mesos/elements/mesos/pre-install.d/10-apt-repo → magnum/drivers/mesos_ubuntu_v1/image/mesos/pre-install.d/10-apt-repo View File


+ 87
- 0
magnum/drivers/mesos_ubuntu_v1/template_def.py View File

@@ -0,0 +1,87 @@
1
+# Copyright 2016 Rackspace Inc. All rights reserved.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# a copy of the License at
6
+#
7
+#      http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+import os
15
+
16
+from magnum.drivers.common import template_def
17
+
18
+
19
+class UbuntuMesosTemplateDefinition(template_def.BaseTemplateDefinition):
20
+    """Mesos template for Ubuntu VM."""
21
+
22
+    provides = [
23
+        {'server_type': 'vm', 'os': 'ubuntu', 'coe': 'mesos'},
24
+    ]
25
+
26
+    def __init__(self):
27
+        super(UbuntuMesosTemplateDefinition, self).__init__()
28
+        self.add_parameter('external_network',
29
+                           baymodel_attr='external_network_id',
30
+                           required=True)
31
+        self.add_parameter('number_of_slaves',
32
+                           bay_attr='node_count')
33
+        self.add_parameter('master_flavor',
34
+                           baymodel_attr='master_flavor_id')
35
+        self.add_parameter('slave_flavor',
36
+                           baymodel_attr='flavor_id')
37
+        self.add_parameter('cluster_name',
38
+                           bay_attr='name')
39
+        self.add_parameter('volume_driver',
40
+                           baymodel_attr='volume_driver')
41
+
42
+        self.add_output('api_address',
43
+                        bay_attr='api_address')
44
+        self.add_output('mesos_master_private',
45
+                        bay_attr=None)
46
+        self.add_output('mesos_master',
47
+                        bay_attr='master_addresses')
48
+        self.add_output('mesos_slaves_private',
49
+                        bay_attr=None)
50
+        self.add_output('mesos_slaves',
51
+                        bay_attr='node_addresses')
52
+
53
+    def get_params(self, context, baymodel, bay, **kwargs):
54
+        extra_params = kwargs.pop('extra_params', {})
55
+        # HACK(apmelton) - This uses the user's bearer token, ideally
56
+        # it should be replaced with an actual trust token with only
57
+        # access to do what the template needs it to do.
58
+        osc = self.get_osc(context)
59
+        extra_params['auth_url'] = context.auth_url
60
+        extra_params['username'] = context.user_name
61
+        extra_params['tenant_name'] = context.tenant
62
+        extra_params['domain_name'] = context.domain_name
63
+        extra_params['region_name'] = osc.cinder_region_name()
64
+
65
+        label_list = ['rexray_preempt', 'mesos_slave_isolation',
66
+                      'mesos_slave_image_providers',
67
+                      'mesos_slave_work_dir',
68
+                      'mesos_slave_executor_env_variables']
69
+
70
+        for label in label_list:
71
+            extra_params[label] = baymodel.labels.get(label)
72
+
73
+        scale_mgr = kwargs.pop('scale_manager', None)
74
+        if scale_mgr:
75
+            hosts = self.get_output('mesos_slaves_private')
76
+            extra_params['slaves_to_remove'] = (
77
+                scale_mgr.get_removal_nodes(hosts))
78
+
79
+        return super(UbuntuMesosTemplateDefinition,
80
+                     self).get_params(context, baymodel, bay,
81
+                                      extra_params=extra_params,
82
+                                      **kwargs)
83
+
84
+    @property
85
+    def template_path(self):
86
+        return os.path.join(os.path.dirname(os.path.realpath(__file__)),
87
+                            'templates/mesoscluster.yaml')

magnum/templates/mesos/fragments/add-proxy.sh → magnum/drivers/mesos_ubuntu_v1/templates/fragments/add-proxy.sh View File


magnum/templates/mesos/fragments/configure-mesos-master.sh → magnum/drivers/mesos_ubuntu_v1/templates/fragments/configure-mesos-master.sh View File


magnum/templates/mesos/fragments/configure-mesos-slave.sh → magnum/drivers/mesos_ubuntu_v1/templates/fragments/configure-mesos-slave.sh View File


magnum/templates/mesos/fragments/start-services-master.sh → magnum/drivers/mesos_ubuntu_v1/templates/fragments/start-services-master.sh View File


magnum/templates/mesos/fragments/start-services-slave.sh → magnum/drivers/mesos_ubuntu_v1/templates/fragments/start-services-slave.sh View File


magnum/templates/mesos/fragments/volume-service.sh → magnum/drivers/mesos_ubuntu_v1/templates/fragments/volume-service.sh View File


magnum/templates/mesos/fragments/write-heat-params-master.sh → magnum/drivers/mesos_ubuntu_v1/templates/fragments/write-heat-params-master.sh View File


magnum/templates/mesos/fragments/write-heat-params.yaml → magnum/drivers/mesos_ubuntu_v1/templates/fragments/write-heat-params.yaml View File


magnum/templates/mesos/mesoscluster.yaml → magnum/drivers/mesos_ubuntu_v1/templates/mesoscluster.yaml View File


magnum/templates/mesos/mesosmaster.yaml → magnum/drivers/mesos_ubuntu_v1/templates/mesosmaster.yaml View File


magnum/templates/mesos/mesosslave.yaml → magnum/drivers/mesos_ubuntu_v1/templates/mesosslave.yaml View File


+ 5
- 4
magnum/tests/unit/conductor/test_template_definition.py View File

@@ -18,6 +18,7 @@ from oslo_config import cfg
18 18
 from magnum.common import exception
19 19
 from magnum.conductor import template_definition as tdef
20 20
 from magnum.drivers.common import template_def as cmn_tdef
21
+from magnum.drivers.mesos_ubuntu_v1 import template_def as mesos_tdef
21 22
 from magnum.drivers.swarm_fedora_atomic_v1 import template_def as swarm_tdef
22 23
 from magnum.tests import base
23 24
 
@@ -87,7 +88,7 @@ class TemplateDefinitionTestCase(base.TestCase):
87 88
             'mesos')
88 89
 
89 90
         self.assertIsInstance(definition,
90
-                              tdef.UbuntuMesosTemplateDefinition)
91
+                              mesos_tdef.UbuntuMesosTemplateDefinition)
91 92
 
92 93
     def test_get_definition_not_supported(self):
93 94
         self.assertRaises(exception.BayTypeNotSupported,
@@ -680,7 +681,7 @@ class UbuntuMesosTemplateDefinitionTestCase(base.TestCase):
680 681
         mock_scale_manager = mock.MagicMock()
681 682
         mock_scale_manager.get_removal_nodes.return_value = removal_nodes
682 683
 
683
-        mesos_def = tdef.UbuntuMesosTemplateDefinition()
684
+        mesos_def = mesos_tdef.UbuntuMesosTemplateDefinition()
684 685
 
685 686
         mesos_def.get_params(mock_context, mock_baymodel, mock_bay,
686 687
                              scale_manager=mock_scale_manager)
@@ -702,7 +703,7 @@ class UbuntuMesosTemplateDefinitionTestCase(base.TestCase):
702 703
                                                 mock_bay, **expected_kwargs)
703 704
 
704 705
     def test_mesos_get_heat_param(self):
705
-        mesos_def = tdef.UbuntuMesosTemplateDefinition()
706
+        mesos_def = mesos_tdef.UbuntuMesosTemplateDefinition()
706 707
 
707 708
         heat_param = mesos_def.get_heat_param(bay_attr='node_count')
708 709
         self.assertEqual('number_of_slaves', heat_param)
@@ -711,7 +712,7 @@ class UbuntuMesosTemplateDefinitionTestCase(base.TestCase):
711 712
         self.assertEqual('number_of_masters', heat_param)
712 713
 
713 714
     def test_update_outputs(self):
714
-        mesos_def = tdef.UbuntuMesosTemplateDefinition()
715
+        mesos_def = mesos_tdef.UbuntuMesosTemplateDefinition()
715 716
 
716 717
         expected_api_address = 'updated_address'
717 718
         expected_node_addresses = ['ex_slave', 'address']

+ 1
- 1
setup.cfg View File

@@ -59,7 +59,7 @@ magnum.template_definitions =
59 59
     magnum_vm_atomic_k8s = magnum.conductor.template_definition:AtomicK8sTemplateDefinition
60 60
     magnum_vm_coreos_k8s = magnum.conductor.template_definition:CoreOSK8sTemplateDefinition
61 61
     magnum_vm_atomic_swarm = magnum.drivers.swarm_fedora_atomic_v1.template_def:AtomicSwarmTemplateDefinition
62
-    magnum_vm_ubuntu_mesos = magnum.conductor.template_definition:UbuntuMesosTemplateDefinition
62
+    magnum_vm_ubuntu_mesos = magnum.drivers.mesos_ubuntu_v1.template_def:UbuntuMesosTemplateDefinition
63 63
 
64 64
 magnum.database.migration_backend =
65 65
     sqlalchemy = magnum.db.sqlalchemy.migration

Loading…
Cancel
Save