Skip to content

Commit

Permalink
Renaming instance-id and instance-name
Browse files Browse the repository at this point in the history
Signed-off-by: Varad Ahirwadkar <varad.ahirwadkar1@ibm.com>
  • Loading branch information
varad-ahirwadkar committed Apr 15, 2024
1 parent 9566e8d commit ac09413
Show file tree
Hide file tree
Showing 19 changed files with 68 additions and 56 deletions.
4 changes: 2 additions & 2 deletions cmd/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ 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.InstanceID, "workspace-id", "i", "", "Workspace ID of the PowerVS workspace")
_ = Cmd.MarkPersistentFlagRequired("workspace-id")
}
4 changes: 2 additions & 2 deletions cmd/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ 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.InstanceID, "workspace-id", "i", "", "Workspace ID of the PowerVS workspace")
_ = Cmd.MarkPersistentFlagRequired("workspace-id")
}
4 changes: 2 additions & 2 deletions cmd/dhcp-sync/dhcp-sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ var Cmd = &cobra.Command{
GroupID: "dhcp",
PreRunE: func(cmd *cobra.Command, args []string) error {
if pkg.Options.InstanceID == "" {
return fmt.Errorf("--instance-id is required")
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 @@ -212,7 +212,7 @@ 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.InstanceID, "workspace-id", "i", "", "Workspace ID of the PowerVS workspace")
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
4 changes: 2 additions & 2 deletions cmd/dhcpserver/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ 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.InstanceID, "workspace-id", "i", "", "Workspace ID of the PowerVS workspace")
_ = Cmd.MarkPersistentFlagRequired("workspace-id")
}
2 changes: 1 addition & 1 deletion cmd/get/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var Cmd = &cobra.Command{
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")
return fmt.Errorf("--workspace-id or --workspace-name required")
}
return nil
},
Expand Down
4 changes: 2 additions & 2 deletions cmd/get/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ 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.InstanceID, "workspace-id", "i", "", "Workspace ID of the PowerVS workspace")
Cmd.PersistentFlags().StringVarP(&pkg.Options.InstanceName, "workspace-name", "n", "", "Workspace name of the PowerVS")
}
6 changes: 3 additions & 3 deletions cmd/get/peravailability/peravailability.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var Cmd = &cobra.Command{
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")
return fmt.Errorf("--workspace-id or --workspace-name required")
}
return nil
},
Expand Down Expand Up @@ -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.Infoln("The following zones/datacenters have support for PER:", perEnabledRegions, ".", "More information at https://cloud.ibm.com/docs/overview?topic=overview-locations")
Expand Down
2 changes: 1 addition & 1 deletion cmd/get/ports/ports.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var Cmd = &cobra.Command{
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")
return fmt.Errorf("--workspace-id or --workspace-name required")
}
return nil
},
Expand Down
10 changes: 5 additions & 5 deletions cmd/image/import/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,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 workspace",
Long: `Import the image into PowerVS workspace
pvsadm image import --help for information
# Set the API key or feed the --api-key commandline argument
Expand Down Expand Up @@ -92,7 +92,7 @@ pvsadm image import -n upstream-core-lon04 -b <BUCKETNAME> --object rhel-83-100
`,
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")
return fmt.Errorf("--pvs-workspace-name or --pvs-workspace-id required")
}

