github.com/vmware/govmomi@v0.43.0/govc/cluster/draft/component/rm.go (about) 1 /* 2 Copyright (c) 2024-2024 VMware, Inc. All Rights Reserved. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package component 18 19 import ( 20 "context" 21 "flag" 22 23 "github.com/vmware/govmomi/govc/cli" 24 "github.com/vmware/govmomi/govc/flags" 25 "github.com/vmware/govmomi/vapi/esx/settings/clusters" 26 ) 27 28 type rm struct { 29 *flags.ClientFlag 30 *flags.OutputFlag 31 32 clusterId string 33 draftId string 34 componentId string 35 } 36 37 func init() { 38 cli.Register("cluster.draft.component.rm", &rm{}) 39 } 40 41 func (cmd *rm) Register(ctx context.Context, f *flag.FlagSet) { 42 cmd.ClientFlag, ctx = flags.NewClientFlag(ctx) 43 cmd.ClientFlag.Register(ctx, f) 44 cmd.OutputFlag, ctx = flags.NewOutputFlag(ctx) 45 46 f.StringVar(&cmd.clusterId, "cluster-id", "", "The identifier of the cluster.") 47 f.StringVar(&cmd.draftId, "draft-id", "", "The identifier of the software draft.") 48 f.StringVar(&cmd.componentId, "component-id", "", "The identifier of the software component.") 49 } 50 51 func (cmd *rm) Process(ctx context.Context) error { 52 return cmd.ClientFlag.Process(ctx) 53 } 54 55 func (cmd *rm) Usage() string { 56 return "CLUSTER" 57 } 58 59 func (cmd *rm) Description() string { 60 return `Removes a component from a software draft. 61 62 Examples: 63 govc cluster.draft.component.rm -cluster-id=domain-c21 -draft-id=13 -component-id=NVD-AIE-800` 64 } 65 66 func (cmd *rm) Run(ctx context.Context, f *flag.FlagSet) error { 67 rc, err := cmd.RestClient() 68 69 if err != nil { 70 return err 71 } 72 73 dm := clusters.NewManager(rc) 74 75 return dm.RemoveSoftwareDraftComponents(cmd.clusterId, cmd.draftId, cmd.componentId) 76 }