Merge lp:~freyes/maas-deployer/virtual-nodes into lp:maas-deployer

Proposed by Felipe Reyes
Status: Merged
Merged at revision: 69
Proposed branch: lp:~freyes/maas-deployer/virtual-nodes
Merge into: lp:maas-deployer
Diff against target: 263 lines (+195/-13)
2 files modified
examples/virtual-nodes.yaml (+166/-0)
maas_deployer/vmaas/engine.py (+29/-13)
To merge this branch: bzr merge lp:~freyes/maas-deployer/virtual-nodes
Reviewer Review Type Date Requested Status
Nobuto Murata Needs Fixing
Billy Olsen Approve
Review via email: mp+289115@code.launchpad.net

Description of the change

Maintainers,

I would like to add the option to create virtual machines (virtual-nodes) and get them registered into the freshly installed maas.

This MP includes a exmple yaml file to understand how this is intended to be used.

Rationale
---------

maas-deployer already has all the plumbing needed to create (through virsh) and register VMs/bare-metal (into MAAS), but some scenarios (specially labs and bug reproducers) require to create extra VMs for the workload that it's intended to be deployed with juju (typically OpenStack), so I pretend to use this for that, as a tool to build disposable labs easily.

Best,

To post a comment you must log in.
Revision history for this message
Billy Olsen (billy-olsen) wrote :

In general, I'm +1 on this. I feel that the virtual-nodes set is something that may be confusing rather than just nodes, however I do understand why its there (so there's a distinction of nodes to create and nodes which are expected to be present). I really waffled back and forth about whether to use virtual-nodes or to use a tag inside of a node, but ultimately it doesn't matter that much so I'll approve as is.

review: Approve
Revision history for this message
Nobuto Murata (nobuto) wrote :

