environment_browser.go 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. Copyright (c) 2023-2023 VMware, Inc. All Rights Reserved.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package object
  14. import (
  15. "context"
  16. "github.com/vmware/govmomi/vim25"
  17. "github.com/vmware/govmomi/vim25/methods"
  18. "github.com/vmware/govmomi/vim25/types"
  19. )
  20. type EnvironmentBrowser struct {
  21. Common
  22. }
  23. func NewEnvironmentBrowser(c *vim25.Client, ref types.ManagedObjectReference) *EnvironmentBrowser {
  24. return &EnvironmentBrowser{
  25. Common: NewCommon(c, ref),
  26. }
  27. }
  28. func (b EnvironmentBrowser) QueryConfigTarget(ctx context.Context, host *HostSystem) (*types.ConfigTarget, error) {
  29. req := types.QueryConfigTarget{
  30. This: b.Reference(),
  31. }
  32. if host != nil {
  33. ref := host.Reference()
  34. req.Host = &ref
  35. }
  36. res, err := methods.QueryConfigTarget(ctx, b.Client(), &req)
  37. if err != nil {
  38. return nil, err
  39. }
  40. return res.Returnval, nil
  41. }
  42. func (b EnvironmentBrowser) QueryTargetCapabilities(ctx context.Context, host *HostSystem) (*types.HostCapability, error) {
  43. req := types.QueryTargetCapabilities{
  44. This: b.Reference(),
  45. }
  46. if host != nil {
  47. ref := host.Reference()
  48. req.Host = &ref
  49. }
  50. res, err := methods.QueryTargetCapabilities(ctx, b.Client(), &req)
  51. if err != nil {
  52. return nil, err
  53. }
  54. return res.Returnval, nil
  55. }
  56. func (b EnvironmentBrowser) QueryConfigOption(ctx context.Context, spec *types.EnvironmentBrowserConfigOptionQuerySpec) (*types.VirtualMachineConfigOption, error) {
  57. req := types.QueryConfigOptionEx{
  58. This: b.Reference(),
  59. Spec: spec,
  60. }
  61. res, err := methods.QueryConfigOptionEx(ctx, b.Client(), &req)
  62. if err != nil {
  63. return nil, err
  64. }
  65. return res.Returnval, nil
  66. }
  67. func (b EnvironmentBrowser) QueryConfigOptionDescriptor(ctx context.Context) ([]types.VirtualMachineConfigOptionDescriptor, error) {
  68. req := types.QueryConfigOptionDescriptor{
  69. This: b.Reference(),
  70. }
  71. res, err := methods.QueryConfigOptionDescriptor(ctx, b.Client(), &req)
  72. if err != nil {
  73. return nil, err
  74. }
  75. return res.Returnval, nil
  76. }