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

PLT-529: add get cluster profile method for all PCG types #42

Merged
merged 1 commit into from
Jul 11, 2023
Merged
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
72 changes: 57 additions & 15 deletions client/private_cloud_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@ func (h *V1Client) GetPCGByName(name *string) (*models.V1Overlord, error) {
return overlord, nil
}

func (h *V1Client) GetPairingCode(cloudType string) (string, error) {
client, err := h.GetClusterClient()
if err != nil {
return "", err
}

codeParams := clusterC.NewV1OverlordsPairingCodeParams().WithContext(h.Ctx).WithCloudType(&cloudType)
ret, err := client.V1OverlordsPairingCode(codeParams)
if err != nil {
return "", err
}

return ret.Payload.PairingCode, nil
}

// PCG - vSphere

func (h *V1Client) CreatePCGVsphere(uid string, cloudConfig *models.V1OverlordVsphereCloudConfig) (string, error) {
Expand Down Expand Up @@ -109,6 +124,20 @@ func (h *V1Client) GetPCGManifestVsphere(pairingCode string) (string, error) {
return success.Payload.Manifest, nil
}

func (h *V1Client) GetPCGClusterProfileVsphere(uid string) (*models.V1ClusterProfile, error) {
client, err := h.GetClusterClient()
if err != nil {
return nil, err
}

params := clusterC.NewV1OverlordsUIDVsphereClusterProfileParams().WithUID(uid)
resp, err := client.V1OverlordsUIDVsphereClusterProfile(params)
if err != nil {
return nil, err
}
return resp.Payload, nil
}

func (h *V1Client) CreateDDNSSearchDomainVsphere(vsphereDnsMapping *models.V1VsphereDNSMapping) error {
client, err := h.GetUserClient()
if err != nil {
Expand Down Expand Up @@ -168,6 +197,20 @@ func (h *V1Client) GetPCGManifestOpenStack(pairingCode string) (string, error) {
return success.Payload.Manifest, nil
}

func (h *V1Client) GetPCGClusterProfileOpenStack(uid string) (*models.V1ClusterProfile, error) {
client, err := h.GetClusterClient()
if err != nil {
return nil, err
}

params := clusterC.NewV1OverlordsUIDOpenStackClusterProfileParams().WithUID(uid)
resp, err := client.V1OverlordsUIDOpenStackClusterProfile(params)
if err != nil {
return nil, err
}
return resp.Payload, nil
}

// PCG - MAAS

func (h *V1Client) CreatePCGCloudAccountMaas(overlordUid string, account *models.V1OverlordMaasAccountCreate) (string, error) {
Expand Down Expand Up @@ -214,6 +257,20 @@ func (h *V1Client) GetPCGManifestMaas(pairingCode string) (string, error) {
return success.Payload.Manifest, nil
}

func (h *V1Client) GetPCGClusterProfileMaas(uid string) (*models.V1ClusterProfile, error) {
client, err := h.GetClusterClient()
if err != nil {
return nil, err
}

params := clusterC.NewV1OverlordsUIDMaasClusterProfileParams().WithUID(uid)
resp, err := client.V1OverlordsUIDMaasClusterProfile(params)
if err != nil {
return nil, err
}
return resp.Payload, nil
}

// IP Pool

func (h *V1Client) CreateIpPool(pcgUID string, pool *models.V1IPPoolInputEntity) (string, error) {
Expand Down Expand Up @@ -294,18 +351,3 @@ func (h *V1Client) DeleteIpPool(pcgUID, poolUID string) error {
_, err = client.V1OverlordsUIDPoolDelete(params)
return err
}

func (h *V1Client) GetPairingCode(cloudType string) (string, error) {
client, err := h.GetClusterClient()
if err != nil {
return "", err
}

codeParams := clusterC.NewV1OverlordsPairingCodeParams().WithContext(h.Ctx).WithCloudType(&cloudType)
ret, err := client.V1OverlordsPairingCode(codeParams)
if err != nil {
return "", err
}

return ret.Payload.PairingCode, nil
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/go-openapi/strfmt v0.20.0
github.com/pkg/errors v0.9.1
github.com/spectrocloud/gomi v1.14.1-0.20230412095143-b0595c6c6f08
github.com/spectrocloud/hapi v1.14.1-0.20230619173315-64e3e574c13d
github.com/spectrocloud/hapi v1.14.1-0.20230708120006-0c3327c8c1bc
github.com/stretchr/testify v1.7.0
)

Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,8 @@ github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
github.com/spectrocloud/gomi v1.14.1-0.20230412095143-b0595c6c6f08 h1:AnOC0U+ExlKBeT5yF2Pg8PPfVOfxwOUBS/5deOl1Q4Y=
github.com/spectrocloud/gomi v1.14.1-0.20230412095143-b0595c6c6f08/go.mod h1:UnhUDpFEvtYh6m384r3xzj8/+Z6/hMp2O8whEMYVHec=
github.com/spectrocloud/hapi v1.14.1-0.20230521133257-d73b9e4aea65 h1:mz46BzwOQg49P+CEGeMQgD7W6u3s0DmixMT4mudNQeA=
github.com/spectrocloud/hapi v1.14.1-0.20230521133257-d73b9e4aea65/go.mod h1:9lX5c6bShSkAg24223A7XBCyJj4/Kr9w0YFv6Mf5ZlE=
github.com/spectrocloud/hapi v1.14.1-0.20230619173315-64e3e574c13d h1:4R0CarVmnTRT0b4SlkFWZcwiNRtavjWAcwnSMYmGhGg=
github.com/spectrocloud/hapi v1.14.1-0.20230619173315-64e3e574c13d/go.mod h1:9lX5c6bShSkAg24223A7XBCyJj4/Kr9w0YFv6Mf5ZlE=
github.com/spectrocloud/hapi v1.14.1-0.20230708120006-0c3327c8c1bc h1:F7K8HjzLPa2DsMftC/hBQjCngEurPuH0mVdfOw7NziA=
github.com/spectrocloud/hapi v1.14.1-0.20230708120006-0c3327c8c1bc/go.mod h1:O/Bkbw92QPSGPNQPqKt7Qlkn+9BKK/a22KTUlk76KHI=
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down