// GetBootTime returns the time at which the machine was started, truncated to the nearest second
7343
func GetBootTime() (time.Time, error) {
	currentTime := time.Now()
	output, _, err := tickCount.Call()
	if errno, ok := err.(syscall.Errno); !ok || errno != 0 {
		return time.Time{}, err
	}
	return currentTime.Add(-time.Duration(output) * time.Millisecond).Truncate(time.Second), nil
}
667462
func getModTime(path string) (t time.Time, err error) {
	// Convert to absolute path
	absPath, err := filepath.Abs(path)
	if err != nil {
		return t, fmt.Errorf("Unable to get absolute path of %s. %s", path, err)
	}

	// Version is minio non-standard, we will use minio binary's
	// ModTime as release time.
	fi, err := os.Stat(absPath)
	if err != nil {
		return t, fmt.Errorf("Unable to get ModTime of %s. %s", absPath, err)
	}

	// Return the ModTime
	return fi.ModTime().UTC(), nil
}
743271
func (agent *Agent) reboot(ctx context.Context) error {
	logging.Infof(ctx, "Rebooting.")
	tsmon.Flush(ctx)
	for {
		if err := agent.strategy.reboot(ctx); err != nil {
			return err
		}
		time.Sleep(60 * time.Second)
		logging.Infof(ctx, "Waiting to reboot...")
	}
}
212282
func (conf *Config) GetRuntime(name string) *types.Runtime {
	conf.Lock()
	defer conf.Unlock()
	if rt, ok := conf.Runtimes[name]; ok {
		return &rt
	}
	return nil
}
628170
func (t *remoteOracle) GetTimestamp() (uint64, error) {
	var err error
	for i := 0; i < maxRetryCnt; i++ {
		ts, e := t.c.GoGetTimestamp().GetTS()
		if e == nil {
			return uint64((ts.Physical << epochShiftBits) + ts.Logical), nil
		}
		err = errors.Trace(e)
	}
	return 0, err
}
443764
func (e *manualEnviron) Bootstrap(ctx environs.BootstrapContext, callCtx context.ProviderCallContext, args environs.BootstrapParams) (*environs.BootstrapResult, error) {
	provisioned, err := sshprovisioner.CheckProvisioned(e.host)
	if err != nil {
		return nil, errors.Annotate(err, "failed to check provisioned status")
	}
	if provisioned {
		return nil, manual.ErrProvisioned
	}
	hw, series, err := e.seriesAndHardwareCharacteristics()
	if err != nil {
		return nil, err
	}
	finalize := func(ctx environs.BootstrapContext, icfg *instancecfg.InstanceConfig, _ environs.BootstrapDialOpts) error {
		icfg.Bootstrap.BootstrapMachineInstanceId = BootstrapInstanceId
		icfg.Bootstrap.BootstrapMachineHardwareCharacteristics = hw
		if err := instancecfg.FinishInstanceConfig(icfg, e.Config()); err != nil {
			return err
		}
		return common.ConfigureMachine(ctx, ssh.DefaultClient, e.host, icfg, nil)
	}

	result := &environs.BootstrapResult{
		Arch:                    *hw.Arch,
		Series:                  series,
		CloudBootstrapFinalizer: finalize,
	}
	return result, nil
}
1115842
func getWaitTime(now time.Time, maxWait time.Duration) time.Duration {
	wait := nextProvision.Sub(now) // might be negative

	// When the system clock falls back an hour, the wait time might be an hour.
	// This sanity check prevents this error.
	if wait > maxWait {
		return maxWait
	}
	if wait < 0 {
		return 0
	}
	return wait
}
1120352
func (opt IteratorOptions) StopTime() int64 {
	if opt.Ascending {
		return opt.EndTime
	}
	return opt.StartTime
}
537810
func (s *SNMP) V2TrapWithBootsTime(varBinds VarBinds, eBoots, eTime int) error {
	if eBoots < 0 || eBoots > math.MaxInt32 {
		return &ArgumentError{
			Value:   eBoots,
			Message: fmt.Sprintf("EngineBoots is range %d..%d", 0, math.MaxInt32),
		}
	}
	if eTime < 0 || eTime > math.MaxInt32 {
		return &ArgumentError{
			Value:   eTime,
			Message: fmt.Sprintf("EngineTime is range %d..%d", 0, math.MaxInt32),
		}
	}

	defer func() {
		s.args.authEngineBoots = 0
		s.args.authEngineTime = 0
	}()
	s.args.authEngineBoots = eBoots
	s.args.authEngineTime = eTime
	return s.v2trap(SNMPTrapV2, varBinds)
}
1352156
func (o *Disk) SetBoot(v *bool) *Disk {
	if o.Boot = v; o.Boot == nil {
		o.nullFields = append(o.nullFields, "Boot")
	}
	return o
}
75002
func (r *RebootAPI) WatchForRebootEvent() (params.NotifyWatchResult, error) {
	err := common.ErrPerm
	var watch state.NotifyWatcher
	var result params.NotifyWatchResult

	if r.auth.AuthOwner(r.machine.Tag()) {
		watch = r.machine.WatchForRebootEvent()
		err = nil
		// Consume the initial event. Technically, API
		// calls to Watch 'transmit' the initial event
		// in the Watch response. But NotifyWatchers
		// have no state to transmit.
		if _, ok := <-watch.Changes(); ok {
			result.NotifyWatcherId = r.resources.Register(watch)
		} else {
			err = watcher.EnsureErr(watch)
		}
	}
	result.Error = common.ServerError(err)
	return result, nil
}
841015
func (client *Client) RebootInstance(instanceId string, forceStop bool) error {
	request := RebootInstanceArgs{
		InstanceId: instanceId,
		ForceStop:  forceStop,
	}
	response := RebootInstanceResponse{}
	err := client.Invoke("RebootInstance", &request, &response)
	return err
}
335006
func (_class NetworkSriovClass) GetRequiresReboot(sessionID SessionRef, self NetworkSriovRef) (_retval bool, _err error) {
	_method := "network_sriov.get_requires_reboot"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_selfArg, _err := convertNetworkSriovRefToXen(fmt.Sprintf("%s(%s)", _method, "self"), self)
	if _err != nil {
		return
	}
	_result, _err := _class.client.APICall(_method, _sessionIDArg, _selfArg)
	if _err != nil {
		return
	}
	_retval, _err = convertBoolToGo(_method + " -> ", _result.Value)
	return
}
807633
func (st *state) GetRebootAction() (params.RebootAction, error) {
	var results params.RebootActionResults
	args := params.Entities{
		Entities: []params.Entity{{Tag: st.machineTag.String()}},
	}

	err := st.facade.FacadeCall("GetRebootAction", args, &results)
	if err != nil {
		return params.ShouldDoNothing, err
	}
	if len(results.Results) != 1 {
		return params.ShouldDoNothing, errors.Errorf("expected 1 result, got %d", len(results.Results))
	}

	if results.Results[0].Error != nil {
		return params.ShouldDoNothing, errors.Trace(results.Results[0].Error)
	}

	return results.Results[0].Result, nil
}
1362059
func (idr *InitDryRunGetter) handleGetBootstrapToken(action core.GetAction) (bool, runtime.Object, error) {
	if !strings.HasPrefix(action.GetName(), "bootstrap-token-") || action.GetNamespace() != metav1.NamespaceSystem || action.GetResource().Resource != "secrets" {
		// We can't handle this event
		return false, nil, nil
	}
	// We can safely return a NotFound error here as the code will just proceed normally and create the Bootstrap Token
	return true, nil, apierrors.NewNotFound(action.GetResource().GroupResource(), "secret not found")
}
446986
func CpuRestGetSumTime(context *gin.Context) {
	body, err := cpu.ServiceGetSummaryTime()
	util.RestHandleResponse(context, body, err)
}
1253731
func GetPodStartTime(pod *v1.Pod) *metav1.Time {
	if pod.Status.StartTime != nil {
		return pod.Status.StartTime
	}
	// Should not reach here as the start time of a running time should not be nil
	// Return current timestamp as the default value.
	// This will not affect the calculation of earliest timestamp of all the pods on one node,
	// because current timestamp is always after the StartTime of any pod in good state.
	klog.Errorf("pod.Status.StartTime is nil for pod %s. Should not reach here.", pod.Name)
	return &metav1.Time{Time: time.Now()}
}