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


Golang VirtualMachine.UpgradeInProgress方法代码示例

本文整理汇总了Golang中github.com/vmware/vic/pkg/vsphere/vm.VirtualMachine.UpgradeInProgress方法的典型用法代码示例。如果您正苦于以下问题:Golang VirtualMachine.UpgradeInProgress方法的具体用法?Golang VirtualMachine.UpgradeInProgress怎么用?Golang VirtualMachine.UpgradeInProgress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/vmware/vic/pkg/vsphere/vm.VirtualMachine的用法示例。


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

示例1: upgradeStatusMessage

// upgradeStatusMessage generates a user facing status string about upgrade progress and status
func (l *List) upgradeStatusMessage(ctx context.Context, vch *vm.VirtualMachine, installerVer *version.Build, vchVer *version.Build) string {
	if sameVer := installerVer.Equal(vchVer); sameVer {
		return "Up to date"
	}

	upgrading, _, err := vch.UpgradeInProgress(ctx, management.UpgradePrefix)
	if err != nil {
		return fmt.Sprintf("Unknown: %s", err)
	}
	if upgrading {
		return "Upgrade in progress"
	}

	canUpgrade, err := installerVer.IsNewer(vchVer)
	if err != nil {
		return fmt.Sprintf("Unknown: %s", err)
	}
	if canUpgrade {
		return fmt.Sprintf("Upgradeable to %s", installerVer.ShortVersion())
	}

	oldInstaller, err := installerVer.IsOlder(vchVer)
	if err != nil {
		return fmt.Sprintf("Unknown: %s", err)
	}
	if oldInstaller {
		return fmt.Sprintf("VCH has newer version")
	}

	// can't get here
	return "Invalid upgrade status"
}
开发者ID:vmware,项目名称:vic,代码行数:33,代码来源:list.go

示例2: upgradeStatusMessage

// upgradeStatusMessage generates a user facing status string about upgrade progress and status
func (i *Inspect) upgradeStatusMessage(ctx context.Context, vch *vm.VirtualMachine, installerVer *version.Build, vchVer *version.Build) {
	if sameVer := installerVer.Equal(vchVer); sameVer {
		log.Info("Installer has same version as VCH")
		log.Info("No upgrade available with this installer version")
		return
	}

	upgrading, _, err := vch.UpgradeInProgress(ctx, management.UpgradePrefix)
	if err != nil {
		log.Errorf("Unable to determine if upgrade is in progress: %s", err)
		return
	}
	if upgrading {
		log.Info("Upgrade in progress")
		return
	}

	canUpgrade, err := installerVer.IsNewer(vchVer)
	if err != nil {
		log.Errorf("Unable to determine if upgrade is availabile: %s", err)
		return
	}
	if canUpgrade {
		log.Info("Upgrade available")
		return
	}

	oldInstaller, err := installerVer.IsOlder(vchVer)
	if err != nil {
		log.Errorf("Unable to determine if upgrade is available: %s", err)
		return
	}
	if oldInstaller {
		log.Info("Installer has older version than VCH")
		log.Info("No upgrade available with this installer version")
		return
	}

	// can't get here
	log.Warn("Invalid upgrade status")
	return
}
开发者ID:vmware,项目名称:vic,代码行数:43,代码来源:inspect.go


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