Skip to content

Commit

Permalink
Wraps the ContainerView managed object. (#667)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmycanady authored and dougm committed Feb 21, 2017
1 parent 93064c0 commit 4994038
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
28 changes: 28 additions & 0 deletions view/container_view.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package view

import (
"context"

"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/vim25"
"github.com/vmware/govmomi/vim25/methods"
"github.com/vmware/govmomi/vim25/types"
)

type ContainerView struct {
object.Common
}

func NewContainerView(c *vim25.Client, ref types.ManagedObjectReference) *ContainerView {
return &ContainerView{
Common: object.NewCommon(c, ref),
}
}

func (v ContainerView) Destroy(ctx context.Context) error {
req := types.DestroyView{
This: v.Reference(),
}
_, err := methods.DestroyView(ctx, v.Client(), &req)
return err
}
17 changes: 17 additions & 0 deletions view/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,20 @@ func (m Manager) CreateListView(ctx context.Context, objects []types.ManagedObje

return NewListView(m.Client(), res.Returnval), nil
}

func (m Manager) CreateContainerView(ctx context.Context, container types.ManagedObjectReference, managedObjectTypes []string, recursive bool) (*ContainerView, error) {

req := types.CreateContainerView{
This: m.Common.Reference(),
Container: container,
Recursive: recursive,
Type: managedObjectTypes,
}

res, err := methods.CreateContainerView(ctx, m.Client(), &req)
if err != nil {
return nil, err
}

return NewContainerView(m.Client(), res.Returnval), nil
}

0 comments on commit 4994038

Please sign in to comment.