// DestroyMachine removes a set of machines from the model.
356827
func (mm *MachineManagerAPI) DestroyMachine(args params.Entities) (params.DestroyMachineResults, error) {
	return mm.destroyMachine(args, false, false, time.Duration(0))
}
486573
func (c *Conn) KillMachine(name, who string, sig syscall.Signal) error {
	return c.object.Call(dbusInterface+".KillMachine", 0, name, who, sig).Err
}
1232894
func (c *Client) DestroyModel(tag names.ModelTag, destroyStorage, force *bool, maxWait *time.Duration) error {
	var args interface{}
	if c.BestAPIVersion() < 4 {
		if destroyStorage == nil || !*destroyStorage {
			return errors.New("this Juju controller requires destroyStorage to be true")
		}
		args = params.Entities{Entities: []params.Entity{{Tag: tag.String()}}}
	} else {
		arg := params.DestroyModelParams{
			ModelTag:       tag.String(),
			DestroyStorage: destroyStorage,
		}
		if c.BestAPIVersion() > 6 {
			arg.Force = force
			arg.MaxWait = maxWait
		}
		args = params.DestroyModelsParams{Models: []params.DestroyModelParams{arg}}
	}
	var results params.ErrorResults
	if err := c.facade.FacadeCall("DestroyModels", args, &results); err != nil {
		return errors.Trace(err)
	}
	if n := len(results.Results); n != 1 {
		return errors.Errorf("expected 1 result, got %d", n)
	}
	if err := results.Results[0].Error; err != nil {
		return errors.Trace(err)
	}
	return nil
}
991161
func (c *Controller) removeModel(ch RemoveModel) error {
	c.mu.Lock()
	defer c.mu.Unlock()

	mod, ok := c.models[ch.ModelUUID]
	if ok {
		if err := mod.evict(); err != nil {
			return errors.Trace(err)
		}
		delete(c.models, ch.ModelUUID)
	}
	return nil
}
1248437
func (*Service) DeleteMachine(c context.Context, req *crimson.DeleteMachineRequest) (*empty.Empty, error) {
	if err := deleteMachine(c, req.Name); err != nil {
		return nil, err
	}
	return &empty.Empty{}, nil
}
586505
func (c *Conn) RegisterMachine(name string, id []byte, service string, class string, pid int, root_directory string) error {
	return c.object.Call(dbusInterface+".RegisterMachine", 0, name, id, service, class, uint32(pid), root_directory).Err
}
1154708
func (m *Model) removeMachine(ch RemoveMachine) error {
	defer m.doLocked()()

	machine, ok := m.machines[ch.Id]
	if ok {
		m.hub.Publish(m.topic(modelAddRemoveMachine), []string{ch.Id})
		if err := machine.evict(); err != nil {
			return errors.Trace(err)
		}
		delete(m.machines, ch.Id)
	}
	return nil
}
464881
func (m *Manager) SetMachine(t interface{}) (err error) {
	machine, ok := t.(Machine)
	if !ok {
		return errors.New("supplied machine does not implement watchers.Machine")
	}

	m.machine = machine

	return nil
}
487956
func deleteMachineCmd(params *Parameters) *subcommands.Command {
	return &subcommands.Command{
		UsageLine: "del-machine -name <name>",
		ShortDesc: "deletes a machine",
		LongDesc:  "Deletes a machine from the database.\n\nExample:\ncrimson del-machine -name xx11-11-720",
		CommandRun: func() subcommands.CommandRun {
			cmd := &DeleteMachineCmd{}
			cmd.Initialize(params)
			cmd.Flags.StringVar(&cmd.req.Name, "name", "", "The name of the machine to delete.")
			return cmd
		},
	}
}
682115
func (c *Conn) TerminateMachine(name string) error {
	return c.object.Call(dbusInterface+".TerminateMachine", 0, name).Err
}
970757
func (p *Provider) DeleteMachine() (err error) {
	err = p.Host.Driver.Remove()
	defer p.Client.Close()
	return
}
779468
func (vm *VM) Destroy() error {
	s, err := vm.getService()
	if err != nil {
		return err
	}

	return s.delete()
}
347298
func createMachine(orgID, teamID, creatorID *identity.ID, name string) (
	*envelope.Machine, []envelope.Membership, error) {

	machineBody := &primitive.Machine{
		Name:        name,
		OrgID:       orgID,
		CreatedBy:   creatorID,
		Created:     time.Now().UTC(),
		DestroyedBy: nil,
		Destroyed:   nil,
		State:       primitive.MachineActiveState,
	}
	machineID, err := identity.NewMutable(machineBody)
	if err != nil {
		return nil, nil, err
	}
	machine := envelope.Machine{
		ID:      &machineID,
		Version: 1,
		Body:    machineBody,
	}

	machineTeamID := identity.DeriveMutable(&primitive.Team{}, orgID, primitive.DerivableMachineTeamSymbol)
	teamIDList := []*identity.ID{&machineTeamID, teamID}
	var memberships []envelope.Membership
	for _, curTeamID := range teamIDList {
		body := primitive.Membership{
			OwnerID: &machineID,
			OrgID:   orgID,
			TeamID:  curTeamID,
		}

		ID, err := identity.NewMutable(&body)
		if err != nil {
			return nil, nil, err
		}

		membership := envelope.Membership{
			ID:      &ID,
			Version: 1,
			Body:    &body,
		}
		memberships = append(memberships, membership)
	}

	return &machine, memberships, nil
}
55635
func (c *Compiler) Destroy() {
	c.setCallbackData(nil)
	if c.compiler != nil {
		c.compiler.finalize()
		c.compiler = nil
	}
}
1202847
func (*Service) RenameMachine(c context.Context, req *crimson.RenameMachineRequest) (*crimson.Machine, error) {
	return renameMachine(c, req.Name, req.NewName)
}
498922
func (c *Controller) removeMachine(ch RemoveMachine) error {
	return errors.Trace(c.removeResident(ch.ModelUUID, func(m *Model) error { return m.removeMachine(ch) }))
}
614236
func (task *provisionerTask) removeMachineFromAZMap(machine apiprovisioner.MachineProvisioner) {
	machineId := machine.Id()
	task.machinesMutex.Lock()
	defer task.machinesMutex.Unlock()
	for _, zoneMachines := range task.availabilityZoneMachines {
		zoneMachines.MachineIds.Remove(machineId)
		zoneMachines.FailedMachineIds.Remove(machineId)
	}
}