本文整理匯總了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
}