Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api bump from v33.0 to v35.0 #434

Merged
merged 19 commits into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changes/v2.15.0/434-improvements.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Bumped Default API Version to V34.0 [GH-434]
2 changes: 1 addition & 1 deletion govcd/api_vcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func NewVCDClient(vcdEndpoint url.URL, insecure bool, options ...VCDClientOption
// Setting defaults
vcdClient := &VCDClient{
Client: Client{
APIVersion: "33.0", // supported by 10.0+
APIVersion: "34.0", // supported by 10.1+
mikeletux marked this conversation as resolved.
Show resolved Hide resolved
// UserAgent cannot embed exact version by default because this is source code and is supposed to be used by programs,
// but any client can customize or disable it at all using WithHttpUserAgent() configuration options function.
UserAgent: "go-vcloud-director",
Expand Down
46 changes: 34 additions & 12 deletions govcd/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,14 @@ func isTcpPortOpen(host, port string, timeout int) bool {

}

// moved from vapp_test.go
func createVappForTest(vcd *TestVCD, vappName string) (*VApp, error) {
// deployVappForTest aims to replace createVappForTest
func deployVappForTest(vcd *TestVCD, vappName string) (*VApp, error) {
// Populate OrgVDCNetwork
var networks []*types.OrgVDCNetwork
net, err := vcd.vdc.GetOrgVdcNetworkByName(vcd.config.VCD.Network.Net1, false)
if err != nil {
return nil, fmt.Errorf("error finding network : %s", err)
}
networks = append(networks, net.OrgVDCNetwork)

// Populate Catalog
Didainius marked this conversation as resolved.
Show resolved Hide resolved
cat, err := vcd.org.GetCatalogByName(vcd.config.VCD.Catalog.Name, false)
if err != nil || cat == nil {
Expand All @@ -294,22 +293,45 @@ func createVappForTest(vcd *TestVCD, vappName string) (*VApp, error) {
if err != nil {
return nil, fmt.Errorf("error finding storage profile: %s", err)
}
// Compose VApp
task, err := vcd.vdc.ComposeVApp(networks, vAppTemplate, storageProfileRef, vappName, "description", true)

// Create empty vApp
vapp, err := vcd.vdc.CreateRawVApp(vappName, "description")
if err != nil {
return nil, fmt.Errorf("error composing vapp: %s", err)
return nil, fmt.Errorf("error creating vapp: %s", err)
}

// After a successful creation, the entity is added to the cleanup list.
// If something fails after this point, the entity will be removed
AddToCleanupList(vappName, "vapp", "", "createTestVapp")
err = task.WaitTaskCompletion()

// Create vApp networking
vAppNetworkConfig, err := vapp.AddOrgNetwork(&VappNetworkSettings{}, net.OrgVDCNetwork, false)
if err != nil {
return nil, fmt.Errorf("error creating vApp network. %s", err)
}

// Create VM with only one NIC connected to vapp_net
networkConnectionSection := &types.NetworkConnectionSection{
PrimaryNetworkConnectionIndex: 0,
}

netConn := &types.NetworkConnection{
Network: vAppNetworkConfig.NetworkConfig[0].NetworkName,
IsConnected: true,
NetworkConnectionIndex: 0,
IPAddressAllocationMode: types.IPAllocationModePool,
}

networkConnectionSection.NetworkConnection = append(networkConnectionSection.NetworkConnection, netConn)

task, err := vapp.AddNewVMWithStorageProfile("test_vm", vAppTemplate, networkConnectionSection, &storageProfileRef, true)
if err != nil {
return nil, fmt.Errorf("error composing vapp: %s", err)
return nil, fmt.Errorf("error creating the VM: %s", err)
}
// Get VApp
vapp, err := vcd.vdc.GetVAppByName(vappName, true)

err = task.WaitTaskCompletion()
if err != nil {
return nil, fmt.Errorf("error getting vapp: %s", err)
return nil, fmt.Errorf("error while waiting for the VM to be created %s", err)
}

err = vapp.BlockWhileStatus("UNRESOLVED", vapp.client.MaxRetryTimeout)
Expand Down
2 changes: 1 addition & 1 deletion govcd/vapp_network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (vcd *TestVCD) Test_UpdateNetworkFirewallRules(check *C) {
func (vcd *TestVCD) prepareVappWithVappNetwork(check *C, vappName, orgVdcNetworkName string) (*VApp, string, *types.NetworkConfigSection, error) {
fmt.Printf("Running: %s\n", check.TestName())

vapp, err := createVappForTest(vcd, vappName)
vapp, err := deployVappForTest(vcd, vappName)
check.Assert(err, IsNil)
check.Assert(vapp, NotNil)

Expand Down
24 changes: 12 additions & 12 deletions govcd/vapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ func (vcd *TestVCD) Test_AddNewVMNilNIC(check *C) {
vapptemplate, err := catitem.GetVAppTemplate()
check.Assert(err, IsNil)

vapp, err := createVappForTest(vcd, "Test_AddNewVMNilNIC")
vapp, err := deployVappForTest(vcd, "Test_AddNewVMNilNIC")
check.Assert(err, IsNil)
check.Assert(vapp, NotNil)
task, err := vapp.AddNewVM(check.TestName(), vapptemplate, nil, true)
Expand Down Expand Up @@ -511,7 +511,7 @@ func (vcd *TestVCD) Test_AddNewVMMultiNIC(check *C) {
vapptemplate, err := catitem.GetVAppTemplate()
check.Assert(err, IsNil)

vapp, err := createVappForTest(vcd, "Test_AddNewVMMultiNIC")
vapp, err := deployVappForTest(vcd, "Test_AddNewVMMultiNIC")
check.Assert(err, IsNil)
check.Assert(vapp, NotNil)

Expand Down Expand Up @@ -751,7 +751,7 @@ func (vcd *TestVCD) Test_GetVM(check *C) {
func (vcd *TestVCD) Test_AddAndRemoveIsolatedVappNetwork(check *C) {
fmt.Printf("Running: %s\n", check.TestName())

vapp, err := createVappForTest(vcd, "Test_AddAndRemoveIsolatedVappNetwork")
vapp, err := deployVappForTest(vcd, "Test_AddAndRemoveIsolatedVappNetwork")
check.Assert(err, IsNil)
check.Assert(vapp, NotNil)

Expand Down Expand Up @@ -838,7 +838,7 @@ func (vcd *TestVCD) Test_AddAndRemoveNatVappNetwork(check *C) {
check.Skip("Skipping test because no network was given")
}

vapp, err := createVappForTest(vcd, "Test_AddAndRemoveNatVappNetwork")
vapp, err := deployVappForTest(vcd, "Test_AddAndRemoveNatVappNetwork")
check.Assert(err, IsNil)
check.Assert(vapp, NotNil)

Expand Down Expand Up @@ -935,7 +935,7 @@ func (vcd *TestVCD) Test_UpdateVappNetwork(check *C) {
check.Skip("Skipping test because no network was given")
}

vapp, err := createVappForTest(vcd, "Test_UpdateVappNetwork")
vapp, err := deployVappForTest(vcd, "Test_UpdateVappNetwork")
check.Assert(err, IsNil)
check.Assert(vapp, NotNil)

Expand Down Expand Up @@ -1094,7 +1094,7 @@ func (vcd *TestVCD) Test_UpdateVappNetwork(check *C) {
func (vcd *TestVCD) Test_AddAndRemoveVappNetworkWithMinimumValues(check *C) {
fmt.Printf("Running: %s\n", check.TestName())

vapp, err := createVappForTest(vcd, "Test_AddAndRemoveVappNetworkWithMinimumValues")
vapp, err := deployVappForTest(vcd, "Test_AddAndRemoveVappNetworkWithMinimumValues")
check.Assert(err, IsNil)
check.Assert(vapp, NotNil)

Expand Down Expand Up @@ -1164,7 +1164,7 @@ func (vcd *TestVCD) Test_AddAndRemoveOrgVappNetworkWithMinimumValues(check *C) {
check.Skip("Skipping test because no network was given")
}

vapp, err := createVappForTest(vcd, "Test_AddAndRemoveOrgVappNetworkWithMinimumValues")
vapp, err := deployVappForTest(vcd, "Test_AddAndRemoveOrgVappNetworkWithMinimumValues")
check.Assert(err, IsNil)
check.Assert(vapp, NotNil)

Expand Down Expand Up @@ -1198,7 +1198,7 @@ func (vcd *TestVCD) Test_AddAndRemoveOrgVappNetworkWithMinimumValues(check *C) {

check.Assert(networkFound.Configuration.ParentNetwork.Name, Equals, vcd.config.VCD.Network.Net1)

err = vcd.vapp.Refresh()
err = vapp.Refresh()
check.Assert(err, IsNil)
vappNetworkConfig, err = vapp.RemoveNetwork(vcd.config.VCD.Network.Net1)
check.Assert(err, IsNil)
Expand Down Expand Up @@ -1226,7 +1226,7 @@ func (vcd *TestVCD) Test_AddAndRemoveOrgVappNetwork(check *C) {
check.Skip("Skipping test because no network was given")
}

vapp, err := createVappForTest(vcd, "Test_AddAndRemoveOrgVappNetwork")
vapp, err := deployVappForTest(vcd, "Test_AddAndRemoveOrgVappNetwork")
check.Assert(err, IsNil)
check.Assert(vapp, NotNil)

Expand Down Expand Up @@ -1289,7 +1289,7 @@ func (vcd *TestVCD) Test_UpdateOrgVappNetwork(check *C) {
check.Skip("Skipping test because no network was given")
}

vapp, err := createVappForTest(vcd, "Test_UpdateOrgVappNetwork")
vapp, err := deployVappForTest(vcd, "Test_UpdateOrgVappNetwork")
check.Assert(err, IsNil)
check.Assert(vapp, NotNil)

Expand Down Expand Up @@ -1420,7 +1420,7 @@ func (vcd *TestVCD) Test_AddNewVMFromMultiVmTemplate(check *C) {
returnedVappTemplate, err := catalog.GetVappTemplateByHref(vmInTemplateRecord.HREF)
check.Assert(err, IsNil)

vapp, err := createVappForTest(vcd, "Test_AddNewVMFromMultiVmTemplate")
vapp, err := deployVappForTest(vcd, "Test_AddNewVMFromMultiVmTemplate")
check.Assert(err, IsNil)
check.Assert(vapp, NotNil)
task, err := vapp.AddNewVM(check.TestName(), *returnedVappTemplate, nil, true)
Expand Down Expand Up @@ -1469,7 +1469,7 @@ func (vcd *TestVCD) Test_AddNewVMWithComputeCapacity(check *C) {
vapptemplate, err := catitem.GetVAppTemplate()
check.Assert(err, IsNil)

vapp, err := createVappForTest(vcd, "Test_AddNewVMWithComputeCapacity")
vapp, err := deployVappForTest(vcd, "Test_AddNewVMWithComputeCapacity")
check.Assert(err, IsNil)
check.Assert(vapp, NotNil)

Expand Down
6 changes: 3 additions & 3 deletions govcd/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ func (vcd *TestVCD) Test_AddNewEmptyVMMultiNIC(check *C) {
check.Skip("skipping test because no vApp is found")
}

vapp, err := createVappForTest(vcd, "Test_AddNewEmptyVMMultiNIC")
vapp, err := deployVappForTest(vcd, "Test_AddNewEmptyVMMultiNIC")
check.Assert(err, IsNil)
check.Assert(vapp, NotNil)

Expand Down Expand Up @@ -1455,7 +1455,7 @@ func (vcd *TestVCD) Test_UpdateVmCpuAndMemoryHotAdd(check *C) {
}

func (vcd *TestVCD) Test_AddNewEmptyVMWithVmComputePolicyAndUpdate(check *C) {
vapp, err := createVappForTest(vcd, "Test_AddNewEmptyVMWithVmComputePolicy")
vapp, err := deployVappForTest(vcd, "Test_AddNewEmptyVMWithVmComputePolicy")
check.Assert(err, IsNil)
check.Assert(vapp, NotNil)

Expand Down Expand Up @@ -1609,7 +1609,7 @@ func (vcd *TestVCD) Test_VMUpdateStorageProfile(check *C) {
check.Skip("Skipping test because both storage profiles have to be configured")
}

vapp, err := createVappForTest(vcd, "Test_VMUpdateStorageProfile")
vapp, err := deployVappForTest(vcd, "Test_VMUpdateStorageProfile")
check.Assert(err, IsNil)
check.Assert(vapp, NotNil)

Expand Down
8 changes: 4 additions & 4 deletions samples/openapi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ func main() {
os.Exit(3)
}

if vcdCli.Client.APIVCDMaxVersionIs("< 33.0") {
fmt.Println("This example requires VCD API to support at least version 33.0 (VCD 10.0) to use '1.0.0/auditTrail' endpoint")
if vcdCli.Client.APIVCDMaxVersionIs("< 34.0") {
Didainius marked this conversation as resolved.
Show resolved Hide resolved
fmt.Println("This example requires VCD API to support at least version 34.0 (VCD 10.1) to use '1.0.0/auditTrail' endpoint")
os.Exit(4)
}

Expand Down Expand Up @@ -87,7 +87,7 @@ func openAPIGetRawJsonAuditTrail(vcdClient *govcd.VCDClient) {
queryParams.Add("filter", "timestamp=gt="+filterTime)

allResponses := []json.RawMessage{{}}
err = vcdClient.Client.OpenApiGetAllItems("33.0", urlRef, queryParams, &allResponses, nil)
err = vcdClient.Client.OpenApiGetAllItems("34.0", urlRef, queryParams, &allResponses, nil)
Didainius marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -145,7 +145,7 @@ func openAPIGetStructAuditTrail(vcdClient *govcd.VCDClient) {
filterTime := time.Now().Add(-12 * time.Hour).Format(types.FiqlQueryTimestampFormat)
queryParams.Add("filter", "timestamp=gt="+filterTime)

err = vcdClient.Client.OpenApiGetAllItems("33.0", urlRef, queryParams, &response, nil)
err = vcdClient.Client.OpenApiGetAllItems("34.0", urlRef, queryParams, &response, nil)
Didainius marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
panic(err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
<Version>33.0</Version>
<LoginUrl>https://192.168.1.109/api/sessions</LoginUrl>
</VersionInfo>
<VersionInfo deprecated="false">
<Version>34.0</Version>
<LoginUrl>https://192.168.1.109/api/sessions</LoginUrl>
</VersionInfo>
<VersionInfo deprecated="true">
<Version>5.5</Version>
<LoginUrl>https://192.168.1.109/api/sessions</LoginUrl>
Expand Down