service_content.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. Copyright (c) 2015 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 methods
  14. import (
  15. "context"
  16. "time"
  17. "github.com/vmware/govmomi/vim25/soap"
  18. "github.com/vmware/govmomi/vim25/types"
  19. )
  20. // copy of vim25.ServiceInstance to avoid import cycle
  21. var serviceInstance = types.ManagedObjectReference{
  22. Type: "ServiceInstance",
  23. Value: "ServiceInstance",
  24. }
  25. func GetServiceContent(ctx context.Context, r soap.RoundTripper) (types.ServiceContent, error) {
  26. req := types.RetrieveServiceContent{
  27. This: serviceInstance,
  28. }
  29. res, err := RetrieveServiceContent(ctx, r, &req)
  30. if err != nil {
  31. return types.ServiceContent{}, err
  32. }
  33. return res.Returnval, nil
  34. }
  35. func GetCurrentTime(ctx context.Context, r soap.RoundTripper) (*time.Time, error) {
  36. req := types.CurrentTime{
  37. This: serviceInstance,
  38. }
  39. res, err := CurrentTime(ctx, r, &req)
  40. if err != nil {
  41. return nil, err
  42. }
  43. return &res.Returnval, nil
  44. }