Skip to content

Commit

Permalink
Add node type
Browse files Browse the repository at this point in the history
Signed-off-by: Wenqi Qiu <[email protected]>
  • Loading branch information
wenqiq committed Jul 8, 2024
1 parent 4bc8285 commit e88b5dc
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 20 deletions.
16 changes: 10 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ replace (
github.com/vmware-tanzu/nsx-operator/pkg/apis/v1alpha1 => ./pkg/apis/v1alpha1
github.com/vmware-tanzu/nsx-operator/pkg/apis/v1alpha2 => ./pkg/apis/v1alpha2
github.com/vmware-tanzu/nsx-operator/pkg/client => ./pkg/client
github.com/vmware/vsphere-automation-sdk-go/lib => github.com/zhengxiexie/vsphere-automation-sdk-go/lib v0.7.3-0.20240628090521-3ad1af047210
github.com/vmware/vsphere-automation-sdk-go/runtime => github.com/zhengxiexie/vsphere-automation-sdk-go/runtime v0.7.3-0.20240628090521-3ad1af047210
github.com/vmware/vsphere-automation-sdk-go/services/nsxt => github.com/zhengxiexie/vsphere-automation-sdk-go/services/nsxt v0.12.3-0.20240628090521-3ad1af047210
github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp => github.com/zhengxiexie/vsphere-automation-sdk-go/services/nsxt-mp v0.6.3-0.20240628090521-3ad1af047210
//github.com/vmware/vsphere-automation-sdk-go/lib => github.com/zhengxiexie/vsphere-automation-sdk-go/lib v0.7.3-0.20240628090521-3ad1af047210
//github.com/vmware/vsphere-automation-sdk-go/runtime => github.com/zhengxiexie/vsphere-automation-sdk-go/runtime v0.7.3-0.20240628090521-3ad1af047210
//github.com/vmware/vsphere-automation-sdk-go/services/nsxt => github.com/zhengxiexie/vsphere-automation-sdk-go/services/nsxt v0.12.3-0.20240628090521-3ad1af047210
//github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp => github.com/zhengxiexie/vsphere-automation-sdk-go/services/nsxt-mp v0.6.3-0.20240628090521-3ad1af047210
github.com/vmware/vsphere-automation-sdk-go/lib => github.com/wenqiq/vsphere-automation-sdk-go/lib v0.7.3-0.20240707161013-a8f39aba7c1e
github.com/vmware/vsphere-automation-sdk-go/runtime => github.com/wenqiq/vsphere-automation-sdk-go/runtime v0.7.3-0.20240707161013-a8f39aba7c1e
github.com/vmware/vsphere-automation-sdk-go/services/nsxt => github.com/wenqiq/vsphere-automation-sdk-go/services/nsxt v0.12.3-0.20240707161013-a8f39aba7c1e
github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp => github.com/wenqiq/vsphere-automation-sdk-go/services/nsxt-mp v0.6.3-0.20240707161013-a8f39aba7c1e
)

