Exemple #1
0
func assertUnitRemoved(c *C, unit *state.Unit) {
	err := unit.Refresh()
	c.Assert(err, checkers.Satisfies, errors.IsNotFoundError)
	err = unit.Destroy()
	c.Assert(err, IsNil)
	err = unit.EnsureDead()
	c.Assert(err, IsNil)
	err = unit.Remove()
	c.Assert(err, IsNil)
}
Exemple #2
0
// remove will remove the supplied unit from state. It will panic if it
// observes inconsistent internal state.
func (d *Deployer) remove(unit *state.Unit) error {
	if d.deployed.Contains(unit.Name()) {
		panic("must not remove a deployed unit")
	} else if unit.Life() == state.Alive {
		panic("must not remove an Alive unit")
	}
	logger.Infof("removing unit %q", unit)
	if err := unit.EnsureDead(); err != nil {
		return err
	}
	return unit.Remove()
}