当前位置: 首页>>代码示例>>Golang>>正文


Golang params.Status函数代码示例

本文整理汇总了Golang中github.com/juju/juju/apiserver/params.Status函数的典型用法代码示例。如果您正苦于以下问题:Golang Status函数的具体用法?Golang Status怎么用?Golang Status使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Status函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestGetUnitStatusIsLeader

func (s *serviceStatusGetterSuite) TestGetUnitStatusIsLeader(c *gc.C) {
	// If the unit isn't the leader, it can't get it.
	unit := s.Factory.MakeUnit(c, &factory.UnitParams{Status: &state.StatusInfo{
		Status: state.StatusMaintenance,
	}})
	service, err := unit.Service()
	c.Assert(err, jc.ErrorIsNil)
	s.State.LeadershipClaimer().ClaimLeadership(
		service.Name(),
		unit.Name(),
		time.Minute)
	result, err := s.getter.Status(params.Entities{[]params.Entity{{
		unit.Tag().String(),
	}}})
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(result.Results, gc.HasLen, 1)
	r := result.Results[0]
	c.Assert(r.Error, gc.IsNil)
	c.Assert(r.Service.Error, gc.IsNil)
	c.Assert(r.Service.Status, gc.Equals, params.Status(state.StatusMaintenance))
	units := r.Units
	c.Assert(units, gc.HasLen, 1)
	status, ok := units[unit.Name()]
	c.Assert(ok, jc.IsTrue)
	c.Assert(status.Error, gc.IsNil)
	c.Assert(status.Status, gc.Equals, params.Status(state.StatusMaintenance))
}
开发者ID:imoapps,项目名称:juju,代码行数:27,代码来源:getstatus_test.go

示例2: serviceStatus

func serviceStatus(s *ServiceStatusGetter, args params.Entities, getService serviceGetter, isLeaderCheck isLeaderFunc) (params.ServiceStatusResults, error) {
	results := params.ServiceStatusResults{
		Results: make([]params.ServiceStatusResult, len(args.Entities)),
	}
	canAccess, err := s.getcanAccess()
	if err != nil {
		return params.ServiceStatusResults{}, err
	}

	for i, serviceUnit := range args.Entities {
		leader, err := isLeaderCheck(s.st, serviceUnit.Tag)
		if err != nil {
			results.Results[i].Error = ServerError(err)
			continue
		}
		if !leader {
			results.Results[i].Error = ServerError(ErrIsNotLeader)
			continue
		}
		var service StatusService
		service, err = getService(s.st, serviceUnit.Tag)
		if err != nil {
			results.Results[i].Error = ServerError(err)
			continue
		}
		if !canAccess(service.Tag()) {
			results.Results[i].Error = ServerError(ErrPerm)
			continue
		}

		serviceStatus, unitStatuses, err := service.ServiceAndUnitsStatus()
		if err != nil {
			results.Results[i].Service.Error = ServerError(err)
			results.Results[i].Error = ServerError(err)
			continue
		}
		results.Results[i].Service.Status = params.Status(serviceStatus.Status)
		results.Results[i].Service.Info = serviceStatus.Message
		results.Results[i].Service.Data = serviceStatus.Data
		results.Results[i].Service.Since = serviceStatus.Since

		results.Results[i].Units = make(map[string]params.StatusResult, len(unitStatuses))
		for uTag, r := range unitStatuses {
			ur := params.StatusResult{
				Status: params.Status(r.Status),
				Info:   r.Message,
				Data:   r.Data,
				Since:  r.Since,
			}
			results.Results[i].Units[uTag] = ur
		}
	}
	return results, nil
}
开发者ID:Pankov404,项目名称:juju,代码行数:54,代码来源:getstatus.go

示例3: processUnitAndAgentStatus

// processUnitAndAgentStatus retrieves status information for both unit and unitAgents.
func processUnitAndAgentStatus(unit *state.Unit, status *params.UnitStatus) {
	status.UnitAgent, status.Workload = processUnitStatus(unit)

	// Legacy fields required until Juju 2.0.
	// We only display pending, started, error, stopped.
	var ok bool
	legacyState, ok := state.TranslateToLegacyAgentState(
		state.Status(status.UnitAgent.Status),
		state.Status(status.Workload.Status),
		status.Workload.Info,
	)
	if !ok {
		logger.Warningf(
			"translate to legacy status encounted unexpected workload status %q and agent status %q",
			status.Workload.Status, status.UnitAgent.Status)
	}
	status.AgentState = params.Status(legacyState)
	if status.AgentState == params.StatusError {
		status.AgentStateInfo = status.Workload.Info
	}
	status.AgentVersion = status.UnitAgent.Version
	status.Life = status.UnitAgent.Life
	status.Err = status.UnitAgent.Err

	processUnitLost(unit, status)

	return
}
开发者ID:imoapps,项目名称:juju,代码行数:29,代码来源:status.go

