~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/juju/gomaasapi/machine_test.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2016 Canonical Ltd.
 
2
// Licensed under the LGPLv3, see LICENCE file for details.
 
3
 
 
4
package gomaasapi
 
5
 
 
6
import (
 
7
        "net/http"
 
8
 
 
9
        "github.com/juju/errors"
 
10
        "github.com/juju/testing"
 
11
        jc "github.com/juju/testing/checkers"
 
12
        "github.com/juju/version"
 
13
        gc "gopkg.in/check.v1"
 
14
)
 
15
 
 
16
type machineSuite struct {
 
17
        testing.LoggingCleanupSuite
 
18
}
 
19
 
 
20
var _ = gc.Suite(&machineSuite{})
 
21
 
 
22
func (*machineSuite) TestNilGetters(c *gc.C) {
 
23
        var empty machine
 
24
        c.Check(empty.Zone() == nil, jc.IsTrue)
 
25
        c.Check(empty.PhysicalBlockDevice(0) == nil, jc.IsTrue)
 
26
        c.Check(empty.Interface(0) == nil, jc.IsTrue)
 
27
        c.Check(empty.BootInterface() == nil, jc.IsTrue)
 
28
}
 
29
 
 
30
func (*machineSuite) TestReadMachinesBadSchema(c *gc.C) {
 
31
        _, err := readMachines(twoDotOh, "wat?")
 
32
        c.Check(err, jc.Satisfies, IsDeserializationError)
 
33
        c.Assert(err.Error(), gc.Equals, `machine base schema check failed: expected list, got string("wat?")`)
 
34
 
 
35
        _, err = readMachines(twoDotOh, []map[string]interface{}{
 
36
                {
 
37
                        "wat": "?",
 
38
                },
 
39
        })
 
40
        c.Check(err, jc.Satisfies, IsDeserializationError)
 
41
        c.Assert(err, gc.ErrorMatches, `machine 0: machine 2.0 schema check failed: .*`)
 
42
}
 
43
 
 
44
func (*machineSuite) TestReadMachines(c *gc.C) {
 
45
        machines, err := readMachines(twoDotOh, parseJSON(c, machinesResponse))
 
46
        c.Assert(err, jc.ErrorIsNil)
 
47
        c.Assert(machines, gc.HasLen, 3)
 
48
 
 
49
        machine := machines[0]
 
50
 
 
51
        c.Check(machine.SystemID(), gc.Equals, "4y3ha3")
 
52
        c.Check(machine.Hostname(), gc.Equals, "untasted-markita")
 
53
        c.Check(machine.FQDN(), gc.Equals, "untasted-markita.maas")
 
54
        c.Check(machine.Tags(), jc.DeepEquals, []string{"virtual", "magic"})
 
55
 
 
56
        c.Check(machine.IPAddresses(), jc.DeepEquals, []string{"192.168.100.4"})
 
57
        c.Check(machine.Memory(), gc.Equals, 1024)
 
58
        c.Check(machine.CPUCount(), gc.Equals, 1)
 
59
        c.Check(machine.PowerState(), gc.Equals, "on")
 
60
        c.Check(machine.Zone().Name(), gc.Equals, "default")
 
61
        c.Check(machine.OperatingSystem(), gc.Equals, "ubuntu")
 
62
        c.Check(machine.DistroSeries(), gc.Equals, "trusty")
 
63
        c.Check(machine.Architecture(), gc.Equals, "amd64/generic")
 
64
        c.Check(machine.StatusName(), gc.Equals, "Deployed")
 
65
        c.Check(machine.StatusMessage(), gc.Equals, "From 'Deploying' to 'Deployed'")
 
66
 
 
67
        bootInterface := machine.BootInterface()
 
68
        c.Assert(bootInterface, gc.NotNil)
 
69
        c.Check(bootInterface.Name(), gc.Equals, "eth0")
 
70
 
 
71
        interfaceSet := machine.InterfaceSet()
 
72
        c.Assert(interfaceSet, gc.HasLen, 2)
 
73
        id := interfaceSet[0].ID()
 
74
        c.Assert(machine.Interface(id), jc.DeepEquals, interfaceSet[0])
 
75
        c.Assert(machine.Interface(id+5), gc.IsNil)
 
76
 
 
77
        blockDevices := machine.BlockDevices()
 
78
        c.Assert(blockDevices, gc.HasLen, 2)
 
79
        c.Assert(blockDevices[0].Name(), gc.Equals, "sda")
 
80
        c.Assert(blockDevices[1].Name(), gc.Equals, "sdb")
 
81
 
 
82
        blockDevices = machine.PhysicalBlockDevices()
 
83
        c.Assert(blockDevices, gc.HasLen, 2)
 
84
        c.Assert(blockDevices[0].Name(), gc.Equals, "sda")
 
85
        c.Assert(blockDevices[1].Name(), gc.Equals, "sdb")
 
86
 
 
87
        id = blockDevices[0].ID()
 
88
        c.Assert(machine.PhysicalBlockDevice(id), jc.DeepEquals, blockDevices[0])
 
89
        c.Assert(machine.PhysicalBlockDevice(id+5), gc.IsNil)
 
90
}
 
91
 
 
92
func (*machineSuite) TestReadMachinesNilValues(c *gc.C) {
 
93
        json := parseJSON(c, machinesResponse)
 
94
        data := json.([]interface{})[0].(map[string]interface{})
 
95
        data["architecture"] = nil
 
96
        data["status_message"] = nil
 
97
        data["boot_interface"] = nil
 
98
        machines, err := readMachines(twoDotOh, json)
 
99
        c.Assert(err, jc.ErrorIsNil)
 
100
        c.Assert(machines, gc.HasLen, 3)
 
101
        machine := machines[0]
 
102
        c.Check(machine.Architecture(), gc.Equals, "")
 
103
        c.Check(machine.StatusMessage(), gc.Equals, "")
 
104
        c.Check(machine.BootInterface(), gc.IsNil)
 
105
}
 
106
 
 
107
func (*machineSuite) TestLowVersion(c *gc.C) {
 
108
        _, err := readMachines(version.MustParse("1.9.0"), parseJSON(c, machinesResponse))
 
109
        c.Assert(err, jc.Satisfies, IsUnsupportedVersionError)
 
110
        c.Assert(err.Error(), gc.Equals, `no machine read func for version 1.9.0`)
 
111
}
 
112
 
 
113
func (*machineSuite) TestHighVersion(c *gc.C) {
 
114
        machines, err := readMachines(version.MustParse("2.1.9"), parseJSON(c, machinesResponse))
 
115
        c.Assert(err, jc.ErrorIsNil)
 
116
        c.Assert(machines, gc.HasLen, 3)
 
117
}
 
118
 
 
119
func (s *machineSuite) getServerAndMachine(c *gc.C) (*SimpleTestServer, *machine) {
 
120
        server, controller := createTestServerController(c, s)
 
121
        // Just have machines return one machine
 
122
        server.AddGetResponse("/api/2.0/machines/", http.StatusOK, "["+machineResponse+"]")
 
123
        machines, err := controller.Machines(MachinesArgs{})
 
124
        c.Assert(err, jc.ErrorIsNil)
 
125
        c.Check(machines, gc.HasLen, 1)
 
126
        machine := machines[0].(*machine)
 
127
        return server, machine
 
128
}
 
