diff --git a/cmd/license-register.go b/cmd/license-register.go index 93df1abb..5c820fcd 100644 --- a/cmd/license-register.go +++ b/cmd/license-register.go @@ -25,6 +25,7 @@ import ( "github.com/google/uuid" "github.com/minio/cli" json "github.com/minio/colorjson" + "github.com/minio/madmin-go" "github.com/minio/mc/pkg/probe" "github.com/minio/pkg/console" ) @@ -172,13 +173,6 @@ func mainLicenseRegister(ctx *cli.Context) error { fatalIf(probe.NewError(e), "unable to parse input values") } - // Create a new MinIO Admin Client - client := getClient(aliasedURL) - - // Fetch info of all servers (cluster or single server) - admInfo, e := client.ServerInfo(globalContext) - fatalIf(probe.NewError(e), "Unable to fetch cluster info") - alias, _ := url2Alias(aliasedURL) clusterName := ctx.String("name") if len(clusterName) == 0 { @@ -189,7 +183,7 @@ func mainLicenseRegister(ctx *cli.Context) error { } } - regInfo := getClusterRegInfo(admInfo, clusterName) + regInfo := getClusterRegInfo(getAdminInfo(aliasedURL), clusterName) alreadyRegistered := false apiKey, lic, e := getSubnetCreds(alias) @@ -234,3 +228,14 @@ func registerOnline(clusterRegInfo ClusterRegistrationInfo, alias string, accAPI extractAndSaveSubnetCreds(alias, resp) } + +func getAdminInfo(aliasedURL string) madmin.InfoMessage { + // Create a new MinIO Admin Client + client := getClient(aliasedURL) + + // Fetch info of all servers (cluster or single server) + admInfo, e := client.ServerInfo(globalContext) + fatalIf(probe.NewError(e), "Unable to fetch cluster info") + + return admInfo +} diff --git a/cmd/license-update.go b/cmd/license-update.go index e3fd3f0a..2d2b930c 100644 --- a/cmd/license-update.go +++ b/cmd/license-update.go @@ -109,6 +109,10 @@ func performLicenseUpdate(licFile string, alias string, airgap bool) licUpdateMe fatalIf(errDummy().Trace(), fmt.Sprintf("License has expired on %s", li.ExpiresAt)) } + if li.DeploymentID != getAdminInfo(alias).DeploymentID { + fatalIf(errDummy().Trace(), fmt.Sprintf("License is invalid for the deployment %s", alias)) + } + setSubnetCreds(alias, "", lic) return lum }