Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(3631)

Side by Side Diff: provider/maas/environ.go

Issue 77890045: Fix maas bridge-utils installation
Patch Set: Created 10 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 Canonical Ltd. 1 // Copyright 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 maas 4 package maas
5 5
6 import ( 6 import (
7 "encoding/base64" 7 "encoding/base64"
8 "fmt" 8 "fmt"
9 "net/url" 9 "net/url"
10 "strings" 10 "strings"
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 if err := environ.releaseInstance(inst); err != nil { 269 if err := environ.releaseInstance(inst); err != nil {
270 logger.Errorf("error releasing failed instance: %v", err) 270 logger.Errorf("error releasing failed instance: %v", err)
271 } 271 }
272 } 272 }
273 }() 273 }()
274 274
275 hostname, err := inst.DNSName() 275 hostname, err := inst.DNSName()
276 if err != nil { 276 if err != nil {
277 return nil, nil, err 277 return nil, nil, err
278 } 278 }
279 » info := machineInfo{hostname} 279 » additionalScripts, err := additionalScripts(hostname)
280 » runCmd, err := info.cloudinitRunCmd()
281 if err != nil { 280 if err != nil {
282 return nil, nil, err 281 return nil, nil, err
283 } 282 }
284 if err := environs.FinishMachineConfig(args.MachineConfig, environ.Confi g(), args.Constraints); err != nil { 283 if err := environs.FinishMachineConfig(args.MachineConfig, environ.Confi g(), args.Constraints); err != nil {
285 return nil, nil, err 284 return nil, nil, err
286 } 285 }
287 // TODO(thumper): 2013-08-28 bug 1217614 286 // TODO(thumper): 2013-08-28 bug 1217614
288 // The machine envronment config values are being moved to the agent con fig. 287 // The machine envronment config values are being moved to the agent con fig.
289 // Explicitly specify that the lxc containers use the network bridge def ined above. 288 // Explicitly specify that the lxc containers use the network bridge def ined above.
290 args.MachineConfig.AgentEnvironment[agent.LxcBridge] = "br0" 289 args.MachineConfig.AgentEnvironment[agent.LxcBridge] = "br0"
291 » userdata, err := environs.ComposeUserData( 290 » userdata, err := environs.ComposeUserData(args.MachineConfig, additional Scripts...)
292 » » args.MachineConfig,
293 » » runCmd,
294 » » "apt-get install bridge-utils",
295 » » createBridgeNetwork(),
296 » » linkBridgeInInterfaces(),
297 » » "service networking restart",
298 » )
299 if err != nil { 291 if err != nil {
300 msg := fmt.Errorf("could not compose userdata for bootstrap node : %v", err) 292 msg := fmt.Errorf("could not compose userdata for bootstrap node : %v", err)
301 return nil, nil, msg 293 return nil, nil, msg
302 } 294 }
303 logger.Debugf("maas user data; %d bytes", len(userdata)) 295 logger.Debugf("maas user data; %d bytes", len(userdata))
304 296
305 series := args.Tools.OneSeries() 297 series := args.Tools.OneSeries()
306 if err := environ.startNode(*inst.maasObject, series, userdata); err != nil { 298 if err := environ.startNode(*inst.maasObject, series, userdata); err != nil {
307 return nil, nil, err 299 return nil, nil, err
308 } 300 }
309 logger.Debugf("started instance %q", inst.Id()) 301 logger.Debugf("started instance %q", inst.Id())
310 // TODO(bug 1193998) - return instance hardware characteristics as well 302 // TODO(bug 1193998) - return instance hardware characteristics as well
311 return inst, nil, nil 303 return inst, nil, nil
312 } 304 }
313 305
306 // additionalScripts is an additional set of commands
307 // to run during cloud-init (before the synchronous phase).
308 func additionalScripts(hostname string) ([]string, error) {
309 info := machineInfo{hostname}
310 runCmd, err := info.cloudinitRunCmd()
311 if err != nil {
312 return nil, err
313 }
314 return []string{
315 runCmd,
316 utils.CommandString(utils.AptGetCommand("update")...),
rog 2014/03/20 09:42:15 It seems a pity that we can't just call SetAptUpda
wwitzel3 2014/03/20 10:02:29 I agree, it is a shame we can't just call SetAptUp
317 utils.CommandString(utils.AptGetCommand("install", "bridge-utils ")...),
318 "ifdown eth0",
319 createBridgeNetwork(),
320 linkBridgeInInterfaces(),
321 "ifup br0",
322 }, nil
323 }
324
314 // StartInstance is specified in the InstanceBroker interface. 325 // StartInstance is specified in the InstanceBroker interface.
315 func (environ *maasEnviron) StopInstances(instances []instance.Instance) error { 326 func (environ *maasEnviron) StopInstances(instances []instance.Instance) error {
316 // Shortcut to exit quickly if 'instances' is an empty slice or nil. 327 // Shortcut to exit quickly if 'instances' is an empty slice or nil.
317 if len(instances) == 0 { 328 if len(instances) == 0 {
318 return nil 329 return nil
319 } 330 }
320 // Tell MAAS to release each of the instances. If there are errors, 331 // Tell MAAS to release each of the instances. If there are errors,
321 // return only the first one (but release all instances regardless). 332 // return only the first one (but release all instances regardless).
322 // Note that releasing instances also turns them off. 333 // Note that releasing instances also turns them off.
323 var firstErr error 334 var firstErr error
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 return []simplestreams.DataSource{ 458 return []simplestreams.DataSource{
448 storage.NewStorageSimpleStreamsDataSource("cloud storage", e.Sto rage(), storage.BaseImagesPath)}, nil 459 storage.NewStorageSimpleStreamsDataSource("cloud storage", e.Sto rage(), storage.BaseImagesPath)}, nil
449 } 460 }
450 461
451 // GetToolsSources returns a list of sources which are used to search for simple streams tools metadata. 462 // GetToolsSources returns a list of sources which are used to search for simple streams tools metadata.
452 func (e *maasEnviron) GetToolsSources() ([]simplestreams.DataSource, error) { 463 func (e *maasEnviron) GetToolsSources() ([]simplestreams.DataSource, error) {
453 // Add the simplestreams source off the control bucket. 464 // Add the simplestreams source off the control bucket.
454 return []simplestreams.DataSource{ 465 return []simplestreams.DataSource{
455 storage.NewStorageSimpleStreamsDataSource("cloud storage", e.Sto rage(), storage.BaseToolsPath)}, nil 466 storage.NewStorageSimpleStreamsDataSource("cloud storage", e.Sto rage(), storage.BaseToolsPath)}, nil
456 } 467 }
OLDNEW
« no previous file with comments | « [revision details] ('k') | provider/maas/environ_test.go » ('j') | provider/maas/environ_test.go » ('J')

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b