Beispiel #1
0
// 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"
}
Beispiel #2
0
// 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
}