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.
20
"github.com/juju/govmomi/vim25"
21
"github.com/juju/govmomi/vim25/methods"
22
"github.com/juju/govmomi/vim25/types"
23
"golang.org/x/net/context"
26
type ResourcePool struct {
32
func NewResourcePool(c *vim25.Client, ref types.ManagedObjectReference) *ResourcePool {
34
Common: NewCommon(c, ref),
38
func (p ResourcePool) ImportVApp(ctx context.Context, spec types.BaseImportSpec, folder *Folder, host *HostSystem) (*HttpNfcLease, error) {
39
req := types.ImportVApp{
45
ref := folder.Reference()
50
ref := host.Reference()
54
res, err := methods.ImportVApp(ctx, p.c, &req)
59
return NewHttpNfcLease(p.c, res.Returnval), nil
62
func (p ResourcePool) Create(ctx context.Context, name string, spec types.ResourceConfigSpec) (*ResourcePool, error) {
63
req := types.CreateResourcePool{
69
res, err := methods.CreateResourcePool(ctx, p.c, &req)
74
return NewResourcePool(p.c, res.Returnval), nil
77
func (p ResourcePool) UpdateConfig(ctx context.Context, name string, config *types.ResourceConfigSpec) error {
78
req := types.UpdateConfig{
84
if config != nil && config.Entity == nil {
87
// Create copy of config so changes won't leak back to the caller
89
newConfig.Entity = &ref
90
req.Config = &newConfig
93
_, err := methods.UpdateConfig(ctx, p.c, &req)
97
func (p ResourcePool) DestroyChildren(ctx context.Context) error {
98
req := types.DestroyChildren{
102
_, err := methods.DestroyChildren(ctx, p.c, &req)
106
func (p ResourcePool) Destroy(ctx context.Context) (*Task, error) {
107
req := types.Destroy_Task{
111
res, err := methods.Destroy_Task(ctx, p.c, &req)
116
return NewTask(p.c, res.Returnval), nil