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

Proposed by Edward Hope-Morley
Status: Merged
Merged at revision: 29
Proposed branch: lp:~hopem/maas-deployer/lp1480263
Merge into: lp:~maas-deployers/maas-deployer/next
Diff against target: 136 lines (+21/-34)
3 files modified
maas_deployer/vmaas/engine.py (+19/-16)
maas_deployer/vmaas/maasclient/clidriver.py (+1/-1)
maas_deployer/vmaas/templates/config-maas.sh (+1/-17)
To merge this branch: bzr merge lp:~hopem/maas-deployer/lp1480263
Reviewer Review Type Date Requested Status
Billy Olsen Approve
Review via email: mp+269822@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Billy Olsen (billy-olsen) wrote :

LGTM, thanks Ed!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'maas_deployer/vmaas/engine.py'
--- maas_deployer/vmaas/engine.py 2015-09-01 13:38:33 +0000
+++ maas_deployer/vmaas/engine.py 2015-09-01 23:16:41 +0000
@@ -65,9 +65,14 @@
65 self.wait_for_maas_installation(maas_config)65 self.wait_for_maas_installation(maas_config)
66 self.configure_maas_virsh_control(maas_config)66 self.configure_maas_virsh_control(maas_config)
67 self.api_key = self._get_api_key(maas_config)67 self.api_key = self._get_api_key(maas_config)
68 self.wait_for_import_boot_images(maas_config)68
6969 api_url = 'http://{}/MAAS/api/1.0'.format(self.ip_addr)
70 self.configure_maas(maas_config)70 client = MAASClient(api_url, self.api_key,
71 ssh_user=maas_config['user'])
72
73 self.apply_maas_settings(client, maas_config)
74 self.wait_for_import_boot_images(client, maas_config)
75 self.configure_maas(client, maas_config)
7176
72 def _get_juju_node_params(self, juju_domain, maas_config):77 def _get_juju_node_params(self, juju_domain, maas_config):
73 """78 """
@@ -186,6 +191,7 @@
186 cmd = self.get_ssh_cmd(maas_config['user'], maas_ip,191 cmd = self.get_ssh_cmd(maas_config['user'], maas_ip,
187 remote_cmd=rcmd)192 remote_cmd=rcmd)
188 util.execc(cmd=cmd)193 util.execc(cmd=cmd)
194 log.info("done.")
189 self._get_api_key_from_cloudinit(maas_config['user'], maas_ip)195 self._get_api_key_from_cloudinit(maas_config['user'], maas_ip)
190196
191 def wait_for_maas_installation(self, maas_config):197 def wait_for_maas_installation(self, maas_config):
@@ -282,9 +288,11 @@
282 """288 """
283 util.exec_script_remote(maas_config['user'], self.ip_addr, script)289 util.exec_script_remote(maas_config['user'], self.ip_addr, script)
284290
285 def wait_for_import_boot_images(self, maas_config):291 def wait_for_import_boot_images(self, client, maas_config):
286 """Polls the import boot image status."""292 """Polls the import boot image status."""
287 log.debug("Importing boot images...")293 log.debug("Starting the import of boot resources")
294 client.import_boot_images()
295
288 ip_addr = self.ip_addr or self._get_maas_ip_address(maas_config)296 ip_addr = self.ip_addr or self._get_maas_ip_address(maas_config)
289 user = maas_config['user']297 user = maas_config['user']
290 password = maas_config['password']298 password = maas_config['password']
@@ -391,17 +399,7 @@
391399
392 self._add_tags_to_node(client, node, maas_node)400 self._add_tags_to_node(client, node, maas_node)
393401
394 def configure_maas(self, maas_config):402 def apply_maas_settings(self, client, maas_config):
395 """
396 Configures the MAAS instance.
397 """
398 api_url = 'http://{}/MAAS/api/1.0'.format(self.ip_addr)
399
400 client = MAASClient(api_url, self.api_key,
401 ssh_user=maas_config['user'])
402
403 nodegroup = client.get_nodegroups()[0]
404
405 log.debug("Configuring MAAS settings...")403 log.debug("Configuring MAAS settings...")
406 maas_settings = maas_config.get('settings', {})404 maas_settings = maas_config.get('settings', {})
407 for key in maas_settings:405 for key in maas_settings:
@@ -410,6 +408,11 @@
410 if not succ:408 if not succ:
411 log.error("Unable to set %s to %s", key, value)409 log.error("Unable to set %s to %s", key, value)
412410
411 def configure_maas(self, client, maas_config):
412 """
413 Configures the MAAS instance.
414 """
415 nodegroup = client.get_nodegroups()[0]
413 log.debug("Creating the nodegroup interfaces...")416 log.debug("Creating the nodegroup interfaces...")
414 node_group_interfaces = copy.deepcopy(maas_config['node_group_ifaces'])417 node_group_interfaces = copy.deepcopy(maas_config['node_group_ifaces'])
415 for iface in node_group_interfaces:418 for iface in node_group_interfaces:
416419
=== modified file 'maas_deployer/vmaas/maasclient/clidriver.py'
--- maas_deployer/vmaas/maasclient/clidriver.py 2015-08-20 04:57:32 +0000
+++ maas_deployer/vmaas/maasclient/clidriver.py 2015-09-01 23:16:41 +0000
@@ -125,7 +125,7 @@
125125
126 :rtype: bool indicating whether the start of the import was successful126 :rtype: bool indicating whether the start of the import was successful
127 """127 """
128 raise NotImplementedError()128 return self._maas_execute('boot-resources', 'import')
129129
130 ###########################################################################130 ###########################################################################
131 # Nodegroup API - http://maas.ubuntu.com/docs/api.html#nodegroups131 # Nodegroup API - http://maas.ubuntu.com/docs/api.html#nodegroups
132132
=== modified file 'maas_deployer/vmaas/templates/config-maas.sh'
--- maas_deployer/vmaas/templates/config-maas.sh 2015-08-25 20:47:21 +0000
+++ maas_deployer/vmaas/templates/config-maas.sh 2015-09-01 23:16:41 +0000
@@ -10,15 +10,8 @@
10 --password={{password}} \10 --password={{password}} \
11 --email={{user}}@localhost11 --email={{user}}@localhost
1212
13
14# Configure the dns nameservers
15echo "Configuring the DNS nameserver"
16for dev in `ip link show | grep eth.*mtu | cut -d':' -f2`; do
17 sudo resolvconf -d ${dev}.inet
18done
19
20sudo sed -i 's/dns-nameserver.*/dns-nameserver 127.0.0.1/g' /etc/network/interfaces13sudo sed -i 's/dns-nameserver.*/dns-nameserver 127.0.0.1/g' /etc/network/interfaces
2114# NOTE: we should cleanup /etc/resolv.conf once MAAS DNS has been configured.
2215
23# Generate a MAAS API key for the admin user and start the importing of boot resources.16# Generate a MAAS API key for the admin user and start the importing of boot resources.
24echo "Generating MAAS API login credentials for admin"17echo "Generating MAAS API login credentials for admin"
@@ -27,13 +20,11 @@
27ipaddr=$(ip route get 8.8.8.8 | awk 'NR==1 {print $NF}')20ipaddr=$(ip route get 8.8.8.8 | awk 'NR==1 {print $NF}')
28maas login maas http://${ipaddr}/MAAS/api/1.0 ${apikey}21maas login maas http://${ipaddr}/MAAS/api/1.0 ${apikey}
2922
30
31# Configure MAAS networks...23# Configure MAAS networks...
32echo "Configuring MAAS node group interfaces (dns and dhcp configuration)..."24echo "Configuring MAAS node group interfaces (dns and dhcp configuration)..."
33maas_ip=$(ip addr show eth0 | awk '/inet / {print $2}' | cut -d/ -f1)25maas_ip=$(ip addr show eth0 | awk '/inet / {print $2}' | cut -d/ -f1)
34maas_net=$(ip addr show eth0 | awk '/inet / {print $2}' | cut -d/ -f1 | cut -d. -f-3)26maas_net=$(ip addr show eth0 | awk '/inet / {print $2}' | cut -d/ -f1 | cut -d. -f-3)
3527
36
37node_group_uuid=$(maas maas node-groups list | grep uuid | cut -d\" -f4)28node_group_uuid=$(maas maas node-groups list | grep uuid | cut -d\" -f4)
38attempts=029attempts=0
39while [[ "$node_group_uuid" == "master" ]] && [ $attempts -le 10 ]30while [[ "$node_group_uuid" == "master" ]] && [ $attempts -le 10 ]
@@ -58,13 +49,6 @@
58iptables -t nat -A POSTROUTING -o $ext_dev -j MASQUERADE49iptables -t nat -A POSTROUTING -o $ext_dev -j MASQUERADE
59sed -i -s "s/^exit 0/iptables -t nat -A POSTROUTING -o $ext_dev -j MASQUERADE\nexit 0/" /etc/rc.local50sed -i -s "s/^exit 0/iptables -t nat -A POSTROUTING -o $ext_dev -j MASQUERADE\nexit 0/" /etc/rc.local
6051
61
62# Create a juju user52# Create a juju user
63sudo adduser --disabled-password --gecos "Juju,,," juju53sudo adduser --disabled-password --gecos "Juju,,," juju
6454
65
66# Kick off the boot-resources import
67echo "Starting the import of boot resources"
68maas maas boot-resources import
69
70

Subscribers

People subscribed via source and target branches