Index: state/addmachine.go |
=== modified file 'state/addmachine.go' |
--- state/addmachine.go 2014-03-25 09:15:00 +0000 |
+++ state/addmachine.go 2014-04-03 03:37:45 +0000 |
@@ -133,6 +133,13 @@ |
var ops []txn.Op |
var mdocs []*machineDoc |
for _, template := range templates { |
+ // Adding a machine without any principals is |
+ // only permitted unit placement is supported. |
+ if len(template.principals) == 0 { |
+ if err := st.supportsUnitPlacement(); err != nil { |
+ return nil, err |
+ } |
+ } |
mdoc, addOps, err := st.addMachineOps(template) |
if err != nil { |
return nil, err |
@@ -292,6 +299,10 @@ |
if containerType == "" { |
return nil, nil, fmt.Errorf("no container type specified") |
} |
+ // Adding a machine within a machine implies add-machine or placement. |
+ if err := st.supportsUnitPlacement(); err != nil { |
+ return nil, nil, err |
+ } |
// If a parent machine is specified, make sure it exists |
// and can support the requested container type. |
@@ -352,6 +363,10 @@ |
if err := st.precheckInstance(parentTemplate.Series, parentTemplate.Constraints); err != nil { |
return nil, nil, err |
} |
+ // Adding a machine within a machine implies add-machine or placement. |
+ if err := st.supportsUnitPlacement(); err != nil { |
+ return nil, nil, err |
+ } |
} |
parentDoc := machineDocForTemplate(parentTemplate, strconv.Itoa(seq)) |