require (
Expand All @@ -32,8 +36,8 @@ require (
github.com/vmware-tanzu/nsx-operator/pkg/client v0.0.0-20240102061654-537b080e159f
github.com/vmware-tanzu/vm-operator/api v1.8.2
github.com/vmware/govmomi v0.27.4
github.com/vmware/vsphere-automation-sdk-go/lib v0.7.0
github.com/vmware/vsphere-automation-sdk-go/runtime v0.7.1-0.20240611083326-25a4e1834c4d
github.com/vmware/vsphere-automation-sdk-go/lib v0.7.1
github.com/vmware/vsphere-automation-sdk-go/runtime v0.7.1
github.com/vmware/vsphere-automation-sdk-go/services/nsxt v0.12.0
github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp v0.6.0
go.uber.org/automaxprocs v1.5.3
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,17 @@ github.com/vmware-tanzu/vm-operator/api v1.8.2/go.mod h1:vauVboD3sQxP+pb28TnI9wf
github.com/vmware/govmomi v0.27.4 h1:5kY8TAkhB20lsjzrjE073eRb8+HixBI29PVMG5lxq6I=
github.com/vmware/govmomi v0.27.4/go.mod h1:daTuJEcQosNMXYJOeku0qdBJP9SOLLWB3Mqz8THtv6o=
github.com/vmware/vmw-guestinfo v0.0.0-20170707015358-25eff159a728/go.mod h1:x9oS4Wk2s2u4tS29nEaDLdzvuHdB19CvSGJjPgkZJNk=
github.com/wenqiq/vsphere-automation-sdk-go/lib v0.7.3-0.20240707161013-a8f39aba7c1e h1:ZZaRftnZ4DP+220Ga4U6Y3/Vw5VXJ96xILvY0IOD1Wc=
github.com/wenqiq/vsphere-automation-sdk-go/lib v0.7.3-0.20240707161013-a8f39aba7c1e/go.mod h1:x4s3xpeRcJk6PTx9Xyb3LSDzHMLz9BKsA708vmss7MQ=
github.com/wenqiq/vsphere-automation-sdk-go/runtime v0.7.3-0.20240707161013-a8f39aba7c1e h1:4GPHMUuBv7uPhg0bqwu3B/i1VZiIxOM8qHlEp58HLWk=
github.com/wenqiq/vsphere-automation-sdk-go/runtime v0.7.3-0.20240707161013-a8f39aba7c1e/go.mod h1:DzLetYAmw1+vj7bqElRWEpuy40WYE/woL3alsymYa/c=
github.com/wenqiq/vsphere-automation-sdk-go/services/nsxt v0.12.3-0.20240707161013-a8f39aba7c1e h1:CxFT1A9bYXCj65epb0JYq3p2l4MearOvS0wn89WG0sk=
github.com/wenqiq/vsphere-automation-sdk-go/services/nsxt v0.12.3-0.20240707161013-a8f39aba7c1e/go.mod h1:5svFmx8JLpYUwXiAevMJ3mcu+OmEkBp/t3TlMXXbovw=
github.com/wenqiq/vsphere-automation-sdk-go/services/nsxt-mp v0.6.3-0.20240707161013-a8f39aba7c1e h1:Qh0W4qbqiEOV9+HUxHRPz/uFfC/2g6Zr0LUjJRwIpME=
github.com/wenqiq/vsphere-automation-sdk-go/services/nsxt-mp v0.6.3-0.20240707161013-a8f39aba7c1e/go.mod h1:KAXagEsQzxWVrf/W1FejwoGI0TFqCvtAlTl4skHnpU4=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/zhengxiexie/vsphere-automation-sdk-go/lib v0.7.3-0.20240628090521-3ad1af047210 h1:ZdoS46cHwnmPh4bs6OxlllI6PX92Z4a3qm428s4f93c=
github.com/zhengxiexie/vsphere-automation-sdk-go/lib v0.7.3-0.20240628090521-3ad1af047210/go.mod h1:CNBmjJmN8Mja3FRhLN4q6n9qhiBfxvq3Uij8t7r6370=
github.com/zhengxiexie/vsphere-automation-sdk-go/runtime v0.7.3-0.20240628090521-3ad1af047210 h1:vYtG51i9JqSO06oJlDa23riTvMP2ppnQ72FdhoJVtGQ=
github.com/zhengxiexie/vsphere-automation-sdk-go/runtime v0.7.3-0.20240628090521-3ad1af047210/go.mod h1:DzLetYAmw1+vj7bqElRWEpuy40WYE/woL3alsymYa/c=
github.com/zhengxiexie/vsphere-automation-sdk-go/services/nsxt v0.12.3-0.20240628090521-3ad1af047210 h1:sclbs9AnzZ6gb8apIUQJI5rqx/SixhoCAu5O1mUcxoY=
github.com/zhengxiexie/vsphere-automation-sdk-go/services/nsxt v0.12.3-0.20240628090521-3ad1af047210/go.mod h1:RACl1XoB+anHOOgmYjM72zJAKOtr1gNkx2u+ZLt93D8=
github.com/zhengxiexie/vsphere-automation-sdk-go/services/nsxt-mp v0.6.3-0.20240628090521-3ad1af047210 h1:34H/XVcNwNYrkdcBNrqOC298XL17idkjvp1kr5HWoHc=
github.com/zhengxiexie/vsphere-automation-sdk-go/services/nsxt-mp v0.6.3-0.20240628090521-3ad1af047210/go.mod h1:ur/ob18hNxdaK42eug61vyiq7rbLQJhnOngdQSvgr54=
go.etcd.io/etcd/api/v3 v3.5.10 h1:szRajuUUbLyppkhs9K6BRtjY37l66XQQmw7oZRANE4k=
go.etcd.io/etcd/api/v3 v3.5.10/go.mod h1:TidfmT4Uycad3NM/o25fG3J07odo4GBB9hoxaodFCtI=
go.etcd.io/etcd/client/pkg/v3 v3.5.10 h1:kfYIdQftBnbAq8pUWFXfpuuxFSKzlmM5cSn76JByiT0=
Expand Down
10 changes: 6 additions & 4 deletions pkg/nsx/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import (
"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/sites/enforcement_points"
projects "github.com/vmware/vsphere-automation-sdk-go/services/nsxt/orgs/projects"
infra "github.com/vmware/vsphere-automation-sdk-go/services/nsxt/orgs/projects/infra"
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/orgs/projects"
"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/vpcs"
nat "github.com/vmware/vsphere-automation-sdk-go/services/nsxt/orgs/projects/vpcs/nat"
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/orgs/projects/vpcs/nat"
vpc_sp "github.com/vmware/vsphere-automation-sdk-go/services/nsxt/orgs/projects/vpcs/security_policies"
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/orgs/projects/vpcs/subnets"
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/orgs/projects/vpcs/subnets/ip_pools"
Expand All @@ -42,10 +42,11 @@ const (
ServiceAccountCertRotation
StaticRoute
VpcAviRule
NodeType
AllFeatures
)

var FeaturesName = [AllFeatures]string{"VPC", "SECURITY_POLICY", "NSX_SERVICE_ACCOUNT", "NSX_SERVICE_ACCOUNT_RESTORE", "NSX_SERVICE_ACCOUNT_CERT_ROTATION", "STATIC_ROUTE", "VPC_AVI_RULE"}
var FeaturesName = [AllFeatures]string{"VPC", "SECURITY_POLICY", "NSX_SERVICE_ACCOUNT", "NSX_SERVICE_ACCOUNT_RESTORE", "NSX_SERVICE_ACCOUNT_CERT_ROTATION", "STATIC_ROUTE", "VPC_AVI_RULE", "NODE_TYPE"}

type Client struct {
NsxConfig *config.NSXOperatorConfig
Expand Down Expand Up @@ -95,6 +96,7 @@ var (
nsx411Version = [3]int64{4, 1, 1}
nsx412Version = [3]int64{4, 1, 2}
nsx413Version = [3]int64{4, 1, 3}
nsx421Version = [3]int64{4, 2, 1}
)

type NSXHealthChecker struct {
Expand Down
3 changes: 3 additions & 0 deletions pkg/nsx/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,9 @@ func (nsxVersion *NsxVersion) featureSupported(feature int) bool {
case VpcAviRule:
minVersion = nsx411Version
validFeature = true
case NodeType:
minVersion = nsx421Version
validFeature = true
}

if validFeature {
Expand Down
6 changes: 6 additions & 0 deletions pkg/nsx/services/nsxserviceaccount/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ var (
revision1 = int64(1)

proxyLabels = map[string]string{"mgmt-proxy.antrea-nsx.vmware.com": ""}

nodeTypeAntrea = "ANTREA_NODE"
)

type NSXServiceAccountService struct {
Expand Down Expand Up @@ -263,6 +265,10 @@ func (s *NSXServiceAccountService) createPIAndCCP(normalizedClusterName string,
NodeId: existingClusterId,
Tags: s.buildBasicTags(obj),
})

if s.NSXClient.NSXCheckVersion(nsx.NodeType) {
ccp.NodeType = &nodeTypeAntrea
}
err = nsxutil.NSXApiError(err)
if err != nil {
return "", err
Expand Down
9 changes: 7 additions & 2 deletions pkg/nsx/services/nsxserviceaccount/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ func TestNSXServiceAccountService_CreateOrUpdateNSXServiceAccount(t *testing.T)
ResourceType: &antreaClusterResourceType,
Certificate: nil,
VhcPath: &vpcPath,
NodeType: &nodeTypeAntrea,
Tags: []model.Tag{{
Scope: &tagScopeCluster,
Tag: &s.NSXConfig.CoeConfig.Cluster,
Expand All @@ -328,7 +329,7 @@ func TestNSXServiceAccountService_CreateOrUpdateNSXServiceAccount(t *testing.T)
}})
patches.ApplyMethodSeq(s.NSXClient, "NSXCheckVersion", []gomonkey.OutputCell{{
Values: gomonkey.Params{true},
Times: 1,
Times: 2,
}})
return patches
},
Expand Down Expand Up @@ -446,7 +447,7 @@ func TestNSXServiceAccountService_CreateOrUpdateNSXServiceAccount(t *testing.T)
}})
patches.ApplyMethodSeq(s.NSXClient, "NSXCheckVersion", []gomonkey.OutputCell{{
Values: gomonkey.Params{true},
Times: 1,
Times: 2,
}})
return patches
},
Expand Down Expand Up @@ -888,6 +889,10 @@ func TestNSXServiceAccountService_RestoreRealizedNSXServiceAccount(t *testing.T)
}, nil},
Times: 1,
}})
patches.ApplyMethodSeq(s.NSXClient, "NSXCheckVersion", []gomonkey.OutputCell{{
Values: gomonkey.Params{true},
Times: 1,
}})
return patches
},
args: args{
Expand Down

0 comments on commit e88b5dc

Please sign in to comment.