1
0
mirror of https://github.com/Oxalide/vsphere-influxdb-go.git synced 2023-10-10 11:36:51 +00:00

add vendoring with go dep

This commit is contained in:
Adrian Todorov
2017-10-25 20:52:40 +00:00
parent 704f4d20d1
commit a59409f16b
1627 changed files with 489673 additions and 0 deletions

217
vendor/github.com/vmware/govmomi/pbm/client.go generated vendored Normal file
View File

@@ -0,0 +1,217 @@
/*
Copyright (c) 2017 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package pbm
import (
"context"
"fmt"
"github.com/vmware/govmomi/pbm/methods"
"github.com/vmware/govmomi/pbm/types"
"github.com/vmware/govmomi/vim25"
"github.com/vmware/govmomi/vim25/soap"
vim "github.com/vmware/govmomi/vim25/types"
)
type Client struct {
*soap.Client
ServiceContent types.PbmServiceInstanceContent
}
func NewClient(ctx context.Context, c *vim25.Client) (*Client, error) {
sc := c.Client.NewServiceClient("/pbm/sdk", "urn:pbm")
req := types.PbmRetrieveServiceContent{
This: vim.ManagedObjectReference{
Type: "PbmServiceInstance",
Value: "ServiceInstance",
},
}
res, err := methods.PbmRetrieveServiceContent(ctx, sc, &req)
if err != nil {
return nil, err
}
return &Client{sc, res.Returnval}, nil
}
func (c *Client) QueryProfile(ctx context.Context, rtype types.PbmProfileResourceType, category string) ([]types.PbmProfileId, error) {
req := types.PbmQueryProfile{
This: c.ServiceContent.ProfileManager,
ResourceType: rtype,
ProfileCategory: category,
}
res, err := methods.PbmQueryProfile(ctx, c, &req)
if err != nil {
return nil, err
}
return res.Returnval, nil
}
func (c *Client) RetrieveContent(ctx context.Context, ids []types.PbmProfileId) ([]types.BasePbmProfile, error) {
req := types.PbmRetrieveContent{
This: c.ServiceContent.ProfileManager,
ProfileIds: ids,
}
res, err := methods.PbmRetrieveContent(ctx, c, &req)
if err != nil {
return nil, err
}
return res.Returnval, nil
}
type PlacementCompatibilityResult []types.PbmPlacementCompatibilityResult
func (c *Client) CheckRequirements(ctx context.Context, hubs []types.PbmPlacementHub, ref *types.PbmServerObjectRef, preq []types.BasePbmPlacementRequirement) (PlacementCompatibilityResult, error) {
req := types.PbmCheckRequirements{
This: c.ServiceContent.PlacementSolver,
HubsToSearch: hubs,
PlacementSubjectRef: ref,
PlacementSubjectRequirement: preq,
}
res, err := methods.PbmCheckRequirements(ctx, c, &req)
if err != nil {
return nil, err
}
return res.Returnval, nil
}
func (l PlacementCompatibilityResult) CompatibleDatastores() []types.PbmPlacementHub {
var compatibleDatastores []types.PbmPlacementHub
for _, res := range l {
if len(res.Error) == 0 {
compatibleDatastores = append(compatibleDatastores, res.Hub)
}
}
return compatibleDatastores
}
func (l PlacementCompatibilityResult) NonCompatibleDatastores() []types.PbmPlacementHub {
var nonCompatibleDatastores []types.PbmPlacementHub
for _, res := range l {
if len(res.Error) > 0 {
nonCompatibleDatastores = append(nonCompatibleDatastores, res.Hub)
}
}
return nonCompatibleDatastores
}
func (c *Client) CreateProfile(ctx context.Context, capabilityProfileCreateSpec types.PbmCapabilityProfileCreateSpec) (*types.PbmProfileId, error) {
req := types.PbmCreate{
This: c.ServiceContent.ProfileManager,
CreateSpec: capabilityProfileCreateSpec,
}
res, err := methods.PbmCreate(ctx, c, &req)
if err != nil {
return nil, err
}
return &res.Returnval, nil
}
func (c *Client) UpdateProfile(ctx context.Context, id types.PbmProfileId, updateSpec types.PbmCapabilityProfileUpdateSpec) error {
req := types.PbmUpdate{
This: c.ServiceContent.ProfileManager,
ProfileId: id,
UpdateSpec: updateSpec,
}
_, err := methods.PbmUpdate(ctx, c, &req)
if err != nil {
return err
}
return nil
}
func (c *Client) DeleteProfile(ctx context.Context, ids []types.PbmProfileId) ([]types.PbmProfileOperationOutcome, error) {
req := types.PbmDelete{
This: c.ServiceContent.ProfileManager,
ProfileId: ids,
}
res, err := methods.PbmDelete(ctx, c, &req)
if err != nil {
return nil, err
}
return res.Returnval, nil
}
func (c *Client) QueryAssociatedEntity(ctx context.Context, id types.PbmProfileId, entityType string) ([]types.PbmServerObjectRef, error) {
req := types.PbmQueryAssociatedEntity{
This: c.ServiceContent.ProfileManager,
Profile: id,
EntityType: entityType,
}
res, err := methods.PbmQueryAssociatedEntity(ctx, c, &req)
if err != nil {
return nil, err
}
return res.Returnval, nil
}
func (c *Client) QueryAssociatedEntities(ctx context.Context, ids []types.PbmProfileId) ([]types.PbmQueryProfileResult, error) {
req := types.PbmQueryAssociatedEntities{
This: c.ServiceContent.ProfileManager,
Profiles: ids,
}
res, err := methods.PbmQueryAssociatedEntities(ctx, c, &req)
if err != nil {
return nil, err
}
return res.Returnval, nil
}
func (c *Client) ProfileIDByName(ctx context.Context, profileName string) (string, error) {
resourceType := types.PbmProfileResourceType{
ResourceType: string(types.PbmProfileResourceTypeEnumSTORAGE),
}
category := types.PbmProfileCategoryEnumREQUIREMENT
ids, err := c.QueryProfile(ctx, resourceType, string(category))
if err != nil {
return "", err
}
profiles, err := c.RetrieveContent(ctx, ids)
if err != nil {
return "", err
}
for i := range profiles {
profile := profiles[i].GetPbmProfile()
if profile.Name == profileName {
return profile.ProfileId.UniqueId, nil
}
}
return "", fmt.Errorf("no pbm profile found with name: %q", profileName)
}

301
vendor/github.com/vmware/govmomi/pbm/client_test.go generated vendored Normal file
View File

@@ -0,0 +1,301 @@
/*
Copyright (c) 2017 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package pbm
import (
"context"
"os"
"reflect"
"sort"
"testing"
"github.com/vmware/govmomi"
"github.com/vmware/govmomi/pbm/types"
"github.com/vmware/govmomi/property"
"github.com/vmware/govmomi/view"
"github.com/vmware/govmomi/vim25/mo"
"github.com/vmware/govmomi/vim25/soap"
vim "github.com/vmware/govmomi/vim25/types"
)
func TestClient(t *testing.T) {
url := os.Getenv("GOVMOMI_PBM_URL")
if url == "" {
t.SkipNow()
}
clusterName := os.Getenv("GOVMOMI_PBM_CLUSTER")
u, err := soap.ParseURL(url)
if err != nil {
t.Fatal(err)
}
ctx := context.Background()
c, err := govmomi.NewClient(ctx, u, true)
if err != nil {
t.Fatal(err)
}
pc, err := NewClient(ctx, c.Client)
if err != nil {
t.Fatal(err)
}
t.Logf("PBM version=%s", pc.ServiceContent.AboutInfo.Version)
rtype := types.PbmProfileResourceType{
ResourceType: string(types.PbmProfileResourceTypeEnumSTORAGE),
}
category := types.PbmProfileCategoryEnumREQUIREMENT
// 1. Query all the profiles on the vCenter.
ids, err := pc.QueryProfile(ctx, rtype, string(category))
if err != nil {
t.Fatal(err)
}
var qids []string
for _, id := range ids {
qids = append(qids, id.UniqueId)
}
var cids []string
// 2. Retrieve the content of all profiles.
policies, err := pc.RetrieveContent(ctx, ids)
if err != nil {
t.Fatal(err)
}
for i := range policies {
profile := policies[i].GetPbmProfile()
cids = append(cids, profile.ProfileId.UniqueId)
}
sort.Strings(qids)
sort.Strings(cids)
// Check whether ids retreived from QueryProfile and RetrieveContent are identical.
if !reflect.DeepEqual(qids, cids) {
t.Error("ids mismatch")
}
// 3. Get list of datastores in a cluster if cluster name is specified.
root := c.ServiceContent.RootFolder
var datastores []vim.ManagedObjectReference
var kind []string
if clusterName == "" {
kind = []string{"Datastore"}
} else {
kind = []string{"ClusterComputeResource"}
}
m := view.NewManager(c.Client)
v, err := m.CreateContainerView(ctx, root, kind, true)
if err != nil {
t.Fatal(err)
}
if clusterName == "" {
datastores, err = v.Find(ctx, kind, nil)
if err != nil {
t.Fatal(err)
}
} else {
var cluster mo.ClusterComputeResource
err = v.RetrieveWithFilter(ctx, kind, []string{"datastore"}, &cluster, property.Filter{"name": clusterName})
if err != nil {
t.Fatal(err)
}
datastores = cluster.Datastore
}
_ = v.Destroy(ctx)
t.Logf("checking %d datatores for compatibility results", len(datastores))
var hubs []types.PbmPlacementHub
for _, ds := range datastores {
hubs = append(hubs, types.PbmPlacementHub{
HubType: ds.Type,
HubId: ds.Value,
})
}
var req []types.BasePbmPlacementRequirement
for _, id := range ids {
req = append(req, &types.PbmPlacementCapabilityProfileRequirement{
ProfileId: id,
})
}
// 4. Get the compatibility results for all the profiles on the vCenter.
res, err := pc.CheckRequirements(ctx, hubs, nil, req)
if err != nil {
t.Fatal(err)
}
t.Logf("CheckRequirements results: %d", len(res))
// user spec for the profile.
// VSAN profile with 2 capability instances - hostFailuresToTolerate = 2, stripeWidth = 1
pbmCreateSpecForVSAN := CapabilityProfileCreateSpec{
Name: "Kubernetes-VSAN-TestPolicy",
Description: "VSAN Test policy create",
Category: string(types.PbmProfileCategoryEnumREQUIREMENT),
CapabilityList: []Capability{
Capability{
ID: "hostFailuresToTolerate",
Namespace: "VSAN",
PropertyList: []Property{
Property{
ID: "hostFailuresToTolerate",
Value: "2",
DataType: "int",
},
},
},
Capability{
ID: "stripeWidth",
Namespace: "VSAN",
PropertyList: []Property{
Property{
ID: "stripeWidth",
Value: "1",
DataType: "int",
},
},
},
},
}
// Create PBM capability spec for the above defined user spec.
createSpecVSAN, err := CreateCapabilityProfileSpec(pbmCreateSpecForVSAN)
if err != nil {
t.Fatal(err)
}
// 5. Create SPBM VSAN profile.
vsanProfileID, err := pc.CreateProfile(ctx, *createSpecVSAN)
if err != nil {
t.Fatal(err)
}
t.Logf("VSAN Profile: %q successfully created", vsanProfileID.UniqueId)
// 6. Verify if profile created exists by issuing a RetrieveContent request.
_, err = pc.RetrieveContent(ctx, []types.PbmProfileId{*vsanProfileID})
if err != nil {
t.Fatal(err)
}
t.Logf("Profile: %q exists on vCenter", vsanProfileID.UniqueId)
// 7. Get compatible datastores for the VSAN profile.
compatibleDatastores := res.CompatibleDatastores()
t.Logf("Found %d compatible-datastores for profile: %q", len(compatibleDatastores), vsanProfileID.UniqueId)
// 8. Get non-compatible datastores for the VSAN profile.
nonCompatibleDatastores := res.NonCompatibleDatastores()
t.Logf("Found %d non-compatible datastores for profile: %q", len(nonCompatibleDatastores), vsanProfileID.UniqueId)
// Check whether count of compatible and non-compatible datastores match the total number of datastores.
if (len(nonCompatibleDatastores) + len(compatibleDatastores)) != len(datastores) {
t.Error("datastore count mismatch")
}
// user spec for the profile.
// VSAN profile with 2 capability instances - stripeWidth = 1 and an SIOC profile.
pbmCreateSpecVSANandSIOC := CapabilityProfileCreateSpec{
Name: "Kubernetes-VSAN-SIOC-TestPolicy",
Description: "VSAN-SIOC-Test policy create",
Category: string(types.PbmProfileCategoryEnumREQUIREMENT),
CapabilityList: []Capability{
Capability{
ID: "stripeWidth",
Namespace: "VSAN",
PropertyList: []Property{
Property{
ID: "stripeWidth",
Value: "1",
DataType: "int",
},
},
},
Capability{
ID: "spm@DATASTOREIOCONTROL",
Namespace: "spm",
PropertyList: []Property{
Property{
ID: "limit",
Value: "200",
DataType: "int",
},
Property{
ID: "reservation",
Value: "1000",
DataType: "int",
},
Property{
ID: "shares",
Value: "2000",
DataType: "int",
},
},
},
},
}
// Create PBM capability spec for the above defined user spec.
createSpecVSANandSIOC, err := CreateCapabilityProfileSpec(pbmCreateSpecVSANandSIOC)
if err != nil {
t.Fatal(err)
}
// 9. Create SPBM VSAN profile.
vsansiocProfileID, err := pc.CreateProfile(ctx, *createSpecVSANandSIOC)
if err != nil {
t.Fatal(err)
}
t.Logf("VSAN-SIOC Profile: %q successfully created", vsansiocProfileID.UniqueId)
// 9. Get ProfileID by Name
profileID, err := pc.ProfileIDByName(ctx, "Kubernetes-VSAN-SIOC-TestPolicy")
if err != nil {
t.Fatal(err)
}
if vsansiocProfileID.UniqueId != profileID {
t.Errorf("vsan-sioc profile: %q and retrieved profileID: %q successfully matched", vsansiocProfileID.UniqueId, profileID)
}
t.Logf("VSAN-SIOC profile: %q and retrieved profileID: %q successfully matched", vsansiocProfileID.UniqueId, profileID)
// 10. Delete VSAN and VSAN-SIOC profile.
_, err = pc.DeleteProfile(ctx, []types.PbmProfileId{*vsanProfileID, *vsansiocProfileID})
if err != nil {
t.Fatal(err)
}
t.Logf("Profile: %+v successfully deleted", []types.PbmProfileId{*vsanProfileID, *vsansiocProfileID})
}

664
vendor/github.com/vmware/govmomi/pbm/methods/methods.go generated vendored Normal file
View File

@@ -0,0 +1,664 @@
/*
Copyright (c) 2014-2017 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package methods
import (
"context"
"github.com/vmware/govmomi/pbm/types"
"github.com/vmware/govmomi/vim25/soap"
)
type PbmAssignDefaultRequirementProfileBody struct {
Req *types.PbmAssignDefaultRequirementProfile `xml:"urn:pbm PbmAssignDefaultRequirementProfile,omitempty"`
Res *types.PbmAssignDefaultRequirementProfileResponse `xml:"urn:pbm PbmAssignDefaultRequirementProfileResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmAssignDefaultRequirementProfileBody) Fault() *soap.Fault { return b.Fault_ }
func PbmAssignDefaultRequirementProfile(ctx context.Context, r soap.RoundTripper, req *types.PbmAssignDefaultRequirementProfile) (*types.PbmAssignDefaultRequirementProfileResponse, error) {
var reqBody, resBody PbmAssignDefaultRequirementProfileBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmCheckCompatibilityBody struct {
Req *types.PbmCheckCompatibility `xml:"urn:pbm PbmCheckCompatibility,omitempty"`
Res *types.PbmCheckCompatibilityResponse `xml:"urn:pbm PbmCheckCompatibilityResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmCheckCompatibilityBody) Fault() *soap.Fault { return b.Fault_ }
func PbmCheckCompatibility(ctx context.Context, r soap.RoundTripper, req *types.PbmCheckCompatibility) (*types.PbmCheckCompatibilityResponse, error) {
var reqBody, resBody PbmCheckCompatibilityBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmCheckCompatibilityWithSpecBody struct {
Req *types.PbmCheckCompatibilityWithSpec `xml:"urn:pbm PbmCheckCompatibilityWithSpec,omitempty"`
Res *types.PbmCheckCompatibilityWithSpecResponse `xml:"urn:pbm PbmCheckCompatibilityWithSpecResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmCheckCompatibilityWithSpecBody) Fault() *soap.Fault { return b.Fault_ }
func PbmCheckCompatibilityWithSpec(ctx context.Context, r soap.RoundTripper, req *types.PbmCheckCompatibilityWithSpec) (*types.PbmCheckCompatibilityWithSpecResponse, error) {
var reqBody, resBody PbmCheckCompatibilityWithSpecBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmCheckComplianceBody struct {
Req *types.PbmCheckCompliance `xml:"urn:pbm PbmCheckCompliance,omitempty"`
Res *types.PbmCheckComplianceResponse `xml:"urn:pbm PbmCheckComplianceResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmCheckComplianceBody) Fault() *soap.Fault { return b.Fault_ }
func PbmCheckCompliance(ctx context.Context, r soap.RoundTripper, req *types.PbmCheckCompliance) (*types.PbmCheckComplianceResponse, error) {
var reqBody, resBody PbmCheckComplianceBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmCheckRequirementsBody struct {
Req *types.PbmCheckRequirements `xml:"urn:pbm PbmCheckRequirements,omitempty"`
Res *types.PbmCheckRequirementsResponse `xml:"urn:pbm PbmCheckRequirementsResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmCheckRequirementsBody) Fault() *soap.Fault { return b.Fault_ }
func PbmCheckRequirements(ctx context.Context, r soap.RoundTripper, req *types.PbmCheckRequirements) (*types.PbmCheckRequirementsResponse, error) {
var reqBody, resBody PbmCheckRequirementsBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmCheckRollupComplianceBody struct {
Req *types.PbmCheckRollupCompliance `xml:"urn:pbm PbmCheckRollupCompliance,omitempty"`
Res *types.PbmCheckRollupComplianceResponse `xml:"urn:pbm PbmCheckRollupComplianceResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmCheckRollupComplianceBody) Fault() *soap.Fault { return b.Fault_ }
func PbmCheckRollupCompliance(ctx context.Context, r soap.RoundTripper, req *types.PbmCheckRollupCompliance) (*types.PbmCheckRollupComplianceResponse, error) {
var reqBody, resBody PbmCheckRollupComplianceBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmCreateBody struct {
Req *types.PbmCreate `xml:"urn:pbm PbmCreate,omitempty"`
Res *types.PbmCreateResponse `xml:"urn:pbm PbmCreateResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmCreateBody) Fault() *soap.Fault { return b.Fault_ }
func PbmCreate(ctx context.Context, r soap.RoundTripper, req *types.PbmCreate) (*types.PbmCreateResponse, error) {
var reqBody, resBody PbmCreateBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmDeleteBody struct {
Req *types.PbmDelete `xml:"urn:pbm PbmDelete,omitempty"`
Res *types.PbmDeleteResponse `xml:"urn:pbm PbmDeleteResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmDeleteBody) Fault() *soap.Fault { return b.Fault_ }
func PbmDelete(ctx context.Context, r soap.RoundTripper, req *types.PbmDelete) (*types.PbmDeleteResponse, error) {
var reqBody, resBody PbmDeleteBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmFetchCapabilityMetadataBody struct {
Req *types.PbmFetchCapabilityMetadata `xml:"urn:pbm PbmFetchCapabilityMetadata,omitempty"`
Res *types.PbmFetchCapabilityMetadataResponse `xml:"urn:pbm PbmFetchCapabilityMetadataResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmFetchCapabilityMetadataBody) Fault() *soap.Fault { return b.Fault_ }
func PbmFetchCapabilityMetadata(ctx context.Context, r soap.RoundTripper, req *types.PbmFetchCapabilityMetadata) (*types.PbmFetchCapabilityMetadataResponse, error) {
var reqBody, resBody PbmFetchCapabilityMetadataBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmFetchCapabilitySchemaBody struct {
Req *types.PbmFetchCapabilitySchema `xml:"urn:pbm PbmFetchCapabilitySchema,omitempty"`
Res *types.PbmFetchCapabilitySchemaResponse `xml:"urn:pbm PbmFetchCapabilitySchemaResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmFetchCapabilitySchemaBody) Fault() *soap.Fault { return b.Fault_ }
func PbmFetchCapabilitySchema(ctx context.Context, r soap.RoundTripper, req *types.PbmFetchCapabilitySchema) (*types.PbmFetchCapabilitySchemaResponse, error) {
var reqBody, resBody PbmFetchCapabilitySchemaBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmFetchComplianceResultBody struct {
Req *types.PbmFetchComplianceResult `xml:"urn:pbm PbmFetchComplianceResult,omitempty"`
Res *types.PbmFetchComplianceResultResponse `xml:"urn:pbm PbmFetchComplianceResultResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmFetchComplianceResultBody) Fault() *soap.Fault { return b.Fault_ }
func PbmFetchComplianceResult(ctx context.Context, r soap.RoundTripper, req *types.PbmFetchComplianceResult) (*types.PbmFetchComplianceResultResponse, error) {
var reqBody, resBody PbmFetchComplianceResultBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmFetchResourceTypeBody struct {
Req *types.PbmFetchResourceType `xml:"urn:pbm PbmFetchResourceType,omitempty"`
Res *types.PbmFetchResourceTypeResponse `xml:"urn:pbm PbmFetchResourceTypeResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmFetchResourceTypeBody) Fault() *soap.Fault { return b.Fault_ }
func PbmFetchResourceType(ctx context.Context, r soap.RoundTripper, req *types.PbmFetchResourceType) (*types.PbmFetchResourceTypeResponse, error) {
var reqBody, resBody PbmFetchResourceTypeBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmFetchRollupComplianceResultBody struct {
Req *types.PbmFetchRollupComplianceResult `xml:"urn:pbm PbmFetchRollupComplianceResult,omitempty"`
Res *types.PbmFetchRollupComplianceResultResponse `xml:"urn:pbm PbmFetchRollupComplianceResultResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmFetchRollupComplianceResultBody) Fault() *soap.Fault { return b.Fault_ }
func PbmFetchRollupComplianceResult(ctx context.Context, r soap.RoundTripper, req *types.PbmFetchRollupComplianceResult) (*types.PbmFetchRollupComplianceResultResponse, error) {
var reqBody, resBody PbmFetchRollupComplianceResultBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmFetchVendorInfoBody struct {
Req *types.PbmFetchVendorInfo `xml:"urn:pbm PbmFetchVendorInfo,omitempty"`
Res *types.PbmFetchVendorInfoResponse `xml:"urn:pbm PbmFetchVendorInfoResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmFetchVendorInfoBody) Fault() *soap.Fault { return b.Fault_ }
func PbmFetchVendorInfo(ctx context.Context, r soap.RoundTripper, req *types.PbmFetchVendorInfo) (*types.PbmFetchVendorInfoResponse, error) {
var reqBody, resBody PbmFetchVendorInfoBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmFindApplicableDefaultProfileBody struct {
Req *types.PbmFindApplicableDefaultProfile `xml:"urn:pbm PbmFindApplicableDefaultProfile,omitempty"`
Res *types.PbmFindApplicableDefaultProfileResponse `xml:"urn:pbm PbmFindApplicableDefaultProfileResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmFindApplicableDefaultProfileBody) Fault() *soap.Fault { return b.Fault_ }
func PbmFindApplicableDefaultProfile(ctx context.Context, r soap.RoundTripper, req *types.PbmFindApplicableDefaultProfile) (*types.PbmFindApplicableDefaultProfileResponse, error) {
var reqBody, resBody PbmFindApplicableDefaultProfileBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmQueryAssociatedEntitiesBody struct {
Req *types.PbmQueryAssociatedEntities `xml:"urn:pbm PbmQueryAssociatedEntities,omitempty"`
Res *types.PbmQueryAssociatedEntitiesResponse `xml:"urn:pbm PbmQueryAssociatedEntitiesResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmQueryAssociatedEntitiesBody) Fault() *soap.Fault { return b.Fault_ }
func PbmQueryAssociatedEntities(ctx context.Context, r soap.RoundTripper, req *types.PbmQueryAssociatedEntities) (*types.PbmQueryAssociatedEntitiesResponse, error) {
var reqBody, resBody PbmQueryAssociatedEntitiesBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmQueryAssociatedEntityBody struct {
Req *types.PbmQueryAssociatedEntity `xml:"urn:pbm PbmQueryAssociatedEntity,omitempty"`
Res *types.PbmQueryAssociatedEntityResponse `xml:"urn:pbm PbmQueryAssociatedEntityResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmQueryAssociatedEntityBody) Fault() *soap.Fault { return b.Fault_ }
func PbmQueryAssociatedEntity(ctx context.Context, r soap.RoundTripper, req *types.PbmQueryAssociatedEntity) (*types.PbmQueryAssociatedEntityResponse, error) {
var reqBody, resBody PbmQueryAssociatedEntityBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmQueryAssociatedProfileBody struct {
Req *types.PbmQueryAssociatedProfile `xml:"urn:pbm PbmQueryAssociatedProfile,omitempty"`
Res *types.PbmQueryAssociatedProfileResponse `xml:"urn:pbm PbmQueryAssociatedProfileResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmQueryAssociatedProfileBody) Fault() *soap.Fault { return b.Fault_ }
func PbmQueryAssociatedProfile(ctx context.Context, r soap.RoundTripper, req *types.PbmQueryAssociatedProfile) (*types.PbmQueryAssociatedProfileResponse, error) {
var reqBody, resBody PbmQueryAssociatedProfileBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmQueryAssociatedProfilesBody struct {
Req *types.PbmQueryAssociatedProfiles `xml:"urn:pbm PbmQueryAssociatedProfiles,omitempty"`
Res *types.PbmQueryAssociatedProfilesResponse `xml:"urn:pbm PbmQueryAssociatedProfilesResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmQueryAssociatedProfilesBody) Fault() *soap.Fault { return b.Fault_ }
func PbmQueryAssociatedProfiles(ctx context.Context, r soap.RoundTripper, req *types.PbmQueryAssociatedProfiles) (*types.PbmQueryAssociatedProfilesResponse, error) {
var reqBody, resBody PbmQueryAssociatedProfilesBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmQueryByRollupComplianceStatusBody struct {
Req *types.PbmQueryByRollupComplianceStatus `xml:"urn:pbm PbmQueryByRollupComplianceStatus,omitempty"`
Res *types.PbmQueryByRollupComplianceStatusResponse `xml:"urn:pbm PbmQueryByRollupComplianceStatusResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmQueryByRollupComplianceStatusBody) Fault() *soap.Fault { return b.Fault_ }
func PbmQueryByRollupComplianceStatus(ctx context.Context, r soap.RoundTripper, req *types.PbmQueryByRollupComplianceStatus) (*types.PbmQueryByRollupComplianceStatusResponse, error) {
var reqBody, resBody PbmQueryByRollupComplianceStatusBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmQueryDefaultRequirementProfileBody struct {
Req *types.PbmQueryDefaultRequirementProfile `xml:"urn:pbm PbmQueryDefaultRequirementProfile,omitempty"`
Res *types.PbmQueryDefaultRequirementProfileResponse `xml:"urn:pbm PbmQueryDefaultRequirementProfileResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmQueryDefaultRequirementProfileBody) Fault() *soap.Fault { return b.Fault_ }
func PbmQueryDefaultRequirementProfile(ctx context.Context, r soap.RoundTripper, req *types.PbmQueryDefaultRequirementProfile) (*types.PbmQueryDefaultRequirementProfileResponse, error) {
var reqBody, resBody PbmQueryDefaultRequirementProfileBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmQueryDefaultRequirementProfilesBody struct {
Req *types.PbmQueryDefaultRequirementProfiles `xml:"urn:pbm PbmQueryDefaultRequirementProfiles,omitempty"`
Res *types.PbmQueryDefaultRequirementProfilesResponse `xml:"urn:pbm PbmQueryDefaultRequirementProfilesResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmQueryDefaultRequirementProfilesBody) Fault() *soap.Fault { return b.Fault_ }
func PbmQueryDefaultRequirementProfiles(ctx context.Context, r soap.RoundTripper, req *types.PbmQueryDefaultRequirementProfiles) (*types.PbmQueryDefaultRequirementProfilesResponse, error) {
var reqBody, resBody PbmQueryDefaultRequirementProfilesBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmQueryMatchingHubBody struct {
Req *types.PbmQueryMatchingHub `xml:"urn:pbm PbmQueryMatchingHub,omitempty"`
Res *types.PbmQueryMatchingHubResponse `xml:"urn:pbm PbmQueryMatchingHubResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmQueryMatchingHubBody) Fault() *soap.Fault { return b.Fault_ }
func PbmQueryMatchingHub(ctx context.Context, r soap.RoundTripper, req *types.PbmQueryMatchingHub) (*types.PbmQueryMatchingHubResponse, error) {
var reqBody, resBody PbmQueryMatchingHubBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmQueryMatchingHubWithSpecBody struct {
Req *types.PbmQueryMatchingHubWithSpec `xml:"urn:pbm PbmQueryMatchingHubWithSpec,omitempty"`
Res *types.PbmQueryMatchingHubWithSpecResponse `xml:"urn:pbm PbmQueryMatchingHubWithSpecResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmQueryMatchingHubWithSpecBody) Fault() *soap.Fault { return b.Fault_ }
func PbmQueryMatchingHubWithSpec(ctx context.Context, r soap.RoundTripper, req *types.PbmQueryMatchingHubWithSpec) (*types.PbmQueryMatchingHubWithSpecResponse, error) {
var reqBody, resBody PbmQueryMatchingHubWithSpecBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmQueryProfileBody struct {
Req *types.PbmQueryProfile `xml:"urn:pbm PbmQueryProfile,omitempty"`
Res *types.PbmQueryProfileResponse `xml:"urn:pbm PbmQueryProfileResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmQueryProfileBody) Fault() *soap.Fault { return b.Fault_ }
func PbmQueryProfile(ctx context.Context, r soap.RoundTripper, req *types.PbmQueryProfile) (*types.PbmQueryProfileResponse, error) {
var reqBody, resBody PbmQueryProfileBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmQueryReplicationGroupsBody struct {
Req *types.PbmQueryReplicationGroups `xml:"urn:pbm PbmQueryReplicationGroups,omitempty"`
Res *types.PbmQueryReplicationGroupsResponse `xml:"urn:pbm PbmQueryReplicationGroupsResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmQueryReplicationGroupsBody) Fault() *soap.Fault { return b.Fault_ }
func PbmQueryReplicationGroups(ctx context.Context, r soap.RoundTripper, req *types.PbmQueryReplicationGroups) (*types.PbmQueryReplicationGroupsResponse, error) {
var reqBody, resBody PbmQueryReplicationGroupsBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmQuerySpaceStatsForStorageContainerBody struct {
Req *types.PbmQuerySpaceStatsForStorageContainer `xml:"urn:pbm PbmQuerySpaceStatsForStorageContainer,omitempty"`
Res *types.PbmQuerySpaceStatsForStorageContainerResponse `xml:"urn:pbm PbmQuerySpaceStatsForStorageContainerResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmQuerySpaceStatsForStorageContainerBody) Fault() *soap.Fault { return b.Fault_ }
func PbmQuerySpaceStatsForStorageContainer(ctx context.Context, r soap.RoundTripper, req *types.PbmQuerySpaceStatsForStorageContainer) (*types.PbmQuerySpaceStatsForStorageContainerResponse, error) {
var reqBody, resBody PbmQuerySpaceStatsForStorageContainerBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmResetDefaultRequirementProfileBody struct {
Req *types.PbmResetDefaultRequirementProfile `xml:"urn:pbm PbmResetDefaultRequirementProfile,omitempty"`
Res *types.PbmResetDefaultRequirementProfileResponse `xml:"urn:pbm PbmResetDefaultRequirementProfileResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmResetDefaultRequirementProfileBody) Fault() *soap.Fault { return b.Fault_ }
func PbmResetDefaultRequirementProfile(ctx context.Context, r soap.RoundTripper, req *types.PbmResetDefaultRequirementProfile) (*types.PbmResetDefaultRequirementProfileResponse, error) {
var reqBody, resBody PbmResetDefaultRequirementProfileBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmResetVSanDefaultProfileBody struct {
Req *types.PbmResetVSanDefaultProfile `xml:"urn:pbm PbmResetVSanDefaultProfile,omitempty"`
Res *types.PbmResetVSanDefaultProfileResponse `xml:"urn:pbm PbmResetVSanDefaultProfileResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmResetVSanDefaultProfileBody) Fault() *soap.Fault { return b.Fault_ }
func PbmResetVSanDefaultProfile(ctx context.Context, r soap.RoundTripper, req *types.PbmResetVSanDefaultProfile) (*types.PbmResetVSanDefaultProfileResponse, error) {
var reqBody, resBody PbmResetVSanDefaultProfileBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmRetrieveContentBody struct {
Req *types.PbmRetrieveContent `xml:"urn:pbm PbmRetrieveContent,omitempty"`
Res *types.PbmRetrieveContentResponse `xml:"urn:pbm PbmRetrieveContentResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmRetrieveContentBody) Fault() *soap.Fault { return b.Fault_ }
func PbmRetrieveContent(ctx context.Context, r soap.RoundTripper, req *types.PbmRetrieveContent) (*types.PbmRetrieveContentResponse, error) {
var reqBody, resBody PbmRetrieveContentBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmRetrieveServiceContentBody struct {
Req *types.PbmRetrieveServiceContent `xml:"urn:pbm PbmRetrieveServiceContent,omitempty"`
Res *types.PbmRetrieveServiceContentResponse `xml:"urn:pbm PbmRetrieveServiceContentResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmRetrieveServiceContentBody) Fault() *soap.Fault { return b.Fault_ }
func PbmRetrieveServiceContent(ctx context.Context, r soap.RoundTripper, req *types.PbmRetrieveServiceContent) (*types.PbmRetrieveServiceContentResponse, error) {
var reqBody, resBody PbmRetrieveServiceContentBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PbmUpdateBody struct {
Req *types.PbmUpdate `xml:"urn:pbm PbmUpdate,omitempty"`
Res *types.PbmUpdateResponse `xml:"urn:pbm PbmUpdateResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *PbmUpdateBody) Fault() *soap.Fault { return b.Fault_ }
func PbmUpdate(ctx context.Context, r soap.RoundTripper, req *types.PbmUpdate) (*types.PbmUpdateResponse, error) {
var reqBody, resBody PbmUpdateBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}

146
vendor/github.com/vmware/govmomi/pbm/pbm_util.go generated vendored Normal file
View File

@@ -0,0 +1,146 @@
/*
Copyright (c) 2017 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package pbm
import (
"fmt"
"strconv"
"strings"
"github.com/vmware/govmomi/pbm/types"
)
// A struct to capture pbm create spec details.
type CapabilityProfileCreateSpec struct {
Name string
Description string
Category string
CapabilityList []Capability
}
// A struct to capture pbm capability instance details.
type Capability struct {
ID string
Namespace string
PropertyList []Property
}
// A struct to capture pbm property instance details.
type Property struct {
ID string
Operator string
Value string
DataType string
}
func CreateCapabilityProfileSpec(pbmCreateSpec CapabilityProfileCreateSpec) (*types.PbmCapabilityProfileCreateSpec, error) {
capabilities, err := createCapabilityInstances(pbmCreateSpec.CapabilityList)
if err != nil {
return nil, err
}
pbmCapabilityProfileSpec := types.PbmCapabilityProfileCreateSpec{
Name: pbmCreateSpec.Name,
Description: pbmCreateSpec.Description,
Category: pbmCreateSpec.Category,
ResourceType: types.PbmProfileResourceType{
ResourceType: string(types.PbmProfileResourceTypeEnumSTORAGE),
},
Constraints: &types.PbmCapabilitySubProfileConstraints{
SubProfiles: []types.PbmCapabilitySubProfile{
types.PbmCapabilitySubProfile{
Capability: capabilities,
},
},
},
}
return &pbmCapabilityProfileSpec, nil
}
func createCapabilityInstances(rules []Capability) ([]types.PbmCapabilityInstance, error) {
var capabilityInstances []types.PbmCapabilityInstance
for _, capabilityRule := range rules {
capability := types.PbmCapabilityInstance{
Id: types.PbmCapabilityMetadataUniqueId{
Namespace: capabilityRule.Namespace,
Id: capabilityRule.ID,
},
}
var propertyInstances []types.PbmCapabilityPropertyInstance
for _, propertyRule := range capabilityRule.PropertyList {
property := types.PbmCapabilityPropertyInstance{
Id: propertyRule.ID,
}
if propertyRule.Operator != "" {
property.Operator = propertyRule.Operator
}
var err error
switch strings.ToLower(propertyRule.DataType) {
case "int":
// Go int32 is marshalled to xsi:int whereas Go int is marshalled to xsi:long when sending down the wire.
var val int32
val, err = verifyPropertyValueIsInt(propertyRule.Value, propertyRule.DataType)
property.Value = val
case "bool":
var val bool
val, err = verifyPropertyValueIsBoolean(propertyRule.Value, propertyRule.DataType)
property.Value = val
case "string":
property.Value = propertyRule.Value
case "set":
set := types.PbmCapabilityDiscreteSet{}
for _, val := range strings.Split(propertyRule.Value, ",") {
set.Values = append(set.Values, val)
}
property.Value = set
default:
return nil, fmt.Errorf("invalid value: %q with datatype: %q", propertyRule.Value, propertyRule.Value)
}
if err != nil {
return nil, fmt.Errorf("invalid value: %q with datatype: %q", propertyRule.Value, propertyRule.Value)
}
propertyInstances = append(propertyInstances, property)
}
constraintInstances := []types.PbmCapabilityConstraintInstance{
types.PbmCapabilityConstraintInstance{
PropertyInstance: propertyInstances,
},
}
capability.Constraint = constraintInstances
capabilityInstances = append(capabilityInstances, capability)
}
return capabilityInstances, nil
}
// Verify if the capability value is of type integer.
func verifyPropertyValueIsInt(propertyValue string, dataType string) (int32, error) {
val, err := strconv.ParseInt(propertyValue, 10, 32)
if err != nil {
return -1, err
}
return int32(val), nil
}
// Verify if the capability value is of type integer.
func verifyPropertyValueIsBoolean(propertyValue string, dataType string) (bool, error) {
val, err := strconv.ParseBool(propertyValue)
if err != nil {
return false, err
}
return val, nil
}

211
vendor/github.com/vmware/govmomi/pbm/types/enum.go generated vendored Normal file
View File

@@ -0,0 +1,211 @@
/*
Copyright (c) 2014-2017 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package types
import (
"reflect"
"github.com/vmware/govmomi/vim25/types"
)
type PbmBuiltinGenericType string
const (
PbmBuiltinGenericTypeVMW_RANGE = PbmBuiltinGenericType("VMW_RANGE")
PbmBuiltinGenericTypeVMW_SET = PbmBuiltinGenericType("VMW_SET")
)
func init() {
types.Add("pbm:PbmBuiltinGenericType", reflect.TypeOf((*PbmBuiltinGenericType)(nil)).Elem())
}
type PbmBuiltinType string
const (
PbmBuiltinTypeXSD_LONG = PbmBuiltinType("XSD_LONG")
PbmBuiltinTypeXSD_SHORT = PbmBuiltinType("XSD_SHORT")
PbmBuiltinTypeXSD_INTEGER = PbmBuiltinType("XSD_INTEGER")
PbmBuiltinTypeXSD_INT = PbmBuiltinType("XSD_INT")
PbmBuiltinTypeXSD_STRING = PbmBuiltinType("XSD_STRING")
PbmBuiltinTypeXSD_BOOLEAN = PbmBuiltinType("XSD_BOOLEAN")
PbmBuiltinTypeXSD_DOUBLE = PbmBuiltinType("XSD_DOUBLE")
PbmBuiltinTypeXSD_DATETIME = PbmBuiltinType("XSD_DATETIME")
PbmBuiltinTypeVMW_TIMESPAN = PbmBuiltinType("VMW_TIMESPAN")
PbmBuiltinTypeVMW_POLICY = PbmBuiltinType("VMW_POLICY")
)
func init() {
types.Add("pbm:PbmBuiltinType", reflect.TypeOf((*PbmBuiltinType)(nil)).Elem())
}
type PbmCapabilityOperator string
const (
PbmCapabilityOperatorNOT = PbmCapabilityOperator("NOT")
)
func init() {
types.Add("pbm:PbmCapabilityOperator", reflect.TypeOf((*PbmCapabilityOperator)(nil)).Elem())
}
type PbmCapabilityTimeUnitType string
const (
PbmCapabilityTimeUnitTypeSECONDS = PbmCapabilityTimeUnitType("SECONDS")
PbmCapabilityTimeUnitTypeMINUTES = PbmCapabilityTimeUnitType("MINUTES")
PbmCapabilityTimeUnitTypeHOURS = PbmCapabilityTimeUnitType("HOURS")
PbmCapabilityTimeUnitTypeDAYS = PbmCapabilityTimeUnitType("DAYS")
PbmCapabilityTimeUnitTypeWEEKS = PbmCapabilityTimeUnitType("WEEKS")
PbmCapabilityTimeUnitTypeMONTHS = PbmCapabilityTimeUnitType("MONTHS")
PbmCapabilityTimeUnitTypeYEARS = PbmCapabilityTimeUnitType("YEARS")
)
func init() {
types.Add("pbm:PbmCapabilityTimeUnitType", reflect.TypeOf((*PbmCapabilityTimeUnitType)(nil)).Elem())
}
type PbmComplianceResultComplianceTaskStatus string
const (
PbmComplianceResultComplianceTaskStatusInProgress = PbmComplianceResultComplianceTaskStatus("inProgress")
PbmComplianceResultComplianceTaskStatusSuccess = PbmComplianceResultComplianceTaskStatus("success")
PbmComplianceResultComplianceTaskStatusFailed = PbmComplianceResultComplianceTaskStatus("failed")
)
func init() {
types.Add("pbm:PbmComplianceResultComplianceTaskStatus", reflect.TypeOf((*PbmComplianceResultComplianceTaskStatus)(nil)).Elem())
}
type PbmComplianceStatus string
const (
PbmComplianceStatusCompliant = PbmComplianceStatus("compliant")
PbmComplianceStatusNonCompliant = PbmComplianceStatus("nonCompliant")
PbmComplianceStatusUnknown = PbmComplianceStatus("unknown")
PbmComplianceStatusNotApplicable = PbmComplianceStatus("notApplicable")
PbmComplianceStatusOutOfDate = PbmComplianceStatus("outOfDate")
)
func init() {
types.Add("pbm:PbmComplianceStatus", reflect.TypeOf((*PbmComplianceStatus)(nil)).Elem())
}
type PbmIofilterInfoFilterType string
const (
PbmIofilterInfoFilterTypeINSPECTION = PbmIofilterInfoFilterType("INSPECTION")
PbmIofilterInfoFilterTypeCOMPRESSION = PbmIofilterInfoFilterType("COMPRESSION")
PbmIofilterInfoFilterTypeENCRYPTION = PbmIofilterInfoFilterType("ENCRYPTION")
PbmIofilterInfoFilterTypeREPLICATION = PbmIofilterInfoFilterType("REPLICATION")
PbmIofilterInfoFilterTypeCACHE = PbmIofilterInfoFilterType("CACHE")
PbmIofilterInfoFilterTypeDATAPROVIDER = PbmIofilterInfoFilterType("DATAPROVIDER")
PbmIofilterInfoFilterTypeDATASTOREIOCONTROL = PbmIofilterInfoFilterType("DATASTOREIOCONTROL")
)
func init() {
types.Add("pbm:PbmIofilterInfoFilterType", reflect.TypeOf((*PbmIofilterInfoFilterType)(nil)).Elem())
}
type PbmLineOfServiceInfoLineOfServiceEnum string
const (
PbmLineOfServiceInfoLineOfServiceEnumINSPECTION = PbmLineOfServiceInfoLineOfServiceEnum("INSPECTION")
PbmLineOfServiceInfoLineOfServiceEnumCOMPRESSION = PbmLineOfServiceInfoLineOfServiceEnum("COMPRESSION")
PbmLineOfServiceInfoLineOfServiceEnumENCRYPTION = PbmLineOfServiceInfoLineOfServiceEnum("ENCRYPTION")
PbmLineOfServiceInfoLineOfServiceEnumREPLICATION = PbmLineOfServiceInfoLineOfServiceEnum("REPLICATION")
PbmLineOfServiceInfoLineOfServiceEnumCACHING = PbmLineOfServiceInfoLineOfServiceEnum("CACHING")
PbmLineOfServiceInfoLineOfServiceEnumPERSISTENCE = PbmLineOfServiceInfoLineOfServiceEnum("PERSISTENCE")
PbmLineOfServiceInfoLineOfServiceEnumDATA_PROVIDER = PbmLineOfServiceInfoLineOfServiceEnum("DATA_PROVIDER")
PbmLineOfServiceInfoLineOfServiceEnumDATASTORE_IO_CONTROL = PbmLineOfServiceInfoLineOfServiceEnum("DATASTORE_IO_CONTROL")
)
func init() {
types.Add("pbm:PbmLineOfServiceInfoLineOfServiceEnum", reflect.TypeOf((*PbmLineOfServiceInfoLineOfServiceEnum)(nil)).Elem())
}
type PbmObjectType string
const (
PbmObjectTypeVirtualMachine = PbmObjectType("virtualMachine")
PbmObjectTypeVirtualMachineAndDisks = PbmObjectType("virtualMachineAndDisks")
PbmObjectTypeVirtualDiskId = PbmObjectType("virtualDiskId")
PbmObjectTypeVirtualDiskUUID = PbmObjectType("virtualDiskUUID")
PbmObjectTypeDatastore = PbmObjectType("datastore")
PbmObjectTypeUnknown = PbmObjectType("unknown")
)
func init() {
types.Add("pbm:PbmObjectType", reflect.TypeOf((*PbmObjectType)(nil)).Elem())
}
type PbmProfileCategoryEnum string
const (
PbmProfileCategoryEnumREQUIREMENT = PbmProfileCategoryEnum("REQUIREMENT")
PbmProfileCategoryEnumRESOURCE = PbmProfileCategoryEnum("RESOURCE")
PbmProfileCategoryEnumDATA_SERVICE_POLICY = PbmProfileCategoryEnum("DATA_SERVICE_POLICY")
)
func init() {
types.Add("pbm:PbmProfileCategoryEnum", reflect.TypeOf((*PbmProfileCategoryEnum)(nil)).Elem())
}
type PbmProfileResourceTypeEnum string
const (
PbmProfileResourceTypeEnumSTORAGE = PbmProfileResourceTypeEnum("STORAGE")
)
func init() {
types.Add("pbm:PbmProfileResourceTypeEnum", reflect.TypeOf((*PbmProfileResourceTypeEnum)(nil)).Elem())
}
type PbmSystemCreatedProfileType string
const (
PbmSystemCreatedProfileTypeVsanDefaultProfile = PbmSystemCreatedProfileType("VsanDefaultProfile")
PbmSystemCreatedProfileTypeVVolDefaultProfile = PbmSystemCreatedProfileType("VVolDefaultProfile")
)
func init() {
types.Add("pbm:PbmSystemCreatedProfileType", reflect.TypeOf((*PbmSystemCreatedProfileType)(nil)).Elem())
}
type PbmVmOperation string
const (
PbmVmOperationCREATE = PbmVmOperation("CREATE")
PbmVmOperationRECONFIGURE = PbmVmOperation("RECONFIGURE")
PbmVmOperationMIGRATE = PbmVmOperation("MIGRATE")
PbmVmOperationCLONE = PbmVmOperation("CLONE")
)
func init() {
types.Add("pbm:PbmVmOperation", reflect.TypeOf((*PbmVmOperation)(nil)).Elem())
}
type PbmVvolType string
const (
PbmVvolTypeConfig = PbmVvolType("Config")
PbmVvolTypeData = PbmVvolType("Data")
PbmVvolTypeSwap = PbmVvolType("Swap")
)
func init() {
types.Add("pbm:PbmVvolType", reflect.TypeOf((*PbmVvolType)(nil)).Elem())
}

139
vendor/github.com/vmware/govmomi/pbm/types/if.go generated vendored Normal file
View File

@@ -0,0 +1,139 @@
/*
Copyright (c) 2014-2017 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package types
import (
"reflect"
"github.com/vmware/govmomi/vim25/types"
)
func (b *PbmCapabilityConstraints) GetPbmCapabilityConstraints() *PbmCapabilityConstraints { return b }
type BasePbmCapabilityConstraints interface {
GetPbmCapabilityConstraints() *PbmCapabilityConstraints
}
func init() {
types.Add("BasePbmCapabilityConstraints", reflect.TypeOf((*PbmCapabilityConstraints)(nil)).Elem())
}
func (b *PbmCapabilityProfile) GetPbmCapabilityProfile() *PbmCapabilityProfile { return b }
type BasePbmCapabilityProfile interface {
GetPbmCapabilityProfile() *PbmCapabilityProfile
}
func init() {
types.Add("BasePbmCapabilityProfile", reflect.TypeOf((*PbmCapabilityProfile)(nil)).Elem())
}
func (b *PbmCapabilityProfilePropertyMismatchFault) GetPbmCapabilityProfilePropertyMismatchFault() *PbmCapabilityProfilePropertyMismatchFault {
return b
}
type BasePbmCapabilityProfilePropertyMismatchFault interface {
GetPbmCapabilityProfilePropertyMismatchFault() *PbmCapabilityProfilePropertyMismatchFault
}
func init() {
types.Add("BasePbmCapabilityProfilePropertyMismatchFault", reflect.TypeOf((*PbmCapabilityProfilePropertyMismatchFault)(nil)).Elem())
}
func (b *PbmCapabilityTypeInfo) GetPbmCapabilityTypeInfo() *PbmCapabilityTypeInfo { return b }
type BasePbmCapabilityTypeInfo interface {
GetPbmCapabilityTypeInfo() *PbmCapabilityTypeInfo
}
func init() {
types.Add("BasePbmCapabilityTypeInfo", reflect.TypeOf((*PbmCapabilityTypeInfo)(nil)).Elem())
}
func (b *PbmCompatibilityCheckFault) GetPbmCompatibilityCheckFault() *PbmCompatibilityCheckFault {
return b
}
type BasePbmCompatibilityCheckFault interface {
GetPbmCompatibilityCheckFault() *PbmCompatibilityCheckFault
}
func init() {
types.Add("BasePbmCompatibilityCheckFault", reflect.TypeOf((*PbmCompatibilityCheckFault)(nil)).Elem())
}
func (b *PbmFault) GetPbmFault() *PbmFault { return b }
type BasePbmFault interface {
GetPbmFault() *PbmFault
}
func init() {
types.Add("BasePbmFault", reflect.TypeOf((*PbmFault)(nil)).Elem())
}
func (b *PbmLineOfServiceInfo) GetPbmLineOfServiceInfo() *PbmLineOfServiceInfo { return b }
type BasePbmLineOfServiceInfo interface {
GetPbmLineOfServiceInfo() *PbmLineOfServiceInfo
}
func init() {
types.Add("BasePbmLineOfServiceInfo", reflect.TypeOf((*PbmLineOfServiceInfo)(nil)).Elem())
}
func (b *PbmPlacementMatchingResources) GetPbmPlacementMatchingResources() *PbmPlacementMatchingResources {
return b
}
type BasePbmPlacementMatchingResources interface {
GetPbmPlacementMatchingResources() *PbmPlacementMatchingResources
}
func init() {
types.Add("BasePbmPlacementMatchingResources", reflect.TypeOf((*PbmPlacementMatchingResources)(nil)).Elem())
}
func (b *PbmPlacementRequirement) GetPbmPlacementRequirement() *PbmPlacementRequirement { return b }
type BasePbmPlacementRequirement interface {
GetPbmPlacementRequirement() *PbmPlacementRequirement
}
func init() {
types.Add("BasePbmPlacementRequirement", reflect.TypeOf((*PbmPlacementRequirement)(nil)).Elem())
}
func (b *PbmProfile) GetPbmProfile() *PbmProfile { return b }
type BasePbmProfile interface {
GetPbmProfile() *PbmProfile
}
func init() {
types.Add("BasePbmProfile", reflect.TypeOf((*PbmProfile)(nil)).Elem())
}
func (b *PbmPropertyMismatchFault) GetPbmPropertyMismatchFault() *PbmPropertyMismatchFault { return b }
type BasePbmPropertyMismatchFault interface {
GetPbmPropertyMismatchFault() *PbmPropertyMismatchFault
}
func init() {
types.Add("BasePbmPropertyMismatchFault", reflect.TypeOf((*PbmPropertyMismatchFault)(nil)).Elem())
}

1712
vendor/github.com/vmware/govmomi/pbm/types/types.go generated vendored Normal file

File diff suppressed because it is too large Load Diff