Skip to content

Commit

Permalink
added domain id on openstack env
Browse files Browse the repository at this point in the history
  • Loading branch information
azhry committed Apr 2, 2023
1 parent 7d5c099 commit d5bd28e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
4 changes: 4 additions & 0 deletions model/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type (
ProjectId string `yaml:"project_id" json:"project_id"`
ProjectName string `yaml:"project_name" json:"project_name"`
UserDomainName string `yaml:"user_domain_name" json:"user_domain_name"`
UserDomainId string `yaml:"user_domain_id" json:"user_domain_id"`
ApplicationCredentialName string `yaml:"application_credential_name" json:"application_credential_name"`
ApplicationCredentialId string `yaml:"application_credential_id" json:"application_credential_id"`
ApplicationCredentialSecret string `yaml:"application_credential_secret" json:"application_credential_secret"`
Expand Down Expand Up @@ -86,6 +87,9 @@ func (y *CloudsYaml) SetEnvironment(options option.OpenstackGenerateClusterOptio
os.Setenv("CAPO_DOMAIN_NAME", authOs.UserDomainName)
openstackConf = openstackConf + `domain-name="` + authOs.UserDomainName + "\"\n"

os.Setenv("CAPO_DOMAIN_ID", authOs.UserDomainId)
openstackConf = openstackConf + `domain-id="` + authOs.UserDomainId + "\"\n"

caCertB64 := base64.StdEncoding.EncodeToString([]byte(cloudOs.CaCert + "\n"))
os.Setenv("OPENSTACK_CLOUD_CACERT_B64", caCertB64)
if cloudOs.CaCert != "" {
Expand Down
16 changes: 8 additions & 8 deletions test/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ import (

// go test ./test -v -run ^TestGenerateClusterTemplate$
func TestGenerateClusterTemplate(t *testing.T) {
yamlByte, _ := os.ReadFile("./data/clouds.yaml")
yamlByte, _ := os.ReadFile("./data/elitery-clouds.yaml")
cloudsYaml := model.CloudsYaml{}
cloudsYaml.Parse(yamlByte)
opt := option.OpenstackGenerateClusterOptions{
ControlPlaneMachineFlavor: "SS2.2",
NodeMachineFlavor: "SM8.4",
ExternalNetworkId: "79241ddc-c51b-4677-a763-f48c60870923",
ImageName: "ubuntu-2004-kube-v1.24.8",
SshKeyName: "kube-key",
ControlPlaneMachineFlavor: "a2.medium-1",
NodeMachineFlavor: "a2.large-2",
ExternalNetworkId: "f30c9e3d-757b-43fb-b4e0-da3ab36708a4",
ImageName: "Ubuntu-22.04-eranyaImage-v1.0",
SshKeyName: "eranya-ssh",
DnsNameServers: "8.8.8.8",
FailureDomain: "az-01", // nova/az-01
IgnoreVolumeAZ: true,
Expand All @@ -37,7 +37,7 @@ func TestGenerateClusterTemplate(t *testing.T) {
infrastructure := "openstack"
capi, _ := api.NewClusterApiClient("", "./data/local.kubeconfig")

clusterName := "capi-local-test"
clusterName := "capi-elitery"
ready, err := capi.InfrastructureReadiness(infrastructure)
if !ready && err == nil {
t.Log("initialize infrastructure")
Expand All @@ -48,7 +48,7 @@ func TestGenerateClusterTemplate(t *testing.T) {
clusterOpt := option.GenerateWorkloadClusterOptions{
ClusterName: clusterName,
KubernetesVersion: "v1.24.8",
WorkerMachineCount: 3,
WorkerMachineCount: 1,
ControlPlaneMachineCount: 1,
InfrastructureProvider: infrastructure,
Flavor: "external-cloud-provider",
Expand Down

0 comments on commit d5bd28e

Please sign in to comment.