Wait, the branch seems not based on /next branch. So some changes in /next have been lost. For example, 'architecture'='amd64/generic' is hard-coded again (I'm using maas-deployer for ppc64el as well). The branch should be re-based and re-submitted.

------------------------------------------------------------
revno: 69 [merge]
committer: Billy Olsen <email address hidden>
branch nick: next
timestamp: Fri 2016-04-15 17:03:06 -0700
message:
  [freyes, r=billy-olsen]

  Add 'virtual-nodes' config key to create extra VMs during deployment.
    ------------------------------------------------------------
    revno: 63.1.2
    committer: Felipe Reyes <email address hidden>
    branch nick: maas-deployer.bzr
    timestamp: Tue 2016-03-15 13:11:10 -0300
    message:
      Add example on how to create virtual nodes during deployment
    ------------------------------------------------------------
    revno: 63.1.1
    committer: Felipe Reyes <email address hidden>
    branch nick: maas-deployer.bzr
    timestamp: Mon 2016-03-14 18:55:46 -0300
    message:
      Add 'virtual-nodes' config key to create extra VMs

=== modified file 'maas_deployer/vmaas/engine.py'
--- maas_deployer/vmaas/engine.py 2016-04-15 16:18:34 +0000
+++ maas_deployer/vmaas/engine.py 2016-04-17 17:07:02 +0000
@@ -77,20 +80,21 @@ class DeploymentEngine(object):
         self.wait_for_import_boot_images(client, maas_config)
         self.configure_maas(client, maas_config)

- def _get_juju_node_params(self, juju_domain, juju_config, maas_config):
+ def _get_node_params(self, node_domain, node_config, maas_config,
+ tags=None):
         """
- Determines the mac address of the juju machine specified.
+ Determines the mac address of the node machine specified.

- :param juju_domain: the juju bootstrap image domain
+ :param node_domain: the juju bootstrap image domain
         :param include_power: a boolean value of whether to include
                               power parameters or not for virsh power
                               control.
         """
         node = {
- 'name': juju_domain.name,
- 'architecture': juju_config.get('arch'),
- 'mac_addresses': [x for x in juju_domain.mac_addresses],
- 'tags': 'bootstrap'
+ 'name': node_domain.name,
+ 'architecture': 'amd64/generic',
+ 'mac_addresses': [x for x in node_domain.mac_addresses],
+ 'tags': tags if tags else node_config['tags'],
         }

         virsh_info = maas_config.get('virsh')

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'examples/virtual-nodes.yaml'
2--- examples/virtual-nodes.yaml 1970-01-01 00:00:00 +0000
3+++ examples/virtual-nodes.yaml 2016-03-15 21:55:48 +0000
4@@ -0,0 +1,166 @@
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+ # Contains a list of nodes to be created and registered
22+ virtual-nodes:
23+ - name: keystone
24+ interfaces: ['bridge=virbr0,model=virtio']
25+ vcpus: 1
26+ memory: 2048
27+ arch: amd64
28+ pool: default
29+ disk_size: 10G
30+ sticky_ip_address:
31+ requested_address: 192.168.122.50
32+ tags: keystone
33+ - name: glance
34+ interfaces: ['bridge=virbr0,model=virtio']
35+ vcpus: 1
36+ memory: 2048
37+ arch: amd64
38+ pool: default
39+ disk_size: 50G
40+ sticky_ip_address:
41+ requested_address: 192.168.122.51
42+ tags: glance
43+
44+ maas:
45+ # Defines the general setup for the MAAS environment, including the
46+ # username and password for the host as well as the MAAS server.
47+ user: ubuntu
48+ password: ubuntu
49+
50+ # Contains the virtual machine parameters for creating the MAAS virtual
51+ # server. Here you can configure the name of the virsh domain, the
52+ # parameters for how the network is attached.
53+ name: maas-boot-vm-dc1
54+ interfaces: ['bridge=virbr0,model=virtio']
55+ memory: 4096
56+ vcpus: 2
57+ arch: amd64
58+ pool: default
59+ disk_size: 60G
60+
61+ # Apt http proxy setting(s)
62+ #apt_http_proxy:
63+
64+ # Package sources. These will be used on the MAAS controller.
65+ apt_sources:
66+ - ppa:maas/stable
67+ - ppa:juju/stable
68+
69+ # Virsh power settings
70+ # Specifies the uri and keys to use for virsh power control of the
71+ # juju virtual machine. If the uri is omitted, the value for the
72+ # --remote is used. If no power settings are desired, then do not
73+ # supply the virsh block.
74+ #virsh:
75+ # rsa_priv_key: /path/to/id_rsa
76+ # rsa_pub_key: /path/to/id_rsa.pub
77+ # uri: qemu+ssh://user@10.0.3.1/system
78+
79+ # Defines the IP Address that the configuration script will use to
80+ # to access the MAAS controller via SSH.
81+ ip_address: 192.168.122.2
82+
83+ # This section allows the user to set a series of options on the
84+ # MAAS server itself. The list of config options can be found in
85+ # the upstream MAAS documentation:
86+ # - http://maas.ubuntu.com/docs/api.html#maas-server
87+ settings:
88+ main_archive: http://archive.ubuntu.com/ubuntu
89+ upstream_dns: 192.168.122.1
90+ maas_name: automaas
91+ # kernel_opts: "console=tty0 console=ttyS1,115200n8"
92+ # ntp_server: ntp.ubuntu.com
93+
94+ # This section is used to define the networking parameters for when
95+ # the node first comes up. It is fed into the meta-data cloud-init
96+ # configuration and is used to configure the networking piece of the
97+ # service. The contents of this section are written directly to the
98+ # /etc/network/interfaces file.
99+ #
100+ # Please note, this is slightly different than the
101+ # node-group-interfaces section below. This will configure the
102+ # machine's networking params, and the node-group-interfaces will
103+ # configure the maas node-group interfaces which is used for
104+ # controlling the dhcp, dns, etc.
105+ network_config: |
106+ auto lo
107+ iface lo inet loopback
108+
109+ auto eth0
110+ iface eth0 inet static
111+ address 192.168.122.2
112+ netmask 255.255.248.0
113+ network 192.168.122.0
114+ broadcast 192.168.122.255
115+ gateway 192.168.122.1
116+ dns-nameservers 192.168.122.1 127.0.0.1
117+
118+ # See https://maas.ubuntu.com/docs/maascli.html#node-groups for
119+ # description and full list of supported options.
120+ # NOTE: interfaces are added using the node_group_interfaces section
121+ # and only one node_group can be created by this bundle.
122+ # Additional node groups can be added post deployment.
123+ #node_group:
124+ # # This is the cluster DNS name.
125+ # name: maas
126+
127+ # The node-group-interfaces section is used to configure the MAAS
128+ # network interfaces. Basic configuration is supported, such as which
129+ # device should be bound, the range of IP addresses, etc.
130+ # Note: this may contain the special identifiers:
131+ # ${maas_net} - the first 3 octets of the ipv4 address
132+ # ${maas_ip} - the ip address of the MAAS controller
133+ node_group_ifaces:
134+ - device: eth0
135+ ip: 192.168.122.2
136+ subnet_mask: 255.255.255.0
137+ broadcast_ip: 192.168.122.255
138+ router_ip: 192.168.122.1
139+ static_range:
140+ low: 192.168.122.51
141+ high: 192.168.122.60
142+ dynamic_range:
143+ low: 192.168.122.5
144+ high: 192.168.122.50
145+
146+ # Physical nodes to be added to the MAAS cluster. Nodes will be
147+ # configured, commissioned and put into the Ready state so
148+ # they are ready to be deployed to.
149+ #nodes:
150+ # - name: node1
151+ # tags: api
152+ # architecture: amd64/generic
153+ # mac_addresses:
154+ # - "38:63:bb:43:b8:9c"
155+ # # MAAS power settings. Supported key/values are described here:
156+ # # https://maas.ubuntu.com/docs/api.html#power-types. For keys
157+ # # that start with 'power_' this part can optionally be omitted
158+ # # and will be automatically prepended by maas-deployer. The
159+ # # 'type' key should be set to the power type you want to
160+ # # configure.
161+ # power:
162+ # type: ipmi
163+ # address: 10.0.1.1
164+ # user: maas
165+ # pass: passw0rd
166+ # driver: LAN_2_0
167+ # sticky_ip_address:
168+ # mac_address: "38:63:bb:43:b8:9c"
169+ # requested_address: 192.168.122.6
170+
171
172=== modified file 'maas_deployer/vmaas/engine.py'
173--- maas_deployer/vmaas/engine.py 2016-02-11 09:57:23 +0000
174+++ maas_deployer/vmaas/engine.py 2016-03-15 21:55:48 +0000
175@@ -60,6 +60,11 @@
176 maas_config)
177 nodes.append(juju_node)
178
179+ # create extra VMs
180+ for node in config.get('virtual-nodes', {}):
181+ n = self.deploy_virtual_node(node, maas_config)
182+ nodes.append(n)
183+
184 self.deploy_maas_node(maas_config)
185
186 self.wait_for_maas_installation(maas_config)
187@@ -74,20 +79,21 @@
188 self.wait_for_import_boot_images(client, maas_config)
189 self.configure_maas(client, maas_config)
190
191- def _get_juju_node_params(self, juju_domain, juju_config, maas_config):
192+ def _get_node_params(self, node_domain, node_config, maas_config,
193+ tags=None):
194 """
195- Determines the mac address of the juju machine specified.
196+ Determines the mac address of the node machine specified.
197
198- :param juju_domain: the juju bootstrap image domain
199+ :param node_domain: the juju bootstrap image domain
200 :param include_power: a boolean value of whether to include
201 power parameters or not for virsh power
202 control.
203 """
204 node = {
205- 'name': juju_domain.name,
206+ 'name': node_domain.name,
207 'architecture': 'amd64/generic',
208- 'mac_addresses': [x for x in juju_domain.mac_addresses],
209- 'tags': 'bootstrap'
210+ 'mac_addresses': [x for x in node_domain.mac_addresses],
211+ 'tags': tags if tags else node_config['tags'],
212 }
213
214 virsh_info = maas_config.get('virsh')
215@@ -96,10 +102,10 @@
216 node.update({
217 'power_type': 'virsh',
218 'power_parameters_power_address': uri,
219- 'power_parameters_power_id': juju_domain.name,
220+ 'power_parameters_power_id': node_domain.name,
221 })
222
223- sticky_cfg = juju_config.get('sticky_ip_address')
224+ sticky_cfg = node_config.get('sticky_ip_address')
225 if sticky_cfg:
226 node['sticky_ip_address'] = sticky_cfg
227 node['sticky_ip_address']['mac_address'] = node['mac_addresses'][0]
228@@ -117,7 +123,16 @@
229 juju_node.define()
230 # Insert juju node information into the maas nodes list.
231 # This allows us to define it in maas.
232- return self._get_juju_node_params(juju_node, params, maas_config)
233+ return self._get_node_params(juju_node, params, maas_config,
234+ tags='bootstrap')
235+
236+ def deploy_virtual_node(self, params, maas_config):
237+ log.debug('Creating VM: %s' % params['name'])
238+ with vm.Instance(params) as node:
239+ node.netboot = True
240+ node.define()
241+
242+ return self._get_node_params(node, params, maas_config)
243
244 def deploy_maas_node(self, params):
245 """
246@@ -538,12 +553,13 @@
247 """
248 util.exec_script_remote(maas_config['user'], self.ip_addr, script)
249
250- # Start juju domain
251+ # Start nodes
252 virsh_info = maas_config.get('virsh')
253- juju_node = self._get_juju_nodename(nodes)
254- if juju_node is not None and not virsh_info:
255+ for n in nodes:
256+ name = n['name']
257 try:
258- util.virsh(['start', juju_node])
259+ log.info('Starting: %s' % name)
260+ util.virsh(['start', name])
261 except CalledProcessError as exc:
262 # Ignore already started error
263 msg = 'Domain is already active'

Subscribers

People subscribed via source and target branches