Skip to content

Commit

Permalink
Merge pull request #163 from bkhadars/master
Browse files Browse the repository at this point in the history
Remove --ostype from import sub-command
  • Loading branch information
Power Cloud Robot authored Aug 26, 2021
2 parents 277147c + 9b28933 commit 88267fb
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 14 deletions.
11 changes: 2 additions & 9 deletions cmd/image/import/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pvsadm image import -n upstream-core-lon04 -b <BUCKETNAME> --accesskey <ACCESSKE
pvsadm image import -n upstream-core-lon04 -b <BUCKETNAME> --pvs-storagetype <STORAGETYPE> --object rhel-83-10032020.ova.gz --pvs-image-name test-image -r <REGION>
# If user wants to specify the type of OS
pvsadm image import -n upstream-core-lon04 -b <BUCKETNAME> --object rhel-83-10032020.ova.gz --pvs-image-name test-image --ostype <OSTYPE> -r <REGION>
pvsadm image import -n upstream-core-lon04 -b <BUCKETNAME> --object rhel-83-10032020.ova.gz --pvs-image-name test-image -r <REGION>
`,
PreRunE: func(cmd *cobra.Command, args []string) error {
if pkg.ImageCMDOptions.InstanceID == "" && pkg.ImageCMDOptions.InstanceName == "" {
Expand All @@ -72,14 +72,8 @@ pvsadm image import -n upstream-core-lon04 -b <BUCKETNAME> --object rhel-83-1003
opt := pkg.ImageCMDOptions
apikey := pkg.Options.APIKey
//validate inputs
validOsType := []string{"aix", "ibmi", "redhat", "sles"}
validStorageType := []string{"tier3", "tier1"}

if opt.OsType != "" && !utils.Contains(validOsType, strings.ToLower(opt.OsType)) {
klog.Errorf("Provide valid OsType.. allowable values are [aix, ibmi, redhat, sles]")
os.Exit(1)
}

if !utils.Contains(validStorageType, strings.ToLower(opt.StorageType)) {
klog.Errorf("Provide valid StorageType.. allowable values are [tier1, tier3]")
os.Exit(1)
Expand Down Expand Up @@ -189,7 +183,7 @@ pvsadm image import -n upstream-core-lon04 -b <BUCKETNAME> --object rhel-83-1003
}

image, err := pvmclient.ImgClient.ImportImage(pvmclient.InstanceID, opt.ImageName, opt.ImageFilename, opt.Region,
opt.AccessKey, opt.SecretKey, opt.BucketName, strings.ToLower(opt.OsType), strings.ToLower(opt.StorageType))
opt.AccessKey, opt.SecretKey, opt.BucketName, strings.ToLower(opt.StorageType))
if err != nil {
return err
}
Expand Down Expand Up @@ -235,7 +229,6 @@ func init() {
Cmd.Flags().StringVar(&pkg.ImageCMDOptions.AccessKey, "accesskey", "", "Cloud Object Storage HMAC access key.")
Cmd.Flags().StringVar(&pkg.ImageCMDOptions.SecretKey, "secretkey", "", "Cloud Object Storage HMAC secret key.")
Cmd.Flags().StringVar(&pkg.ImageCMDOptions.ImageName, "pvs-image-name", "", "Name to PowerVS imported image.")
Cmd.Flags().StringVar(&pkg.ImageCMDOptions.OsType, "ostype", "redhat", "Image OS Type, accepted values are[aix, ibmi, redhat, sles].")
Cmd.Flags().BoolVarP(&pkg.ImageCMDOptions.Watch, "watch", "w", false, "After image import watch for image to be published and ready to use")
Cmd.Flags().DurationVar(&pkg.ImageCMDOptions.WatchTimeout, "watch-timeout", 1*time.Hour, "watch timeout")
Cmd.Flags().StringVar(&pkg.ImageCMDOptions.StorageType, "pvs-storagetype", "tier3", "PowerVS Storage type, accepted values are [tier1, tier3].")
Expand Down
3 changes: 1 addition & 2 deletions docs/How to Import Image to PowerVS Instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Flags:
-i, --instance-id string Instance ID of the PowerVS instance
-n, --instance-name string Instance name of the PowerVS
-o, --object-name string Cloud Storage image filename
--ostype string Image OS Type, accepted values are[aix, ibmi, redhat, sles] (default "redhat")
-r, --region string COS bucket location
--secretkey string Cloud Storage secret key
--service-credential-name string Service Credential name to be auto generated (default "pvsadm-service-cred")
Expand Down Expand Up @@ -53,5 +52,5 @@ $pvsadm image import -n <POWERVS_INSTANCE_NAME> -b <BUCKETNAME> --object rhel-83
### 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> --ostype <OSTYPE>
$pvsadm image import -n <POWERVS_INSTANCE_NAME> -b <BUCKETNAME> --object rhel-83-10032020.ova.gz --pvs-image-name test-image -r <REGION>
```
3 changes: 1 addition & 2 deletions pkg/client/image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (c *Client) Delete(id string) error {
}

//func ImportImage imports image from S3 Instance
func (c *Client) ImportImage(instanceID, imageName, s3Filename, region, accessKey, secretKey, bucketName, osType, storageType string) (*models.Image, error) {
func (c *Client) ImportImage(instanceID, imageName, s3Filename, region, accessKey, secretKey, bucketName, storageType string) (*models.Image, error) {
var source = "url"
var body = models.CreateImage{
ImageName: imageName,
Expand All @@ -65,7 +65,6 @@ func (c *Client) ImportImage(instanceID, imageName, s3Filename, region, accessKe
AccessKey: accessKey,
SecretKey: secretKey,
BucketName: bucketName,
OsType: osType,
DiskType: storageType,
Source: &source,
}
Expand Down
1 change: 0 additions & 1 deletion pkg/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ type imageCMDOptions struct {
ImageFilename string
AccessKey string
SecretKey string
OsType string
StorageType string
InstanceID string
ServiceCredName string
Expand Down

0 comments on commit 88267fb

Please sign in to comment.