// GetMachineByPID gets a machine specified by a PID from systemd-machined
764825
func (c *Conn) GetMachineByPID(pid uint) (dbus.ObjectPath, error) {
	return c.getPath("GetMachineByPID", pid)
}
1679
func (m *MachinesClient) Get(ctx context.Context, machineID *identity.ID) (*apitypes.MachineSegment, error) {
	resp := &apitypes.MachineSegment{}
	err := m.client.RoundTrip(ctx, "GET", "/machines/"+(*machineID).String(), nil, nil, &resp)
	return resp, err
}
1005183
func ModelMachineInfo(st ModelManagerBackend) (machineInfo []params.ModelMachineInfo, _ error) {
	machines, err := st.AllMachines()
	if err != nil {
		return nil, errors.Trace(err)
	}
	for _, m := range machines {
		if m.Life() != state.Alive {
			continue
		}
		var status string
		// This is suboptimal as if there are many machines,
		// we are making many calls into the DB for each machine.
		statusInfo, err := m.Status()
		if err == nil {
			status = string(statusInfo.Status)
		} else {
			status = err.Error()
		}
		mInfo := params.ModelMachineInfo{
			Id:        m.Id(),
			HasVote:   m.HasVote(),
			WantsVote: m.WantsVote(),
			Status:    status,
			Message:   statusInfo.Message,
		}
		instId, displayName, err := m.InstanceNames()
		switch {
		case err == nil:
			mInfo.InstanceId = string(instId)
			mInfo.DisplayName = displayName
		case errors.IsNotProvisioned(err):
			// ok, but no instance ID to get.
		default:
			return nil, errors.Trace(err)
		}
		if m.ContainerType() != "" && m.ContainerType() != instance.NONE {
			machineInfo = append(machineInfo, mInfo)
			continue
		}
		// Only include cores for physical machines.
		hw, err := m.HardwareCharacteristics()
		if err != nil && !errors.IsNotFound(err) {
			return nil, errors.Trace(err)
		}
		if hw != nil && hw.String() != "" {
			hwParams := &params.MachineHardware{
				Cores:            hw.CpuCores,
				Arch:             hw.Arch,
				Mem:              hw.Mem,
				RootDisk:         hw.RootDisk,
				CpuPower:         hw.CpuPower,
				Tags:             hw.Tags,
				AvailabilityZone: hw.AvailabilityZone,
			}
			mInfo.Hardware = hwParams
		}
		machineInfo = append(machineInfo, mInfo)
	}
	return machineInfo, nil
}
660943
func GetCgroupPathByPid(pid int, controller string) (string, error) {
	parts, err := parseCgroupController(fmt.Sprintf("/proc/%d/cgroup", pid), controller)
	if err != nil {
		return "", err
	}
	return parts[2], nil
}
975984
func (c *Cloud) getInstanceByID(instanceID string) (*ec2.Instance, error) {
	instances, err := c.getInstancesByIDs([]*string{&instanceID})
	if err != nil {
		return nil, err
	}

	if len(instances) == 0 {
		return nil, cloudprovider.ErrInstanceNotFound
	}
	if len(instances) > 1 {
		return nil, fmt.Errorf("multiple instances found for instance: %s", instanceID)
	}

	return instances[instanceID], nil
}
327153
func (az *Cloud) getVmssMachineID(resourceGroup, scaleSetName, instanceID string) string {
	return fmt.Sprintf(
		vmssMachineIDTemplate,
		az.SubscriptionID,
		strings.ToLower(resourceGroup),
		scaleSetName,
		instanceID)
}
396176
func (dc *Datacenter) GetVMByUUID(ctx context.Context, vmUUID string) (*VirtualMachine, error) {
	s := object.NewSearchIndex(dc.Client())
	vmUUID = strings.ToLower(strings.TrimSpace(vmUUID))
	svm, err := s.FindByUuid(ctx, dc.Datacenter, vmUUID, true, nil)
	if err != nil {
		klog.Errorf("Failed to find VM by UUID. VM UUID: %s, err: %+v", vmUUID, err)
		return nil, err
	}
	if svm == nil {
		klog.Errorf("Unable to find VM by UUID. VM UUID: %s", vmUUID)
		return nil, ErrNoVMFound
	}
	virtualMachine := VirtualMachine{object.NewVirtualMachine(dc.Client(), svm.Reference()), dc}
	return &virtualMachine, nil
}
571582
func MachineID(f func() (uint16, error)) func(*sonyflake.Settings) {
	return func(s *sonyflake.Settings) {
		s.MachineID = f
	}
}
518360
func (p *initProcess) getChildPid() (int, error) {
	var pid pid
	if err := json.NewDecoder(p.parentPipe).Decode(&pid); err != nil {
		p.cmd.Wait()
		return -1, err
	}

	// Clean up the zombie parent process
	// On Unix systems FindProcess always succeeds.
	firstChildProcess, _ := os.FindProcess(pid.PidFirstChild)

	// Ignore the error in case the child has already been reaped for any reason
	_, _ = firstChildProcess.Wait()

	return pid.Pid, nil
}
1295220
func (m *Manager) GetByID(iyoid string) (*Identifier, error) {
	var idObj Identifier

	if err := m.getIdentifierCollection().Find(bson.M{"iyoids": iyoid}).One(&idObj); err != nil {
		return nil, err
	}

	return &idObj, nil
}
785856
func (_m *DBClient) GetDevicesByProfileId(pid string) ([]models.Device, error) {
	ret := _m.Called(pid)

	var r0 []models.Device
	if rf, ok := ret.Get(0).(func(string) []models.Device); ok {
		r0 = rf(pid)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).([]models.Device)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(string) error); ok {
		r1 = rf(pid)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
1240082
func (_m *DBClient) GetDeviceReportById(id string) (models.DeviceReport, error) {
	ret := _m.Called(id)

	var r0 models.DeviceReport
	if rf, ok := ret.Get(0).(func(string) models.DeviceReport); ok {
		r0 = rf(id)
	} else {
		r0 = ret.Get(0).(models.DeviceReport)
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(string) error); ok {
		r1 = rf(id)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
836605
func (i *IDStore) GetAirportByID(id string) (*Airport, error) {
	return getAirportByKey(i.IdToAirport, id)
}
1038448
func (vb *VirtualBox) FindMachine(nameOrID string) (*Machine, error) {
	if err := vb.assertMobRef(); err != nil {
		return nil, err
	}

	request := findMachineRequest{VbID: vb.mobref, NameOrID: nameOrID}
	response := new(findMachineResponse)
	err := vb.send(request, response)
	if err != nil {
		return nil, err
	}

	m := &Machine{mobref: response.Returnval, vb: vb}
	return m, nil
}
994408
func (api *API) GetProviderInterfaceInfo(machine names.MachineTag) ([]network.ProviderInterfaceInfo, error) {
	var result params.ProviderInterfaceInfoResults
	args := wrapEntities(machine)
	err := api.facade.FacadeCall("GetMachineProviderInterfaceInfo", &args, &result)
	if err != nil {
		return nil, errors.Trace(err)
	}
	if len(result.Results) != 1 {
		return nil, errors.Errorf("expected one result, got %d", len(result.Results))
	}
	item := result.Results[0]
	if item.MachineTag != machine.String() {
		return nil, errors.Errorf("expected interface info for %s but got %s", machine, item.MachineTag)
	}
	infos := make([]network.ProviderInterfaceInfo, len(item.Interfaces))
	for i, info := range item.Interfaces {
		infos[i].InterfaceName = info.InterfaceName
		infos[i].MACAddress = info.MACAddress
		infos[i].ProviderId = network.Id(info.ProviderId)
	}
	return infos, nil
}
31652
func (s *MacroService) FindMacroByID(ctx context.Context, id platform.ID) (*platform.Macro, error) {
	path := macroIDPath(id)
	url, err := newURL(s.Addr, path)
	if err != nil {
		return nil, err
	}

	req, err := http.NewRequest("GET", url.String(), nil)
	if err != nil {
		return nil, err
	}

	SetToken(s.Token, req)
	hc := newClient(url.Scheme, s.InsecureSkipVerify)

	resp, err := hc.Do(req)
	if err != nil {
		return nil, err
	}

	if err := CheckError(resp, true); err != nil {
		return nil, err
	}

	var mr macroResponse
	if err := json.NewDecoder(resp.Body).Decode(&mr); err != nil {
		return nil, err
	}

	macro := mr.Macro
	return macro, nil
}
1025249
func (p *ProvisionerAPI) DistributionGroupByMachineId(args params.Entities) (params.StringsResults, error) {
	result := params.StringsResults{
		Results: make([]params.StringsResult, len(args.Entities)),
	}
	canAccess, err := p.getAuthFunc()
	if err != nil {
		return params.StringsResults{}, err
	}
	for i, entity := range args.Entities {
		tag, err := names.ParseMachineTag(entity.Tag)
		if err != nil {
			result.Results[i].Error = common.ServerError(common.ErrPerm)
			continue
		}
		machine, err := p.getMachine(canAccess, tag)
		if err == nil {
			// If the machine is a controller, return
			// controller instances. Otherwise, return
			// instances with services in common with the machine
			// being provisioned.
			if machine.IsManager() {
				result.Results[i].Result, err = controllerMachineIds(p.st, machine)
			} else {
				result.Results[i].Result, err = commonApplicationMachineId(p.st, machine)
			}
		}
		result.Results[i].Error = common.ServerError(err)
	}
	return result, nil
}