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

Add NSX-T Firewall Group Support (Security Groups and IP Sets) #368

Merged
merged 16 commits into from
May 11, 2021
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@
structure does not list child Catalogs anymore [#371](https://github.com/vmware/go-vcloud-director/pull/371)
* Drop legacy authentication mechanism (vcdAuthorize) and use only new Cloud API provided (vcdCloudApiAuthorize) as
API V33.0 is sufficient for it [#371](https://github.com/vmware/go-vcloud-director/pull/371)
* Added NSX-T Firewall Group type (which represents a Security Group or an IP Set) support by using
structures `NsxtFirewallGroup` and `NsxtFirewallGroupMemberVms`. The following methods are
introduced for managing Security Groups and Ip Sets: `Vdc.CreateNsxtFirewallGroup`,
`NsxtEdgeGateway.CreateNsxtFirewallGroup`, `Org.GetAllNsxtFirewallGroups`,
`Vdc.GetAllNsxtFirewallGroups`, `Org.GetNsxtFirewallGroupByName`,
`Vdc.GetNsxtFirewallGroupByName`, `NsxtEdgeGateway.GetNsxtFirewallGroupByName`,
`Org.GetNsxtFirewallGroupById`, `Vdc.GetNsxtFirewallGroupById`,
`NsxtEdgeGateway.GetNsxtFirewallGroupById`, `NsxtFirewallGroup.Update`,
`NsxtFirewallGroup.Delete`, `NsxtFirewallGroup.GetAssociatedVms`,
`NsxtFirewallGroup.IsSecurityGroup`, `NsxtFirewallGroup.IsIpSet`
[#368](https://github.com/vmware/go-vcloud-director/pull/368)
* Added methods Org.QueryVmList and Org.QueryVmById to find VM by ID in an Org
[#368](https://github.com/vmware/go-vcloud-director/pull/368)

BREAKING CHANGES:
* Added parameter `description` to method `vdc.ComposeRawVapp` [#372](https://github.com/vmware/go-vcloud-director/pull/372)
Expand All @@ -22,6 +35,10 @@ BREAKING CHANGES:
IMPROVEMENTS:
* Only send xml.Header when payload is not empty (some WAFs block empty requests with XML header)
[#367](https://github.com/vmware/go-vcloud-director/pull/367)
* Improved test entity cleanup to find standalone VMs in any VDC (not only default NSX-V one)
[#368](https://github.com/vmware/go-vcloud-director/pull/368)
* Improved test entity cleanup to allow specifying parent VDC for vApp removals
[#368](https://github.com/vmware/go-vcloud-director/pull/368)

## 2.11.0 (March 10, 2021)

Expand Down
7 changes: 6 additions & 1 deletion govcd/adminorg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func (vcd *TestVCD) TestOrg_AdminOrg_QueryCatalogList(check *C) {
}

// Test_GetAllVDCs checks that adminOrg.GetAllVDCs returns at least one VDC
func (vcd *TestVCD) Test_GetAllVDCs(check *C) {
func (vcd *TestVCD) Test_AdminOrgGetAllVDCs(check *C) {
if vcd.skipAdminTests {
check.Skip(fmt.Sprintf(TestRequiresSysAdminPrivileges, check.TestName()))
}
Expand All @@ -239,6 +239,11 @@ func (vcd *TestVCD) Test_GetAllVDCs(check *C) {
vdcs, err := adminOrg.GetAllVDCs(true)
check.Assert(err, IsNil)
check.Assert(len(vdcs) > 0, Equals, true)

// If NSX-T VDC is configured we expect to see at least 2 VDCs (NSX-V and NSX-T)
if vcd.config.VCD.Nsxt.Vdc != "" {
check.Assert(len(vdcs) >= 2, Equals, true)
}
}

// Test_GetAllStorageProfileReferences checks that adminOrg.GetAllStorageProfileReferences returns at least one storage
Expand Down
17 changes: 15 additions & 2 deletions govcd/api_vcd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -759,11 +759,24 @@ func (vcd *TestVCD) removeLeftoverEntities(entity CleanupEntity) {
vcd.infoCleanup(removedMsg, entity.EntityType, entity.Name, entity.CreatedBy)

case "vapp":
vapp, err := vcd.vdc.GetVAppByName(entity.Name, true)
vdc := vcd.vdc
var err error

// Check if parent VDC was specified. If not - use the default NSX-V VDC
if entity.Parent != "" {
vdc, err = vcd.org.GetVDCByName(entity.Parent, true)
if err != nil {
vcd.infoCleanup(notDeletedMsg, entity.EntityType, entity.Name, err)
return
}
}

vapp, err := vdc.GetVAppByName(entity.Name, true)
if err != nil {
vcd.infoCleanup(notFoundMsg, entity.EntityType, entity.Name)
return
}

task, _ := vapp.Undeploy()
_ = task.WaitTaskCompletion()
// Detach all Org networks during vApp removal because network removal errors if it happens
Expand Down Expand Up @@ -1030,7 +1043,7 @@ func (vcd *TestVCD) removeLeftoverEntities(entity CleanupEntity) {
}
return
case "standaloneVm":
vm, err := vcd.vdc.QueryVmById(entity.Name) // The VM ID must be passed as Name
vm, err := vcd.org.QueryVmById(entity.Name) // The VM ID must be passed as Name
if IsNotFound(err) {
vcd.infoCleanup(notFoundMsg, entity.EntityType, entity.Name)
return
Expand Down
4 changes: 2 additions & 2 deletions govcd/nsxt_edgegateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ func (egw *NsxtEdgeGateway) Update(edgeGatewayConfig *types.OpenAPIEdgeGateway)
return returnEgw, nil
}

// Update allows to delete NSX-T edge gateway for Org admins
// Delete allows to delete NSX-T edge gateway for sysadmins
func (egw *NsxtEdgeGateway) Delete() error {
if !egw.client.IsSysAdmin {
return fmt.Errorf("only Provider can update Edge Gateway")
return fmt.Errorf("only Provider can delete Edge Gateway")
}

endpoint := types.OpenApiPathVersion1_0_0 + types.OpenApiEndpointEdgeGateways
Expand Down
Loading