示例4: storageDetailsFromLegacy

func storageDetailsFromLegacy(legacy params.LegacyStorageDetails) params.StorageDetails {
	nowUTC := time.Now().UTC()
	details := params.StorageDetails{
		legacy.StorageTag,
		legacy.OwnerTag,
		legacy.Kind,
		params.EntityStatus{
			Status: params.Status(legacy.Status),
			Since:  &nowUTC,
		},
		legacy.Persistent,
		nil,
	}
	if legacy.UnitTag != "" {
		details.Attachments = map[string]params.StorageAttachmentDetails{
			legacy.UnitTag: params.StorageAttachmentDetails{
				legacy.StorageTag,
				legacy.UnitTag,
				"", // machine is unknown in legacy
				legacy.Location,
			},
		}
	}
	return details
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:25,代码来源:storage.go

示例5: makeStatusForEntity

// makeStatusForEntity creates status information for machines, units.
func makeStatusForEntity(agent *api.AgentStatus, getter state.StatusGetter) {
	statusInfo, err := getter.Status()
	agent.Err = err
	agent.Status = params.Status(statusInfo.Status)
	agent.Info = statusInfo.Message
	agent.Data = filterStatusData(statusInfo.Data)
	agent.Since = statusInfo.Since
}
开发者ID:vonwenm,项目名称:juju,代码行数:9,代码来源:status.go

示例6: populateStatusFromGetter

// populateStatusFromGetter creates status information for machines, units.
func populateStatusFromGetter(agent *params.AgentStatus, getter state.StatusGetter) {
	statusInfo, err := getter.Status()
	agent.Err = err
	agent.Status = params.Status(statusInfo.Status)
	agent.Info = statusInfo.Message
	agent.Data = filterStatusData(statusInfo.Data)
	agent.Since = statusInfo.Since
}
开发者ID:imoapps,项目名称:juju,代码行数:9,代码来源:status.go

示例7: EntityStatusFromState

// EntityStatusFromState converts a state.StatusInfo into a params.EntityStatus.
func EntityStatusFromState(status state.StatusInfo) params.EntityStatus {
	return params.EntityStatus{
		params.Status(status.Status),
		status.Message,
		status.Data,
		status.Since,
	}
}
开发者ID:imoapps,项目名称:juju,代码行数:9,代码来源:getstatus.go

示例8: SetUnitStatus

// SetUnitStatus will set the given status for this unit.
func (ctx *HookContext) SetUnitStatus(status jujuc.StatusInfo) error {
	ctx.hasRunStatusSet = true
	logger.Debugf("[WORKLOAD-STATUS] %s: %s", status.Status, status.Info)
	return ctx.unit.SetUnitStatus(
		params.Status(status.Status),
		status.Info,
		status.Data,
	)
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:10,代码来源:context.go

示例9: processService

func (context *statusContext) processService(service *state.Service) (status params.ServiceStatus) {
	serviceCharmURL, _ := service.CharmURL()
	status.Charm = serviceCharmURL.String()
	status.Exposed = service.IsExposed()
	status.Life = processLife(service)

	latestCharm, ok := context.latestCharms[*serviceCharmURL.WithRevision(-1)]
	if ok && latestCharm != serviceCharmURL.String() {
		status.CanUpgradeTo = latestCharm
	}
	var err error
	status.Relations, status.SubordinateTo, err = context.processServiceRelations(service)
	if err != nil {
		status.Err = err
		return
	}
	networks, err := service.Networks()
	if err != nil {
		status.Err = err
		return
	}
	var cons constraints.Value
	if service.IsPrincipal() {
		// Only principals can have constraints.
		cons, err = service.Constraints()
		if err != nil {
			status.Err = err
			return
		}
	}
	// TODO(dimitern): Drop support for this in a follow-up.
	if len(networks) > 0 || cons.HaveNetworks() {
		// Only the explicitly requested networks (using "juju deploy
		// <svc> --networks=...") will be enabled, and altough when
		// specified, networks constraints will be used for instance
		// selection, they won't be actually enabled.
		status.Networks = params.NetworksSpecification{
			Enabled:  networks,
			Disabled: append(cons.IncludeNetworks(), cons.ExcludeNetworks()...),
		}
	}
	if service.IsPrincipal() {
		status.Units = context.processUnits(context.units[service.Name()], serviceCharmURL.String())
		serviceStatus, err := service.Status()
		if err != nil {
			status.Err = err
			return
		}
		status.Status.Status = params.Status(serviceStatus.Status)
		status.Status.Info = serviceStatus.Message
		status.Status.Data = serviceStatus.Data
		status.Status.Since = serviceStatus.Since

		status.MeterStatuses = context.processUnitMeterStatuses(context.units[service.Name()])
	}
	return status
}
开发者ID:imoapps,项目名称:juju,代码行数:57,代码来源:status.go

示例10: TestGetMachineStatus

func (s *statusGetterSuite) TestGetMachineStatus(c *gc.C) {
	machine := s.Factory.MakeMachine(c, nil)
	result, err := s.getter.Status(params.Entities{[]params.Entity{{
		machine.Tag().String(),
	}}})
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(result.Results, gc.HasLen, 1)
	status := result.Results[0]
	c.Assert(status.Error, gc.IsNil)
	c.Assert(status.Status, gc.Equals, params.Status(state.StatusPending))
}
开发者ID:imoapps,项目名称:juju,代码行数:11,代码来源:getstatus_test.go

示例11: checkStatusInfo

func checkStatusInfo(c *gc.C, obtained []params.AgentStatus, expected []state.StatusInfo) {
	c.Assert(len(obtained), gc.Equals, len(expected))
	lastTimestamp := int64(0)
	for i, obtainedInfo := range obtained {
		thisTimeStamp := obtainedInfo.Since.Unix()
		c.Assert(thisTimeStamp >= lastTimestamp, jc.IsTrue)
		lastTimestamp = thisTimeStamp
		obtainedInfo.Since = nil
		c.Assert(obtainedInfo.Status, gc.Equals, params.Status(expected[i].Status))
		c.Assert(obtainedInfo.Info, gc.Equals, expected[i].Message)
	}
}
开发者ID:imoapps,项目名称:juju,代码行数:12,代码来源:statushistory_test.go

示例12: TestGetServiceStatus

func (s *statusGetterSuite) TestGetServiceStatus(c *gc.C) {
	service := s.Factory.MakeService(c, &factory.ServiceParams{Status: &state.StatusInfo{
		Status: state.StatusMaintenance,
	}})
	result, err := s.getter.Status(params.Entities{[]params.Entity{{
		service.Tag().String(),
	}}})
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(result.Results, gc.HasLen, 1)
	status := result.Results[0]
	c.Assert(status.Error, gc.IsNil)
	c.Assert(status.Status, gc.Equals, params.Status(state.StatusMaintenance))
}
开发者ID:imoapps,项目名称:juju,代码行数:13,代码来源:getstatus_test.go

示例13: agentStatusFromStatusInfo

func agentStatusFromStatusInfo(s []state.StatusInfo, kind params.HistoryKind) []params.AgentStatus {
	result := []params.AgentStatus{}
	for _, v := range s {
		result = append(result, params.AgentStatus{
			Status: params.Status(v.Status),
			Info:   v.Message,
			Data:   v.Data,
			Since:  v.Since,
			Kind:   kind,
		})
	}
	return result

}
开发者ID:imoapps,项目名称:juju,代码行数:14,代码来源:status.go

示例14: TestGetUnitStatus

func (s *statusGetterSuite) TestGetUnitStatus(c *gc.C) {
	// The status has to be a valid workload status, because get status
	// on the unit returns the workload status not the agent status as it
	// does on a machine.
	unit := s.Factory.MakeUnit(c, &factory.UnitParams{Status: &state.StatusInfo{
		Status: state.StatusMaintenance,
	}})
	result, err := s.getter.Status(params.Entities{[]params.Entity{{
		unit.Tag().String(),
	}}})
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(result.Results, gc.HasLen, 1)
	status := result.Results[0]
	c.Assert(status.Error, gc.IsNil)
	c.Assert(status.Status, gc.Equals, params.Status(state.StatusMaintenance))
}
开发者ID:imoapps,项目名称:juju,代码行数:16,代码来源:getstatus_test.go

示例15: TestBulk

func (s *statusGetterSuite) TestBulk(c *gc.C) {
	s.badTag = names.NewMachineTag("42")
	machine := s.Factory.MakeMachine(c, nil)
	result, err := s.getter.Status(params.Entities{[]params.Entity{{
		s.badTag.String(),
	}, {
		machine.Tag().String(),
	}, {
		"bad-tag",
	}}})
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(result.Results, gc.HasLen, 3)
	c.Assert(result.Results[0].Error, jc.Satisfies, params.IsCodeUnauthorized)
	c.Assert(result.Results[1].Error, gc.IsNil)
	c.Assert(result.Results[1].Status, gc.Equals, params.Status(state.StatusPending))
	c.Assert(result.Results[2].Error, gc.ErrorMatches, `"bad-tag" is not a valid tag`)
}
开发者ID:imoapps,项目名称:juju,代码行数:17,代码来源:getstatus_test.go


注:本文中的github.com/juju/juju/apiserver/params.Status函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。