diff --git a/cli/internal/terraform/terraform.go b/cli/internal/terraform/terraform.go index 58ce818e11..374170eccb 100644 --- a/cli/internal/terraform/terraform.go +++ b/cli/internal/terraform/terraform.go @@ -340,6 +340,18 @@ func (c *Client) ShowInfrastructure(ctx context.Context, provider cloudprovider. LoadBalancerName: loadBalancerName, AttestationURL: attestationURL, } + case cloudprovider.OpenStack: + networkIDOutput, ok := tfState.Values.Outputs["network_id"] + if !ok { + return state.Infrastructure{}, errors.New("no network_id output found") + } + networkID, ok := networkIDOutput.Value.(string) + if !ok { + return state.Infrastructure{}, errors.New("invalid type in network_id output: not a string") + } + res.OpenStack = &state.OpenStack{ + NetworkID: networkID, + } } return res, nil } diff --git a/internal/constellation/helm/overrides.go b/internal/constellation/helm/overrides.go index 2b075516ac..48e25c1ec4 100644 --- a/internal/constellation/helm/overrides.go +++ b/internal/constellation/helm/overrides.go @@ -125,6 +125,8 @@ func extraConstellationServicesValues( "yawolFloatingID": openStackCfg.FloatingIPPoolID, "yawolFlavorID": openStackCfg.YawolFlavorID, "yawolImageID": openStackCfg.YawolImageID, + "yawolNetworkID": output.OpenStack.NetworkID, + "yawolAPIHost": fmt.Sprintf("https://%s:%d", output.InClusterEndpoint, constants.KubernetesPort), } } case cloudprovider.GCP: diff --git a/internal/constellation/state/state.go b/internal/constellation/state/state.go index 4ebc11f4f7..80610c5964 100644 --- a/internal/constellation/state/state.go +++ b/internal/constellation/state/state.go @@ -132,6 +132,9 @@ type Infrastructure struct { // description: | // Values specific to a Constellation cluster running on GCP. GCP *GCP `yaml:"gcp,omitempty"` + // description: | + // Values specific to a Constellation cluster running on OpenStack. + OpenStack *OpenStack `yaml:"openstack,omitempty"` } // GCP describes the infra state related to GCP. @@ -168,6 +171,13 @@ type Azure struct { AttestationURL string `yaml:"attestationURL"` } +// OpenStack describes the infra state related to OpenStack. +type OpenStack struct { + // description: | + // ID of the network + NetworkID string `yaml:"networkID"` +} + // New creates a new cluster state (file). func New() *State { return &State{ diff --git a/internal/constellation/state/state_doc.go b/internal/constellation/state/state_doc.go index 7666c26d92..230bdb6989 100644 --- a/internal/constellation/state/state_doc.go +++ b/internal/constellation/state/state_doc.go @@ -16,6 +16,7 @@ var ( InfrastructureDoc encoder.Doc GCPDoc encoder.Doc AzureDoc encoder.Doc + OpenStackDoc encoder.Doc ) func init() { @@ -74,7 +75,7 @@ func init() { FieldName: "infrastructure", }, } - InfrastructureDoc.Fields = make([]encoder.Doc, 9) + InfrastructureDoc.Fields = make([]encoder.Doc, 10) InfrastructureDoc.Fields[0].Name = "uid" InfrastructureDoc.Fields[0].Type = "string" InfrastructureDoc.Fields[0].Note = "" @@ -120,6 +121,11 @@ func init() { InfrastructureDoc.Fields[8].Note = "" InfrastructureDoc.Fields[8].Description = "Values specific to a Constellation cluster running on GCP." InfrastructureDoc.Fields[8].Comments[encoder.LineComment] = "Values specific to a Constellation cluster running on GCP." + InfrastructureDoc.Fields[9].Name = "openstack" + InfrastructureDoc.Fields[9].Type = "OpenStack" + InfrastructureDoc.Fields[9].Note = "" + InfrastructureDoc.Fields[9].Description = "Values specific to a Constellation cluster running on OpenStack." + InfrastructureDoc.Fields[9].Comments[encoder.LineComment] = "Values specific to a Constellation cluster running on OpenStack." GCPDoc.Type = "GCP" GCPDoc.Comments[encoder.LineComment] = "GCP describes the infra state related to GCP." @@ -182,6 +188,22 @@ func init() { AzureDoc.Fields[5].Note = "" AzureDoc.Fields[5].Description = "MAA endpoint that can be used as a fallback for veryifying the ID key digests\nin the cluster's attestation report if the enforcement policy is set accordingly.\nCan be left empty otherwise." AzureDoc.Fields[5].Comments[encoder.LineComment] = "MAA endpoint that can be used as a fallback for veryifying the ID key digests" + + OpenStackDoc.Type = "OpenStack" + OpenStackDoc.Comments[encoder.LineComment] = "OpenStack describes the infra state related to OpenStack." + OpenStackDoc.Description = "OpenStack describes the infra state related to OpenStack." + OpenStackDoc.AppearsIn = []encoder.Appearance{ + { + TypeName: "Infrastructure", + FieldName: "openstack", + }, + } + OpenStackDoc.Fields = make([]encoder.Doc, 1) + OpenStackDoc.Fields[0].Name = "networkID" + OpenStackDoc.Fields[0].Type = "string" + OpenStackDoc.Fields[0].Note = "" + OpenStackDoc.Fields[0].Description = "ID of the network" + OpenStackDoc.Fields[0].Comments[encoder.LineComment] = "ID of the network" } func (_ State) Doc() *encoder.Doc { @@ -204,6 +226,10 @@ func (_ Azure) Doc() *encoder.Doc { return &AzureDoc } +func (_ OpenStack) Doc() *encoder.Doc { + return &OpenStackDoc +} + // GetConfigurationDoc returns documentation for the file ./state_doc.go. func GetConfigurationDoc() *encoder.FileDoc { return &encoder.FileDoc{ @@ -215,6 +241,7 @@ func GetConfigurationDoc() *encoder.FileDoc { &InfrastructureDoc, &GCPDoc, &AzureDoc, + &OpenStackDoc, }, } } diff --git a/terraform/infrastructure/openstack/outputs.tf b/terraform/infrastructure/openstack/outputs.tf index 34b84a61e3..35a85fe50d 100644 --- a/terraform/infrastructure/openstack/outputs.tf +++ b/terraform/infrastructure/openstack/outputs.tf @@ -35,3 +35,10 @@ output "ip_cidr_node" { value = local.cidr_vpc_subnet_nodes description = "CIDR block of the node network." } + +# OpenStack-specific outputs + +output "network_id" { + value = openstack_networking_network_v2.vpc_network.id + description = "The OpenStack network id the cluster is deployed in." +}