github.com/vmware/govmomi@v0.51.0/cli/host/vswitch/remove.go (about)

     1  // © Broadcom. All Rights Reserved.
     2  // The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
     3  // SPDX-License-Identifier: Apache-2.0
     4  
     5  package vswitch
     6  
     7  import (
     8  	"context"
     9  	"flag"
    10  
    11  	"github.com/vmware/govmomi/cli"
    12  	"github.com/vmware/govmomi/cli/flags"
    13  )
    14  
    15  type remove struct {
    16  	*flags.HostSystemFlag
    17  }
    18  
    19  func init() {
    20  	cli.Register("host.vswitch.remove", &remove{})
    21  }
    22  
    23  func (cmd *remove) Register(ctx context.Context, f *flag.FlagSet) {
    24  	cmd.HostSystemFlag, ctx = flags.NewHostSystemFlag(ctx)
    25  	cmd.HostSystemFlag.Register(ctx, f)
    26  }
    27  
    28  func (cmd *remove) Process(ctx context.Context) error {
    29  	if err := cmd.HostSystemFlag.Process(ctx); err != nil {
    30  		return err
    31  	}
    32  	return nil
    33  }
    34  
    35  func (cmd *remove) Usage() string {
    36  	return "NAME"
    37  }
    38  
    39  func (cmd *remove) Run(ctx context.Context, f *flag.FlagSet) error {
    40  	ns, err := cmd.HostNetworkSystem()
    41  	if err != nil {
    42  		return err
    43  	}
    44  
    45  	return ns.RemoveVirtualSwitch(ctx, f.Arg(0))
    46  }