1 # Copyright (c) 2016 Cable Television Laboratories, Inc. ("CableLabs")
2 # and others. All rights reserved.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 class ClusterTemplate(object):
19 Class for OpenStack cluster template domain object
22 def __init__(self, **kwargs):
25 :param id: the cluster template's UUID
26 :param name: the cluster template's name
27 :param image: name or ID of the base image in Glance used to boot the
28 cluster's servers. The image must have the attribute
29 'os-distro' defined as appropriate for the cluster
31 :param keypair: name or ID of the keypair to gain cluster machine
33 :param network_driver: The name of a network driver for providing the
34 networks for the containers. Note that this is
35 different and separate from the Neutron network
36 for the bay/cluster. The operation and
37 networking model are specific to the particular
39 :param external_net: name or IDof the external Neutron network to
40 provide connectivity to the cluster
41 :param floating_ip_enabled: Whether enable or not using the floating IP
42 of cloud provider. Some cloud providers
43 used floating IP, some used public IP,
44 thus Magnum provide this option for
45 specifying the choice of using floating IP
46 :param docker_volume_size: The size in GB for the local storage on each
47 server for the Docker daemon to cache the
48 images and host the containers. Cinder
49 volumes provide the storage. The default is
50 25 GB. For the devicemapper storage driver,
51 the minimum value is 3GB. For the overlay
52 storage driver, the minimum value is 1GB.
53 :param server_type: server type string
54 :param flavor: name or ID of the nova flavor for booting the node
56 :param master_flavor: name or ID of the nova flavor of the master node
58 :param coe: ContainerOrchestrationEngine enum instance
59 :param fixed_net: name of a Neutron network to provide connectivity
60 to the internal network for the cluster
61 :param fixed_subnet: Fixed subnet that are using to allocate network
62 address for nodes in bay/cluster
63 :param registry_enabled: Docker images by default are pulled from the
64 public Docker registry, but in some cases,
65 users may want to use a private registry.
66 This option provides an alternative registry
67 based on the Registry V2: Magnum will create a
68 local registry in the bay/cluster backed by
69 swift to host the images
70 :param insecure_registry: The URL pointing to the user's own private
71 insecure docker registry to deploy and run
73 :param docker_storage_driver: DockerStorageDriver enum instance to
74 manage storage for the images and
75 container's writable layer
76 :param dns_nameserver: The DNS nameserver for the servers and
77 containers in the bay/cluster to use.
78 This is configured in the private Neutron
79 network for the bay/cluster.
80 :param public: denotes whether or not the cluster type is public
81 :param tls_disabled: denotes whether or not TLS should be enabled
82 :param http_proxy: host:port for a proxy to use when direct HTTP
83 access from the servers to sites on the external
85 :param https_proxy: host:port for a proxy to use when direct HTTPS
86 access from the servers to sites on the external
88 :param no_proxy: comma separated list of IPs that should not be
89 redirected through the proxy
90 :param volume_driver: The name of a volume driver for managing the
91 persistent storage for the containers. The
92 functionality supported are specific to the
94 :param master_lb_enabled: Since multiple masters may exist in a
95 bay/cluster, a Neutron load balancer is
96 created to provide the API endpoint for the
97 bay/cluster and to direct requests to the
98 masters. In some cases, such as when the
99 LBaaS service is not available, this option
100 can be set to false to create a bay/cluster
101 without the load balancer. In this case, one
102 of the masters will serve as the API endpoint
103 :param labels: Arbitrary labels in the form of a dict. The accepted
104 keys and valid values are defined in the bay/cluster
105 drivers. They are used as a way to pass additional
106 parameters that are specific to a bay/cluster driver.
108 self.id = kwargs.get('id')
109 self.name = kwargs.get('name')
110 self.image = kwargs.get('image')
111 self.keypair = kwargs.get('keypair')
112 self.network_driver = kwargs.get('network_driver')
113 self.external_net = kwargs.get('external_net')
114 self.floating_ip_enabled = kwargs.get('floating_ip_enabled')
115 self.docker_volume_size = int(kwargs.get('docker_volume_size', 3))
116 self.server_type = kwargs.get('server_type')
117 self.flavor = kwargs.get('flavor')
118 self.master_flavor = kwargs.get('master_flavor')
119 self.coe = kwargs.get('coe')
120 self.fixed_net = kwargs.get('fixed_net')
121 self.fixed_subnet = kwargs.get('fixed_subnet')
122 self.registry_enabled = kwargs.get('registry_enabled')
123 self.insecure_registry = kwargs.get('insecure_registry')
124 self.docker_storage_driver = kwargs.get('docker_storage_driver')
125 self.dns_nameserver = kwargs.get('dns_nameserver')
126 self.public = kwargs.get('public', False)
127 self.tls_disabled = kwargs.get('tls_disabled')
128 self.http_proxy = kwargs.get('http_proxy')
129 self.https_proxy = kwargs.get('https_proxy')
130 self.no_proxy = kwargs.get('no_proxy')
131 self.volume_driver = kwargs.get('volume_driver')
132 self.master_lb_enabled = kwargs.get('master_lb_enabled', True)
133 self.labels = kwargs.get('labels')
135 def __eq__(self, other):
137 if (self.labels and isinstance(self.labels, dict)
138 and len(self.labels) == 0):
139 if (other.labels and isinstance(other.labels, dict)
140 and len(other.labels) == 0):
142 elif not self.labels:
143 if (not other.labels or
144 (isinstance(other.labels, dict)
145 and len(other.labels) == 0)):
148 labels_eq = self.labels == other.labels
150 return (self.name == other.name
151 and self.id == other.id
152 and self.image == other.image
153 and self.keypair == other.keypair
154 and self.network_driver == other.network_driver
155 and self.external_net == other.external_net
156 and self.floating_ip_enabled == other.floating_ip_enabled
157 and self.docker_volume_size == other.docker_volume_size
158 and self.server_type == other.server_type
159 and self.flavor == other.flavor
160 and self.master_flavor == other.master_flavor
161 and self.coe == other.coe
162 and self.fixed_net == other.fixed_net
163 and self.fixed_subnet == other.fixed_subnet
164 and self.registry_enabled == other.registry_enabled
165 and self.insecure_registry == other.insecure_registry
166 and self.docker_storage_driver == other.docker_storage_driver
167 and self.dns_nameserver == other.dns_nameserver
168 and self.public == other.public
169 and self.tls_disabled == other.tls_disabled
170 and self.http_proxy == other.http_proxy
171 and self.https_proxy == other.https_proxy
172 and self.no_proxy == other.no_proxy
173 and self.volume_driver == other.volume_driver
174 and self.master_lb_enabled == other.master_lb_enabled