case1 := pkg.ImageCMDOptions.AccessKey == "" && pkg.ImageCMDOptions.SecretKey != ""
Expand Down Expand Up @@ -251,8 +251,8 @@ 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.")
Cmd.Flags().StringVarP(&pkg.ImageCMDOptions.InstanceName, "pvs-workspace-name", "n", "", "PowerVS Workspace name.")
Cmd.Flags().StringVarP(&pkg.ImageCMDOptions.InstanceID, "pvs-workspace-id", "i", "", "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.

2 changes: 1 addition & 1 deletion cmd/purge/images/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var Cmd = &cobra.Command{
pvsadm purge --help for information
`,
RunE: func(cmd *cobra.Command, args []string) error {
klog.Infof("Purge the images for the instance: %v", pkg.Options.InstanceID)
klog.Infof("Purge the images for the workspace: %v", pkg.Options.InstanceID)
opt := pkg.Options

c, err := client.NewClientWithEnv(opt.APIKey, opt.Environment, opt.Debug)
Expand Down
30 changes: 15 additions & 15 deletions cmd/purge/purge.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,37 +37,37 @@ export IBMCLOUD_API_KEY=<IBM_CLOUD_API_KEY>
Examples:
# Delete all the virtual machines which are created before 4hrs
pvsadm purge vms --instance-name upstream-core --before 4h
pvsadm purge vms --workspace-name upstream-core --before 4h
# Delete all the virtual machines created since 24hrs
pvsadm purge vms --instance-name upstream-core --since 24h
pvsadm purge vms --workspace-name upstream-core --since 24h
# Delete all the volumes which aren't assigned to any virtual machines
pvsadm purge volumes --instance-name upstream-core
pvsadm purge volumes --workspace-name upstream-core
# Delete all the networks and ignore if any errors during the delete operation
pvsadm purge networks --instance-name upstream-core --ignore-errors
pvsadm purge networks --workspace-name upstream-core --ignore-errors
# Delete all the networks along with the instances and their assigned ports
pvsadm purge networks --instance-name upstream-core --instances true --ports true
# Delete all the networks along with the instance and their assigned ports
pvsadm purge networks --workspace-name upstream-core --instances true --ports true
# Delete all the images without asking any confirmation
pvsadm purge images --instance-name upstream-core --no-prompt
pvsadm purge images --workspace-name upstream-core --no-prompt
# Delete all the images with debugging logs for IBM cloud APIs
pvsadm purge images --instance-name upstream-core --debug
pvsadm purge images --workspace-name upstream-core --debug
# Delete all the virtual machines starts with k8s-cluster-
pvsadm purge vms --instance-name upstream-core --regexp "^k8s-cluster-.*"
pvsadm purge vms --workspace-name upstream-core --regexp "^k8s-cluster-.*"
# List the purgeable candidate virtual machines and exit without deleting
pvsadm purge vms --instance-name upstream-core --dry-run
pvsadm purge vms --workspace-name upstream-core --dry-run
# Delete all the ssh keys which are created before 12hrs
pvsadm purge keys --instance-name upstream-core --before 12h --regexp "^rdr-.*"
pvsadm purge keys --workspace-name upstream-core --before 12h --regexp "^rdr-.*"
# Delete all the ssh keys starts with rdr-
pvsadm purge keys --instance-name upstream-core --regexp "^rdr-.*"
pvsadm purge keys --workspace-name upstream-core --regexp "^rdr-.*"
`,
GroupID: "resource",
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -85,7 +85,7 @@ Examples:
return fmt.Errorf("--since and --before options can not be set at a time")
}
if pkg.Options.InstanceID == "" && pkg.Options.InstanceName == "" {
return fmt.Errorf("--instance-id or --instance-name required")
return fmt.Errorf("--workspace-id or --workspace-name required")
}
return nil
},
Expand All @@ -97,8 +97,8 @@ func init() {
Cmd.AddCommand(networks.Cmd)
Cmd.AddCommand(volumes.Cmd)
Cmd.AddCommand(keys.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.InstanceID, "workspace-id", "i", "", "Workspace ID of the PowerVS workspace")
Cmd.PersistentFlags().StringVarP(&pkg.Options.InstanceName, "workspace-name", "n", "", "Workspace name of the PowerVS")
Cmd.PersistentFlags().BoolVar(&pkg.Options.DryRun, "dry-run", false, "dry run the action and don't delete the actual resources")
Cmd.PersistentFlags().DurationVar(&pkg.Options.Since, "since", 0*time.Second, "Remove resources since mentioned duration(format: 99h99m00s), mutually exclusive with --before")
Cmd.PersistentFlags().DurationVar(&pkg.Options.Before, "before", 0*time.Second, "Remove resources before mentioned duration(format: 99h99m00s), mutually exclusive with --since")
Expand Down
20 changes: 10 additions & 10 deletions docs/How to Import Image to PowerVS Instance.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Overview
This guide talks about how to import image to PowerVs instance using pvsadm.
This guide talks about how to import image to PowerVS workspace using pvsadm.

# Prerequisite
- pvsadm tool
- IBMCLOUD_API_KEY. [How to create api key](https://cloud.ibm.com/docs/account?topic=account-userapikey#create_user_key)
- S3 BucketName, Bucket Region, ObjectName
- PowerVS Instance Name/PowerVS Instance ID.
- PowerVS Workspace Name/PowerVS Workspace ID.

# Image import Command help
```shell
Expand All @@ -15,8 +15,8 @@ Flags:
-b, --bucket string Cloud Storage bucket name
-h, --help help for import
--image-name string Name to give imported image
-i, --instance-id string Instance ID of the PowerVS instance
-n, --instance-name string Instance name of the PowerVS
-i, --workspace-id string Workspace ID of the PowerVS workspace
-n, --workspace-name string Workspace name of the PowerVS
-o, --object-name string Cloud Storage image filename
-r, --region string COS bucket location
-p, --public-bucket Cloud Storage public bucket
Expand All @@ -26,7 +26,7 @@ Flags:

```

# Importing Image to PowerVS instance from S3 Bucket using pvsadm
# Importing Image to PowerVS workspace from S3 Bucket using pvsadm

Set the API key variable
```shell
Expand All @@ -36,29 +36,29 @@ $export IBMCLOUD_API_KEY=<IBM_CLOUD_API_KEY>
### case 1:
Importing the image using auto-generated s3 credential
```shell
$pvsadm image import -n <POWERVS_INSTANCE_NAME> -b <BUCKETNAME> --object rhel-83-10032020.ova.gz --pvs-image-name test-image -r <REGION>
$pvsadm image import -n <POWERVS_WORKSPACE_NAME> -b <BUCKETNAME> --object rhel-83-10032020.ova.gz --pvs-image-name test-image -r <REGION>
```

### case 2:
Importing the image using accesskey and secretkey
```shell
$pvsadm image import -n <POWERVS_INSTANCE_NAME> -b <BUCKETNAME> --accesskey <ACCESSKEY> --secretkey <SECRETKEY> --object rhel-83-10032020.ova.gz --pvs-image-name test-image -r <REGION>
$pvsadm image import -n <POWERVS_WORKSPACE_NAME> -b <BUCKETNAME> --accesskey <ACCESSKEY> --secretkey <SECRETKEY> --object rhel-83-10032020.ova.gz --pvs-image-name test-image -r <REGION>
```

### case 3:
If user wants to specify the PowerVS storage type for importing the image
```shell
$pvsadm image import -n <POWERVS_INSTANCE_NAME> -b <BUCKETNAME> --object rhel-83-10032020.ova.gz --pvs-image-name test-image -r <REGION> --storagetype <POWERVS_STORAGE_TYPE>
$pvsadm image import -n <POWERVS_WORKSPACE_NAME> -b <BUCKETNAME> --object rhel-83-10032020.ova.gz --pvs-image-name test-image -r <REGION> --storagetype <POWERVS_STORAGE_TYPE>
```

### case 4:
If user wants to specify type of OS
```shell
$pvsadm image import -n <POWERVS_INSTANCE_NAME> -b <BUCKETNAME> --object rhel-83-10032020.ova.gz --pvs-image-name test-image -r <REGION>
$pvsadm image import -n <POWERVS_WORKSPACE_NAME> -b <BUCKETNAME> --object rhel-83-10032020.ova.gz --pvs-image-name test-image -r <REGION>
```

### case 5:
Importing the image from public bucket
```shell
$pvsadm image import -n <POWERVS_INSTANCE_NAME> -b <BUCKETNAME> --object rhel-83-10032020.ova.gz --pvs-image-name test-image -r <REGION> --public-bucket
$pvsadm image import -n <POWERVS_WORKSPACE_NAME> -b <BUCKETNAME> --object rhel-83-10032020.ova.gz --pvs-image-name test-image -r <REGION> --public-bucket
```
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ require (
github.com/fsnotify/fsnotify v1.7.0
github.com/go-openapi/strfmt v0.23.0
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/golang/mock v1.6.0
github.com/klauspost/pgzip v1.2.6
github.com/manifoldco/promptui v0.9.0
github.com/olekukonko/tablewriter v0.0.5
Expand Down Expand Up @@ -86,7 +87,7 @@ require (
go.opentelemetry.io/otel/trace v1.17.0 // indirect
golang.org/x/crypto v0.19.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sync v0.4.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/term v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
Expand Down
Loading

0 comments on commit ac09413

Please sign in to comment.