Skip to content

Commit

Permalink
Add load balancer virtual server CRUD (#215)
Browse files Browse the repository at this point in the history
* Add load balancer virtual server CRUD
* Add integration test
* Add fix/workaround for issue #218
  • Loading branch information
Didainius authored Jul 22, 2019
1 parent 3f6bb23 commit 828dbc8
Show file tree
Hide file tree
Showing 10 changed files with 857 additions and 53 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Added load balancer server pool [#205](https://github.com/vmware/go-vcloud-director/pull/205)
* Added load balancer application profile [#208](https://github.com/vmware/go-vcloud-director/pull/208)
* Added load balancer application rule [#212](https://github.com/vmware/go-vcloud-director/pull/212)
* Added load balancer virtual server [#215](https://github.com/vmware/go-vcloud-director/pull/215)
* Added functions for refreshing, getting and update Org VDC [#206](https://github.com/vmware/go-vcloud-director/pull/206)
* Added VDC meta data create/get/delete functions [#203](https://github.com/vmware/go-vcloud-director/pull/203)
* Added org user create/delete/update functions [#18](https://github.com/vmware/go-vcloud-director/issues/18)
Expand Down
55 changes: 48 additions & 7 deletions govcd/api_vcd_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build api functional catalog vapp gateway network org query extnetwork task vm vdc system disk lb lbAppRule lbAppProfile lbServerPool lbServiceMonitor user ALL
// +build api functional catalog vapp gateway network org query extnetwork task vm vdc system disk lb lbAppRule lbAppProfile lbServerPool lbServiceMonitor lbVirtualServer user ALL

/*
* Copyright 2019 VMware, Inc. All rights reserved. Licensed under the Apache v2 License.
Expand Down Expand Up @@ -62,6 +62,8 @@ const (
TestLBServerPool = "TestLBServerPool"
TestLBAppProfile = "TestLBAppProfile"
TestLBAppRule = "TestLBAppRule"
TestLBVirtualServer = "TestLBVirtualServer"
TestLB = "TestLB"
)

const (
Expand Down Expand Up @@ -128,8 +130,9 @@ type TestConfig struct {
OVAChunkedPath string `yaml:"ovaChunkedPath,omitempty"`
} `yaml:"ova"`
Media struct {
MediaPath string `yaml:"mediaPath,omitempty"`
Media string `yaml:"mediaName,omitempty"`
MediaPath string `yaml:"mediaPath,omitempty"`
Media string `yaml:"mediaName,omitempty"`
PhotonOsOvaPath string `yaml:"photonOsOvaPath,omitempty"`
} `yaml:"media"`
}

Expand Down Expand Up @@ -366,8 +369,9 @@ func getOrgVdcEdgeByNames(vcd *TestVCD, orgName, vdcName, edgeName string) (Org,
}

edge, err := vdc.FindEdgeGateway(edgeName)

if err != nil {
vcd.infoCleanup("could not find edge '%s'", vdcName)
vcd.infoCleanup("could not find edge '%s': %s", edgeName, err)
}
return org, vdc, edge, nil
}
Expand Down Expand Up @@ -687,10 +691,13 @@ func (vcd *TestVCD) removeLeftoverEntities(entity CleanupEntity) {
}

err = edge.DeleteLBServiceMonitorByName(entity.Name)
if err != nil {
if err != nil && strings.Contains(err.Error(), ErrorEntityNotFound.Error()) {
vcd.infoCleanup(notFoundMsg, entity.EntityType, entity.Name)
return
}
if err != nil {
vcd.infoCleanup(notDeletedMsg, entity.EntityType, entity.Name, err)
}

vcd.infoCleanup(removedMsg, entity.EntityType, entity.Name, entity.CreatedBy)
return
Expand All @@ -709,10 +716,13 @@ func (vcd *TestVCD) removeLeftoverEntities(entity CleanupEntity) {
}

err = edge.DeleteLBServerPoolByName(entity.Name)
if err != nil {
if err != nil && strings.Contains(err.Error(), ErrorEntityNotFound.Error()) {
vcd.infoCleanup(notFoundMsg, entity.EntityType, entity.Name)
return
}
if err != nil {
vcd.infoCleanup(notDeletedMsg, entity.EntityType, entity.Name, err)
}

vcd.infoCleanup(removedMsg, entity.EntityType, entity.Name, entity.CreatedBy)
return
Expand All @@ -730,10 +740,38 @@ func (vcd *TestVCD) removeLeftoverEntities(entity CleanupEntity) {
}

err = edge.DeleteLBAppProfileByName(entity.Name)
if err != nil && strings.Contains(err.Error(), ErrorEntityNotFound.Error()) {
vcd.infoCleanup(notFoundMsg, entity.EntityType, entity.Name)
return
}
if err != nil {
vcd.infoCleanup(notDeletedMsg, entity.EntityType, entity.Name, err)
}

vcd.infoCleanup(removedMsg, entity.EntityType, entity.Name, entity.CreatedBy)
return

case "lbVirtualServer":
if entity.Parent == "" {
vcd.infoCleanup("removeLeftoverEntries: [ERROR] No parent specified '%s'\n", entity.Name)
return
}

orgName, vdcName, edgeName := splitParent(entity.Parent, "|")

_, _, edge, err := getOrgVdcEdgeByNames(vcd, orgName, vdcName, edgeName)
if err != nil {
vcd.infoCleanup("removeLeftoverEntries: [ERROR] %s \n", err)
}

err = edge.DeleteLBVirtualServerByName(entity.Name)
if err != nil && strings.Contains(err.Error(), ErrorEntityNotFound.Error()) {
vcd.infoCleanup(notFoundMsg, entity.EntityType, entity.Name)
return
}
if err != nil {
vcd.infoCleanup(notDeletedMsg, entity.EntityType, entity.Name, err)
}

vcd.infoCleanup(removedMsg, entity.EntityType, entity.Name, entity.CreatedBy)
return
Expand All @@ -751,10 +789,13 @@ func (vcd *TestVCD) removeLeftoverEntities(entity CleanupEntity) {
}

err = edge.DeleteLBAppRuleByName(entity.Name)
if err != nil {
if err != nil && strings.Contains(err.Error(), ErrorEntityNotFound.Error()) {
vcd.infoCleanup(notFoundMsg, entity.EntityType, entity.Name)
return
}
if err != nil {
vcd.infoCleanup(notDeletedMsg, entity.EntityType, entity.Name, err)
}

vcd.infoCleanup(removedMsg, entity.EntityType, entity.Name, entity.CreatedBy)
return
Expand Down
Loading

0 comments on commit 828dbc8

Please sign in to comment.