datastore.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. Copyright (c) 2017 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 simulator
  14. import (
  15. "time"
  16. "github.com/vmware/govmomi/object"
  17. "github.com/vmware/govmomi/vim25/methods"
  18. "github.com/vmware/govmomi/vim25/mo"
  19. "github.com/vmware/govmomi/vim25/soap"
  20. "github.com/vmware/govmomi/vim25/types"
  21. )
  22. type Datastore struct {
  23. mo.Datastore
  24. }
  25. func parseDatastorePath(dsPath string) (*object.DatastorePath, types.BaseMethodFault) {
  26. var p object.DatastorePath
  27. if p.FromString(dsPath) {
  28. return &p, nil
  29. }
  30. return nil, &types.InvalidDatastorePath{DatastorePath: dsPath}
  31. }
  32. func (ds *Datastore) RefreshDatastore(*types.RefreshDatastore) soap.HasFault {
  33. r := &methods.RefreshDatastoreBody{}
  34. err := ds.stat()
  35. if err != nil {
  36. r.Fault_ = Fault(err.Error(), &types.HostConfigFault{})
  37. return r
  38. }
  39. info := ds.Info.GetDatastoreInfo()
  40. now := time.Now()
  41. info.Timestamp = &now
  42. return r
  43. }