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

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

Issue 77930043: Container Manager Interface
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
« no previous file with comments | « container/testing/common.go ('k') | worker/provisioner/kvm-broker.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013, 2014 Canonical Ltd. 1 // Copyright 2013, 2014 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 local 4 package local
5 5
6 import ( 6 import (
7 "fmt" 7 "fmt"
8 "net" 8 "net"
9 "os" 9 "os"
10 "os/exec" 10 "os/exec"
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 logger.Debugf("tools: %#v", args.MachineConfig.Tools) 303 logger.Debugf("tools: %#v", args.MachineConfig.Tools)
304 network := container.BridgeNetworkConfig(env.config.networkBridge()) 304 network := container.BridgeNetworkConfig(env.config.networkBridge())
305 if err := environs.FinishMachineConfig(args.MachineConfig, env.config.Co nfig, args.Constraints); err != nil { 305 if err := environs.FinishMachineConfig(args.MachineConfig, env.config.Co nfig, args.Constraints); err != nil {
306 return nil, nil, err 306 return nil, nil, err
307 } 307 }
308 // TODO: evaluate the impact of setting the contstraints on the 308 // TODO: evaluate the impact of setting the contstraints on the
309 // machineConfig for all machines rather than just state server nodes. 309 // machineConfig for all machines rather than just state server nodes.
310 // This limiation is why the constraints are assigned directly here. 310 // This limiation is why the constraints are assigned directly here.
311 args.MachineConfig.Constraints = args.Constraints 311 args.MachineConfig.Constraints = args.Constraints
312 args.MachineConfig.AgentEnvironment[agent.Namespace] = env.config.namesp ace() 312 args.MachineConfig.AgentEnvironment[agent.Namespace] = env.config.namesp ace()
313 » inst, hardware, err := env.containerManager.StartContainer(args.MachineC onfig, series, network) 313 » inst, hardware, err := env.containerManager.CreateContainer(args.Machine Config, series, network)
314 if err != nil { 314 if err != nil {
315 return nil, nil, err 315 return nil, nil, err
316 } 316 }
317 return inst, hardware, nil 317 return inst, hardware, nil
318 } 318 }
319 319
320 // StartInstance is specified in the InstanceBroker interface. 320 // StartInstance is specified in the InstanceBroker interface.
321 func (env *localEnviron) StopInstances(instances []instance.Instance) error { 321 func (env *localEnviron) StopInstances(instances []instance.Instance) error {
322 for _, inst := range instances { 322 for _, inst := range instances {
323 if inst.Id() == bootstrapInstanceId { 323 if inst.Id() == bootstrapInstanceId {
324 return fmt.Errorf("cannot stop the bootstrap instance") 324 return fmt.Errorf("cannot stop the bootstrap instance")
325 } 325 }
326 » » if err := env.containerManager.StopContainer(inst); err != nil { 326 » » if err := env.containerManager.DestroyContainer(inst); err != ni l {
327 return err 327 return err
328 } 328 }
329 } 329 }
330 return nil 330 return nil
331 } 331 }
332 332
333 // Instances is specified in the Environ interface. 333 // Instances is specified in the Environ interface.
334 func (env *localEnviron) Instances(ids []instance.Id) ([]instance.Instance, erro r) { 334 func (env *localEnviron) Instances(ids []instance.Id) ([]instance.Instance, erro r) {
335 if len(ids) == 0 { 335 if len(ids) == 0 {
336 return nil, nil 336 return nil, nil
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 cmd.Stderr = os.Stderr 412 cmd.Stderr = os.Stderr
413 return cmd.Run() 413 return cmd.Run()
414 } 414 }
415 // Kill all running instances. This must be done as 415 // Kill all running instances. This must be done as
416 // root, or listing/stopping containers will fail. 416 // root, or listing/stopping containers will fail.
417 containers, err := env.containerManager.ListContainers() 417 containers, err := env.containerManager.ListContainers()
418 if err != nil { 418 if err != nil {
419 return err 419 return err
420 } 420 }
421 for _, inst := range containers { 421 for _, inst := range containers {
422 » » if err := env.containerManager.StopContainer(inst); err != nil { 422 » » if err := env.containerManager.DestroyContainer(inst); err != ni l {
423 return err 423 return err
424 } 424 }
425 } 425 }
426 cmd := exec.Command( 426 cmd := exec.Command(
427 "pkill", 427 "pkill",
428 fmt.Sprintf("-%d", terminationworker.TerminationSignal), 428 fmt.Sprintf("-%d", terminationworker.TerminationSignal),
429 "-f", filepath.Join(regexp.QuoteMeta(env.config.rootDir()), ".*" , "jujud"), 429 "-f", filepath.Join(regexp.QuoteMeta(env.config.rootDir()), ".*" , "jujud"),
430 ) 430 )
431 if err := cmd.Run(); err != nil { 431 if err := cmd.Run(); err != nil {
432 if err, ok := err.(*exec.ExitError); ok { 432 if err, ok := err.(*exec.ExitError); ok {
(...skipping 22 matching lines...) Expand all
455 455
456 // Ports is specified in the Environ interface. 456 // Ports is specified in the Environ interface.
457 func (env *localEnviron) Ports() ([]instance.Port, error) { 457 func (env *localEnviron) Ports() ([]instance.Port, error) {
458 return nil, nil 458 return nil, nil
459 } 459 }
460 460
461 // Provider is specified in the Environ interface. 461 // Provider is specified in the Environ interface.
462 func (env *localEnviron) Provider() environs.EnvironProvider { 462 func (env *localEnviron) Provider() environs.EnvironProvider {
463 return providerInstance 463 return providerInstance
464 } 464 }
OLDNEW
« no previous file with comments | « container/testing/common.go ('k') | worker/provisioner/kvm-broker.go » ('j') | no next file with comments »

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