func (s *LxcSuite) TestContainerState(c *gc.C) { manager := s.makeManager(c, "test") c.Logf("%#v", manager) instance := containertesting.CreateContainer(c, manager, "1/lxc/0") // The mock container will be immediately "running". c.Assert(instance.Status(), gc.Equals, string(golxc.StateRunning)) // DestroyContainer stops and then destroys the container, putting it // into "unknown" state. err := manager.DestroyContainer(instance.Id()) c.Assert(err, jc.ErrorIsNil) c.Assert(instance.Status(), gc.Equals, string(golxc.StateUnknown)) }
// AllInstances returns all instances currently known to the broker. func (env *environ) AllInstances() ([]instance.Instance, error) { // Please note that this must *not* return instances that have not been // allocated as part of this environment -- if it does, juju will see they // are not tracked in state, assume they're stale/rogue, and shut them down. logger.Tracef("environ.AllInstances...") servers, err := env.client.instances() if err != nil { logger.Tracef("environ.AllInstances failed: %v", err) return nil, err } instances := make([]instance.Instance, 0, len(servers)) for _, server := range servers { instance := sigmaInstance{server: server} instances = append(instances, instance) } if logger.LogLevel() <= loggo.TRACE { logger.Tracef("All instances, len = %d:", len(instances)) for _, instance := range instances { logger.Tracef("... id: %q, status: %q", instance.Id(), instance.Status()) } } return instances, nil }