portgroup.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. "github.com/vmware/govmomi/vim25/methods"
  16. "github.com/vmware/govmomi/vim25/mo"
  17. "github.com/vmware/govmomi/vim25/soap"
  18. "github.com/vmware/govmomi/vim25/types"
  19. )
  20. type DistributedVirtualPortgroup struct {
  21. mo.DistributedVirtualPortgroup
  22. }
  23. func (s *DistributedVirtualPortgroup) ReconfigureDVPortgroupTask(req *types.ReconfigureDVPortgroup_Task) soap.HasFault {
  24. task := CreateTask(s, "reconfigureDvPortgroup", func(t *Task) (types.AnyType, types.BaseMethodFault) {
  25. s.Config.DefaultPortConfig = req.Spec.DefaultPortConfig
  26. s.Config.NumPorts = req.Spec.NumPorts
  27. s.Config.AutoExpand = req.Spec.AutoExpand
  28. s.Config.Type = req.Spec.Type
  29. s.Config.Description = req.Spec.Description
  30. s.Config.DynamicData = req.Spec.DynamicData
  31. s.Config.Name = req.Spec.Name
  32. s.Config.Policy = req.Spec.Policy
  33. s.Config.PortNameFormat = req.Spec.PortNameFormat
  34. s.Config.VmVnicNetworkResourcePoolKey = req.Spec.VmVnicNetworkResourcePoolKey
  35. return nil, nil
  36. })
  37. return &methods.ReconfigureDVPortgroup_TaskBody{
  38. Res: &types.ReconfigureDVPortgroup_TaskResponse{
  39. Returnval: task.Run(),
  40. },
  41. }
  42. }
  43. func (s *DistributedVirtualPortgroup) DestroyTask(req *types.Destroy_Task) soap.HasFault {
  44. task := CreateTask(s, "destroy", func(t *Task) (types.AnyType, types.BaseMethodFault) {
  45. vswitch := Map.Get(*s.Config.DistributedVirtualSwitch).(*DistributedVirtualSwitch)
  46. Map.RemoveReference(vswitch, &vswitch.Portgroup, s.Reference())
  47. Map.removeString(vswitch, &vswitch.Summary.PortgroupName, s.Name)
  48. f := Map.getEntityParent(vswitch, "Folder").(*Folder)
  49. f.removeChild(s.Reference())
  50. return nil, nil
  51. })
  52. return &methods.Destroy_TaskBody{
  53. Res: &types.Destroy_TaskResponse{
  54. Returnval: task.Run(),
  55. },
  56. }
  57. }