1
0
mirror of https://github.com/minio/mc.git synced 2025-12-10 10:22:47 +03:00
Files
mc/cmd/subnet-utils_test.go
Shireesh Anjal e4d4bf6641 Add register sub-command to mc admin subnet (#3808)
By default, it will run in `online` mode and try to register the cluster
on subnet. If the subnet license is not available in minio/mc config, it
will

- ask the user for login credentials
- use the credentials for authentication and call the registration api
- get the license from response of the api and store it in config
- use the stored license for any subsequent calls

In case the user belongs to multiple organizations in subnet, they will
be prompted to choose the appropriate organization from the list.

If the client machine is in an airgapped environment, user can choose to
use the `--offline` flag when running the command. In this case, it will

- generate and print the registration token
- ask the user to paste it in the subnet registration screen
- accept the license generated by subnet and store it in config

As part of this work, the `health` sub-command is also enhanced to:
- run in `online` mode by default, which tries to upload the health
report to subnet. Here the user will be prompted for subnet credentials
(if license not available in config) _before_ generating the health
report as it is a long running process.
- support a new flag `--offline` which can be used when subnet is not
reachable. When used, the health report will be generated in a local
json.gz file, which can then be uploaded on subnet.

The examples in help text of both the sub-commands are enhanced to list
multiple use cases.

When saving license to config, first preference is given to minio
config. If the minio server supports the `subnet license` key, the
license will be stored here. In case it is an older version of minio
that doesn't support this key, then the license will be stored in mc
host config.
2021-10-07 11:20:28 -07:00

35 lines
1.0 KiB
Go

// Copyright (c) 2015-2021 MinIO, Inc.
//
// This file is part of MinIO Object Storage stack
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package cmd
import (
"net/url"
"testing"
)
func TestSubnetBaseURL(t *testing.T) {
sbu := subnetBaseURL()
u, err := url.ParseRequestURI(sbu)
if err != nil {
t.Fatal(err)
}
if u.Scheme != "https" {
t.Fatalf("Expected TestSubnetBaseURL() to return an https url, received %s", u.Scheme)
}
}