// RenameMachine changes a machine's name
341511
func (c *CloudAPI) RenameMachine(machineID, newName string) error {
	if err := c.ProcessFunctionHook(c, machineID, newName); err != nil {
		return err
	}

	for _, machine := range c.machines {
		if machine.Id == machineID {
			machine.Name = newName
			machine.Updated = time.Now().Format("2013-11-26T19:47:13.448Z")
			return nil
		}
	}

	return fmt.Errorf("Machine %s not found", machineID)
}
591713
func (fs *FS) Rename(oldpath, newpath string) (err error) {
	fs.log.CDebugf(fs.ctx, "Rename %s -> %s", oldpath, newpath)
	defer func() {
		fs.deferLog.CDebugf(fs.ctx, "Rename done: %+v", err)
		err = translateErr(err)
	}()

	if err := fs.requireNonEmpty(); err != nil {
		return err
	}

	err = fs.mkdirAll(path.Dir(newpath), 0755)
	if err != nil && !os.IsExist(err) {
		return err
	}

	oldParent, _, oldBase, err := fs.lookupParent(oldpath)
	if err != nil {
		return err
	}

	newParent, _, newBase, err := fs.lookupParent(newpath)
	if err != nil {
		return err
	}

	return fs.config.KBFSOps().Rename(
		fs.ctx, oldParent, oldBase, newParent, newBase)
}
532225
func (h *fs) Rename(from, to string) error {
	return os.Rename(from, to)
}
123661
func (fs *fakeFs) Rename(oldpath, newpath string) error {
	return fs.a.Fs.Rename(oldpath, newpath)
}
1099166
func Rename(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Cache-Control", "must-revalidate")
	w.Header().Set("Content-Type", "text/plain")
	w.Header().Set("Access-Control-Allow-Origin", "*")
	w.Header().Set("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS")
	var oldName, newName string
	if !Require(w, r, "old", &oldName) {
		return
	}
	if !Require(w, r, "new", &newName) {
		return
	}
	if err := HttpDB.Rename(oldName, newName); err != nil {
		http.Error(w, fmt.Sprint(err), http.StatusBadRequest)
	}
}
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
}
544591
func (c *Conn) GetMachine(name string) (dbus.ObjectPath, error) {
	return c.getPath("GetMachine", name)
}
1354290
func (f *File) RenameSection(name, value string) {
	f.RenameSectionRaw(name, f.SectionManipFunc(value))
}
383443
func (m *Model) updateMachine(ch MachineChange, rm *residentManager) {
	m.mu.Lock()

	machine, found := m.machines[ch.Id]
	if !found {
		machine = newMachine(m, rm.new())
		m.machines[ch.Id] = machine
		m.hub.Publish(m.topic(modelAddRemoveMachine), []string{ch.Id})
	}
	machine.setDetails(ch)

	m.mu.Unlock()
}
427284
func (c *Controller) updateMachine(ch MachineChange) {
	c.ensureModel(ch.ModelUUID).updateMachine(ch, c.manager)
}
425010
func (c *Client) Rename(key string, newkey string) (string, error) {
	var ret string

	err := c.command(
		&ret,
		[]byte("RENAME"),
		[]byte(key),
		[]byte(newkey),
	)

	return ret, err
}
1264371
func Rename(name, newName string, opts *RenameOpts) error {
	cmd := newCmd("rename")
	if opts != nil {
		cmd = addOpt(cmd, opts.CreateParents, "-p")
		cmd = addOpt(cmd, opts.DontReMount, "-u")
		cmd = addOpt(cmd, opts.ForceUnmount, "-f")
		cmd = addOpt(cmd, opts.Recurse, "-r")
	}
	cmd = addNonEmpty(cmd, name, newName)
	return zExecNoOut(cmd)
}
772168
func (h *bundleHandler) resolveMachine(placeholder string) (string, error) {
	logger.Debugf("resolveMachine(%q)", placeholder)
	machineOrUnit := resolve(placeholder, h.results)
	if !names.IsValidUnit(machineOrUnit) {
		return machineOrUnit, nil
	}
	for h.unitStatus[machineOrUnit] == "" {
		if err := h.updateUnitStatus(); err != nil {
			return "", errors.Annotate(err, "cannot resolve machine")
		}
	}
	return h.unitStatus[machineOrUnit], nil
}
1103
func (client *Client) DestroyMachines(machines ...string) ([]params.DestroyMachineResult, error) {
	return client.destroyMachines("DestroyMachine", machines)
}
1225282
func (p *Provider) CreateMachine() (machine *iaas.Machine, err error) {
	err = p.Client.Create(p.Host)
	if err != nil {
		return
	}
	config, err := getConfig(p.Client.GetMachinesDir(), p.Name)
	if err != nil {
		return
	}
	ip, err := p.Host.Driver.GetIP()
	if err != nil {
		return
	}

	machine = &iaas.Machine{
		ID:        "",
		IP:        ip,
		Image:     config.Driver.MachineImage,
		Kind:      config.DriverName,
		Name:      p.Name,
		SSHKeysID: []int{},
		CertsDir:  p.ClientPath + "/certs",
	}
	return
}
69539
func (c *Client) CreateMachine(opts CreateMachineOpts) (*Machine, error) {
	var resp Machine
	req := request{
		method:         client.POST,
		url:            apiMachines,
		reqValue:       opts,
		resp:           &resp,
		expectedStatus: http.StatusCreated,
	}
	if _, err := c.sendRequest(req); err != nil {
		return nil, errors.Newf(err, "failed to create machine with name: %s", opts.Name)
	}
	return &resp, nil
}
983679
func (u *Unit) AssignToMachine(m *Machine) (err error) {
	defer assignContextf(&err, u.Name(), fmt.Sprintf("machine %s", m))
	return u.assignToMachine(m, false)
}