github.com/vmware/govmomi@v0.43.0/govc/vm/check/compat.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 check 18 19 import ( 20 "context" 21 "flag" 22 23 "github.com/vmware/govmomi/govc/cli" 24 ) 25 26 type compat struct { 27 checkFlag 28 } 29 30 func init() { 31 cli.Register("vm.check.compat", &compat{}, true) 32 } 33 34 func (cmd *compat) Description() string { 35 return `Check if VM can be placed on the given HOST in the given resource POOL. 36 37 Examples: 38 govc vm.check.compat -vm my-vm -host $host -pool $pool` 39 } 40 41 func (cmd *compat) Run(ctx context.Context, f *flag.FlagSet) error { 42 vm, err := cmd.VirtualMachine() 43 if err != nil { 44 return err 45 } 46 47 if vm == nil { 48 return flag.ErrHelp 49 } 50 51 checker, err := cmd.compatChecker() 52 if err != nil { 53 return err 54 } 55 56 res, err := checker.CheckCompatibility(ctx, vm.Reference(), cmd.Host, cmd.Pool, cmd.testTypes...) 57 if err != nil { 58 return err 59 } 60 61 return cmd.result(ctx, res) 62 }