Skip to content

Commit

Permalink
Deprecating instance-id and instance-name
Browse files Browse the repository at this point in the history
Signed-off-by: Varad Ahirwadkar <[email protected]>
  • Loading branch information
varad-ahirwadkar committed May 29, 2024
1 parent 3b388b0 commit a1a8e5f
Show file tree
Hide file tree
Showing 30 changed files with 144 additions and 109 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ The typical image workflow comprises of the following steps:
- How to convert RHEL qcow2 to ova image format - [guide](docs/RHEL%20Qcow2%20to%20OVA.md)
- How to convert RHCOS(Red Hat CoreOS) qcow2 to ova image format - [guide](docs/RHCOS%20Qcow2%20to%20OVA.md)
- Advanced scenarios for Qcow2 to ova image conversion - [guide](docs/Advanced%20Scenarios%20for%20Qcow2%20to%20OVA.md)
- How to import image to PowerVS instance from COS - [guide](docs/How%20to%20Import%20Image%20to%20PowerVS%20Instance.md)
- How to import image to PowerVS workspace from COS - [guide](docs/How%20to%20Import%20Image%20to%20PowerVS%20Instance.md)
- How to upload image to COS bucket using pvsadm - [guide](docs/How%20to%20Upload%20Image%20to%20COS.md)
- How to build DHCP supported centos image - [guide](docs/Build%20DHCP%20enabled%20Centos%20Images.md)

