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
1=== modified file 'maas_deployer/vmaas/engine.py'
2--- maas_deployer/vmaas/engine.py 2015-09-01 13:38:33 +0000
3+++ maas_deployer/vmaas/engine.py 2015-09-01 23:16:41 +0000
4@@ -65,9 +65,14 @@
5 self.wait_for_maas_installation(maas_config)
6 self.configure_maas_virsh_control(maas_config)
7 self.api_key = self._get_api_key(maas_config)
8- self.wait_for_import_boot_images(maas_config)
9-
10- self.configure_maas(maas_config)
11+
12+ api_url = 'http://{}/MAAS/api/1.0'.format(self.ip_addr)
13+ client = MAASClient(api_url, self.api_key,
14+ ssh_user=maas_config['user'])
15+
16+ self.apply_maas_settings(client, maas_config)
17+ self.wait_for_import_boot_images(client, maas_config)
18+ self.configure_maas(client, maas_config)
19
20 def _get_juju_node_params(self, juju_domain, maas_config):
21 """
22@@ -186,6 +191,7 @@
23 cmd = self.get_ssh_cmd(maas_config['user'], maas_ip,
24 remote_cmd=rcmd)
25 util.execc(cmd=cmd)
26+ log.info("done.")
27 self._get_api_key_from_cloudinit(maas_config['user'], maas_ip)
28
29 def wait_for_maas_installation(self, maas_config):
30@@ -282,9 +288,11 @@
31 """
32 util.exec_script_remote(maas_config['user'], self.ip_addr, script)
33
34- def wait_for_import_boot_images(self, maas_config):
35+ def wait_for_import_boot_images(self, client, maas_config):
36 """Polls the import boot image status."""
37- log.debug("Importing boot images...")
38+ log.debug("Starting the import of boot resources")
39+ client.import_boot_images()
40+
41 ip_addr = self.ip_addr or self._get_maas_ip_address(maas_config)
42 user = maas_config['user']
43 password = maas_config['password']
44@@ -391,17 +399,7 @@
45
46 self._add_tags_to_node(client, node, maas_node)
47
48- def configure_maas(self, maas_config):
49- """
50- Configures the MAAS instance.
51- """
52- api_url = 'http://{}/MAAS/api/1.0'.format(self.ip_addr)
53-
54- client = MAASClient(api_url, self.api_key,
55- ssh_user=maas_config['user'])
56-
57- nodegroup = client.get_nodegroups()[0]
58-
59+ def apply_maas_settings(self, client, maas_config):
60 log.debug("Configuring MAAS settings...")
61 maas_settings = maas_config.get('settings', {})
62 for key in maas_settings:
63@@ -410,6 +408,11 @@
64 if not succ:
65 log.error("Unable to set %s to %s", key, value)
66
67+ def configure_maas(self, client, maas_config):
68+ """
69+ Configures the MAAS instance.
70+ """
71+ nodegroup = client.get_nodegroups()[0]
72 log.debug("Creating the nodegroup interfaces...")
73 node_group_interfaces = copy.deepcopy(maas_config['node_group_ifaces'])
74 for iface in node_group_interfaces:
75
76=== modified file 'maas_deployer/vmaas/maasclient/clidriver.py'
77--- maas_deployer/vmaas/maasclient/clidriver.py 2015-08-20 04:57:32 +0000
78+++ maas_deployer/vmaas/maasclient/clidriver.py 2015-09-01 23:16:41 +0000
79@@ -125,7 +125,7 @@
80
81 :rtype: bool indicating whether the start of the import was successful
82 """
83- raise NotImplementedError()
84+ return self._maas_execute('boot-resources', 'import')
85
86 ###########################################################################
87 # Nodegroup API - http://maas.ubuntu.com/docs/api.html#nodegroups
88
89=== modified file 'maas_deployer/vmaas/templates/config-maas.sh'
90--- maas_deployer/vmaas/templates/config-maas.sh 2015-08-25 20:47:21 +0000
91+++ maas_deployer/vmaas/templates/config-maas.sh 2015-09-01 23:16:41 +0000
92@@ -10,15 +10,8 @@
93 --password={{password}} \
94 --email={{user}}@localhost
95
96-
97-# Configure the dns nameservers
98-echo "Configuring the DNS nameserver"
99-for dev in `ip link show | grep eth.*mtu | cut -d':' -f2`; do
100- sudo resolvconf -d ${dev}.inet
101-done
102-
103 sudo sed -i 's/dns-nameserver.*/dns-nameserver 127.0.0.1/g' /etc/network/interfaces
104-
105+# NOTE: we should cleanup /etc/resolv.conf once MAAS DNS has been configured.
106
107 # Generate a MAAS API key for the admin user and start the importing of boot resources.
108 echo "Generating MAAS API login credentials for admin"
109@@ -27,13 +20,11 @@
110 ipaddr=$(ip route get 8.8.8.8 | awk 'NR==1 {print $NF}')
111 maas login maas http://${ipaddr}/MAAS/api/1.0 ${apikey}
112
113-
114 # Configure MAAS networks...
115 echo "Configuring MAAS node group interfaces (dns and dhcp configuration)..."
116 maas_ip=$(ip addr show eth0 | awk '/inet / {print $2}' | cut -d/ -f1)
117 maas_net=$(ip addr show eth0 | awk '/inet / {print $2}' | cut -d/ -f1 | cut -d. -f-3)
118
119-
120 node_group_uuid=$(maas maas node-groups list | grep uuid | cut -d\" -f4)
121 attempts=0
122 while [[ "$node_group_uuid" == "master" ]] && [ $attempts -le 10 ]
123@@ -58,13 +49,6 @@
124 iptables -t nat -A POSTROUTING -o $ext_dev -j MASQUERADE
125 sed -i -s "s/^exit 0/iptables -t nat -A POSTROUTING -o $ext_dev -j MASQUERADE\nexit 0/" /etc/rc.local
126
127-
128 # Create a juju user
129 sudo adduser --disabled-password --gecos "Juju,,," juju
130
131-
132-# Kick off the boot-resources import
133-echo "Starting the import of boot resources"
134-maas maas boot-resources import
135-
136-

Subscribers

People subscribed via source and target branches