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


Golang api.UnitStatus类代码示例

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


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

示例1: processUnitAndAgentStatus

// processUnitAndAgentStatus retrieves status information for both unit and unitAgents.
func processUnitAndAgentStatus(unit *state.Unit, status *api.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:vonwenm,项目名称:juju,代码行数:29,代码来源:status.go

示例2: processUnit

func (context *statusContext) processUnit(unit *state.Unit, serviceCharm string) api.UnitStatus {
	var result api.UnitStatus
	result.PublicAddress, _ = unit.PublicAddress()
	unitPorts, _ := unit.OpenedPorts()
	for _, port := range unitPorts {
		result.OpenedPorts = append(result.OpenedPorts, port.String())
	}
	if unit.IsPrincipal() {
		result.Machine, _ = unit.AssignedMachineId()
	}
	curl, _ := unit.CharmURL()
	if serviceCharm != "" && curl != nil && curl.String() != serviceCharm {
		result.Charm = curl.String()
	}
	processUnitAndAgentStatus(unit, &result)

	if subUnits := unit.SubordinateNames(); len(subUnits) > 0 {
		result.Subordinates = make(map[string]api.UnitStatus)
		for _, name := range subUnits {
			subUnit := context.unitByName(name)
			// subUnit may be nil if subordinate was filtered out.
			if subUnit != nil {
				result.Subordinates[name] = context.processUnit(subUnit, serviceCharm)
			}
		}
	}
	return result
}
开发者ID:vonwenm,项目名称:juju,代码行数:28,代码来源:status.go

示例3: updateUnitStatusInfo

func (sf *statusFormatter) updateUnitStatusInfo(unit *api.UnitStatus, serviceName string) {
	// This logic has no business here but can't be moved until Juju 2.0.
	statusInfo := unit.Workload.Info
	if unit.Workload.Status == "" {
		// Old server that doesn't support this field and others.
		// Just use the info string as-is.
		statusInfo = unit.AgentStateInfo
	}
	if unit.Workload.Status == params.StatusError {
		if relation, ok := sf.relations[getRelationIdFromData(unit)]; ok {
			// Append the details of the other endpoint on to the status info string.
			if ep, ok := findOtherEndpoint(relation.Endpoints, serviceName); ok {
				unit.Workload.Info = statusInfo + " for " + ep.String()
				unit.AgentStateInfo = unit.Workload.Info
			}
		}
	}
}
开发者ID:Pankov404,项目名称:juju,代码行数:18,代码来源:status.go


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