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/environs" | 10 "launchpad.net/juju-core/environs" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 } | 177 } |
178 secretAttrs, err := env.Provider().SecretAttrs(config) | 178 secretAttrs, err := env.Provider().SecretAttrs(config) |
179 for k := range secretAttrs { | 179 for k := range secretAttrs { |
180 allAttrs[k] = "not available" | 180 allAttrs[k] = "not available" |
181 } | 181 } |
182 } | 182 } |
183 result.Config = allAttrs | 183 result.Config = allAttrs |
184 return result, nil | 184 return result, nil |
185 } | 185 } |
186 | 186 |
| 187 // AddSupportedContainers updates the list of containers supported by the machin
es passed in args. |
| 188 func (p *ProvisionerAPI) AddSupportedContainers( |
| 189 args params.AddSupportedContainers) (params.ErrorResults, error) { |
| 190 |
| 191 result := params.ErrorResults{ |
| 192 Results: make([]params.ErrorResult, len(args.Params)), |
| 193 } |
| 194 for i, arg := range args.Params { |
| 195 canAccess, err := p.getAuthFunc() |
| 196 if err != nil { |
| 197 return result, err |
| 198 } |
| 199 machine, err := p.getMachine(canAccess, arg.MachineTag) |
| 200 if err != nil { |
| 201 result.Results[i].Error = common.ServerError(err) |
| 202 continue |
| 203 } |
| 204 err = machine.AddSupportedContainers(arg.ContainerTypes) |
| 205 if err != nil { |
| 206 result.Results[i].Error = common.ServerError(err) |
| 207 } |
| 208 } |
| 209 return result, nil |
| 210 } |
| 211 |
187 // ContainerConfig returns information from the environment config that are | 212 // ContainerConfig returns information from the environment config that are |
188 // needed for container cloud-init. | 213 // needed for container cloud-init. |
189 func (p *ProvisionerAPI) ContainerConfig() (params.ContainerConfig, error) { | 214 func (p *ProvisionerAPI) ContainerConfig() (params.ContainerConfig, error) { |
190 result := params.ContainerConfig{} | 215 result := params.ContainerConfig{} |
191 config, err := p.st.EnvironConfig() | 216 config, err := p.st.EnvironConfig() |
192 if err != nil { | 217 if err != nil { |
193 return result, err | 218 return result, err |
194 } | 219 } |
195 result.ProviderType = config.Type() | 220 result.ProviderType = config.Type() |
196 result.AuthorizedKeys = config.AuthorizedKeys() | 221 result.AuthorizedKeys = config.AuthorizedKeys() |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 // Consume the initial event and forward it to the result. | 342 // Consume the initial event and forward it to the result. |
318 if changes, ok := <-watch.Changes(); ok { | 343 if changes, ok := <-watch.Changes(); ok { |
319 result.StringsWatcherId = p.resources.Register(watch) | 344 result.StringsWatcherId = p.resources.Register(watch) |
320 result.Changes = changes | 345 result.Changes = changes |
321 } else { | 346 } else { |
322 err := watcher.MustErr(watch) | 347 err := watcher.MustErr(watch) |
323 return result, fmt.Errorf("cannot obtain initial environment mac
hines: %v", err) | 348 return result, fmt.Errorf("cannot obtain initial environment mac
hines: %v", err) |
324 } | 349 } |
325 return result, nil | 350 return result, nil |
326 } | 351 } |
OLD | NEW |