Debian Codegraph @

contrib/drivers/k8s_opensuse_v1/template_def.py

raw
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
15 import os
16
17 import magnum.conf
18 from magnum.drivers.common import k8s_template_def
19 from magnum.drivers.common import template_def
20
21 CONF = magnum.conf.CONF
22
23
24 class JeOSK8sTemplateDefinition(k8s_template_def.K8sTemplateDefinition):
25 """Kubernetes template for openSUSE/SLES JeOS VM."""
26
27 def __init__(self):
28 super(JeOSK8sTemplateDefinition, self).__init__()
29 self.add_parameter('docker_volume_size',
30 cluster_template_attr='docker_volume_size')
31 self.add_output('kube_minions',
32 cluster_attr='node_addresses')
33 self.add_output('kube_masters',
34 cluster_attr='master_addresses')
35
36 def get_params(self, context, cluster_template, cluster, **kwargs):
37 extra_params = kwargs.pop('extra_params', {})
38
39 extra_params['username'] = context.user_name
40 extra_params['tenant_name'] = context.tenant
41
42 return super(JeOSK8sTemplateDefinition,
43 self).get_params(context, cluster_template, cluster,
44 extra_params=extra_params,
45 **kwargs)
46
47 def get_env_files(self, cluster):
48 env_files = []
49 if cluster.master_lb_enabled:
50 env_files.append(
51 template_def.COMMON_ENV_PATH + 'with_master_lb.yaml')
52 else:
53 env_files.append(
54 template_def.COMMON_ENV_PATH + 'no_master_lb.yaml')
55 if cluster.floating_ip_enabled:
56 env_files.append(
57 template_def.COMMON_ENV_PATH + 'enable_floating_ip.yaml')
58 else:
59 env_files.append(
60 template_def.COMMON_ENV_PATH + 'disable_floating_ip.yaml')
61
62 return env_files
63
64 @property
65 def driver_module_path(self):
66 return __name__[:__name__.rindex('.')]
67
68 @property
69 def template_path(self):
70 return os.path.join(os.path.dirname(os.path.realpath(__file__)),
71 'templates/kubecluster.yaml')