Merge lp:~hopem/maas-deployer/lp1491594 into lp:~maas-deployers/maas-deployer/next

Proposed by Edward Hope-Morley
Status: Merged
Merged at revision: 33
Proposed branch: lp:~hopem/maas-deployer/lp1491594
Merge into: lp:~maas-deployers/maas-deployer/next
Diff against target: 217 lines (+72/-66)
3 files modified
examples/deployment.yaml (+15/-12)
maas_deployer/vmaas/engine.py (+32/-20)
maas_deployer/vmaas/vm.py (+25/-34)
To merge this branch: bzr merge lp:~hopem/maas-deployer/lp1491594
Reviewer Review Type Date Requested Status
Billy Olsen Approve
Review via email: mp+270241@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Billy Olsen (billy-olsen) wrote :

LGTM, Approved.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'examples/deployment.yaml'
2--- examples/deployment.yaml 2015-08-25 20:47:21 +0000
3+++ examples/deployment.yaml 2015-09-05 12:13:36 +0000
4@@ -1,6 +1,19 @@
5 # This file defines the deployment for the MAAS environment which is to be
6 # deployed and automated.
7 demo-maas:
8+ # Contains the virtual machine parameters for creating the Juju bootstrap
9+ # node virtual machine
10+ juju-bootstrap:
11+ name: juju-boot-vm-dc1
12+ interfaces: ['bridge=virbr0,model=virtio']
13+ memory: 2048
14+ vcpus: 2
15+ arch: amd64
16+ pool: default
17+ disk_size: 20G
18+ sticky_ip_address:
19+ requested_address: 192.168.122.5
20+
21 maas:
22 # Defines the general setup for the MAAS environment, including the
23 # username and password for the host as well as the MAAS server.
24@@ -105,15 +118,5 @@
25 driver: LAN_2_0
26 sticky_ip_address:
27 mac_address: "38:63:bb:43:b8:9c"
28- requested_address: 192.168.122.5
29-
30- # Contains the virtual machine parameters for creating the Juju bootstrap
31- # node virtual machine
32- juju-bootstrap:
33- name: juju-boot-vm-dc1
34- interfaces: ['bridge=virbr0,model=virtio']
35- memory: 2048
36- vcpus: 2
37- arch: amd64
38- pool: default
39- disk_size: 20G
40+ requested_address: 192.168.122.6
41+
42
43=== modified file 'maas_deployer/vmaas/engine.py'
44--- maas_deployer/vmaas/engine.py 2015-09-02 18:34:36 +0000
45+++ maas_deployer/vmaas/engine.py 2015-09-05 12:13:36 +0000
46@@ -52,7 +52,8 @@
47
48 # Insert juju node information into the maas nodes list.
49 # This allows us to define it in maas.
50- juju_node = self._get_juju_node_params(juju_domain, maas_config)
51+ juju_node = self._get_juju_node_params(juju_domain, juju_config,
52+ maas_config)
53
54 nodes = maas_config.get('nodes', [])
55 if not nodes:
56@@ -75,7 +76,7 @@
57 self.wait_for_import_boot_images(client, maas_config)
58 self.configure_maas(client, maas_config)
59
60- def _get_juju_node_params(self, juju_domain, maas_config):
61+ def _get_juju_node_params(self, juju_domain, juju_config, maas_config):
62 """
63 Determines the mac address of the juju machine specified.
64
65@@ -100,6 +101,11 @@
66 'power_parameters_power_id': juju_domain.name,
67 })
68
69+ sticky_cfg = juju_config.get('sticky_ip_address')
70+ if sticky_cfg:
71+ node['sticky_ip_address'] = sticky_cfg
72+ node['sticky_ip_address']['mac_address'] = node['mac_addresses'][0]
73+
74 return node
75
76 def deploy_juju_bootstrap(self, params):
77@@ -107,7 +113,7 @@
78 Deploys the juju bootstrap node.
79 """
80 log.debug("Creating Juju bootstrap node...")
81- juju_node = vm.Instance(**params)
82+ juju_node = vm.Instance(params)
83 juju_node.netboot = True
84 juju_node.define()
85 return juju_node
86@@ -117,7 +123,7 @@
87 Deploys the virtual maas node.
88 """
89 log.debug("Creating MAAS Virtual Machine...")
90- maas = vm.CloudInstance(**params)
91+ maas = vm.CloudInstance(params)
92 maas.create()
93 return maas
94
95@@ -532,22 +538,28 @@
96 Claim sticky IP address
97 """
98 maas_nodes = client.get_nodes()
99- nodes = maas_config.get('nodes', [])
100- for maas_node in maas_nodes:
101- hostname = maas_node['hostname']
102- for node in nodes:
103- if (hostname.startswith("%s." % node['name']) and
104- 'sticky_ip_address' in node):
105- sticky_ip_addr = node['sticky_ip_address']
106- mac_address = sticky_ip_addr.get('mac_address', None)
107- requested_address = sticky_ip_addr.get('requested_address')
108- if requested_address:
109- log.debug("Claiming sticky IP address '%s'",
110- requested_address)
111- fn = client.claim_sticky_ip_address
112- if not fn(maas_node, requested_address, mac_address):
113- log.warning(">> Failed to claim sticky ip address "
114- "'%s'", (requested_address))
115+ config_nodes = maas_config.get('nodes', [])
116+ sticky_nodes = {}
117+ for m_node in maas_nodes:
118+ hostname = m_node['hostname']
119+ for c_node in config_nodes:
120+ sticky_addr_cfg = c_node.get('sticky_ip_address')
121+ if (hostname.startswith("%s." % c_node['name']) and
122+ sticky_addr_cfg):
123+ ip_addr = sticky_addr_cfg.get('requested_address')
124+ mac_addr = sticky_addr_cfg.get('mac_address')
125+ if ip_addr and mac_addr:
126+ sticky_nodes[ip_addr] = {'mac_addr': mac_addr,
127+ 'maas_node': m_node}
128+
129+ for ip_addr, cfg in sticky_nodes.iteritems():
130+ node = cfg['maas_node']
131+ log.debug("Claiming sticky IP address '%s' for node '%s'",
132+ ip_addr, node['hostname'])
133+ rc = client.claim_sticky_ip_address(node, ip_addr,
134+ cfg['mac_addr'])
135+ if not rc:
136+ log.warning("Failed to claim sticky ip address '%s'", ip_addr)
137
138 def get_power_parameters(self, config_parms):
139 """
140
141=== modified file 'maas_deployer/vmaas/vm.py'
142--- maas_deployer/vmaas/vm.py 2015-08-14 16:59:12 +0000
143+++ maas_deployer/vmaas/vm.py 2015-09-05 12:13:36 +0000
144@@ -38,19 +38,17 @@
145
146 class Instance(object):
147
148- def __init__(self, name, interfaces, arch='amd64', disk_size='20G',
149- vcpus=1, memory=1024, pool='default', netboot=False):
150- self.name = name
151- self.interfaces = interfaces
152- self.arch = arch
153- self.disk_size = disk_size
154- self.vcpus = vcpus
155- self.memory = memory
156- self.pool = pool
157- self.netboot = netboot
158+ def __init__(self, params):
159+ self.name = params.get('name')
160+ self.interfaces = params.get('interfaces')
161+ self.arch = params.get('arch', 'amd64')
162+ self.disk_size = params.get('disk_size', '20G')
163+ self.vcpus = params.get('vcpus', 1)
164+ self.memory = params.get('memory', 1024)
165+ self.pool = params.get('pool', 'default')
166+ self.netboot = params.get('netboot', False)
167 self.conn = libvirt.open(cfg.remote)
168-
169- self.assert_pool_exists(pool)
170+ self.assert_pool_exists(self.pool)
171
172 @staticmethod
173 def assert_pool_exists(pool='default'):
174@@ -265,28 +263,21 @@
175
176 class CloudInstance(Instance):
177
178- def __init__(self, name, interfaces, disk_size='40G', vcpus=2,
179- memory=4096, pool='default', user='ubuntu', password='ubuntu',
180- release='trusty', arch='amd64', **kwargs):
181- super(CloudInstance, self).__init__(self, name, interfaces)
182- self.name = name
183- self.interfaces = interfaces
184- self.disk_size = disk_size
185- self.vcpus = vcpus
186- self.memory = memory
187- self.pool = pool
188- self.release = release
189- self.user = user
190- self.password = password
191- self.arch = arch
192-
193- if 'network_config' in kwargs:
194- self.network_interfaces_content = kwargs['network_config']
195-
196- if 'node_group_ifaces' in kwargs:
197- self.node_group_ifaces = kwargs['node_group_ifaces']
198-
199- self.apt_http_proxy = kwargs.get('apt_http_proxy')
200+ def __init__(self, params):
201+ super(CloudInstance, self).__init__(params)
202+ self.name = params.get('name')
203+ self.interfaces = params.get('interfaces')
204+ self.arch = params.get('arch', 'amd64')
205+ self.disk_size = params.get('disk_size', '40G')
206+ self.vcpus = params.get('vcpus', 2)
207+ self.memory = params.get('memory', 4096)
208+ self.pool = params.get('pool', 'default')
209+ self.release = params.get('release', 'trusty')
210+ self.user = params.get('user', 'ubuntu')
211+ self.password = params.get('password', 'ubuntu')
212+ self.network_interfaces_content = params.get('network_config')
213+ self.node_group_ifaces = params.get('node_group_ifaces')
214+ self.apt_http_proxy = params.get('apt_http_proxy')
215
216 def _get_cloud_image_info(self):
217 """

Subscribers

People subscribed via source and target branches