129
 
 
130
func (s *machineSuite) TestStart(c *gc.C) {
 
131
        server, machine := s.getServerAndMachine(c)
 
132
        response := updateJSONMap(c, machineResponse, map[string]interface{}{
 
133
                "status_name":    "Deploying",
 
134
                "status_message": "for testing",
 
135
        })
 
136
        server.AddPostResponse(machine.resourceURI+"?op=deploy", http.StatusOK, response)
 
137
 
 
138
        err := machine.Start(StartArgs{
 
139
                UserData:     "userdata",
 
140
                DistroSeries: "trusty",
 
141
                Kernel:       "kernel",
 
142
                Comment:      "a comment",
 
143
        })
 
144
        c.Assert(err, jc.ErrorIsNil)
 
145
        c.Assert(machine.StatusName(), gc.Equals, "Deploying")
 
146
        c.Assert(machine.StatusMessage(), gc.Equals, "for testing")
 
147
 
 
148
        request := server.LastRequest()
 
149
        // There should be one entry in the form values for each of the args.
 
150
        form := request.PostForm
 
151
        c.Assert(form, gc.HasLen, 4)
 
152
        c.Check(form.Get("user_data"), gc.Equals, "userdata")
 
153
        c.Check(form.Get("distro_series"), gc.Equals, "trusty")
 
154
        c.Check(form.Get("hwe_kernel"), gc.Equals, "kernel")
 
155
        c.Check(form.Get("comment"), gc.Equals, "a comment")
 
156
}
 
157
 
 
158
func (s *machineSuite) TestStartMachineNotFound(c *gc.C) {
 
159
        server, machine := s.getServerAndMachine(c)
 
160
        server.AddPostResponse(machine.resourceURI+"?op=deploy", http.StatusNotFound, "can't find machine")
 
161
        err := machine.Start(StartArgs{})
 
162
        c.Assert(err, jc.Satisfies, IsBadRequestError)
 
163
        c.Assert(err.Error(), gc.Equals, "can't find machine")
 
164
}
 
165
 
 
166
func (s *machineSuite) TestStartMachineConflict(c *gc.C) {
 
167
        server, machine := s.getServerAndMachine(c)
 
168
        server.AddPostResponse(machine.resourceURI+"?op=deploy", http.StatusConflict, "machine not allocated")
 
169
        err := machine.Start(StartArgs{})
 
170
        c.Assert(err, jc.Satisfies, IsBadRequestError)
 
171
        c.Assert(err.Error(), gc.Equals, "machine not allocated")
 
172
}
 
173
 
 
174
func (s *machineSuite) TestStartMachineForbidden(c *gc.C) {
 
175
        server, machine := s.getServerAndMachine(c)
 
176
        server.AddPostResponse(machine.resourceURI+"?op=deploy", http.StatusForbidden, "machine not yours")
 
177
        err := machine.Start(StartArgs{})
 
178
        c.Assert(err, jc.Satisfies, IsPermissionError)
 
179
        c.Assert(err.Error(), gc.Equals, "machine not yours")
 
180
}
 
181
 
 
182
func (s *machineSuite) TestStartMachineServiceUnavailable(c *gc.C) {
 
183
        server, machine := s.getServerAndMachine(c)
 
184
        server.AddPostResponse(machine.resourceURI+"?op=deploy", http.StatusServiceUnavailable, "no ip addresses available")
 
185
        err := machine.Start(StartArgs{})
 
186
        c.Assert(err, jc.Satisfies, IsCannotCompleteError)
 
187
        c.Assert(err.Error(), gc.Equals, "no ip addresses available")
 
188
}
 
189
 
 
190
func (s *machineSuite) TestStartMachineUnknown(c *gc.C) {
 
191
        server, machine := s.getServerAndMachine(c)
 
192
        server.AddPostResponse(machine.resourceURI+"?op=deploy", http.StatusMethodNotAllowed, "wat?")
 
193
        err := machine.Start(StartArgs{})
 
194
        c.Assert(err, jc.Satisfies, IsUnexpectedError)
 
195
        c.Assert(err.Error(), gc.Equals, "unexpected: ServerError: 405 Method Not Allowed (wat?)")
 
196
}
 
197
 
 
198
func (s *machineSuite) TestDevices(c *gc.C) {
 
199
        server, machine := s.getServerAndMachine(c)
 
200
        server.AddGetResponse("/api/2.0/devices/", http.StatusOK, devicesResponse)
 
201
        devices, err := machine.Devices(DevicesArgs{})
 
202
        c.Assert(err, jc.ErrorIsNil)
 
203
        c.Assert(devices, gc.HasLen, 1)
 
204
        c.Assert(devices[0].Parent(), gc.Equals, machine.SystemID())
 
205
}
 
206
 
 
207
func (s *machineSuite) TestDevicesNone(c *gc.C) {
 
208
        server, machine := s.getServerAndMachine(c)
 
209
        response := updateJSONMap(c, deviceResponse, map[string]interface{}{
 
210
                "parent": "other",
 
211
        })
 
212
        server.AddGetResponse("/api/2.0/devices/", http.StatusOK, "["+response+"]")
 
213
        devices, err := machine.Devices(DevicesArgs{})
 
214
        c.Assert(err, jc.ErrorIsNil)
 
215
        c.Assert(devices, gc.HasLen, 0)
 
216
}
 
217
 
 
218
func (s *machineSuite) TestCreateMachineDeviceArgsValidate(c *gc.C) {
 
219
        for i, test := range []struct {
 
220
                args    CreateMachineDeviceArgs
 
221
                errText string
 
222
        }{{
 
223
                errText: "missing InterfaceName not valid",
 
224
        }, {
 
225
                args: CreateMachineDeviceArgs{
 
226
                        InterfaceName: "eth1",
 
227
                },
 
228
                errText: `missing MACAddress not valid`,
 
229
        }, {
 
230
                args: CreateMachineDeviceArgs{
 
231
                        InterfaceName: "eth1",
 
232
                        MACAddress:    "something",
 
233
                },
 
234
                errText: `missing Subnet not valid`,
 
235
        }, {
 
236
                args: CreateMachineDeviceArgs{
 
237
                        InterfaceName: "eth1",
 
238
                        MACAddress:    "something",
 
239
                        Subnet:        &fakeSubnet{},
 
240
                },
 
241
        }, {
 
242
                args: CreateMachineDeviceArgs{
 
243
                        Hostname:      "is-optional",
 
244
                        InterfaceName: "eth1",
 
245
                        MACAddress:    "something",
 
246
                        Subnet:        &fakeSubnet{},
 
247
                },
 
248
        }} {
 
249
                c.Logf("test %d", i)
 
250
                err := test.args.Validate()
 
251
                if test.errText == "" {
 
252
                        c.Check(err, jc.ErrorIsNil)
 
253
                } else {
 
254
                        c.Check(err, jc.Satisfies, errors.IsNotValid)
 
255
                        c.Check(err.Error(), gc.Equals, test.errText)
 
256
                }
 
257
        }
 
258
}
 
