// MachineId returns the ID of the machine hosting this unit.
188442
func (u *Unit) MachineId() string {
	u.mu.Lock()
	defer u.mu.Unlock()
	return u.details.MachineId
}
693005
func controllerMachineIds(st *state.State, m *state.Machine) ([]string, error) {
	info, err := st.ControllerInfo()
	if err != nil {
		return nil, err
	}
	result := set.NewStrings(info.MachineIds...)
	result.Remove(m.Id())
	return result.SortedValues(), nil
}
1364550
func InstanceID(
	ctx types.Context, config gofig.Config) (*types.InstanceID, error) {

	var hostName string
	if config == nil {
		hostName = config.GetString(s3fs.ConfigS3FSHostName)
	} else {
		hostName, _ = os.Hostname()
	}
	return &types.InstanceID{ID: hostName, Driver: s3fs.Name}, nil
}
52084
func (u *Unit) AssignedMachineId() (id string, err error) {
	if u.IsPrincipal() {
		if u.doc.MachineId == "" {
			return "", unitNotAssignedError(u)
		}
		return u.doc.MachineId, nil
	}

	units, closer := u.st.db().GetCollection(unitsC)
	defer closer()

	pudoc := unitDoc{}
	err = units.FindId(u.doc.Principal).One(&pudoc)
	if err == mgo.ErrNotFound {
		return "", errors.NotFoundf("principal unit %q of %q", u.doc.Principal, u)
	} else if err != nil {
		return "", err
	}
	if pudoc.MachineId == "" {
		return "", unitNotAssignedError(u)
	}
	return pudoc.MachineId, nil
}
1197737
func machineIdsToTags(ids ...string) []string {
	var result []string
	for _, id := range ids {
		result = append(result, names.NewMachineTag(id).String())
	}
	return result
}
32229
func InstanceID(ctx context.Context) (*types.InstanceID, bool) {
	v, ok := ctx.Value(InstanceIDKey).(*types.InstanceID)
	return v, ok
}
654313
func (m *Machine) Id() string {
	m.mu.Lock()
	defer m.mu.Unlock()
	return m.details.Id
}
858369
func GlobalMachineID() int {
	var id int
	globalmachineID.RLock()
	id = int(globalmachineID.id)
	globalmachineID.RUnlock()
	return id
}
649138
func (id *IdentityID) HostID() (string, error) {
	parts := strings.Split(id.HostUUID, ".")
	if len(parts) < 2 {
		return "", trace.BadParameter("expected 2 parts in %q", id.HostUUID)
	}
	return parts[0], nil
}
1190612
func (s *SliceQuery) Id(id int) *SliceQuery {
	s.id = &id
	return s
}
1278333
func (s *stateShim) MachineSeries(id string) (string, error) {
	m, err := s.State.Machine(id)
	if err != nil {
		return "", errors.Trace(err)
	}
	return m.Series(), nil
}
888293
func (m *Machine) InstanceId() (instance.Id, error) {
	instId, _, err := m.InstanceNames()
	return instId, err
}
1242606
func (c *Connection) ID() int {
	c.RLock()
	defer c.RUnlock()
	return c.id
}
1121491
func (p *Provider) SessionID() string {
	p.sessionLock.RLock()
	defer p.sessionLock.RUnlock()
	return p.sessionID
}
195231
func ProtectedID(appID string) (string, error) {
	id, err := ID()
	if err != nil {
		return "", fmt.Errorf("machineid: %v", err)
	}
	return protect(appID, id), nil
}
1244029
func (m *Machine) ParentId() (string, bool) {
	parentId := ParentId(m.Id())
	return parentId, parentId != ""
}
810459
func InstanceID() (*types.InstanceID, error) {

	macs, err := getMacs()
	if err != nil {
		return nil, err
	}

	iid := &types.InstanceID{Driver: vbox.Name}
	if err := iid.MarshalMetadata(macs); err != nil {
		return nil, err
	}

	return iid, nil
}