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

Delete NCP created resources in cleanup #624

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
14 changes: 11 additions & 3 deletions pkg/nsx/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ import (
mpsearch "github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp/nsx/search"
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp/nsx/trust_management"
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp/nsx/trust_management/principal_identities"
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/infra"
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/infra/domains"
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/infra/domains/security_policies"
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/infra/shares"
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/infra/sites/enforcement_points"
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/orgs"
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/orgs/projects"
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/orgs/projects/infra"
project_infra "github.com/vmware/vsphere-automation-sdk-go/services/nsxt/orgs/projects/infra"
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/orgs/projects/infra/realized_state"
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/orgs/projects/transit_gateways"
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/orgs/projects/vpcs"
Expand Down Expand Up @@ -77,7 +79,7 @@ type Client struct {
ProjectInfraClient projects.InfraClient
VPCClient projects.VpcsClient
VPCConnectivityProfilesClient projects.VpcConnectivityProfilesClient
IPBlockClient infra.IpBlocksClient
IPBlockClient project_infra.IpBlocksClient
StaticRouteClient vpcs.StaticRoutesClient
NATRuleClient nat.NatRulesClient
VpcGroupClient vpcs.GroupsClient
Expand All @@ -92,6 +94,12 @@ type Client struct {
ProjectClient orgs.ProjectsClient
TransitGatewayClient projects.TransitGatewaysClient
TransitGatewayAttachmentClient transit_gateways.AttachmentsClient
CertificateClient infra.CertificatesClient
ShareClient infra.SharesClient
SharedResourceClient shares.ResourcesClient
LbAppProfileClient infra.LbAppProfilesClient
LbPersistenceProfilesClient infra.LbPersistenceProfilesClient
LbMonitorProfilesClient infra.LbMonitorProfilesClient

NSXChecker NSXHealthChecker
NSXVerChecker NSXVersionChecker
Expand Down Expand Up @@ -162,7 +170,7 @@ func GetClient(cf *config.NSXOperatorConfig) *Client {
projectClient := orgs.NewProjectsClient(restConnector(cluster))
vpcClient := projects.NewVpcsClient(restConnector(cluster))
vpcConnectivityProfilesClient := projects.NewVpcConnectivityProfilesClient(restConnector(cluster))
ipBlockClient := infra.NewIpBlocksClient(restConnector(cluster))
ipBlockClient := project_infra.NewIpBlocksClient(restConnector(cluster))
staticRouteClient := vpcs.NewStaticRoutesClient(restConnector(cluster))
natRulesClient := nat.NewNatRulesClient(restConnector(cluster))
vpcGroupClient := vpcs.NewGroupsClient(restConnector(cluster))
Expand Down
54 changes: 31 additions & 23 deletions pkg/nsx/services/common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,29 +140,37 @@ var (
)

var (
ResourceType = "resource_type"
ResourceTypeInfra = "Infra"
ResourceTypeDomain = "Domain"
ResourceTypeSecurityPolicy = "SecurityPolicy"
ResourceTypeNetworkPolicy = "NetworkPolicy"
ResourceTypeGroup = "Group"
ResourceTypeRule = "Rule"
ResourceTypeIPBlock = "IpAddressBlock"
ResourceTypeOrgRoot = "OrgRoot"
ResourceTypeOrg = "Org"
ResourceTypeProject = "Project"
ResourceTypeVpc = "Vpc"
ResourceTypeSubnetPort = "VpcSubnetPort"
ResourceTypeVirtualMachine = "VirtualMachine"
ResourceTypeLBService = "LBService"
ResourceTypeShare = "Share"
ResourceTypeSharedResource = "SharedResource"
ResourceTypeChildSharedResource = "ChildSharedResource"
ResourceTypeChildShare = "ChildShare"
ResourceTypeChildRule = "ChildRule"
ResourceTypeChildGroup = "ChildGroup"
ResourceTypeChildSecurityPolicy = "ChildSecurityPolicy"
ResourceTypeChildResourceReference = "ChildResourceReference"
ResourceType = "resource_type"
ResourceTypeInfra = "Infra"
ResourceTypeDomain = "Domain"
ResourceTypeSecurityPolicy = "SecurityPolicy"
ResourceTypeNetworkPolicy = "NetworkPolicy"
ResourceTypeGroup = "Group"
ResourceTypeRule = "Rule"
ResourceTypeIPBlock = "IpAddressBlock"
ResourceTypeOrgRoot = "OrgRoot"
ResourceTypeOrg = "Org"
ResourceTypeProject = "Project"
ResourceTypeVpc = "Vpc"
ResourceTypeSubnetPort = "VpcSubnetPort"
ResourceTypeVirtualMachine = "VirtualMachine"
ResourceTypeLBService = "LBService"
ResourceTypeShare = "Share"
ResourceTypeSharedResource = "SharedResource"
ResourceTypeChildSharedResource = "ChildSharedResource"
ResourceTypeChildShare = "ChildShare"
ResourceTypeChildRule = "ChildRule"
ResourceTypeChildGroup = "ChildGroup"
ResourceTypeChildSecurityPolicy = "ChildSecurityPolicy"
ResourceTypeChildResourceReference = "ChildResourceReference"
ResourceTypeTlsCertificate = "TlsCertificate"
ResourceTypeLBHttpProfile = "LBHttpProfile"
ResourceTypeLBFastTcpProfile = "LBFastTcpProfile"
ResourceTypeLBFastUdpProfile = "LBFastUdpProfile"
ResourceTypeLBCookiePersistenceProfile = "LBCookiePersistenceProfile"
ResourceTypeLBSourceIpPersistenceProfile = "LBSourceIpPersistenceProfile"
ResourceTypeLBHttpMonitorProfile = "LBHttpMonitorProfile"
ResourceTypeLBTcpMonitorProfile = "LBTcpMonitorProfile"

// ResourceTypeClusterControlPlane is used by NSXServiceAccountController
ResourceTypeClusterControlPlane = "clustercontrolplane"
Expand Down
9 changes: 9 additions & 0 deletions pkg/nsx/services/vpc/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,15 @@ func (vs *VPCStore) GetByKey(key string) *model.Vpc {
return nil
}

// ResourceStore is a store to query nsx resource
type ResourceStore struct {
common.ResourceStore
}

func (r *ResourceStore) Apply(i interface{}) error {
return nil
}

func (is *IPBlockStore) GetByIndex(index string, value string) *model.IpAddressBlock {
indexResults, err := is.ResourceStore.Indexer.ByIndex(index, value)
if err != nil || len(indexResults) == 0 {
Expand Down
Loading