本文整理汇总了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"
}
示例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
}