Expand Down
5 changes: 3 additions & 2 deletions cmd/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var Cmd = &cobra.Command{

func init() {
Cmd.AddCommand(port.Cmd)
Cmd.PersistentFlags().StringVarP(&pkg.Options.InstanceID, "instance-id", "i", "", "Instance ID of the PowerVS instance")
_ = Cmd.MarkPersistentFlagRequired("instance-id")
Cmd.PersistentFlags().StringVarP(&pkg.Options.WorkspaceID, "instance-id", "i", "", "Instance ID of the PowerVS instance")
Cmd.PersistentFlags().MarkDeprecated("instance-id", "instance-id is deprecated, workspace-id should be used")
Cmd.PersistentFlags().StringVarP(&pkg.Options.WorkspaceID, "workspace-id", "", "", "Workspace ID of the PowerVS workspace")
}
8 changes: 7 additions & 1 deletion cmd/create/port/port.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ var Cmd = &cobra.Command{
Use: "port",
Short: "Create PowerVS network port",
Long: `Create PowerVS network port`,
PreRunE: func(cmd *cobra.Command, args []string) error {
if pkg.Options.WorkspaceID == "" {
return fmt.Errorf("--workspace-id required")
}
return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
opt := pkg.Options

Expand All @@ -44,7 +50,7 @@ var Cmd = &cobra.Command{
return err
}

pvmclient, err := client.NewPVMClientWithEnv(c, opt.InstanceID, opt.InstanceName, opt.Environment)
pvmclient, err := client.NewPVMClientWithEnv(c, opt.WorkspaceID, opt.WorkspaceName, opt.Environment)
if err != nil {
return err
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var Cmd = &cobra.Command{

func init() {
Cmd.AddCommand(port.Cmd)
Cmd.PersistentFlags().StringVarP(&pkg.Options.InstanceID, "instance-id", "i", "", "Instance ID of the PowerVS instance")
_ = Cmd.MarkPersistentFlagRequired("instance-id")
Cmd.PersistentFlags().StringVarP(&pkg.Options.WorkspaceID, "instance-id", "i", "", "Instance ID of the PowerVS instance")
Cmd.PersistentFlags().MarkDeprecated("instance-id", "instance-id is deprecated, workspace-id should be used")
Cmd.PersistentFlags().StringVarP(&pkg.Options.WorkspaceID, "workspace-id", "", "", "Workspace ID of the PowerVS instance")
}
8 changes: 7 additions & 1 deletion cmd/delete/port/port.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ var Cmd = &cobra.Command{
Use: "port",
Short: "Delete PowerVS network port",
Long: `Delete PowerVS network port`,
PreRunE: func(cmd *cobra.Command, args []string) error {
if pkg.Options.WorkspaceID == "" {
return fmt.Errorf("--workspace-id required")
}
return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
opt := pkg.Options

Expand All @@ -43,7 +49,7 @@ var Cmd = &cobra.Command{
return err
}

pvmclient, err := client.NewPVMClientWithEnv(c, opt.InstanceID, opt.InstanceName, opt.Environment)
pvmclient, err := client.NewPVMClientWithEnv(c, opt.WorkspaceID, opt.WorkspaceName, opt.Environment)
if err != nil {
return err
}
Expand Down
10 changes: 6 additions & 4 deletions cmd/dhcp-sync/dhcp-sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func syncDHCPD() {
klog.Fatalf("failed to create a session with IBM cloud: %v", err)
}

pvmclient, err := client.NewPVMClientWithEnv(c, pkg.Options.InstanceID, "", "prod")
pvmclient, err := client.NewPVMClientWithEnv(c, pkg.Options.WorkspaceID, "", "prod")
if err != nil {
klog.Fatalf("failed to create a PVM client: %v", err)
}
Expand Down Expand Up @@ -159,8 +159,8 @@ var Cmd = &cobra.Command{
Long: `dhcp-sync tool is a tool populating the dhcpd.conf file from the PowerVS network and restart the dhcpd service.`,
GroupID: "dhcp",
PreRunE: func(cmd *cobra.Command, args []string) error {
if pkg.Options.InstanceID == "" {
return fmt.Errorf("--instance-id is required")
if pkg.Options.WorkspaceID == "" {
return fmt.Errorf("--workspace-id is required")
}
if pkg.Options.APIKey == "" {
return fmt.Errorf("api-key can't be empty, pass the token via --api-key or set IBMCLOUD_API_KEY environment variable")
Expand Down Expand Up @@ -211,7 +211,9 @@ var Cmd = &cobra.Command{
}

func init() {
Cmd.Flags().StringVarP(&pkg.Options.InstanceID, "instance-id", "i", "", "Instance ID of the PowerVS instance")
Cmd.Flags().StringVarP(&pkg.Options.WorkspaceID, "instance-id", "i", "", "Instance ID of the PowerVS instance")
Cmd.Flags().MarkDeprecated("instance-id", "instance-id is deprecated, workspace-id should be used")
Cmd.Flags().StringVarP(&pkg.Options.WorkspaceID, "workspace-id", "w", "", "Workspace ID of the PowerVS instance")
Cmd.Flags().StringVar(&networkID, "network-id", "", "Network ID to be monitored")
Cmd.Flags().StringVar(&file, "file", "/etc/dhcp/dhcpd.conf", "DHCP conf file")
Cmd.Flags().StringVar(&gateway, "gateway", "", "Override the gateway value with")
Expand Down
8 changes: 6 additions & 2 deletions cmd/dhcpserver/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ var Cmd = &cobra.Command{
if pkg.Options.APIKey == "" {
return fmt.Errorf("api-key can't be empty, pass the token via --api-key or set IBMCLOUD_API_KEY environment variable")
}
if pkg.Options.WorkspaceID == "" {
return fmt.Errorf("--workspace-id required")
}
return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -43,6 +46,7 @@ func init() {
Cmd.AddCommand(getCmd)
Cmd.AddCommand(deleteCmd)

Cmd.PersistentFlags().StringVarP(&pkg.Options.InstanceID, "instance-id", "i", "", "Instance ID of the PowerVS instance")
_ = Cmd.MarkPersistentFlagRequired("instance-id")
Cmd.PersistentFlags().StringVarP(&pkg.Options.WorkspaceID, "instance-id", "i", "", "Instance ID of the PowerVS instance")
Cmd.PersistentFlags().MarkDeprecated("instance-id", "instance-id is deprecated, workspace-id should be used")
Cmd.PersistentFlags().StringVarP(&pkg.Options.WorkspaceID, "workspace-id", "", "", "Workspace ID of the PowerVS instance")
}
2 changes: 1 addition & 1 deletion cmd/dhcpserver/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var createCmd = &cobra.Command{
return err
}

pvmclient, err := client.NewPVMClientWithEnv(c, opt.InstanceID, opt.InstanceName, opt.Environment)
pvmclient, err := client.NewPVMClientWithEnv(c, opt.WorkspaceID, opt.WorkspaceName, opt.Environment)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/dhcpserver/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var deleteCmd = &cobra.Command{
return err
}

pvmclient, err := client.NewPVMClientWithEnv(c, opt.InstanceID, opt.InstanceName, opt.Environment)
pvmclient, err := client.NewPVMClientWithEnv(c, opt.WorkspaceID, opt.WorkspaceName, opt.Environment)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/dhcpserver/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var getCmd = &cobra.Command{
return err
}

pvmclient, err := client.NewPVMClientWithEnv(c, opt.InstanceID, opt.InstanceName, opt.Environment)
pvmclient, err := client.NewPVMClientWithEnv(c, opt.WorkspaceID, opt.WorkspaceName, opt.Environment)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/dhcpserver/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var listCmd = &cobra.Command{
return err
}

pvmclient, err := client.NewPVMClientWithEnv(c, opt.InstanceID, opt.InstanceName, opt.Environment)
pvmclient, err := client.NewPVMClientWithEnv(c, opt.WorkspaceID, opt.WorkspaceName, opt.Environment)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/get/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ var Cmd = &cobra.Command{
Short: "Get Powervs events",
Long: `Get the PowerVS events`,
PreRunE: func(cmd *cobra.Command, args []string) error {
if pkg.Options.InstanceID == "" && pkg.Options.InstanceName == "" {
return fmt.Errorf("--instance-id or --instance-name required")
if pkg.Options.WorkspaceID == "" && pkg.Options.WorkspaceName == "" {
return fmt.Errorf("--workspace-id or --workspace-name required")
}
return nil
},
Expand All @@ -49,7 +49,7 @@ var Cmd = &cobra.Command{
return err
}

pvmclient, err := client.NewPVMClientWithEnv(c, opt.InstanceID, opt.InstanceName, opt.Environment)
pvmclient, err := client.NewPVMClientWithEnv(c, opt.WorkspaceID, opt.WorkspaceName, opt.Environment)
if err != nil {
return err
}
Expand Down
8 changes: 6 additions & 2 deletions cmd/get/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ func init() {
Cmd.AddCommand(events.Cmd)
Cmd.AddCommand(peravailability.Cmd)
Cmd.AddCommand(ports.Cmd)
Cmd.PersistentFlags().StringVarP(&pkg.Options.InstanceID, "instance-id", "i", "", "Instance ID of the PowerVS instance")
Cmd.PersistentFlags().StringVarP(&pkg.Options.InstanceName, "instance-name", "n", "", "Instance name of the PowerVS")
Cmd.PersistentFlags().StringVarP(&pkg.Options.WorkspaceID, "instance-id", "i", "", "Instance ID of the PowerVS instance")
Cmd.PersistentFlags().MarkDeprecated("instance-id", "instance-id is deprecated, workspace-id should be used")
Cmd.PersistentFlags().StringVarP(&pkg.Options.WorkspaceName, "instance-name", "n", "", "Instance name of the PowerVS")
Cmd.PersistentFlags().MarkDeprecated("instance-name", "instance-name is deprecated, workspace-name should be used")
Cmd.PersistentFlags().StringVarP(&pkg.Options.WorkspaceID, "workspace-id", "", "", "Workspace ID of the PowerVS instance")
Cmd.PersistentFlags().StringVarP(&pkg.Options.WorkspaceName, "workspace-name", "", "", "Workspace name of the PowerVS")
}
10 changes: 5 additions & 5 deletions cmd/get/peravailability/peravailability.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ var Cmd = &cobra.Command{
Short: "List regions that support PER",
Long: "List regions that support Power Edge Router (PER)",
PreRunE: func(cmd *cobra.Command, args []string) error {
if pkg.Options.InstanceID == "" && pkg.Options.InstanceName == "" {
return fmt.Errorf("--instance-id or --instance-name required")
if pkg.Options.WorkspaceID == "" && pkg.Options.WorkspaceName == "" {
return fmt.Errorf("--workspace-id or --workspace-name required")
}
return nil
},
Expand All @@ -46,7 +46,7 @@ var Cmd = &cobra.Command{
return err
}

pvmclient, err := client.NewPVMClientWithEnv(c, opt.InstanceID, opt.InstanceName, opt.Environment)
pvmclient, err := client.NewPVMClientWithEnv(c, opt.WorkspaceID, opt.WorkspaceName, opt.Environment)
if err != nil {
return err
}
Expand All @@ -64,9 +64,9 @@ var Cmd = &cobra.Command{
}
}
if !supportsPER {
klog.Infof("%s, where the current instance is present does not support PER.", pvmclient.Zone)
klog.Infof("%s, where the current workspace is present does not support PER.", pvmclient.Zone)
} else {
klog.Infof("%s, where the current instance is present supports PER.", pvmclient.Zone)
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)
Expand Down
6 changes: 3 additions & 3 deletions cmd/get/ports/ports.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ var Cmd = &cobra.Command{
Short: "Get PowerVS network ports",
Long: `Get PowerVS network ports`,
PreRunE: func(cmd *cobra.Command, args []string) error {
if pkg.Options.InstanceID == "" && pkg.Options.InstanceName == "" {
return fmt.Errorf("--instance-id or --instance-name required")
if pkg.Options.WorkspaceID == "" && pkg.Options.WorkspaceName == "" {
return fmt.Errorf("--workspace-id or --workspace-name required")
}
return nil
},
Expand All @@ -49,7 +49,7 @@ var Cmd = &cobra.Command{
return err
}

pvmclient, err := client.NewPVMClientWithEnv(c, opt.InstanceID, opt.InstanceName, opt.Environment)
pvmclient, err := client.NewPVMClientWithEnv(c, opt.WorkspaceID, opt.WorkspaceName, opt.Environment)
if err != nil {
return err
}
Expand Down
21 changes: 13 additions & 8 deletions cmd/image/import/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ func findCOSInstanceDetails(resources []models.ServiceInstanceV2, bxCli *client.

var Cmd = &cobra.Command{
Use: "import",
Short: "Import the image into PowerVS instances",
Long: `Import the image into PowerVS instances
Short: "Import the image into PowerVS workpace",
Long: `Import the image into PowerVS workpace
pvsadm image import --help for information
# Set the API key or feed the --api-key commandline argument
Expand All @@ -90,11 +90,11 @@ pvsadm image import -n upstream-core-lon04 -b <BUCKETNAME> --pvs-storagetype <ST
pvsadm image import -n upstream-core-lon04 -b <BUCKETNAME> --object rhel-83-10032020.ova.gz --pvs-image-name test-image -r <REGION>
# import image from a public IBM Cloud Storage bucket
pvsadm image import -n upstream-core-lon04 -b <BUCKETNAME> --object rhel-83-10032020.ova.gz --pvs-image-name test-image -r <REGION> --public-bucket
pvsadm image import -n upstream-core-lon04 -b <BUCKETNAME> --object rhel-83-10032020.ova.gz --pvs-image-name test-image -r <REGION> --public-bucket
`,
PreRunE: func(cmd *cobra.Command, args []string) error {
if pkg.ImageCMDOptions.InstanceID == "" && pkg.ImageCMDOptions.InstanceName == "" {
return fmt.Errorf("--pvs-instance-name or --pvs-instance-id required")
if pkg.ImageCMDOptions.WorkspaceID == "" && pkg.ImageCMDOptions.WorkspaceName == "" {
return fmt.Errorf("--workspace-name or --workspace-id required")
}

case1 := pkg.ImageCMDOptions.AccessKey == "" && pkg.ImageCMDOptions.SecretKey != ""
Expand Down Expand Up @@ -174,7 +174,7 @@ pvsadm image import -n upstream-core-lon04 -b <BUCKETNAME> --object rhel-83-100
opt.SecretKey = cred["secret_access_key"].(string)
}

pvmclient, err := client.NewPVMClientWithEnv(bxCli, opt.InstanceID, opt.InstanceName, pkg.Options.Environment)
pvmclient, err := client.NewPVMClientWithEnv(bxCli, opt.WorkspaceID, opt.WorkspaceName, pkg.Options.Environment)
if err != nil {
return err
}
Expand Down Expand Up @@ -242,8 +242,13 @@ pvsadm image import -n upstream-core-lon04 -b <BUCKETNAME> --object rhel-83-100
}

func init() {
Cmd.Flags().StringVarP(&pkg.ImageCMDOptions.InstanceName, "pvs-instance-name", "n", "", "PowerVS Instance name.")
Cmd.Flags().StringVarP(&pkg.ImageCMDOptions.InstanceID, "pvs-instance-id", "i", "", "PowerVS Instance ID.")
// TODO pvs-instance-name and pvs-instance-id is deprecated and will be removed in a future release
Cmd.Flags().StringVarP(&pkg.ImageCMDOptions.WorkspaceName, "pvs-instance-name", "n", "", "PowerVS Instance name.")
Cmd.Flags().MarkDeprecated("pvs-instance-name", "pvs-instance-name is deprecated, workspace-name should be used")
Cmd.Flags().StringVarP(&pkg.ImageCMDOptions.WorkspaceID, "pvs-instance-id", "i", "", "PowerVS Instance ID.")
Cmd.Flags().MarkDeprecated("pvs-instance-id", "pvs-instance-id is deprecated, workspace-id should be used")
Cmd.Flags().StringVarP(&pkg.ImageCMDOptions.WorkspaceName, "workspace-name", "", "", "PowerVS Workspace name.")
Cmd.Flags().StringVarP(&pkg.ImageCMDOptions.WorkspaceID, "workspace-id", "", "", "PowerVS Workspace ID.")
Cmd.Flags().StringVarP(&pkg.ImageCMDOptions.BucketName, "bucket", "b", "", "Cloud Object Storage bucket name.")
Cmd.Flags().StringVarP(&pkg.ImageCMDOptions.COSInstanceName, "cos-instance-name", "s", "", "Cloud Object Storage instance name.")
// TODO It's deprecated and will be removed in a future release
Expand Down
1 change: 1 addition & 0 deletions cmd/image/sync/mock/sync_client_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a1a8e5f

Please sign in to comment.