From b35c8c598b94d4fef2d4bb294504dec527394c0f Mon Sep 17 00:00:00 2001 From: Manjunath A Kumatagi Date: Mon, 12 Oct 2020 17:51:33 +0530 Subject: [PATCH] Update usage --- cmd/purge/images/images.go | 4 +++- cmd/purge/networks/networks.go | 4 +++- cmd/purge/purge.go | 31 ++++++++++++++++++++++++++++++- cmd/purge/vms/vms.go | 4 +++- cmd/purge/volumes/volumes.go | 4 +++- 5 files changed, 42 insertions(+), 5 deletions(-) diff --git a/cmd/purge/images/images.go b/cmd/purge/images/images.go index c8cd9471..c5a4dcfd 100644 --- a/cmd/purge/images/images.go +++ b/cmd/purge/images/images.go @@ -15,7 +15,9 @@ const deletePromptMessage = "Deleting all the above images, images can't be clai var Cmd = &cobra.Command{ Use: "images", Short: "Purge the powervs images", - Long: `Purge the powervs images!`, + Long: `Purge the powervs images! +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) opt := pkg.Options diff --git a/cmd/purge/networks/networks.go b/cmd/purge/networks/networks.go index 283990c1..db953517 100644 --- a/cmd/purge/networks/networks.go +++ b/cmd/purge/networks/networks.go @@ -15,7 +15,9 @@ const deletePromptMessage = "Deleting all the above networks, networks can't be var Cmd = &cobra.Command{ Use: "networks", Short: "Purge the powervs networks", - Long: `Purge the powervs networks!`, + Long: `Purge the powervs networks! +pvsadm purge --help for information +`, RunE: func(cmd *cobra.Command, args []string) error { opt := pkg.Options diff --git a/cmd/purge/purge.go b/cmd/purge/purge.go index abd14baa..56ab9c0f 100644 --- a/cmd/purge/purge.go +++ b/cmd/purge/purge.go @@ -14,7 +14,36 @@ import ( var Cmd = &cobra.Command{ Use: "purge", Short: "Purge the powervs resources", - Long: `Purge the powervs resources`, + Long: `Purge the powervs resources + +# Set the API key or feed the --api-key commandline argument +export IBMCLOUD_API_KEY= + +Examples: + # Delete all the virtual machines which are created before 4hrs + pvsadm purge vms --instance-name upstream-core --before 4h + + # Delete all the virtual machines created since 24hrs + pvsadm purge vms --instance-name upstream-core --since 24h + + # Delete all the volumes which aren't assigned to any virtual machines + pvsadm purge volumes --instance-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 + + # Delete all the images without asking any confirmation + pvsadm purge images --instance-name upstream-core --no-prompt + + # Delete all the images with debugging logs for IBM cloud APIs + pvsadm purge images --instance-name upstream-core --debug + + # Delete all the virtual machines starts with k8s-cluster- + pvsadm purge vms --instance-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 +`, PersistentPreRunE: func(cmd *cobra.Command, args []string) error { if pkg.Options.Since != 0 && pkg.Options.Before != 0 { return fmt.Errorf("--since and --before options can not be set at a time") diff --git a/cmd/purge/vms/vms.go b/cmd/purge/vms/vms.go index 735cd486..275a6eae 100644 --- a/cmd/purge/vms/vms.go +++ b/cmd/purge/vms/vms.go @@ -20,7 +20,9 @@ const deletePromptMessage = "Deleting all the above instances, instances can't b var Cmd = &cobra.Command{ Use: "vms", Short: "Purge the powervs vms", - Long: `Purge the powervs vms!`, + Long: `Purge the powervs vms! +pvsadm purge --help for information +`, RunE: func(cmd *cobra.Command, args []string) error { opt := pkg.Options diff --git a/cmd/purge/volumes/volumes.go b/cmd/purge/volumes/volumes.go index 20f43a08..5c84cfb3 100644 --- a/cmd/purge/volumes/volumes.go +++ b/cmd/purge/volumes/volumes.go @@ -18,7 +18,9 @@ const deletePromptMessage = "Deleting all the volumes in available state, volume var Cmd = &cobra.Command{ Use: "volumes", Short: "Purge the powervs volumes", - Long: `Deletes all the volumes for the powervs instance which are in available state(not attached to any instances)`, + Long: `Deletes all the volumes for the powervs instance which are in available state(not attached to any instances) +pvsadm purge --help for information +`, RunE: func(cmd *cobra.Command, args []string) error { opt := pkg.Options