2
Copyright (c) 2014 VMware, Inc. All Rights Reserved.
4
Licensed under the Apache License, Version 2.0 (the "License");
5
you may not use this file except in compliance with the License.
6
You may obtain a copy of the License at
8
http://www.apache.org/licenses/LICENSE-2.0
10
Unless required by applicable law or agreed to in writing, software
11
distributed under the License is distributed on an "AS IS" BASIS,
12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
See the License for the specific language governing permissions and
14
limitations under the License.
22
"github.com/juju/govmomi/vim25"
23
"github.com/juju/govmomi/vim25/mo"
24
"github.com/juju/govmomi/vim25/types"
25
"golang.org/x/net/context"
28
type DistributedVirtualPortgroup struct {
34
func NewDistributedVirtualPortgroup(c *vim25.Client, ref types.ManagedObjectReference) *DistributedVirtualPortgroup {
35
return &DistributedVirtualPortgroup{
36
Common: NewCommon(c, ref),
39
func (p DistributedVirtualPortgroup) Name() string {
40
return path.Base(p.InventoryPath)
43
// EthernetCardBackingInfo returns the VirtualDeviceBackingInfo for this DistributedVirtualPortgroup
44
func (p DistributedVirtualPortgroup) EthernetCardBackingInfo(ctx context.Context) (types.BaseVirtualDeviceBackingInfo, error) {
45
var dvp mo.DistributedVirtualPortgroup
46
var dvs mo.VmwareDistributedVirtualSwitch // TODO: should be mo.BaseDistributedVirtualSwitch
48
if err := p.Properties(ctx, p.Reference(), []string{"key", "config.distributedVirtualSwitch"}, &dvp); err != nil {
52
if err := p.Properties(ctx, *dvp.Config.DistributedVirtualSwitch, []string{"uuid"}, &dvs); err != nil {
56
backing := &types.VirtualEthernetCardDistributedVirtualPortBackingInfo{
57
Port: types.DistributedVirtualSwitchPortConnection{
58
PortgroupKey: dvp.Key,