github.com/vmware/govmomi@v0.43.0/object/vm_provisioning_checker.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 object 18 19 import ( 20 "context" 21 22 "github.com/vmware/govmomi/vim25" 23 "github.com/vmware/govmomi/vim25/methods" 24 "github.com/vmware/govmomi/vim25/types" 25 ) 26 27 // VmProvisioningChecker models the ProvisioningChecker, a singleton managed 28 // object that can answer questions about the feasibility of certain 29 // provisioning operations. 30 // 31 // For more information, see: 32 // https://dp-downloads.broadcom.com/api-content/apis/API_VWSA_001/8.0U3/html/ReferenceGuides/vim.vm.check.ProvisioningChecker.html 33 type VmProvisioningChecker struct { 34 Common 35 } 36 37 func NewVmProvisioningChecker(c *vim25.Client) *VmProvisioningChecker { 38 return &VmProvisioningChecker{ 39 Common: NewCommon(c, *c.ServiceContent.VmProvisioningChecker), 40 } 41 } 42 43 func (c VmProvisioningChecker) CheckRelocate( 44 ctx context.Context, 45 vm types.ManagedObjectReference, 46 spec types.VirtualMachineRelocateSpec, 47 testTypes ...types.CheckTestType) ([]types.CheckResult, error) { 48 49 req := types.CheckRelocate_Task{ 50 This: c.Reference(), 51 Vm: vm, 52 Spec: spec, 53 TestType: checkTestTypesToStrings(testTypes), 54 } 55 56 res, err := methods.CheckRelocate_Task(ctx, c.c, &req) 57 if err != nil { 58 return nil, err 59 } 60 61 ti, err := NewTask(c.c, res.Returnval).WaitForResult(ctx) 62 if err != nil { 63 return nil, err 64 } 65 66 return ti.Result.(types.ArrayOfCheckResult).CheckResult, nil 67 }