~james-page/ubuntu/wily/juju-core/mir-fixes

« back to all changes in this revision

Viewing changes to src/launchpad.net/juju-core/state/addmachine.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-03-28 08:58:42 UTC
  • mfrom: (1.1.21)
  • Revision ID: package-import@ubuntu.com-20140328085842-cyzrgc120bdfxwj0
Tags: 1.17.7-0ubuntu1
* New upstream point release, including fixes for:
  - no debug log with all providers on Ubuntu 14.04 (LP: #1294776).
* d/control: Add cpu-checker dependency to juju-local (LP: #1297077).

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
        // be associated with the machine.
54
54
        HardwareCharacteristics instance.HardwareCharacteristics
55
55
 
 
56
        // IncludeNetworks holds a list of networks the machine should be
 
57
        // part of.
 
58
        IncludeNetworks []string
 
59
 
 
60
        // ExcludeNetworks holds a list of network the machine should not
 
61
        // be part of.
 
62
        ExcludeNetworks []string
 
63
 
56
64
        // Nonce holds a unique value that can be used to check
57
65
        // if a new instance was really started for this machine.
58
66
        // See Machine.SetProvisioned. This must be set if InstanceId is set.
230
238
        }
231
239
        mdoc := machineDocForTemplate(template, strconv.Itoa(seq))
232
240
        var ops []txn.Op
233
 
        ops = append(ops, st.insertNewMachineOps(mdoc, template.Constraints)...)
 
241
        ops = append(ops, st.insertNewMachineOps(mdoc, template)...)
234
242
        ops = append(ops, st.insertNewContainerRefOp(mdoc.Id))
235
243
        if template.InstanceId != "" {
236
244
                ops = append(ops, txn.Op{
301
309
        mdoc := machineDocForTemplate(template, newId)
302
310
        mdoc.ContainerType = string(containerType)
303
311
        var ops []txn.Op
304
 
        ops = append(ops, st.insertNewMachineOps(mdoc, template.Constraints)...)
 
312
        ops = append(ops, st.insertNewMachineOps(mdoc, template)...)
305
313
        ops = append(ops,
306
314
                // Update containers record for host machine.
307
315
                st.addChildToContainerRefOp(parentId, mdoc.Id),
358
366
        mdoc := machineDocForTemplate(template, newId)
359
367
        mdoc.ContainerType = string(containerType)
360
368
        var ops []txn.Op
361
 
        ops = append(ops, st.insertNewMachineOps(parentDoc, parentTemplate.Constraints)...)
362
 
        ops = append(ops, st.insertNewMachineOps(mdoc, template.Constraints)...)
 
369
        ops = append(ops, st.insertNewMachineOps(parentDoc, parentTemplate)...)
 
370
        ops = append(ops, st.insertNewMachineOps(mdoc, template)...)
363
371
        ops = append(ops,
364
372
                // The host machine doesn't exist yet, create a new containers record.
365
373
                st.insertNewContainerRefOp(mdoc.Id),
385
393
}
386
394
 
387
395
// insertNewMachineOps returns operations to insert the given machine
388
 
// document and its associated constraints into the database.
389
 
func (st *State) insertNewMachineOps(mdoc *machineDoc, cons constraints.Value) []txn.Op {
 
396
// document into the database, based on the given template. Only the
 
397
// constraints and networks are used from the template.
 
398
func (st *State) insertNewMachineOps(mdoc *machineDoc, template MachineTemplate) []txn.Op {
390
399
        return []txn.Op{
391
400
                {
392
401
                        C:      st.machines.Name,
394
403
                        Assert: txn.DocMissing,
395
404
                        Insert: mdoc,
396
405
                },
397
 
                createConstraintsOp(st, machineGlobalKey(mdoc.Id), cons),
 
406
                createConstraintsOp(st, machineGlobalKey(mdoc.Id), template.Constraints),
398
407
                createStatusOp(st, machineGlobalKey(mdoc.Id), statusDoc{
399
408
                        Status: params.StatusPending,
400
409
                }),
 
410
                createNetworksOp(st, machineGlobalKey(mdoc.Id),
 
411
                        template.IncludeNetworks,
 
412
                        template.ExcludeNetworks,
 
413
                ),
401
414
        }
402
415
}
403
416