From d6e1aef53e6cc1b161b85c9c6d0ff53f097f53f6 Mon Sep 17 00:00:00 2001 From: Vaidotas Bauzys Date: Fri, 21 Jun 2019 17:51:45 +0300 Subject: [PATCH 01/11] Add new functions to support getting and update Org vDC Signed-off-by: Vaidotas Bauzys --- govcd/api_vcd_test.go | 1 + govcd/org.go | 78 +++++++++++++++ govcd/org_test.go | 210 +++++++++++++++++++++++++++++++++++++++++ types/v56/constants.go | 2 + types/v56/types.go | 72 +++++++++----- 5 files changed, 340 insertions(+), 23 deletions(-) diff --git a/govcd/api_vcd_test.go b/govcd/api_vcd_test.go index 505ca69d4..624938506 100644 --- a/govcd/api_vcd_test.go +++ b/govcd/api_vcd_test.go @@ -39,6 +39,7 @@ const ( TestUploadOvf = "TestUploadOvf" TestDeleteCatalogItem = "TestDeleteCatalogItem" TestCreateOrgVdc = "TestCreateOrgVdc" + TestRefreshOrgVdc = "TestRefreshOrgVdc" TestCreateOrgVdcNetworkEGW = "TestCreateOrgVdcNetworkEGW" TestCreateOrgVdcNetworkIso = "TestCreateOrgVdcNetworkIso" TestCreateOrgVdcNetworkDirect = "TestCreateOrgVdcNetworkDirect" diff --git a/govcd/org.go b/govcd/org.go index 4a9286795..acc557c6c 100644 --- a/govcd/org.go +++ b/govcd/org.go @@ -97,6 +97,84 @@ func (org *Org) GetVdcByName(vdcname string) (Vdc, error) { return Vdc{}, nil } +// Given an adminVdc with a valid HREF, the function refresh the adminVdc +// and updates the adminVdc data. Otherwise if the function fails, +// it returns an error. Users should use refresh whenever they have +// a stale vDC due to the creation/update/deletion of a resource +// within the org or the vDC itself. +func (adminVdc *AdminVdc) Refresh() error { + if *adminVdc == (AdminVdc{}) { + return fmt.Errorf("cannot refresh, Object is empty") + } + + // Empty struct before a new unmarshal, otherwise we end up with duplicate + // elements in slices. + unmarshalledAdminVdc := &types.AdminVdc{} + + _, err := adminVdc.client.ExecuteRequest(adminVdc.AdminVdc.HREF, http.MethodGet, + "", "error refreshing vDC: %s", nil, unmarshalledAdminVdc) + if err != nil { + return err + } + adminVdc.AdminVdc = unmarshalledAdminVdc + + return nil +} + +// GetAdminVdcByName function uses user specifies valid vdc name and then returns a admin vDC object. +// If no vDC is found, then it returns an empty vDC and no error. +// Otherwise it returns an empty vDC and an error. +func (adminOrg *AdminOrg) GetAdminVdcByName(vdcname string) (AdminVdc, error) { + for _, vdcs := range adminOrg.AdminOrg.Vdcs.Vdcs { + if vdcs.Name == vdcname { + + adminVdc := NewAdminVdc(adminOrg.client) + + _, err := adminOrg.client.ExecuteRequest(vdcs.HREF, http.MethodGet, + "", "error getting vdc: %s", nil, adminVdc.AdminVdc) + + return *adminVdc, err + } + } + return AdminVdc{}, nil +} + +// Function UpdateAsync() updated vCD from current vCD struct contents. +// Any differences that may be legally applied will be updated. +// Returns an error if the call to vCD fails. +// API Documentation: https://vdc-repo.vmware.com/vmwb-repository/dcr-public/7a028e78-bd37-4a6a-8298-9c26c7eeb9aa/09142237-dd46-4dee-8326-e07212fb63a8/doc/doc/operations/PUT-Vdc.html +func (adminVdc *AdminVdc) UpdateAsync() (Task, error) { + + adminVdc.AdminVdc.Xmlns = types.XMLNamespaceVCloud + + // Return the task + return adminVdc.client.ExecuteTaskRequest(adminVdc.AdminVdc.HREF, http.MethodPut, + types.MimeAdminVDC, "error updating vDC: %s", adminVdc.AdminVdc) +} + +// Function Update() updated vCD from current vCD struct contents. +// Any differences that may be legally applied will be updated. +// Returns an empty AdminVdc struct and error if the call to vCD fails. +// API Documentation: https://vdc-repo.vmware.com/vmwb-repository/dcr-public/7a028e78-bd37-4a6a-8298-9c26c7eeb9aa/09142237-dd46-4dee-8326-e07212fb63a8/doc/doc/operations/PUT-Vdc.html +func (adminVdc *AdminVdc) Update() (AdminVdc, error) { + task, err := adminVdc.UpdateAsync() + if err != nil { + return AdminVdc{}, err + } + + err = task.WaitTaskCompletion() + if err != nil { + return AdminVdc{}, err + } + + err = adminVdc.Refresh() + if err != nil { + return AdminVdc{}, err + } + + return *adminVdc, nil +} + // AdminOrg gives an admin representation of an org. // Administrators can delete and update orgs with an admin org object. // AdminOrg includes all members of the Org element, and adds several diff --git a/govcd/org_test.go b/govcd/org_test.go index 274f9e3ee..f44830ebf 100644 --- a/govcd/org_test.go +++ b/govcd/org_test.go @@ -420,3 +420,213 @@ func (vcd *TestVCD) Test_GetAdminCatalog(check *C) { check.Assert(cat.AdminCatalog.Description, Equals, vcd.config.VCD.Catalog.Description) } } + +// Tests Refresh for Vdc by updating the Vdc and then asserting if the +// variable is updated. +func (vcd *TestVCD) Test_RefreshVdc(check *C) { + + adminOrg, err, vdcConfiguration := setupVDc(vcd, check) + + // Refresh so the new VDC shows up in the org's list + err = adminOrg.Refresh() + check.Assert(err, IsNil) + + adminVdc, err := adminOrg.GetAdminVdcByName(vdcConfiguration.Name) + + check.Assert(err, IsNil) + check.Assert(adminVdc, Not(Equals), Vdc{}) + check.Assert(adminVdc.AdminVdc.Name, Equals, vdcConfiguration.Name) + check.Assert(adminVdc.AdminVdc.IsEnabled, Equals, vdcConfiguration.IsEnabled) + check.Assert(adminVdc.AdminVdc.AllocationModel, Equals, vdcConfiguration.AllocationModel) + + adminVdc.AdminVdc.Name = TestRefreshOrgVdc + _, err = adminVdc.Update() + check.Assert(err, IsNil) + AddToCleanupList(TestRefreshOrgVdc, "vdc", vcd.org.Org.Name, check.TestName()) + + // Test Refresh on vdc + err = adminVdc.Refresh() + check.Assert(err, IsNil) + check.Assert(adminVdc.AdminVdc.Name, Equals, TestRefreshOrgVdc) +} + +func setupVDc(vcd *TestVCD, check *C) (AdminOrg, error, *types.VdcConfiguration) { + if vcd.skipAdminTests { + check.Skip(fmt.Sprintf(TestRequiresSysAdminPrivileges, check.TestName())) + } + if vcd.config.VCD.ProviderVdc.Name == "" { + check.Skip("No Provider VDC name given for VDC tests") + } + if vcd.config.VCD.ProviderVdc.StorageProfile == "" { + check.Skip("No Storage Profile given for VDC tests") + } + if vcd.config.VCD.ProviderVdc.NetworkPool == "" { + check.Skip("No Network Pool given for VDC tests") + } + adminOrg, err := GetAdminOrgByName(vcd.client, vcd.org.Org.Name) + check.Assert(err, IsNil) + check.Assert(adminOrg, Not(Equals), AdminOrg{}) + results, err := vcd.client.QueryWithNotEncodedParams(nil, map[string]string{ + "type": "providerVdc", + "filter": fmt.Sprintf("(name==%s)", vcd.config.VCD.ProviderVdc.Name), + }) + check.Assert(err, IsNil) + if len(results.Results.VMWProviderVdcRecord) == 0 { + check.Skip(fmt.Sprintf("No Provider VDC found with name '%s'", vcd.config.VCD.ProviderVdc.Name)) + } + providerVdcHref := results.Results.VMWProviderVdcRecord[0].HREF + results, err = vcd.client.QueryWithNotEncodedParams(nil, map[string]string{ + "type": "providerVdcStorageProfile", + "filter": fmt.Sprintf("(name==%s)", vcd.config.VCD.ProviderVdc.StorageProfile), + }) + check.Assert(err, IsNil) + if len(results.Results.ProviderVdcStorageProfileRecord) == 0 { + check.Skip(fmt.Sprintf("No storage profile found with name '%s'", vcd.config.VCD.ProviderVdc.StorageProfile)) + } + providerVdcStorageProfileHref := results.Results.ProviderVdcStorageProfileRecord[0].HREF + results, err = vcd.client.QueryWithNotEncodedParams(nil, map[string]string{ + "type": "networkPool", + "filter": fmt.Sprintf("(name==%s)", vcd.config.VCD.ProviderVdc.NetworkPool), + }) + check.Assert(err, IsNil) + if len(results.Results.NetworkPoolRecord) == 0 { + check.Skip(fmt.Sprintf("No network pool found with name '%s'", vcd.config.VCD.ProviderVdc.NetworkPool)) + } + networkPoolHref := results.Results.NetworkPoolRecord[0].HREF + vdcConfiguration := &types.VdcConfiguration{ + Name: TestCreateOrgVdc + "ForRefresh", + Xmlns: types.XMLNamespaceVCloud, + AllocationModel: "AllocationPool", + ComputeCapacity: []*types.ComputeCapacity{ + &types.ComputeCapacity{ + CPU: &types.CapacityWithUsage{ + Units: "MHz", + Allocated: 1024, + Limit: 1024, + }, + Memory: &types.CapacityWithUsage{ + Allocated: 1024, + Limit: 1024, + Units: "MB", + }, + }, + }, + VdcStorageProfile: []*types.VdcStorageProfile{&types.VdcStorageProfile{ + Enabled: true, + Units: "MB", + Limit: 1024, + Default: true, + ProviderVdcStorageProfile: &types.Reference{ + HREF: providerVdcStorageProfileHref, + }, + }, + }, + NetworkPoolReference: &types.Reference{ + HREF: networkPoolHref, + }, + ProviderVdcReference: &types.Reference{ + HREF: providerVdcHref, + }, + IsEnabled: true, + IsThinProvision: true, + UsesFastProvisioning: true, + } + vdc, err := adminOrg.GetVdcByName(vdcConfiguration.Name) + check.Assert(err, IsNil) + if vdc != (Vdc{}) { + err = vdc.DeleteWait(true, true) + check.Assert(err, IsNil) + } + err = adminOrg.CreateVdcWait(vdcConfiguration) + check.Assert(err, IsNil) + AddToCleanupList(vdcConfiguration.Name, "vdc", vcd.org.Org.Name, check.TestName()) + return adminOrg, err, vdcConfiguration +} + +// Tests Vdc by updating the Vdc and then asserting if the +// variable is updated. +func (vcd *TestVCD) Test_UpdateVdc(check *C) { + adminOrg, err, vdcConfiguration := setupVDc(vcd, check) + + // Refresh so the new VDC shows up in the org's list + err = adminOrg.Refresh() + check.Assert(err, IsNil) + + adminVdc, err := adminOrg.GetAdminVdcByName(vdcConfiguration.Name) + + check.Assert(err, IsNil) + check.Assert(adminVdc, Not(Equals), Vdc{}) + check.Assert(adminVdc.AdminVdc.Name, Equals, vdcConfiguration.Name) + check.Assert(adminVdc.AdminVdc.IsEnabled, Equals, vdcConfiguration.IsEnabled) + check.Assert(adminVdc.AdminVdc.AllocationModel, Equals, vdcConfiguration.AllocationModel) + + updateDescription := "updateDescription" + computeCapacity := []*types.ComputeCapacity{ + &types.ComputeCapacity{ + CPU: &types.CapacityWithUsage{ + Units: "MHz", + Allocated: 2024, + Limit: 2024, + }, + Memory: &types.CapacityWithUsage{ + Allocated: 2024, + Limit: 2024, + Units: "MB", + }, + }, + } + quota := 111 + vCpu := int64(1000) + guaranteed := float64(0.6) + adminVdc.AdminVdc.Description = updateDescription + adminVdc.AdminVdc.ComputeCapacity = computeCapacity + adminVdc.AdminVdc.IsEnabled = false + adminVdc.AdminVdc.IsThinProvision = false + adminVdc.AdminVdc.NetworkQuota = quota + adminVdc.AdminVdc.VMQuota = quota + adminVdc.AdminVdc.OverCommitAllowed = false + adminVdc.AdminVdc.VCpuInMhz = vCpu + adminVdc.AdminVdc.UsesFastProvisioning = false + adminVdc.AdminVdc.ResourceGuaranteedCpu = guaranteed + adminVdc.AdminVdc.ResourceGuaranteedMemory = guaranteed + + updatedVdc, err := adminVdc.Update() + check.Assert(err, IsNil) + check.Assert(updatedVdc, Not(IsNil)) + check.Assert(updatedVdc.AdminVdc.Description, Equals, updateDescription) + check.Assert(updatedVdc.AdminVdc.ComputeCapacity[0].CPU.Allocated, Equals, computeCapacity[0].CPU.Allocated) + check.Assert(updatedVdc.AdminVdc.IsEnabled, Equals, false) + check.Assert(updatedVdc.AdminVdc.IsThinProvision, Equals, false) + check.Assert(updatedVdc.AdminVdc.NetworkQuota, Equals, quota) + check.Assert(updatedVdc.AdminVdc.VMQuota, Equals, quota) + check.Assert(updatedVdc.AdminVdc.OverCommitAllowed, Equals, false) + check.Assert(updatedVdc.AdminVdc.VCpuInMhz, Equals, vCpu) + check.Assert(updatedVdc.AdminVdc.UsesFastProvisioning, Equals, false) + check.Assert(updatedVdc.AdminVdc.ResourceGuaranteedCpu, Equals, guaranteed) + check.Assert(updatedVdc.AdminVdc.ResourceGuaranteedMemory, Equals, guaranteed) +} + +// Tests org function GetAdminVdcByName with the vdc specified +// in the config file. Then tests with a vdc that doesn't exist. +// Fails if the config file name doesn't match with the found vDC, or +// if the invalid vDC is found by the function. Also tests an vDC +// that doesn't exist. Asserts an error if the function finds it or +// if the error is not nil. +func (vcd *TestVCD) Test_GetAdminVdcByName(check *C) { + if vcd.skipAdminTests { + check.Skip(fmt.Sprintf(TestRequiresSysAdminPrivileges, check.TestName())) + } + + adminOrg, err := GetAdminOrgByName(vcd.client, vcd.org.Org.Name) + check.Assert(err, IsNil) + check.Assert(adminOrg, Not(Equals), AdminOrg{}) + + adminVdc, err := adminOrg.GetAdminVdcByName(vcd.config.VCD.Vdc) + check.Assert(adminVdc, Not(Equals), AdminVdc{}) + check.Assert(err, IsNil) + check.Assert(adminVdc.AdminVdc.Name, Equals, vcd.config.VCD.Vdc) + // Try a vdc that doesn't exist + adminVdc, err = adminOrg.GetAdminVdcByName(INVALID_NAME) + check.Assert(adminVdc, Equals, AdminVdc{}) + check.Assert(err, IsNil) +} diff --git a/types/v56/constants.go b/types/v56/constants.go index 474242b6f..80ee0e1ae 100644 --- a/types/v56/constants.go +++ b/types/v56/constants.go @@ -33,6 +33,8 @@ const ( MimeCatalogItem = "application/vnd.vmware.vcloud.catalogItem+xml" // MimeVDC mime for a VDC MimeVDC = "application/vnd.vmware.vcloud.vdc+xml" + // MimeVDC mime for a admin VDC + MimeAdminVDC = "application/vnd.vmware.admin.vdc+xml" // MimeVAppTemplate mime for a vapp template MimeVAppTemplate = "application/vnd.vmware.vcloud.vAppTemplate+xml" // MimeVApp mime for a vApp diff --git a/types/v56/types.go b/types/v56/types.go index d82d9b09b..534905c64 100644 --- a/types/v56/types.go +++ b/types/v56/types.go @@ -367,22 +367,22 @@ type Vdc struct { ID string `xml:"id,attr,omitempty"` OperationKey string `xml:"operationKey,attr,omitempty"` Name string `xml:"name,attr"` - Status int `xml:"status,attr,omitempty"` + Status string `xml:"status,attr,omitempty"` + Link LinkList `xml:"Link,omitempty"` + Description string `xml:"Description,omitempty"` AllocationModel string `xml:"AllocationModel"` + ComputeCapacity []*ComputeCapacity `xml:"ComputeCapacity"` + ResourceEntities []*ResourceEntities `xml:"ResourceEntities,omitempty"` AvailableNetworks []*AvailableNetworks `xml:"AvailableNetworks,omitempty"` Capabilities []*Capabilities `xml:"Capabilities,omitempty"` - ComputeCapacity []*ComputeCapacity `xml:"ComputeCapacity"` - Description string `xml:"Description,omitempty"` - IsEnabled bool `xml:"IsEnabled"` - Link LinkList `xml:"Link,omitempty"` - NetworkQuota int `xml:"NetworkQuota"` NicQuota int `xml:"NicQuota"` - ResourceEntities []*ResourceEntities `xml:"ResourceEntities,omitempty"` + NetworkQuota int `xml:"NetworkQuota"` + VMQuota int `xml:"VmQuota"` + IsEnabled bool `xml:"IsEnabled"` Tasks *TasksInProgress `xml:"Tasks,omitempty"` UsedNetworkCount int `xml:"UsedNetworkCount,omitempty"` VdcStorageProfiles []*VdcStorageProfiles `xml:"VdcStorageProfiles"` - VMQuota int `xml:"VmQuota"` } // AdminVdc represents the admin view of an organization vDC. @@ -391,6 +391,7 @@ type Vdc struct { // Description: Represents the admin view of an organization vDC. // Since: 0.9 type AdminVdc struct { + Xmlns string `xml:"xmlns,attr"` Vdc ResourceGuaranteedMemory float64 `xml:"ResourceGuaranteedMemory,omitempty"` @@ -1981,21 +1982,22 @@ type QueryResultRecordsType struct { PageSize int `xml:"pageSize,attr,omitempty"` // Page size, as a number of records or references. Total float64 `xml:"total,attr,omitempty"` // Total number of records or references in the container. // Elements - Link []*Link `xml:"Link,omitempty"` // A reference to an entity or operation associated with this object. - EdgeGatewayRecord []*QueryResultEdgeGatewayRecordType `xml:"EdgeGatewayRecord"` // A record representing a EdgeGateway result. - VMRecord []*QueryResultVMRecordType `xml:"VMRecord"` // A record representing a VM result. - AdminVMRecord []*QueryResultVMRecordType `xml:"AdminVMRecord"` // A record representing a Admin VM result. - VAppRecord []*QueryResultVAppRecordType `xml:"VAppRecord"` // A record representing a VApp result. - OrgVdcStorageProfileRecord []*QueryResultOrgVdcStorageProfileRecordType `xml:"OrgVdcStorageProfileRecord"` // A record representing storage profiles - MediaRecord []*MediaRecordType `xml:"MediaRecord"` // A record representing media - AdminMediaRecord []*MediaRecordType `xml:"AdminMediaRecord"` // A record representing Admin media - VMWProviderVdcRecord []*QueryResultVMWProviderVdcRecordType `xml:"VMWProviderVdcRecord"` // A record representing a Provider VDC result. - ProviderVdcStorageProfileRecord []*QueryResultProviderVdcStorageProfileRecordType `xml:"ProviderVdcStorageProfileRecord"` // A record representing a Provider VDC storage profile result - NetworkPoolRecord []*QueryResultNetworkPoolRecordType `xml:"NetworkPoolRecord"` // A record representing a network pool - DiskRecord []*DiskRecordType `xml:"DiskRecord"` // A record representing a independent Disk. - AdminDiskRecord []*DiskRecordType `xml:"AdminDiskRecord"` // A record representing a independent Disk. - VirtualCenterRecord []*QueryResultVirtualCenterRecordType `xml:"VirtualCenterRecord"` // A record representing a vSphere server - PortGroupRecord []*PortGroupRecordType `xml:"PortgroupRecord"` // A record representing a port group + Link []*Link `xml:"Link,omitempty"` // A reference to an entity or operation associated with this object. + EdgeGatewayRecord []*QueryResultEdgeGatewayRecordType `xml:"EdgeGatewayRecord"` // A record representing a EdgeGateway result. + VMRecord []*QueryResultVMRecordType `xml:"VMRecord"` // A record representing a VM result. + AdminVMRecord []*QueryResultVMRecordType `xml:"AdminVMRecord"` // A record representing a Admin VM result. + VAppRecord []*QueryResultVAppRecordType `xml:"VAppRecord"` // A record representing a VApp result. + OrgVdcStorageProfileRecord []*QueryResultOrgVdcStorageProfileRecordType `xml:"OrgVdcStorageProfileRecord"` // A record representing storage profiles + MediaRecord []*MediaRecordType `xml:"MediaRecord"` // A record representing media + AdminMediaRecord []*MediaRecordType `xml:"AdminMediaRecord"` // A record representing Admin media + VMWProviderVdcRecord []*QueryResultVMWProviderVdcRecordType `xml:"VMWProviderVdcRecord"` // A record representing a Provider VDC result. + ProviderVdcStorageProfileRecord []*QueryResultProviderVdcStorageProfileRecordType `xml:"ProviderVdcStorageProfileRecord"` // A record representing a Provider VDC storage profile result + NetworkPoolRecord []*QueryResultNetworkPoolRecordType `xml:"NetworkPoolRecord"` // A record representing a network pool + DiskRecord []*DiskRecordType `xml:"DiskRecord"` // A record representing a independent Disk. + AdminDiskRecord []*DiskRecordType `xml:"AdminDiskRecord"` // A record representing a independent Disk. + VirtualCenterRecord []*QueryResultVirtualCenterRecordType `xml:"VirtualCenterRecord"` // A record representing a vSphere server + PortGroupRecord []*PortGroupRecordType `xml:"PortgroupRecord"` // A record representing a port group + OrgVdcNetworkRecord []*QueryResultOrgVdcNetworkRecordType `xml:"QueryResultOrgVdcNetworkRecordType"` // A record representing a org vDC network } // QueryResultEdgeGatewayRecordType represents an edge gateway record as query result. @@ -2435,3 +2437,27 @@ type PortGroupRecordType struct { ScopeType int `xml:"scopeType,attr,omitempty"` // Scope of network using the portgroup(1=Global, 2=Organization, 3=vApp) Link []*Link `xml:"Link,omitempty"` } + +// Represents org VDC Network +// Reference: vCloud API 27.0 - Org VDC Network +// https://code.vmware.com/apis/72/doc/doc/types/QueryResultOrgVdcNetworkRecordType.html +type QueryResultOrgVdcNetworkRecordType struct { + Xmlns string `xml:"xmlns,attr,omitempty"` + HREF string `xml:"href,attr,omitempty"` + Id string `xml:"id,attr,omitempty"` + Type string `xml:"type,attr,omitempty"` + Name string `xml:"name,attr,omitempty"` + DefaultGateway string `xml:"defaultGateway,attr,omitempty"` + Netmask string `xml:"netmask,attr,omitempty"` + Dns1 string `xml:"dns1,attr,omitempty"` + Dns2 string `xml:"dns2,attr,omitempty"` + DnsSuffix string `xml:"dnsSuffix,attr,omitempty"` + LinkType int `xml:"linkType,attr,omitempty"` + ConnectedTo string `xml:"connectedTo,attr,omitempty"` + Vdc string `xml:"vdc,attr,omitempty"` + IsBusy bool `xml:"isBusy,attr,omitempty"` + IsShared bool `xml:"isShared,attr,omitempty"` + VdcName string `xml:"vdcName,attr,omitempty"` + IsIpScopeInherited bool `xml:"isIpScopeInherited,attr,omitempty"` + Link []*Link `xml:"Link,omitempty"` +} From 8bd8e3cf61c46a515245ad6134f613d0ff144c2a Mon Sep 17 00:00:00 2001 From: Vaidotas Bauzys Date: Thu, 27 Jun 2019 16:39:00 +0300 Subject: [PATCH 02/11] Add new function to get network pool info Signed-off-by: Vaidotas Bauzys --- govcd/system.go | 15 +++++++++++++++ govcd/system_test.go | 22 ++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/govcd/system.go b/govcd/system.go index 071547872..f31fd9f19 100644 --- a/govcd/system.go +++ b/govcd/system.go @@ -12,6 +12,7 @@ import ( "strings" "github.com/vmware/go-vcloud-director/v2/types/v56" + "github.com/vmware/go-vcloud-director/v2/util" ) // Simple structure to pass Edge Gateway creation parameters. @@ -500,3 +501,17 @@ func QueryProviderVdcByName(vcdCli *VCDClient, name string) ([]*types.QueryResul return results.Results.VMWProviderVdcRecord, nil } + +// GetNetworkPoolByHREF functions fetches an network pool using VDC client and network pool href +func GetNetworkPoolByHREF(client *VCDClient, href string) (*types.VMWNetworkPool, error) { + util.Logger.Printf("[TRACE] Get network pool by HREF: %s\n", href) + + networkPool := &types.VMWNetworkPool{} + + _, err := client.Client.ExecuteRequest(href, http.MethodGet, + "", "error fetching network ppol: %s", nil, networkPool) + + // Return the disk + return networkPool, err + +} diff --git a/govcd/system_test.go b/govcd/system_test.go index 380e51998..3a1273e24 100644 --- a/govcd/system_test.go +++ b/govcd/system_test.go @@ -189,6 +189,28 @@ func (vcd *TestVCD) Test_FindBadlyNamedStorageProfile(check *C) { check.Assert(err.Error(), Matches, reNotFound) } +// Test getting network pool by href and vdc client +func (vcd *TestVCD) Test_GetNetworkPoolByHREF(check *C) { + if vcd.config.VCD.ProviderVdc.NetworkPool == "" { + check.Skip("Skipping test because network pool is not configured") + } + + fmt.Printf("Running: %s\n", check.TestName()) + + adminOrg, err := GetAdminOrgByName(vcd.client, vcd.config.VCD.Org) + check.Assert(adminOrg, Not(Equals), AdminOrg{}) + check.Assert(err, IsNil) + + adminVdc, err := adminOrg.GetAdminVdcByName(vcd.config.VCD.Vdc) + check.Assert(adminVdc, Not(Equals), AdminVdc{}) + check.Assert(err, IsNil) + + // Get network pool by href + foundNetworkPool, err := GetNetworkPoolByHREF(vcd.client, adminVdc.AdminVdc.NetworkPoolReference.HREF) + check.Assert(err, IsNil) + check.Assert(foundNetworkPool, Not(Equals), types.VMWNetworkPool{}) +} + // longer than the 128 characters so nothing can be named this var INVALID_NAME = `*******************************************INVALID **************************************************** From 04830fe5d672438f12ded026b5f53e430afea7d8 Mon Sep 17 00:00:00 2001 From: Vaidotas Bauzys Date: Thu, 27 Jun 2019 16:39:40 +0300 Subject: [PATCH 03/11] Change to be able to serialize zeroes Signed-off-by: Vaidotas Bauzys --- govcd/org_test.go | 2 +- types/v56/types.go | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/govcd/org_test.go b/govcd/org_test.go index f44830ebf..a3b9674ff 100644 --- a/govcd/org_test.go +++ b/govcd/org_test.go @@ -577,7 +577,7 @@ func (vcd *TestVCD) Test_UpdateVdc(check *C) { } quota := 111 vCpu := int64(1000) - guaranteed := float64(0.6) + guaranteed := "0.6" adminVdc.AdminVdc.Description = updateDescription adminVdc.AdminVdc.ComputeCapacity = computeCapacity adminVdc.AdminVdc.IsEnabled = false diff --git a/types/v56/types.go b/types/v56/types.go index 534905c64..41107b73d 100644 --- a/types/v56/types.go +++ b/types/v56/types.go @@ -394,8 +394,8 @@ type AdminVdc struct { Xmlns string `xml:"xmlns,attr"` Vdc - ResourceGuaranteedMemory float64 `xml:"ResourceGuaranteedMemory,omitempty"` - ResourceGuaranteedCpu float64 `xml:"ResourceGuaranteedCpu,omitempty"` + ResourceGuaranteedMemory string `xml:"ResourceGuaranteedMemory,omitempty"` + ResourceGuaranteedCpu string `xml:"ResourceGuaranteedCpu,omitempty"` VCpuInMhz int64 `xml:"VCpuInMhz,omitempty"` IsThinProvision bool `xml:"IsThinProvision,omitempty"` NetworkPoolReference *Reference `xml:"NetworkPoolReference,omitempty"` @@ -2461,3 +2461,16 @@ type QueryResultOrgVdcNetworkRecordType struct { IsIpScopeInherited bool `xml:"isIpScopeInherited,attr,omitempty"` Link []*Link `xml:"Link,omitempty"` } + +// Represents org VDC Network +// Reference: vCloud API 27.0 - Network Pool +// https://code.vmware.com/apis/72/vcloud-director#/doc/doc/types/VMWNetworkPoolType.html +type VMWNetworkPool struct { + HREF string `xml:"href,attr,omitempty"` + Id string `xml:"id,attr,omitempty"` + Type string `xml:"type,attr,omitempty"` + Name string `xml:"name,attr"` + Status int `xml:"status,attr,omitempty"` + Description string `xml:"netmask,omitempty"` + Tasks *TasksInProgress `xml:"Tasks,omitempty"` +} From db223e2830a3f41de9b5bdb0acaabe9968f4a0b4 Mon Sep 17 00:00:00 2001 From: Vaidotas Bauzys Date: Fri, 28 Jun 2019 10:03:19 +0300 Subject: [PATCH 04/11] Better fix for allowing serialize 0 and empty values Signed-off-by: Vaidotas Bauzys --- govcd/org_test.go | 6 +++--- types/v56/types.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/govcd/org_test.go b/govcd/org_test.go index a3b9674ff..8a7e2d703 100644 --- a/govcd/org_test.go +++ b/govcd/org_test.go @@ -577,7 +577,7 @@ func (vcd *TestVCD) Test_UpdateVdc(check *C) { } quota := 111 vCpu := int64(1000) - guaranteed := "0.6" + guaranteed := float64(0.6) adminVdc.AdminVdc.Description = updateDescription adminVdc.AdminVdc.ComputeCapacity = computeCapacity adminVdc.AdminVdc.IsEnabled = false @@ -587,8 +587,8 @@ func (vcd *TestVCD) Test_UpdateVdc(check *C) { adminVdc.AdminVdc.OverCommitAllowed = false adminVdc.AdminVdc.VCpuInMhz = vCpu adminVdc.AdminVdc.UsesFastProvisioning = false - adminVdc.AdminVdc.ResourceGuaranteedCpu = guaranteed - adminVdc.AdminVdc.ResourceGuaranteedMemory = guaranteed + adminVdc.AdminVdc.ResourceGuaranteedCpu = &guaranteed + adminVdc.AdminVdc.ResourceGuaranteedMemory = &guaranteed updatedVdc, err := adminVdc.Update() check.Assert(err, IsNil) diff --git a/types/v56/types.go b/types/v56/types.go index 41107b73d..c8e72e88d 100644 --- a/types/v56/types.go +++ b/types/v56/types.go @@ -394,8 +394,8 @@ type AdminVdc struct { Xmlns string `xml:"xmlns,attr"` Vdc - ResourceGuaranteedMemory string `xml:"ResourceGuaranteedMemory,omitempty"` - ResourceGuaranteedCpu string `xml:"ResourceGuaranteedCpu,omitempty"` + ResourceGuaranteedMemory *float64 `xml:"ResourceGuaranteedMemory,omitempty"` + ResourceGuaranteedCpu *float64 `xml:"ResourceGuaranteedCpu,omitempty"` VCpuInMhz int64 `xml:"VCpuInMhz,omitempty"` IsThinProvision bool `xml:"IsThinProvision,omitempty"` NetworkPoolReference *Reference `xml:"NetworkPoolReference,omitempty"` From f85306f16cd26659547c2df4617dcebb3ffaac13 Mon Sep 17 00:00:00 2001 From: Vaidotas Bauzys Date: Fri, 28 Jun 2019 11:46:53 +0300 Subject: [PATCH 05/11] Improve comments and other small improvements Signed-off-by: Vaidotas Bauzys --- govcd/org.go | 16 ++++++++-------- govcd/org_test.go | 4 ++-- types/v56/types.go | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/govcd/org.go b/govcd/org.go index acc557c6c..17cde6fee 100644 --- a/govcd/org.go +++ b/govcd/org.go @@ -98,13 +98,13 @@ func (org *Org) GetVdcByName(vdcname string) (Vdc, error) { } // Given an adminVdc with a valid HREF, the function refresh the adminVdc -// and updates the adminVdc data. Otherwise if the function fails, -// it returns an error. Users should use refresh whenever they have +// and updates the adminVdc data. Returns an error on failure +// Users should use refresh whenever they suspect // a stale vDC due to the creation/update/deletion of a resource -// within the org or the vDC itself. +// within the the vDC itself. func (adminVdc *AdminVdc) Refresh() error { - if *adminVdc == (AdminVdc{}) { - return fmt.Errorf("cannot refresh, Object is empty") + if *adminVdc == (AdminVdc{}) || adminVdc.AdminVdc.HREF == "" { + return fmt.Errorf("cannot refresh, Object is empty or HREF is empty") } // Empty struct before a new unmarshal, otherwise we end up with duplicate @@ -121,7 +121,7 @@ func (adminVdc *AdminVdc) Refresh() error { return nil } -// GetAdminVdcByName function uses user specifies valid vdc name and then returns a admin vDC object. +// GetAdminVdcByName function uses a valid VDC name and returns a admin VDC object. // If no vDC is found, then it returns an empty vDC and no error. // Otherwise it returns an empty vDC and an error. func (adminOrg *AdminOrg) GetAdminVdcByName(vdcname string) (AdminVdc, error) { @@ -139,7 +139,7 @@ func (adminOrg *AdminOrg) GetAdminVdcByName(vdcname string) (AdminVdc, error) { return AdminVdc{}, nil } -// Function UpdateAsync() updated vCD from current vCD struct contents. +// UpdateAsync updates VDC from current VDC struct contents. // Any differences that may be legally applied will be updated. // Returns an error if the call to vCD fails. // API Documentation: https://vdc-repo.vmware.com/vmwb-repository/dcr-public/7a028e78-bd37-4a6a-8298-9c26c7eeb9aa/09142237-dd46-4dee-8326-e07212fb63a8/doc/doc/operations/PUT-Vdc.html @@ -152,7 +152,7 @@ func (adminVdc *AdminVdc) UpdateAsync() (Task, error) { types.MimeAdminVDC, "error updating vDC: %s", adminVdc.AdminVdc) } -// Function Update() updated vCD from current vCD struct contents. +// Update function updates an Admin VDC from current VDC struct contents. // Any differences that may be legally applied will be updated. // Returns an empty AdminVdc struct and error if the call to vCD fails. // API Documentation: https://vdc-repo.vmware.com/vmwb-repository/dcr-public/7a028e78-bd37-4a6a-8298-9c26c7eeb9aa/09142237-dd46-4dee-8326-e07212fb63a8/doc/doc/operations/PUT-Vdc.html diff --git a/govcd/org_test.go b/govcd/org_test.go index 8a7e2d703..962aa0481 100644 --- a/govcd/org_test.go +++ b/govcd/org_test.go @@ -421,7 +421,7 @@ func (vcd *TestVCD) Test_GetAdminCatalog(check *C) { } } -// Tests Refresh for Vdc by updating the Vdc and then asserting if the +// Tests Refresh for VDC by updating it and then asserting if the // variable is updated. func (vcd *TestVCD) Test_RefreshVdc(check *C) { @@ -543,7 +543,7 @@ func setupVDc(vcd *TestVCD, check *C) (AdminOrg, error, *types.VdcConfiguration) return adminOrg, err, vdcConfiguration } -// Tests Vdc by updating the Vdc and then asserting if the +// Tests VDC by updating it and then asserting if the // variable is updated. func (vcd *TestVCD) Test_UpdateVdc(check *C) { adminOrg, err, vdcConfiguration := setupVDc(vcd, check) diff --git a/types/v56/types.go b/types/v56/types.go index c8e72e88d..76f03400a 100644 --- a/types/v56/types.go +++ b/types/v56/types.go @@ -367,7 +367,7 @@ type Vdc struct { ID string `xml:"id,attr,omitempty"` OperationKey string `xml:"operationKey,attr,omitempty"` Name string `xml:"name,attr"` - Status string `xml:"status,attr,omitempty"` + Status int `xml:"status,attr,omitempty"` Link LinkList `xml:"Link,omitempty"` Description string `xml:"Description,omitempty"` From e8e0f571ca65a228098703f7392cc4348b3992a0 Mon Sep 17 00:00:00 2001 From: Vaidotas Bauzys Date: Mon, 1 Jul 2019 11:15:19 +0300 Subject: [PATCH 06/11] Fix comments Signed-off-by: Vaidotas Bauzys --- govcd/org.go | 12 ++++++------ govcd/org_test.go | 4 ++-- types/v56/types.go | 22 +++++++++++----------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/govcd/org.go b/govcd/org.go index 17cde6fee..564321995 100644 --- a/govcd/org.go +++ b/govcd/org.go @@ -100,8 +100,8 @@ func (org *Org) GetVdcByName(vdcname string) (Vdc, error) { // Given an adminVdc with a valid HREF, the function refresh the adminVdc // and updates the adminVdc data. Returns an error on failure // Users should use refresh whenever they suspect -// a stale vDC due to the creation/update/deletion of a resource -// within the the vDC itself. +// a stale VDC due to the creation/update/deletion of a resource +// within the the VDC itself. func (adminVdc *AdminVdc) Refresh() error { if *adminVdc == (AdminVdc{}) || adminVdc.AdminVdc.HREF == "" { return fmt.Errorf("cannot refresh, Object is empty or HREF is empty") @@ -112,7 +112,7 @@ func (adminVdc *AdminVdc) Refresh() error { unmarshalledAdminVdc := &types.AdminVdc{} _, err := adminVdc.client.ExecuteRequest(adminVdc.AdminVdc.HREF, http.MethodGet, - "", "error refreshing vDC: %s", nil, unmarshalledAdminVdc) + "", "error refreshing VDC: %s", nil, unmarshalledAdminVdc) if err != nil { return err } @@ -122,8 +122,8 @@ func (adminVdc *AdminVdc) Refresh() error { } // GetAdminVdcByName function uses a valid VDC name and returns a admin VDC object. -// If no vDC is found, then it returns an empty vDC and no error. -// Otherwise it returns an empty vDC and an error. +// If no VDC is found, then it returns an empty VDC and no error. +// Otherwise it returns an empty VDC and an error. func (adminOrg *AdminOrg) GetAdminVdcByName(vdcname string) (AdminVdc, error) { for _, vdcs := range adminOrg.AdminOrg.Vdcs.Vdcs { if vdcs.Name == vdcname { @@ -149,7 +149,7 @@ func (adminVdc *AdminVdc) UpdateAsync() (Task, error) { // Return the task return adminVdc.client.ExecuteTaskRequest(adminVdc.AdminVdc.HREF, http.MethodPut, - types.MimeAdminVDC, "error updating vDC: %s", adminVdc.AdminVdc) + types.MimeAdminVDC, "error updating VDC: %s", adminVdc.AdminVdc) } // Update function updates an Admin VDC from current VDC struct contents. diff --git a/govcd/org_test.go b/govcd/org_test.go index 962aa0481..b2f1c7f02 100644 --- a/govcd/org_test.go +++ b/govcd/org_test.go @@ -608,8 +608,8 @@ func (vcd *TestVCD) Test_UpdateVdc(check *C) { // Tests org function GetAdminVdcByName with the vdc specified // in the config file. Then tests with a vdc that doesn't exist. -// Fails if the config file name doesn't match with the found vDC, or -// if the invalid vDC is found by the function. Also tests an vDC +// Fails if the config file name doesn't match with the found VDC, or +// if the invalid VDC is found by the function. Also tests an VDC // that doesn't exist. Asserts an error if the function finds it or // if the error is not nil. func (vcd *TestVCD) Test_GetAdminVdcByName(check *C) { diff --git a/types/v56/types.go b/types/v56/types.go index 76f03400a..420fb457e 100644 --- a/types/v56/types.go +++ b/types/v56/types.go @@ -315,10 +315,10 @@ type InstantiationParams struct { // SnapshotSection SnapshotSection `xml:"SnapshotSection,omitempty"` } -// OrgVDCNetwork represents an Org vDC network in the vCloud model. +// OrgVDCNetwork represents an Org VDC network in the vCloud model. // Type: OrgVdcNetworkType // Namespace: http://www.vmware.com/vcloud/v1.5 -// Description: Represents an Org vDC network in the vCloud model. +// Description: Represents an Org VDC network in the vCloud model. // Since: 5.1 type OrgVDCNetwork struct { XMLName xml.Name `xml:"OrgVdcNetwork"` @@ -334,7 +334,7 @@ type OrgVDCNetwork struct { EdgeGateway *Reference `xml:"EdgeGateway,omitempty"` IsShared bool `xml:"IsShared"` Link []Link `xml:"Link,omitempty"` - ServiceConfig *GatewayFeatures `xml:"ServiceConfig,omitempty"` // Specifies the service configuration for an isolated Org vDC networks + ServiceConfig *GatewayFeatures `xml:"ServiceConfig,omitempty"` // Specifies the service configuration for an isolated Org VDC networks Tasks *TasksInProgress `xml:"Tasks,omitempty"` } @@ -356,10 +356,10 @@ type Capabilities struct { SupportedHardwareVersions *SupportedHardwareVersions `xml:"SupportedHardwareVersions,omitempty"` // Read-only list of virtual hardware versions supported by this vDC. } -// Vdc represents the user view of an organization vDC. +// Vdc represents the user view of an organization VDC. // Type: VdcType // Namespace: http://www.vmware.com/vcloud/v1.5 -// Description: Represents the user view of an organization vDC. +// Description: Represents the user view of an organization VDC. // Since: 0.9 type Vdc struct { HREF string `xml:"href,attr,omitempty"` @@ -385,10 +385,10 @@ type Vdc struct { VdcStorageProfiles []*VdcStorageProfiles `xml:"VdcStorageProfiles"` } -// AdminVdc represents the admin view of an organization vDC. +// AdminVdc represents the admin view of an organization VDC. // Type: AdminVdcType // Namespace: http://www.vmware.com/vcloud/v1.5 -// Description: Represents the admin view of an organization vDC. +// Description: Represents the admin view of an organization VDC. // Since: 0.9 type AdminVdc struct { Xmlns string `xml:"xmlns,attr"` @@ -422,7 +422,7 @@ type VdcStorageProfile struct { // VdcConfiguration models the payload for creating a VDC. // Type: CreateVdcParamsType // Namespace: http://www.vmware.com/vcloud/v1.5 -// Description: Parameters for creating an organization vDC +// Description: Parameters for creating an organization VDC // Since: 5.1 // https://code.vmware.com/apis/220/vcloud#/doc/doc/types/CreateVdcParamsType.html type VdcConfiguration struct { @@ -492,10 +492,10 @@ type CapacityWithUsage struct { Overhead int64 `xml:"Overhead,omitempty"` // not available anymore from API v30.0 } -// ComputeCapacity represents vDC compute capacity. +// ComputeCapacity represents VDC compute capacity. // Type: ComputeCapacityType // Namespace: http://www.vmware.com/vcloud/v1.5 -// Description: Represents vDC compute capacity. +// Description: Represents VDC compute capacity. // Since: 0.9 type ComputeCapacity struct { CPU *CapacityWithUsage `xml:"Cpu"` @@ -1997,7 +1997,7 @@ type QueryResultRecordsType struct { AdminDiskRecord []*DiskRecordType `xml:"AdminDiskRecord"` // A record representing a independent Disk. VirtualCenterRecord []*QueryResultVirtualCenterRecordType `xml:"VirtualCenterRecord"` // A record representing a vSphere server PortGroupRecord []*PortGroupRecordType `xml:"PortgroupRecord"` // A record representing a port group - OrgVdcNetworkRecord []*QueryResultOrgVdcNetworkRecordType `xml:"QueryResultOrgVdcNetworkRecordType"` // A record representing a org vDC network + OrgVdcNetworkRecord []*QueryResultOrgVdcNetworkRecordType `xml:"QueryResultOrgVdcNetworkRecordType"` // A record representing a org VDC network } // QueryResultEdgeGatewayRecordType represents an edge gateway record as query result. From 6366deeb420cf0e6651e870837acc96a784cc915 Mon Sep 17 00:00:00 2001 From: Vaidotas Bauzys Date: Mon, 1 Jul 2019 11:52:32 +0300 Subject: [PATCH 07/11] Fix test Signed-off-by: Vaidotas Bauzys --- govcd/org_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/govcd/org_test.go b/govcd/org_test.go index b2f1c7f02..c48a62098 100644 --- a/govcd/org_test.go +++ b/govcd/org_test.go @@ -602,8 +602,8 @@ func (vcd *TestVCD) Test_UpdateVdc(check *C) { check.Assert(updatedVdc.AdminVdc.OverCommitAllowed, Equals, false) check.Assert(updatedVdc.AdminVdc.VCpuInMhz, Equals, vCpu) check.Assert(updatedVdc.AdminVdc.UsesFastProvisioning, Equals, false) - check.Assert(updatedVdc.AdminVdc.ResourceGuaranteedCpu, Equals, guaranteed) - check.Assert(updatedVdc.AdminVdc.ResourceGuaranteedMemory, Equals, guaranteed) + check.Assert(*updatedVdc.AdminVdc.ResourceGuaranteedCpu, Equals, guaranteed) + check.Assert(*updatedVdc.AdminVdc.ResourceGuaranteedMemory, Equals, guaranteed) } // Tests org function GetAdminVdcByName with the vdc specified From 0a4f0cb27a17c2a1c85a191232d701b5d1292d93 Mon Sep 17 00:00:00 2001 From: Vaidotas Bauzys Date: Mon, 1 Jul 2019 12:07:57 +0300 Subject: [PATCH 08/11] Fix test Signed-off-by: Vaidotas Bauzys --- govcd/org_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/govcd/org_test.go b/govcd/org_test.go index c48a62098..d1f3bd4f3 100644 --- a/govcd/org_test.go +++ b/govcd/org_test.go @@ -602,8 +602,8 @@ func (vcd *TestVCD) Test_UpdateVdc(check *C) { check.Assert(updatedVdc.AdminVdc.OverCommitAllowed, Equals, false) check.Assert(updatedVdc.AdminVdc.VCpuInMhz, Equals, vCpu) check.Assert(updatedVdc.AdminVdc.UsesFastProvisioning, Equals, false) - check.Assert(*updatedVdc.AdminVdc.ResourceGuaranteedCpu, Equals, guaranteed) - check.Assert(*updatedVdc.AdminVdc.ResourceGuaranteedMemory, Equals, guaranteed) + check.Assert(*updatedVdc.AdminVdc.ResourceGuaranteedCpu-guaranteed < 0.001, Equals, true) + check.Assert(*updatedVdc.AdminVdc.ResourceGuaranteedMemory-guaranteed < 0.001, Equals, true) } // Tests org function GetAdminVdcByName with the vdc specified From 3093ef1faa8d5c46b63f0b8283a744bfd2ed9440 Mon Sep 17 00:00:00 2001 From: Vaidotas Bauzys Date: Mon, 1 Jul 2019 12:12:34 +0300 Subject: [PATCH 09/11] Fix test Signed-off-by: Vaidotas Bauzys --- govcd/org_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/govcd/org_test.go b/govcd/org_test.go index d1f3bd4f3..454fb0fa4 100644 --- a/govcd/org_test.go +++ b/govcd/org_test.go @@ -8,6 +8,7 @@ package govcd import ( "fmt" + "math" "time" "github.com/vmware/go-vcloud-director/v2/types/v56" @@ -602,8 +603,8 @@ func (vcd *TestVCD) Test_UpdateVdc(check *C) { check.Assert(updatedVdc.AdminVdc.OverCommitAllowed, Equals, false) check.Assert(updatedVdc.AdminVdc.VCpuInMhz, Equals, vCpu) check.Assert(updatedVdc.AdminVdc.UsesFastProvisioning, Equals, false) - check.Assert(*updatedVdc.AdminVdc.ResourceGuaranteedCpu-guaranteed < 0.001, Equals, true) - check.Assert(*updatedVdc.AdminVdc.ResourceGuaranteedMemory-guaranteed < 0.001, Equals, true) + check.Assert(math.Abs(*updatedVdc.AdminVdc.ResourceGuaranteedCpu-guaranteed) < 0.001, Equals, true) + check.Assert(math.Abs(*updatedVdc.AdminVdc.ResourceGuaranteedMemory-guaranteed) < 0.001, Equals, true) } // Tests org function GetAdminVdcByName with the vdc specified From 96c94694d9144434251de480e666053236580e07 Mon Sep 17 00:00:00 2001 From: Vaidotas Bauzys Date: Mon, 1 Jul 2019 12:27:21 +0300 Subject: [PATCH 10/11] Add changelog Signed-off-by: Vaidotas Bauzys --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86ceb0def..a58c9ee53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ * Added edge gateway create/delete functions [#130](https://github.com/vmware/go-vcloud-director/issues/130). * Added load balancer service monitor [#196](https://github.com/vmware/go-vcloud-director/pull/196) * Added load balancer server pool [#205](https://github.com/vmware/go-vcloud-director/pull/205) +* Added vCD meta data create/get/delete functions [#206](https://github.com/vmware/go-vcloud-director/pull/206) ## 2.2.0 (May 15, 2019) From 642be46d76d803149015e823988251aa6db5beaf Mon Sep 17 00:00:00 2001 From: Vaidotas Bauzys Date: Mon, 1 Jul 2019 12:28:37 +0300 Subject: [PATCH 11/11] Fix changelog message Signed-off-by: Vaidotas Bauzys --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a58c9ee53..db0f968fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ * Added edge gateway create/delete functions [#130](https://github.com/vmware/go-vcloud-director/issues/130). * Added load balancer service monitor [#196](https://github.com/vmware/go-vcloud-director/pull/196) * Added load balancer server pool [#205](https://github.com/vmware/go-vcloud-director/pull/205) -* Added vCD meta data create/get/delete functions [#206](https://github.com/vmware/go-vcloud-director/pull/206) +* Added functions for refreshing, getting and update Org VDC [#206](https://github.com/vmware/go-vcloud-director/pull/206) ## 2.2.0 (May 15, 2019)