github.com/vmware/govmomi@v0.51.0/cli/vcsa/shutdown/cancel.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 shutdown 6 7 import ( 8 "context" 9 "flag" 10 11 "github.com/vmware/govmomi/cli" 12 "github.com/vmware/govmomi/cli/flags" 13 "github.com/vmware/govmomi/vapi/appliance/shutdown" 14 ) 15 16 type cancel struct { 17 *flags.ClientFlag 18 } 19 20 func init() { 21 cli.Register("vcsa.shutdown.cancel", &cancel{}) 22 } 23 24 func (cmd *cancel) Register(ctx context.Context, f *flag.FlagSet) { 25 cmd.ClientFlag, ctx = flags.NewClientFlag(ctx) 26 cmd.ClientFlag.Register(ctx, f) 27 } 28 29 func (cmd *cancel) Description() string { 30 return `Cancel pending shutdown action. 31 32 Note: This command requires vCenter 7.0.2 or higher. 33 34 Examples: 35 govc vcsa.shutdown.cancel` 36 } 37 38 func (cmd *cancel) Run(ctx context.Context, f *flag.FlagSet) error { 39 c, err := cmd.RestClient() 40 if err != nil { 41 return err 42 } 43 44 m := shutdown.NewManager(c) 45 46 if err = m.Cancel(ctx); err != nil { 47 return err 48 } 49 50 return nil 51 }