networks

package
v0.1.1-alpha.6 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:   "networks",
	Short: "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

		c, err := client.NewClientWithEnv(opt.APIKey, opt.Environment, opt.Debug)
		if err != nil {
			return err
		}

		pvmclient, err := client.NewPVMClientWithEnv(c, opt.InstanceID, opt.InstanceName, pkg.Options.Environment)
		if err != nil {
			return err
		}
		klog.Infof("Purging the networks for the instance: %v", pvmclient.InstanceID)

		networks, err := pvmclient.NetworkClient.GetAllPurgeable(opt.Before, opt.Since, opt.Expr)
		if err != nil {
			return fmt.Errorf("failed to get the list of networks: %v", err)
		}
		table := utils.NewTable()

		table.Render(networks, []string{"href"})
		if !opt.DryRun && len(networks) != 0 {
			if opt.NoPrompt || utils.AskYesOrNo(deletePromptMessage) {
				for _, network := range networks {
					klog.Infof("Deleting the %s, and ID: %s", *network.Name, *network.NetworkID)
					err = pvmclient.NetworkClient.Delete(*network.NetworkID)
					if err != nil {
						if opt.IgnoreErrors {
							klog.Infof("error occurred while deleting the network: %v", err)
						} else {
							return err
						}
					}
					audit.Log("networks", "delete", pvmclient.InstanceName+":"+*network.Name)
				}
			}
		}
		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