OLD | NEW |
1 // Copyright 2012, 2013 Canonical Ltd. | 1 // Copyright 2012, 2013 Canonical Ltd. |
2 // Licensed under the AGPLv3, see LICENCE file for details. | 2 // Licensed under the AGPLv3, see LICENCE file for details. |
3 | 3 |
4 package provisioner | 4 package provisioner |
5 | 5 |
6 import ( | 6 import ( |
7 "fmt" | 7 "fmt" |
8 | 8 |
9 "launchpad.net/juju-core/constraints" | 9 "launchpad.net/juju-core/constraints" |
| 10 "launchpad.net/juju-core/container" |
10 "launchpad.net/juju-core/instance" | 11 "launchpad.net/juju-core/instance" |
11 "launchpad.net/juju-core/names" | 12 "launchpad.net/juju-core/names" |
12 "launchpad.net/juju-core/state" | 13 "launchpad.net/juju-core/state" |
13 "launchpad.net/juju-core/state/api/params" | 14 "launchpad.net/juju-core/state/api/params" |
14 "launchpad.net/juju-core/state/apiserver/common" | 15 "launchpad.net/juju-core/state/apiserver/common" |
15 "launchpad.net/juju-core/state/watcher" | 16 "launchpad.net/juju-core/state/watcher" |
16 "launchpad.net/juju-core/utils/set" | 17 "launchpad.net/juju-core/utils/set" |
17 ) | 18 ) |
18 | 19 |
19 // ProvisionerAPI provides access to the Provisioner API facade. | 20 // ProvisionerAPI provides access to the Provisioner API facade. |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 } else { | 184 } else { |
184 err = machine.SetSupportedContainers(arg.ContainerTypes) | 185 err = machine.SetSupportedContainers(arg.ContainerTypes) |
185 } | 186 } |
186 if err != nil { | 187 if err != nil { |
187 result.Results[i].Error = common.ServerError(err) | 188 result.Results[i].Error = common.ServerError(err) |
188 } | 189 } |
189 } | 190 } |
190 return result, nil | 191 return result, nil |
191 } | 192 } |
192 | 193 |
| 194 // ContainerManagerConfig returns information from the environment config that a
re |
| 195 // needed for configuring the container manager. |
| 196 func (p *ProvisionerAPI) ContainerManagerConfig(args params.ContainerManagerConf
igParams) (params.ContainerManagerConfig, error) { |
| 197 var result params.ContainerManagerConfig |
| 198 config, err := p.st.EnvironConfig() |
| 199 if err != nil { |
| 200 return result, err |
| 201 } |
| 202 cfg := make(map[string]string) |
| 203 cfg[container.ConfigName] = "juju" |
| 204 switch args.Type { |
| 205 case instance.LXC: |
| 206 cfg["use-clone"] = fmt.Sprint(config.LXCUseClone()) |
| 207 } |
| 208 result.ManagerConfig = cfg |
| 209 return result, nil |
| 210 } |
| 211 |
193 // ContainerConfig returns information from the environment config that are | 212 // ContainerConfig returns information from the environment config that are |
194 // needed for container cloud-init. | 213 // needed for container cloud-init. |
195 func (p *ProvisionerAPI) ContainerConfig() (params.ContainerConfig, error) { | 214 func (p *ProvisionerAPI) ContainerConfig() (params.ContainerConfig, error) { |
196 result := params.ContainerConfig{} | 215 result := params.ContainerConfig{} |
197 config, err := p.st.EnvironConfig() | 216 config, err := p.st.EnvironConfig() |
198 if err != nil { | 217 if err != nil { |
199 return result, err | 218 return result, err |
200 } | 219 } |
201 result.ProviderType = config.Type() | 220 result.ProviderType = config.Type() |
202 result.AuthorizedKeys = config.AuthorizedKeys() | 221 result.AuthorizedKeys = config.AuthorizedKeys() |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 } | 606 } |
588 watch := newWatchMachineErrorRetry() | 607 watch := newWatchMachineErrorRetry() |
589 // Consume any initial event and forward it to the result. | 608 // Consume any initial event and forward it to the result. |
590 if _, ok := <-watch.Changes(); ok { | 609 if _, ok := <-watch.Changes(); ok { |
591 result.NotifyWatcherId = p.resources.Register(watch) | 610 result.NotifyWatcherId = p.resources.Register(watch) |
592 } else { | 611 } else { |
593 return result, watcher.MustErr(watch) | 612 return result, watcher.MustErr(watch) |
594 } | 613 } |
595 return result, nil | 614 return result, nil |
596 } | 615 } |
OLD | NEW |