259
 
 
260
func (s *machineSuite) TestCreateDeviceValidates(c *gc.C) {
 
261
        _, machine := s.getServerAndMachine(c)
 
262
        _, err := machine.CreateDevice(CreateMachineDeviceArgs{})
 
263
        c.Assert(err, jc.Satisfies, errors.IsNotValid)
 
264
        c.Assert(err.Error(), gc.Equals, "missing InterfaceName not valid")
 
265
}
 
266
 
 
267
func (s *machineSuite) TestCreateDevice(c *gc.C) {
 
268
        server, machine := s.getServerAndMachine(c)
 
269
        // The createDeviceResponse returns a single interface with the name "eth0".
 
270
        server.AddPostResponse("/api/2.0/devices/?op=", http.StatusOK, createDeviceResponse)
 
271
        updateInterfaceResponse := updateJSONMap(c, interfaceResponse, map[string]interface{}{
 
272
                "name":         "eth4",
 
273
                "links":        []interface{}{},
 
274
                "resource_uri": "/MAAS/api/2.0/nodes/4y3haf/interfaces/48/",
 
275
        })
 
276
        server.AddPutResponse("/MAAS/api/2.0/nodes/4y3haf/interfaces/48/", http.StatusOK, updateInterfaceResponse)
 
277
        linkSubnetResponse := updateJSONMap(c, interfaceResponse, map[string]interface{}{
 
278
                "name":         "eth4",
 
279
                "resource_uri": "/MAAS/api/2.0/nodes/4y3haf/interfaces/48/",
 
280
        })
 
281
        server.AddPostResponse("/MAAS/api/2.0/nodes/4y3haf/interfaces/48/?op=link_subnet", http.StatusOK, linkSubnetResponse)
 
282
        subnet := machine.BootInterface().Links()[0].Subnet()
 
283
        device, err := machine.CreateDevice(CreateMachineDeviceArgs{
 
284
                InterfaceName: "eth4",
 
285
                MACAddress:    "fake-mac-address",
 
286
                Subnet:        subnet,
 
287
        })
 
288
        c.Assert(err, jc.ErrorIsNil)
 
289
        c.Assert(device.InterfaceSet()[0].Name(), gc.Equals, "eth4")
 
290
        c.Assert(device.InterfaceSet()[0].VLAN().ID(), gc.Equals, subnet.VLAN().ID())
 
291
}
 
292
 
 
293
func (s *machineSuite) TestCreateDeviceTriesToDeleteDeviceOnError(c *gc.C) {
 
294
        server, machine := s.getServerAndMachine(c)
 
295
        // The createDeviceResponse returns a single interface with the name "eth0".
 
296
        server.AddPostResponse("/api/2.0/devices/?op=", http.StatusOK, createDeviceResponse)
 
297
        updateInterfaceResponse := updateJSONMap(c, interfaceResponse, map[string]interface{}{
 
298
                "name":         "eth4",
 
299
                "links":        []interface{}{},
 
300
                "resource_uri": "/MAAS/api/2.0/nodes/4y3haf/interfaces/48/",
 
301
        })
 
302
        server.AddPutResponse("/MAAS/api/2.0/nodes/4y3haf/interfaces/48/", http.StatusOK, updateInterfaceResponse)
 
303
        server.AddPostResponse("/MAAS/api/2.0/nodes/4y3haf/interfaces/48/?op=link_subnet", http.StatusServiceUnavailable, "no addresses")
 
304
        // We'll ignore that that it fails to delete, all we care about testing is that it tried.
 
305
        subnet := machine.BootInterface().Links()[0].Subnet()
 
306
        _, err := machine.CreateDevice(CreateMachineDeviceArgs{
 
307
                InterfaceName: "eth4",
 
308
                MACAddress:    "fake-mac-address",
 
309
                Subnet:        subnet,
 
310
        })
 
311
        c.Assert(err, jc.Satisfies, IsCannotCompleteError)
 
312
 
 
313
        request := server.LastRequest()
 
314
        c.Assert(request.Method, gc.Equals, "DELETE")
 
315
        c.Assert(request.RequestURI, gc.Equals, "/MAAS/api/2.0/devices/4y3haf/")
 
316
}
 
