peravailability

package
v0.1.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:   "per-availability",
	Short: "List regions that support PER",
	Long:  "List regions that support Power Edge Router (PER)",
	PreRunE: func(cmd *cobra.Command, args []string) error {
		return utils.EnsureWorkspaceIDorNameIsSet(pkg.Options.WorkspaceID, pkg.Options.WorkspaceName)
	},
	RunE: func(cmd *cobra.Command, args []string) error {
		var perEnabledRegions []string
		opt := pkg.Options
		c, err := client.NewClientWithEnv(opt.APIKey, opt.Environment, opt.Debug)
		if err != nil {
			klog.Errorf("failed to create a session with IBM cloud, err: %v", err)
			return err
		}

		pvmclient, err := client.NewPVMClientWithEnv(c, opt.WorkspaceID, opt.WorkspaceName, opt.Environment)
		if err != nil {
			return err
		}
		ret, err := pvmclient.DatacenterClient.GetAll()
		if err != nil {
			return err
		}
		var supportsPER bool
		for _, datacenter := range ret.Datacenters {
			if datacenter.Capabilities[powerEdgeRouter] {
				perEnabledRegions = append(perEnabledRegions, *datacenter.Location.Region)
				if pvmclient.Zone == *datacenter.Location.Region {
					supportsPER = true
				}
			}
		}
		if !supportsPER {
			klog.Infof("%s, where the current workspace is present does not support PER.", pvmclient.Zone)
		} else {
			klog.Infof("%s, where the current workspace is present supports PER.", pvmclient.Zone)
		}
		sort.Strings(perEnabledRegions)
		klog.Infof("The following zones/datacenters have support for PER:%v.More information at https://cloud.ibm.com/docs/overview?topic=overview-locations", perEnabledRegions)
		return nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL