Skip to content

Commit

Permalink
Add ResourcePool.resourceConfigSpecDetailed to missingSet filter
Browse files Browse the repository at this point in the history
New property (resourceConfigSpecDetailed) is only valid when collected against vCenter.
Against ESX is NotSupported and returned by RetrievePropertiesEx in the missingSet
when all properties are requested, which by default is propagated as an error.

Signed-off-by: Doug MacEachern <[email protected]>
  • Loading branch information
dougm committed Jan 27, 2025
1 parent a6f1508 commit ca8c642
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 15 deletions.
23 changes: 8 additions & 15 deletions vim25/mo/retrieve.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
/*
Copyright (c) 2014-2024 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// © Broadcom. All Rights Reserved.
// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
// SPDX-License-Identifier: Apache-2.0

package mo

Expand All @@ -36,6 +24,11 @@ func ignoreMissingProperty(ref types.ManagedObjectReference, p types.MissingProp
// Seen with vApp child VM
return true
}
case "ResourcePool":
switch p.Path {
case "resourceConfigSpecDetailed":
return true
}
}

return false
Expand Down
36 changes: 36 additions & 0 deletions vim25/mo/retrieve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,39 @@ func TestDatastoreInfoURL(t *testing.T) {
t.Errorf("info.name=%s", info.Name)
}
}

func TestIgnoreMissingProperty(t *testing.T) {
// subset of RetrievePropertiesEx response, see ignoreMissingProperty()
content := []types.ObjectContent{{
Obj: types.ManagedObjectReference{Type: "ResourcePool", Value: "ha-root-pool"},
PropSet: []types.DynamicProperty{{
Name: "config",
Val: types.ResourceConfigSpec{
CpuAllocation: types.ResourceAllocationInfo{
Reservation: types.NewInt64(5585),
Limit: types.NewInt64(5585),
},
MemoryAllocation: types.ResourceAllocationInfo{
Reservation: types.NewInt64(13652),
Limit: types.NewInt64(13652),
},
},
}},
MissingSet: []types.MissingProperty{
{
Path: "resourceConfigSpecDetailed",
Fault: types.LocalizedMethodFault{
Fault: &types.SystemError{
Reason: "unexpected error reading property",
},
},
},
},
}}

var pool ResourcePool

if err := LoadObjectContent(content, &pool); err != nil {
t.Fatal(err)
}
}

0 comments on commit ca8c642

Please sign in to comment.