github.com/vmware/govmomi@v0.43.0/govc/cluster/draft/baseimage/set.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 draft 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 set struct { 29 *flags.ClientFlag 30 31 clusterId string 32 draftId string 33 version string 34 } 35 36 func init() { 37 cli.Register("cluster.draft.baseimage.set", &set{}) 38 } 39 40 func (cmd *set) Register(ctx context.Context, f *flag.FlagSet) { 41 cmd.ClientFlag, ctx = flags.NewClientFlag(ctx) 42 cmd.ClientFlag.Register(ctx, f) 43 44 f.StringVar(&cmd.clusterId, "cluster-id", "", "The identifier of the cluster.") 45 f.StringVar(&cmd.draftId, "draft-id", "", "The identifier of the software draft.") 46 f.StringVar(&cmd.version, "version", "", "The identifier of the ESXi image version.") 47 } 48 49 func (cmd *set) Process(ctx context.Context) error { 50 return cmd.ClientFlag.Process(ctx) 51 } 52 53 func (cmd *set) Usage() string { 54 return "CLUSTER" 55 } 56 57 func (cmd *set) Description() string { 58 return `Sets the ESXi base image on the software draft. 59 60 Examples: 61 govc cluster.draft.baseimage.set -cluster-id=domain-c21 -draft-id=31` 62 } 63 64 func (cmd *set) Run(ctx context.Context, f *flag.FlagSet) error { 65 rc, err := cmd.RestClient() 66 67 if err != nil { 68 return err 69 } 70 71 dm := clusters.NewManager(rc) 72 73 return dm.SetSoftwareDraftBaseImage(cmd.clusterId, cmd.draftId, cmd.version) 74 }