317
 
 
318
const (
 
319
        machineResponse = `
 
320
        {
 
321
        "netboot": false,
 
322
        "system_id": "4y3ha3",
 
323
        "ip_addresses": [
 
324
            "192.168.100.4"
 
325
        ],
 
326
        "virtualblockdevice_set": [],
 
327
        "memory": 1024,
 
328
        "cpu_count": 1,
 
329
        "hwe_kernel": "hwe-t",
 
330
        "status_action": "",
 
331
        "osystem": "ubuntu",
 
332
        "node_type_name": "Machine",
 
333
        "macaddress_set": [
 
334
            {
 
335
                "mac_address": "52:54:00:55:b6:80"
 
336
            }
 
337
        ],
 
338
        "special_filesystems": [],
 
339
        "status": 6,
 
340
        "physicalblockdevice_set": [
 
341
            {
 
342
                "path": "/dev/disk/by-dname/sda",
 
343
                "name": "sda",
 
344
                "used_for": "MBR partitioned with 1 partition",
 
345
                "partitions": [
 
346
                    {
 
347
                        "bootable": false,
 
348
                        "id": 1,
 
349
                        "path": "/dev/disk/by-dname/sda-part1",
 
350
                        "filesystem": {
 
351
                            "fstype": "ext4",
 
352
                            "mount_point": "/",
 
353
                            "label": "root",
 
354
                            "mount_options": null,
 
355
                            "uuid": "fcd7745e-f1b5-4f5d-9575-9b0bb796b752"
 
356
                        },
 
357
                        "type": "partition",
 
358
                        "resource_uri": "/MAAS/api/2.0/nodes/4y3ha3/blockdevices/34/partition/1",
 
359
                        "uuid": "6199b7c9-b66f-40f6-a238-a938a58a0adf",
 
360
                        "used_for": "ext4 formatted filesystem mounted at /",
 
361
                        "size": 8581545984
 
362
                    }
 
363
                ],
 
364
                "filesystem": null,
 
365
                "id_path": "/dev/disk/by-id/ata-QEMU_HARDDISK_QM00001",
 
366
                "resource_uri": "/MAAS/api/2.0/nodes/4y3ha3/blockdevices/34/",
 
367
                "id": 34,
 
368
                "serial": "QM00001",
 
369
                "type": "physical",
 
370
                "block_size": 4096,
 
371
                "used_size": 8586788864,
 
372
                "available_size": 0,
 
373
                "partition_table_type": "MBR",
 
374
                "uuid": null,
 
375
                "size": 8589934592,
 
376
                "model": "QEMU HARDDISK",
 
377
                "tags": [
 
378
                    "rotary"
 
379
                ]
 
380
            },
 
381
            {
 
382
                "path": "/dev/disk/by-dname/sdb",
 
383
                "name": "sdb",
 
384
                "used_for": "MBR partitioned with 1 partition",
 
385
                "partitions": [
 
386
                    {
 
387
                        "bootable": false,
 
388
                        "id": 101,
 
389
                        "path": "/dev/disk/by-dname/sdb-part1",
 
390
                        "filesystem": {
 
391
                            "fstype": "ext4",
 
392
                            "mount_point": "/home",
 
393
                            "label": "home",
 
394
                            "mount_options": null,
 
395
                            "uuid": "fcd7745e-f1b5-4f5d-9575-9b0bb796b753"
 
396
                        },
 
397
                        "type": "partition",
 
398
                        "resource_uri": "/MAAS/api/2.0/nodes/4y3ha3/blockdevices/98/partition/101",
 
399
                        "uuid": "6199b7c9-b66f-40f6-a238-a938a58a0ae0",
 
400
                        "used_for": "ext4 formatted filesystem mounted at /home",
 
401
                        "size": 8581545984
 
402
                    }
 
403
                ],
 
404
                "filesystem": null,
 
405
                "id_path": "/dev/disk/by-id/ata-QEMU_HARDDISK_QM00002",
 
406
                "resource_uri": "/MAAS/api/2.0/nodes/4y3ha3/blockdevices/98/",
 
407
                "id": 98,
 
408
                "serial": "QM00002",
 
409
                "type": "physical",
 
410
                "block_size": 4096,
 
411
                "used_size": 8586788864,
 
412
                "available_size": 0,
 
413
                "partition_table_type": "MBR",
 
414
                "uuid": null,
 
415
                "size": 8589934592,
 
416
                "model": "QEMU HARDDISK",
 
417
                "tags": [
 
418
                    "rotary"
 
419
                ]
 
420
            }
 
421
        ],
 
422
        "interface_set": [
 
423
            {
 
424
                "effective_mtu": 1500,
 
425
                "mac_address": "52:54:00:55:b6:80",
 
426
                "children": [],
 
427
                "discovered": [],
 
428
                "params": "",
 
429
                "vlan": {
 
430
                    "resource_uri": "/MAAS/api/2.0/vlans/1/",
 
431
                    "id": 1,
 
432
                    "secondary_rack": null,
 
433
                    "mtu": 1500,
 
434
                    "primary_rack": "4y3h7n",
 
435
                    "name": "untagged",
 
436
                    "fabric": "fabric-0",
 
437
                    "dhcp_on": true,
 
438
                    "vid": 0
 
439
                },
 
440
                "name": "eth0",
 
441
                "enabled": true,
 
442
                "parents": [],
 
443
                "id": 35,
 
444
                "type": "physical",
 
445
                "resource_uri": "/MAAS/api/2.0/nodes/4y3ha3/interfaces/35/",
 
446
                "tags": [],
 
447
                "links": [
 
448
                    {
 
449
                        "id": 82,
 
450
                        "ip_address": "192.168.100.4",
 
451
                        "subnet": {
 
452
                            "resource_uri": "/MAAS/api/2.0/subnets/1/",
 
453
                            "id": 1,
 
454
                            "rdns_mode": 2,
 
455
                            "vlan": {
 
456
                                "resource_uri": "/MAAS/api/2.0/vlans/1/",
 
457
                                "id": 1,
 
458
                                "secondary_rack": null,
 
459
                                "mtu": 1500,
 
460
                                "primary_rack": "4y3h7n",
 
461
                                "name": "untagged",
 
462
                                "fabric": "fabric-0",
 
463
                                "dhcp_on": true,
 
464
                                "vid": 0
 
465
                            },
 
466
                            "dns_servers": [],
 
467
                            "space": "space-0",
 
468
                            "name": "192.168.100.0/24",
 
469
                            "gateway_ip": "192.168.100.1",
 
470
                            "cidr": "192.168.100.0/24"
 
471
                        },
 
472
                        "mode": "auto"
 
473
                    }
 
474
                ]
 
475
            },
 
476
            {
 
477
                "effective_mtu": 1500,
 
478
                "mac_address": "52:54:00:55:b6:81",
 
479
                "children": [],
 
480
                "discovered": [],
 
481
                "params": "",
 
482
                "vlan": {
 
483
                    "resource_uri": "/MAAS/api/2.0/vlans/1/",
 
484
                    "id": 1,
 
485
                    "secondary_rack": null,
 
486
                    "mtu": 1500,
 
487
                    "primary_rack": "4y3h7n",
 
488
                    "name": "untagged",
 
489
                    "fabric": "fabric-0",
 
490
                    "dhcp_on": true,
 
491
                    "vid": 0
 
492
                },
 
493
                "name": "eth0",
 
494
                "enabled": true,
 
495
                "parents": [],
 
496
                "id": 99,
 
497
                "type": "physical",
 
498
                "resource_uri": "/MAAS/api/2.0/nodes/4y3ha3/interfaces/99/",
 
499
                "tags": [],
 
500
                "links": [
 
501
                    {
 
502
                        "id": 83,
 
503
                        "ip_address": "192.168.100.5",
 
504
                        "subnet": {
 
505
                            "resource_uri": "/MAAS/api/2.0/subnets/1/",
 
506
                            "id": 1,
 
507
                            "rdns_mode": 2,
 
508
                            "vlan": {
 
509
                                "resource_uri": "/MAAS/api/2.0/vlans/1/",
 
510
                                "id": 1,
 
511
                                "secondary_rack": null,
 
512
                                "mtu": 1500,
 
513
                                "primary_rack": "4y3h7n",
 
514
                                "name": "untagged",
 
515
                                "fabric": "fabric-0",
 
516
                                "dhcp_on": true,
 
517
                                "vid": 0
 
518
                            },
 
519
                            "dns_servers": [],
 
520
                            "space": "space-0",
 
521
                            "name": "192.168.100.0/24",
 
522
                            "gateway_ip": "192.168.100.1",
 
523
                            "cidr": "192.168.100.0/24"
 
524
                        },
 
525
                        "mode": "auto"
 
526
                    }
 
527
                ]
 
528
            }
 
529
        ],
 
530
        "resource_uri": "/MAAS/api/2.0/machines/4y3ha3/",
 
531
        "hostname": "untasted-markita",
 
532
        "status_name": "Deployed",
 
533
        "min_hwe_kernel": "",
 
534
        "address_ttl": null,
 
535
        "boot_interface": {
 
536
            "effective_mtu": 1500,
 
537
            "mac_address": "52:54:00:55:b6:80",
 
538
            "children": [],
 
539
            "discovered": [],
 
540
            "params": "",
 
541
            "vlan": {
 
542
                "resource_uri": "/MAAS/api/2.0/vlans/1/",
 
543
                "id": 1,
 
544
                "secondary_rack": null,
 
545
                "mtu": 1500,
 
546
                "primary_rack": "4y3h7n",
 
547
                "name": "untagged",
 
548
                "fabric": "fabric-0",
 
549
                "dhcp_on": true,
 
550
                "vid": 0
 
551
            },
 
552
            "name": "eth0",
 
553
            "enabled": true,
 
554
            "parents": [],
 
555
            "id": 35,
 
556
            "type": "physical",
 
557
            "resource_uri": "/MAAS/api/2.0/nodes/4y3ha3/interfaces/35/",
 
558
            "tags": [],
 
559
            "links": [
 
560
                {
 
561
                    "id": 82,
 
562
                    "ip_address": "192.168.100.4",
 
563
                    "subnet": {
 
564
                        "resource_uri": "/MAAS/api/2.0/subnets/1/",
 
565
                        "id": 1,
 
566
                        "rdns_mode": 2,
 
567
                        "vlan": {
 
568
                            "resource_uri": "/MAAS/api/2.0/vlans/1/",
 
569
                            "id": 1,
 
570
                            "secondary_rack": null,
 
571
                            "mtu": 1500,
 
572
                            "primary_rack": "4y3h7n",
 
573
                            "name": "untagged",
 
574
                            "fabric": "fabric-0",
 
575
                            "dhcp_on": true,
 
576
                            "vid": 0
 
577
                        },
 
578
                        "dns_servers": [],
 
579
                        "space": "space-0",
 
580
                        "name": "192.168.100.0/24",
 
581
                        "gateway_ip": "192.168.100.1",
 
582
                        "cidr": "192.168.100.0/24"
 
583
                    },
 
584
                    "mode": "auto"
 
585
                }
 
586
            ]
 
587
        },
 
588
        "power_state": "on",
 
589
        "architecture": "amd64/generic",
 
590
        "power_type": "virsh",
 
591
        "distro_series": "trusty",
 
592
        "tag_names": [
 
593
            "virtual", "magic"
 
594
        ],
 
595
        "disable_ipv4": false,
 
596
        "status_message": "From 'Deploying' to 'Deployed'",
 
597
        "swap_size": null,
 
598
        "blockdevice_set": [
 
599
            {
 
600
                "path": "/dev/disk/by-dname/sda",
 
601
                "partition_table_type": "MBR",
 
602
                "name": "sda",
 
603
                "used_for": "MBR partitioned with 1 partition",
 
604
                "partitions": [
 
605
                    {
 
606
                        "bootable": false,
 
607
                        "id": 1,
 
608
                        "path": "/dev/disk/by-dname/sda-part1",
 
609
                        "filesystem": {
 
610
                            "fstype": "ext4",
 
611
                            "mount_point": "/",
 
612
                            "label": "root",
 
613
                            "mount_options": null,
 
614
                            "uuid": "fcd7745e-f1b5-4f5d-9575-9b0bb796b752"
 
615
                        },
 
616
                        "type": "partition",
 
617
                        "resource_uri": "/MAAS/api/2.0/nodes/4y3ha3/blockdevices/34/partition/1",
 
618
                        "uuid": "6199b7c9-b66f-40f6-a238-a938a58a0adf",
 
619
                        "used_for": "ext4 formatted filesystem mounted at /",
 
620
                        "size": 8581545984
 
621
                    }
 
622
                ],
 
623
                "filesystem": null,
 
624
                "id_path": "/dev/disk/by-id/ata-QEMU_HARDDISK_QM00001",
 
625
                "resource_uri": "/MAAS/api/2.0/nodes/4y3ha3/blockdevices/34/",
 
626
                "id": 34,
 
627
                "serial": "QM00001",
 
628
                "block_size": 4096,
 
629
                "type": "physical",
 
630
                "used_size": 8586788864,
 
631
                "tags": [
 
632
                    "rotary"
 
633
                ],
 
634
                "available_size": 0,
 
635
                "uuid": null,
 
636
                "size": 8589934592,
 
637
                "model": "QEMU HARDDISK"
 
638
            },
 
639
            {
 
640
                "path": "/dev/disk/by-dname/sdb",
 
641
                "name": "sdb",
 
642
                "used_for": "MBR partitioned with 1 partition",
 
643
                "partitions": [
 
644
                    {
 
645
                        "bootable": false,
 
646
                        "id": 101,
 
647
                        "path": "/dev/disk/by-dname/sdb-part1",
 
648
                        "filesystem": {
 
649
                            "fstype": "ext4",
 
650
                            "mount_point": "/home",
 
651
                            "label": "home",
 
652
                            "mount_options": null,
 
653
                            "uuid": "fcd7745e-f1b5-4f5d-9575-9b0bb796b753"
 
654
                        },
 
655
                        "type": "partition",
 
656
                        "resource_uri": "/MAAS/api/2.0/nodes/4y3ha3/blockdevices/98/partition/101",
 
657
                        "uuid": "6199b7c9-b66f-40f6-a238-a938a58a0ae0",
 
658
                        "used_for": "ext4 formatted filesystem mounted at /home",
 
659
                        "size": 8581545984
 
660
                    }
 
661
                ],
 
662
                "filesystem": null,
 
663
                "id_path": "/dev/disk/by-id/ata-QEMU_HARDDISK_QM00002",
 
664
                "resource_uri": "/MAAS/api/2.0/nodes/4y3ha3/blockdevices/98/",
 
665
                "id": 98,
 
666
                "serial": "QM00002",
 
667
                "type": "physical",
 
668
                "block_size": 4096,
 
669
                "used_size": 8586788864,
 
670
                "available_size": 0,
 
671
                "partition_table_type": "MBR",
 
672
                "uuid": null,
 
673
                "size": 8589934592,
 
674
                "model": "QEMU HARDDISK",
 
675
                "tags": [
 
676
                    "rotary"
 
677
                ]
 
678
            }
 
679
        ],
 
680
        "zone": {
 
681
            "description": "",
 
682
            "resource_uri": "/MAAS/api/2.0/zones/default/",
 
683
            "name": "default"
 
684
        },
 
685
        "fqdn": "untasted-markita.maas",
 
686
        "storage": 8589.934592,
 
687
        "node_type": 0,
 
688
        "boot_disk": null,
 
689
        "owner": "thumper",
 
690
        "domain": {
 
691
            "id": 0,
 
692
            "name": "maas",
 
693
            "resource_uri": "/MAAS/api/2.0/domains/0/",
 
694
            "resource_record_count": 0,
 
695
            "ttl": null,
 
696
            "authoritative": true
 
697
        }
 
698
    }
 
699
`
 
700
        machinesResponse = "[" + machineResponse + `,
 
701
    {
 
702
        "netboot": true,
 
703
        "system_id": "4y3ha4",
 
704
        "ip_addresses": [],
 
705
        "virtualblockdevice_set": [],
 
706
        "memory": 1024,
 
707
        "cpu_count": 1,
 
708
        "hwe_kernel": "",
 
709
        "status_action": "",
 
710
        "osystem": "",
 
711
        "node_type_name": "Machine",
 
712
        "macaddress_set": [
 
713
            {
 
714
                "mac_address": "52:54:00:33:6b:2c"
 
715
            }
 
716
        ],
 
717
        "special_filesystems": [],
 
718
        "status": 4,
 
719
        "physicalblockdevice_set": [
 
720
            {
 
721
                "path": "/dev/disk/by-dname/sda",
 
722
                "name": "sda",
 
723
                "used_for": "MBR partitioned with 1 partition",
 
724
                "partitions": [
 
725
                    {
 
726
                        "bootable": false,
 
727
                        "id": 2,
 
728
                        "path": "/dev/disk/by-dname/sda-part1",
 
729
                        "filesystem": {
 
730
                            "fstype": "ext4",
 
731
                            "mount_point": "/",
 
732
                            "label": "root",
 
733
                            "mount_options": null,
 
734
                            "uuid": "7a0e75a8-0bc6-456b-ac92-4769e97baf02"
 
735
                        },
 
736
                        "type": "partition",
 
737
                        "resource_uri": "/MAAS/api/2.0/nodes/4y3ha4/blockdevices/35/partition/2",
 
738
                        "uuid": "6fe782cf-ad1a-4b31-8beb-333401b4d4bb",
 
739
                        "used_for": "ext4 formatted filesystem mounted at /",
 
740
                        "size": 8581545984
 
741
                    }
 
742
                ],
 
743
                "filesystem": null,
 
744
                "id_path": "/dev/disk/by-id/ata-QEMU_HARDDISK_QM00001",
 
745
                "resource_uri": "/MAAS/api/2.0/nodes/4y3ha4/blockdevices/35/",
 
746
                "id": 35,
 
747
                "serial": "QM00001",
 
748
                "type": "physical",
 
749
                "block_size": 4096,
 
750
                "used_size": 8586788864,
 
751
                "available_size": 0,
 
752
                "partition_table_type": "MBR",
 
753
                "uuid": null,
 
754
                "size": 8589934592,
 
755
                "model": "QEMU HARDDISK",
 
756
                "tags": [
 
757
                    "rotary"
 
758
                ]
 
759
            }
 
760
        ],
 
761
        "interface_set": [
 
762
            {
 
763
                "effective_mtu": 1500,
 
764
                "mac_address": "52:54:00:33:6b:2c",
 
765
                "children": [],
 
766
                "discovered": [],
 
767
                "params": "",
 
768
                "vlan": {
 
769
                    "resource_uri": "/MAAS/api/2.0/vlans/1/",
 
770
                    "id": 1,
 
771
                    "secondary_rack": null,
 
772
                    "mtu": 1500,
 
773
                    "primary_rack": "4y3h7n",
 
774
                    "name": "untagged",
 
775
                    "fabric": "fabric-0",
 
776
                    "dhcp_on": true,
 
777
                    "vid": 0
 
778
                },
 
779
                "name": "eth0",
 
780
                "enabled": true,
 
781
                "parents": [],
 
782
                "id": 39,
 
783
                "type": "physical",
 
784
                "resource_uri": "/MAAS/api/2.0/nodes/4y3ha4/interfaces/39/",
 
785
                "tags": [],
 
786
                "links": [
 
787
                    {
 
788
                        "id": 67,
 
789
                        "mode": "auto",
 
790
                        "subnet": {
 
791
                            "resource_uri": "/MAAS/api/2.0/subnets/1/",
 
792
                            "id": 1,
 
793
                            "rdns_mode": 2,
 
794
                            "vlan": {
 
795
                                "resource_uri": "/MAAS/api/2.0/vlans/1/",
 
796
                                "id": 1,
 
797
                                "secondary_rack": null,
 
798
                                "mtu": 1500,
 
799
                                "primary_rack": "4y3h7n",
 
800
                                "name": "untagged",
 
801
                                "fabric": "fabric-0",
 
802
                                "dhcp_on": true,
 
803
                                "vid": 0
 
804
                            },
 
805
                            "dns_servers": [],
 
806
                            "space": "space-0",
 
807
                            "name": "192.168.100.0/24",
 
808
                            "gateway_ip": "192.168.100.1",
 
809
                            "cidr": "192.168.100.0/24"
 
810
                        }
 
811
                    }
 
812
                ]
 
813
            }
 
814
        ],
 
815
        "resource_uri": "/MAAS/api/2.0/machines/4y3ha4/",
 
816
        "hostname": "lowlier-glady",
 
817
        "status_name": "Ready",
 
818
        "min_hwe_kernel": "",
 
819
        "address_ttl": null,
 
820
        "boot_interface": {
 
821
            "effective_mtu": 1500,
 
822
            "mac_address": "52:54:00:33:6b:2c",
 
823
            "children": [],
 
824
            "discovered": [],
 
825
            "params": "",
 
826
            "vlan": {
 
827
                "resource_uri": "/MAAS/api/2.0/vlans/1/",
 
828
                "id": 1,
 
829
                "secondary_rack": null,
 
830
                "mtu": 1500,
 
831
                "primary_rack": "4y3h7n",
 
832
                "name": "untagged",
 
833
                "fabric": "fabric-0",
 
834
                "dhcp_on": true,
 
835
                "vid": 0
 
836
            },
 
837
            "name": "eth0",
 
838
            "enabled": true,
 
839
            "parents": [],
 
840
            "id": 39,
 
841
            "type": "physical",
 
842
            "resource_uri": "/MAAS/api/2.0/nodes/4y3ha4/interfaces/39/",
 
843
            "tags": [],
 
844
            "links": [
 
845
                {
 
846
                    "id": 67,
 
847
                    "mode": "auto",
 
848
                    "subnet": {
 
849
                        "resource_uri": "/MAAS/api/2.0/subnets/1/",
 
850
                        "id": 1,
 
851
                        "rdns_mode": 2,
 
852
                        "vlan": {
 
853
                            "resource_uri": "/MAAS/api/2.0/vlans/1/",
 
854
                            "id": 1,
 
855
                            "secondary_rack": null,
 
856
                            "mtu": 1500,
 
857
                            "primary_rack": "4y3h7n",
 
858
                            "name": "untagged",
 
859
                            "fabric": "fabric-0",
 
860
                            "dhcp_on": true,
 
861
                            "vid": 0
 
862
                        },
 
863
                        "dns_servers": [],
 
864
                        "space": "space-0",
 
865
                        "name": "192.168.100.0/24",
 
866
                        "gateway_ip": "192.168.100.1",
 
867
                        "cidr": "192.168.100.0/24"
 
868
                    }
 
869
                }
 
870
            ]
 
871
        },
 
872
        "power_state": "off",
 
873
        "architecture": "amd64/generic",
 
874
        "power_type": "virsh",
 
875
        "distro_series": "",
 
876
        "tag_names": [
 
877
            "virtual"
 
878
        ],
 
879
        "disable_ipv4": false,
 
880
        "status_message": "From 'Commissioning' to 'Ready'",
 
881
        "swap_size": null,
 
882
        "blockdevice_set": [
 
883
            {
 
884
                "path": "/dev/disk/by-dname/sda",
 
885
                "partition_table_type": "MBR",
 
886
                "name": "sda",
 
887
                "used_for": "MBR partitioned with 1 partition",
 
888
                "partitions": [
 
889
                    {
 
890
                        "bootable": false,
 
891
                        "id": 2,
 
892
                        "path": "/dev/disk/by-dname/sda-part1",
 
893
                        "filesystem": {
 
894
                            "fstype": "ext4",
 
895
                            "mount_point": "/",
 
896
                            "label": "root",
 
897
                            "mount_options": null,
 
898
                            "uuid": "7a0e75a8-0bc6-456b-ac92-4769e97baf02"
 
899
                        },
 
900
                        "type": "partition",
 
901
                        "resource_uri": "/MAAS/api/2.0/nodes/4y3ha4/blockdevices/35/partition/2",
 
902
                        "uuid": "6fe782cf-ad1a-4b31-8beb-333401b4d4bb",
 
903
                        "used_for": "ext4 formatted filesystem mounted at /",
 
904
                        "size": 8581545984
 
905
                    }
 
906
                ],
 
907
                "filesystem": null,
 
908
                "id_path": "/dev/disk/by-id/ata-QEMU_HARDDISK_QM00001",
 
909
                "resource_uri": "/MAAS/api/2.0/nodes/4y3ha4/blockdevices/35/",
 
910
                "id": 35,
 
911
                "serial": "QM00001",
 
912
                "block_size": 4096,
 
913
                "type": "physical",
 
914
                "used_size": 8586788864,
 
915
                "tags": [
 
916
                    "rotary"
 
917
                ],
 
918
                "available_size": 0,
 
919
                "uuid": null,
 
920
                "size": 8589934592,
 
921
                "model": "QEMU HARDDISK"
 
922
            }
 
923
        ],
 
924
        "zone": {
 
925
            "description": "",
 
926
            "resource_uri": "/MAAS/api/2.0/zones/default/",
 
927
            "name": "default"
 
928
        },
 
929
        "fqdn": "lowlier-glady.maas",
 
930
        "storage": 8589.934592,
 
931
        "node_type": 0,
 
932
        "boot_disk": null,
 
933
        "owner": null,
 
934
        "domain": {
 
935
            "id": 0,
 
936
            "name": "maas",
 
937
            "resource_uri": "/MAAS/api/2.0/domains/0/",
 
938
            "resource_record_count": 0,
 
939
            "ttl": null,
 
940
            "authoritative": true
 
941
        }
 
942
    },
 
943
    {
 
944
        "netboot": true,
 
945
        "system_id": "4y3ha6",
 
946
        "ip_addresses": [],
 
947
        "virtualblockdevice_set": [],
 
948
        "memory": 1024,
 
949
        "cpu_count": 1,
 
950
        "hwe_kernel": "",
 
951
        "status_action": "",
 
952
        "osystem": "",
 
953
        "node_type_name": "Machine",
 
954
        "macaddress_set": [
 
955
            {
 
956
                "mac_address": "52:54:00:c9:6a:45"
 
957
            }
 
958
        ],
 
959
        "special_filesystems": [],
 
960
        "status": 4,
 
961
        "physicalblockdevice_set": [
 
962
            {
 
963
                "path": "/dev/disk/by-dname/sda",
 
964
                "name": "sda",
 
965
                "used_for": "MBR partitioned with 1 partition",
 
966
                "partitions": [
 
967
                    {
 
968
                        "bootable": false,
 
969
                        "id": 3,
 
970
                        "path": "/dev/disk/by-dname/sda-part1",
 
971
                        "filesystem": {
 
972
                            "fstype": "ext4",
 
973
                            "mount_point": "/",
 
974
                            "label": "root",
 
975
                            "mount_options": null,
 
976
                            "uuid": "f15b4e94-7dc3-460d-8838-0c299905c799"
 
977
                        },
 
978
                        "type": "partition",
 
979
                        "resource_uri": "/MAAS/api/2.0/nodes/4y3ha6/blockdevices/36/partition/3",
 
980
                        "uuid": "a20ae130-bd8f-41b5-bdb3-47ab11a621b5",
 
981
                        "used_for": "ext4 formatted filesystem mounted at /",
 
982
                        "size": 8581545984
 
983
                    }
 
984
                ],
 
985
                "filesystem": null,
 
986
                "id_path": "/dev/disk/by-id/ata-QEMU_HARDDISK_QM00001",
 
987
                "resource_uri": "/MAAS/api/2.0/nodes/4y3ha6/blockdevices/36/",
 
988
                "id": 36,
 
989
                "serial": "QM00001",
 
990
                "type": "physical",
 
991
                "block_size": 4096,
 
992
                "used_size": 8586788864,
 
993
                "available_size": 0,
 
994
                "partition_table_type": "MBR",
 
995
                "uuid": null,
 
996
                "size": 8589934592,
 
997
                "model": "QEMU HARDDISK",
 
998
                "tags": [
 
999
                    "rotary"
 
1000
                ]
 
1001
            }
 
1002
        ],
 
1003
        "interface_set": [
 
1004
            {
 
1005
                "effective_mtu": 1500,
 
1006
                "mac_address": "52:54:00:c9:6a:45",
 
1007
                "children": [],
 
1008
                "discovered": [],
 
1009
                "params": "",
 
1010
                "vlan": {
 
1011
                    "resource_uri": "/MAAS/api/2.0/vlans/1/",
 
1012
                    "id": 1,
 
1013
                    "secondary_rack": null,
 
1014
                    "mtu": 1500,
 
1015
                    "primary_rack": "4y3h7n",
 
1016
                    "name": "untagged",
 
1017
                    "fabric": "fabric-0",
 
1018
                    "dhcp_on": true,
 
1019
                    "vid": 0
 
1020
                },
 
1021
                "name": "eth0",
 
1022
                "enabled": true,
 
1023
                "parents": [],
 
1024
                "id": 40,
 
1025
                "type": "physical",
 
1026
                "resource_uri": "/MAAS/api/2.0/nodes/4y3ha6/interfaces/40/",
 
1027
                "tags": [],
 
1028
                "links": [
 
1029
                    {
 
1030
                        "id": 69,
 
1031
                        "mode": "auto",
 
1032
                        "subnet": {
 
1033
                            "resource_uri": "/MAAS/api/2.0/subnets/1/",
 
1034
                            "id": 1,
 
1035
                            "rdns_mode": 2,
 
1036
                            "vlan": {
 
1037
                                "resource_uri": "/MAAS/api/2.0/vlans/1/",
 
1038
                                "id": 1,
 
1039
                                "secondary_rack": null,
 
1040
                                "mtu": 1500,
 
1041
                                "primary_rack": "4y3h7n",
 
1042
                                "name": "untagged",
 
1043
                                "fabric": "fabric-0",
 
1044
                                "dhcp_on": true,
 
1045
                                "vid": 0
 
1046
                            },
 
1047
                            "dns_servers": [],
 
1048
                            "space": "space-0",
 
1049
                            "name": "192.168.100.0/24",
 
1050
                            "gateway_ip": "192.168.100.1",
 
1051
                            "cidr": "192.168.100.0/24"
 
1052
                        }
 
1053
                    }
 
1054
                ]
 
1055
            }
 
1056
        ],
 
1057
        "resource_uri": "/MAAS/api/2.0/machines/4y3ha6/",
 
1058
        "hostname": "icier-nina",
 
1059
        "status_name": "Ready",
 
1060
        "min_hwe_kernel": "",
 
1061
        "address_ttl": null,
 
1062
        "boot_interface": {
 
1063
            "effective_mtu": 1500,
 
1064
            "mac_address": "52:54:00:c9:6a:45",
 
1065
            "children": [],
 
1066
            "discovered": [],
 
1067
            "params": "",
 
1068
            "vlan": {
 
1069
                "resource_uri": "/MAAS/api/2.0/vlans/1/",
 
1070
                "id": 1,
 
1071
                "secondary_rack": null,
 
1072
                "mtu": 1500,
 
1073
                "primary_rack": "4y3h7n",
 
1074
                "name": "untagged",
 
1075
                "fabric": "fabric-0",
 
1076
                "dhcp_on": true,
 
1077
                "vid": 0
 
1078
            },
 
1079
            "name": "eth0",
 
1080
            "enabled": true,
 
1081
            "parents": [],
 
1082
            "id": 40,
 
1083
            "type": "physical",
 
1084
            "resource_uri": "/MAAS/api/2.0/nodes/4y3ha6/interfaces/40/",
 
1085
            "tags": [],
 
1086
            "links": [
 
1087
                {
 
1088
                    "id": 69,
 
1089
                    "mode": "auto",
 
1090
                    "subnet": {
 
1091
                        "resource_uri": "/MAAS/api/2.0/subnets/1/",
 
1092
                        "id": 1,
 
1093
                        "rdns_mode": 2,
 
1094
                        "vlan": {
 
1095
                            "resource_uri": "/MAAS/api/2.0/vlans/1/",
 
1096
                            "id": 1,
 
1097
                            "secondary_rack": null,
 
1098
                            "mtu": 1500,
 
1099
                            "primary_rack": "4y3h7n",
 
1100
                            "name": "untagged",
 
1101
                            "fabric": "fabric-0",
 
1102
                            "dhcp_on": true,
 
1103
                            "vid": 0
 
1104
                        },
 
1105
                        "dns_servers": [],
 
1106
                        "space": "space-0",
 
1107
                        "name": "192.168.100.0/24",
 
1108
                        "gateway_ip": "192.168.100.1",
 
1109
                        "cidr": "192.168.100.0/24"
 
1110
                    }
 
1111
                }
 
1112
            ]
 
1113
        },
 
1114
        "power_state": "off",
 
1115
        "architecture": "amd64/generic",
 
1116
        "power_type": "virsh",
 
1117
        "distro_series": "",
 
1118
        "tag_names": [
 
1119
            "virtual"
 
1120
        ],
 
1121
        "disable_ipv4": false,
 
1122
        "status_message": "From 'Commissioning' to 'Ready'",
 
1123
        "swap_size": null,
 
1124
        "blockdevice_set": [
 
1125
            {
 
1126
                "path": "/dev/disk/by-dname/sda",
 
1127
                "partition_table_type": "MBR",
 
1128
                "name": "sda",
 
1129
                "used_for": "MBR partitioned with 1 partition",
 
1130
                "partitions": [
 
1131
                    {
 
1132
                        "bootable": false,
 
1133
                        "id": 3,
 
1134
                        "path": "/dev/disk/by-dname/sda-part1",
 
1135
                        "filesystem": {
 
1136
                            "fstype": "ext4",
 
1137
                            "mount_point": "/",
 
1138
                            "label": "root",
 
1139
                            "mount_options": null,
 
1140
                            "uuid": "f15b4e94-7dc3-460d-8838-0c299905c799"
 
1141
                        },
 
1142
                        "type": "partition",
 
1143
                        "resource_uri": "/MAAS/api/2.0/nodes/4y3ha6/blockdevices/36/partition/3",
 
1144
                        "uuid": "a20ae130-bd8f-41b5-bdb3-47ab11a621b5",
 
1145
                        "used_for": "ext4 formatted filesystem mounted at /",
 
1146
                        "size": 8581545984
 
1147
                    }
 
1148
                ],
 
1149
                "filesystem": null,
 
1150
                "id_path": "/dev/disk/by-id/ata-QEMU_HARDDISK_QM00001",
 
1151
                "resource_uri": "/MAAS/api/2.0/nodes/4y3ha6/blockdevices/36/",
 
1152
                "id": 36,
 
1153
                "serial": "QM00001",
 
1154
                "block_size": 4096,
 
1155
                "type": "physical",
 
1156
                "used_size": 8586788864,
 
1157
                "tags": [
 
1158
                    "rotary"
 
1159
                ],
 
1160
                "available_size": 0,
 
1161
                "uuid": null,
 
1162
                "size": 8589934592,
 
1163
                "model": "QEMU HARDDISK"
 
1164
            }
 
1165
        ],
 
1166
        "zone": {
 
1167
            "description": "",
 
1168
            "resource_uri": "/MAAS/api/2.0/zones/default/",
 
1169
            "name": "default"
 
1170
        },
 
1171
        "fqdn": "icier-nina.maas",
 
1172
        "storage": 8589.934592,
 
1173
        "node_type": 0,
 
1174
        "boot_disk": null,
 
1175
        "owner": null,
 
1176
        "domain": {
 
1177
            "id": 0,
 
1178
            "name": "maas",
 
1179
            "resource_uri": "/MAAS/api/2.0/domains/0/",
 
1180
            "resource_record_count": 0,
 
1181
            "ttl": null,
 
1182
            "authoritative": true
 
1183
        }
 
1184
    }
 
1185
]
 
1186
`
 
1187
 
 
1188
        createDeviceResponse = `
 
1189
{
 
1190
        "zone": {
 
1191
                "description": "",
 
1192
                "resource_uri": "/MAAS/api/2.0/zones/default/",
 
1193
                "name": "default"
 
1194
        },
 
1195
        "domain": {
 
1196
                "resource_record_count": 0,
 
1197
                "resource_uri": "/MAAS/api/2.0/domains/0/",
 
1198
                "authoritative": true,
 
1199
                "name": "maas",
 
1200
                "ttl": null,
 
1201
                "id": 0
 
1202
        },
 
1203
        "node_type_name": "Device",
 
1204
        "address_ttl": null,
 
1205
        "hostname": "furnacelike-brittney",
 
1206
        "node_type": 1,
 
1207
        "resource_uri": "/MAAS/api/2.0/devices/4y3haf/",
 
1208
        "ip_addresses": ["192.168.100.11"],
 
1209
        "owner": "thumper",
 
1210
        "tag_names": [],
 
1211
        "fqdn": "furnacelike-brittney.maas",
 
1212
        "system_id": "4y3haf",
 
1213
        "parent": "4y3ha3",
 
1214
        "interface_set": [
 
1215
                {
 
1216
                        "resource_uri": "/MAAS/api/2.0/nodes/4y3haf/interfaces/48/",
 
1217
                        "type": "physical",
 
1218
                        "mac_address": "78:f0:f1:16:a7:46",
 
1219
                        "params": "",
 
1220
                        "discovered": null,
 
1221
                        "effective_mtu": 1500,
 
1222
                        "id": 48,
 
1223
                        "children": [],
 
1224
                        "links": [],
 
1225
                        "name": "eth0",
 
1226
                        "vlan": {
 
1227
                                "secondary_rack": null,
 
1228
                                "dhcp_on": true,
 
1229
                                "fabric": "fabric-0",
 
1230
                                "mtu": 1500,
 
1231
                                "primary_rack": "4y3h7n",
 
1232
                                "resource_uri": "/MAAS/api/2.0/vlans/1/",
 
1233
                                "external_dhcp": null,
 
1234
                                "name": "untagged",
 
1235
                                "id": 1,
 
1236
                                "vid": 0
 
1237
                        },
 
1238
                        "tags": [],
 
1239
                        "parents": [],
 
1240
                        "enabled": true
 
1241
                }
 
1242
        ]
 
1243
}
 
1244
`
 
1245
)