mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -04:00
openstack: set region in cluster cloud client (#3375)
This commit is contained in:
parent
d65987cb15
commit
882d602524
@ -172,6 +172,20 @@ func (c *imdsClient) userDomainName(ctx context.Context) (string, error) {
|
|||||||
return c.userDataCache.UserDomainName, nil
|
return c.userDataCache.UserDomainName, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *imdsClient) regionName(ctx context.Context) (string, error) {
|
||||||
|
if c.timeForUpdate(c.cacheTime) || c.userDataCache.RegionName == "" {
|
||||||
|
if err := c.update(ctx); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.userDataCache.RegionName == "" {
|
||||||
|
return "", errors.New("unable to get user domain name")
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.userDataCache.RegionName, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (c *imdsClient) username(ctx context.Context) (string, error) {
|
func (c *imdsClient) username(ctx context.Context) (string, error) {
|
||||||
if c.timeForUpdate(c.cacheTime) || c.userDataCache.Username == "" {
|
if c.timeForUpdate(c.cacheTime) || c.userDataCache.Username == "" {
|
||||||
if err := c.update(ctx); err != nil {
|
if err := c.update(ctx); err != nil {
|
||||||
@ -295,6 +309,7 @@ type metadataTags struct {
|
|||||||
type userDataResponse struct {
|
type userDataResponse struct {
|
||||||
AuthURL string `json:"openstack-auth-url,omitempty"`
|
AuthURL string `json:"openstack-auth-url,omitempty"`
|
||||||
UserDomainName string `json:"openstack-user-domain-name,omitempty"`
|
UserDomainName string `json:"openstack-user-domain-name,omitempty"`
|
||||||
|
RegionName string `json:"openstack-region-name,omitempty"`
|
||||||
Username string `json:"openstack-username,omitempty"`
|
Username string `json:"openstack-username,omitempty"`
|
||||||
Password string `json:"openstack-password,omitempty"`
|
Password string `json:"openstack-password,omitempty"`
|
||||||
LoadBalancerEndpoint string `json:"openstack-load-balancer-endpoint,omitempty"`
|
LoadBalancerEndpoint string `json:"openstack-load-balancer-endpoint,omitempty"`
|
||||||
|
@ -54,6 +54,10 @@ func New(ctx context.Context) (*MetadataClient, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("getting user domain name: %w", err)
|
return nil, fmt.Errorf("getting user domain name: %w", err)
|
||||||
}
|
}
|
||||||
|
regionName, err := imds.regionName(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("getting region name: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
clientOpts := &clientconfig.ClientOpts{
|
clientOpts := &clientconfig.ClientOpts{
|
||||||
AuthType: clientconfig.AuthV3Password,
|
AuthType: clientconfig.AuthV3Password,
|
||||||
@ -63,6 +67,7 @@ func New(ctx context.Context) (*MetadataClient, error) {
|
|||||||
Username: username,
|
Username: username,
|
||||||
Password: password,
|
Password: password,
|
||||||
},
|
},
|
||||||
|
RegionName: regionName,
|
||||||
}
|
}
|
||||||
|
|
||||||
serversClient, err := clientconfig.NewServiceClient(ctx, "compute", clientOpts)
|
serversClient, err := clientconfig.NewServiceClient(ctx, "compute", clientOpts)
|
||||||
|
@ -242,6 +242,7 @@ module "instance_group" {
|
|||||||
openstack_username = local.cloudyaml["auth"]["username"]
|
openstack_username = local.cloudyaml["auth"]["username"]
|
||||||
openstack_password = local.cloudyaml["auth"]["password"]
|
openstack_password = local.cloudyaml["auth"]["password"]
|
||||||
openstack_user_domain_name = local.cloudyaml["auth"]["user_domain_name"]
|
openstack_user_domain_name = local.cloudyaml["auth"]["user_domain_name"]
|
||||||
|
openstack_region_name = local.cloudyaml["region_name"]
|
||||||
openstack_load_balancer_endpoint = openstack_networking_floatingip_v2.public_ip.address
|
openstack_load_balancer_endpoint = openstack_networking_floatingip_v2.public_ip.address
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,6 +80,7 @@ resource "openstack_compute_instance_v2" "instance_group_member" {
|
|||||||
openstack-username = var.openstack_username
|
openstack-username = var.openstack_username
|
||||||
openstack-password = var.openstack_password
|
openstack-password = var.openstack_password
|
||||||
openstack-user-domain-name = var.openstack_user_domain_name
|
openstack-user-domain-name = var.openstack_user_domain_name
|
||||||
|
openstack-region-name = var.openstack_region_name
|
||||||
openstack-load-balancer-endpoint = var.openstack_load_balancer_endpoint
|
openstack-load-balancer-endpoint = var.openstack_load_balancer_endpoint
|
||||||
})
|
})
|
||||||
availability_zone_hints = length(var.availability_zone) > 0 ? var.availability_zone : null
|
availability_zone_hints = length(var.availability_zone) > 0 ? var.availability_zone : null
|
||||||
|
@ -97,6 +97,11 @@ variable "openstack_password" {
|
|||||||
description = "OpenStack password."
|
description = "OpenStack password."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "openstack_region_name" {
|
||||||
|
type = string
|
||||||
|
description = "OpenStack region name."
|
||||||
|
}
|
||||||
|
|
||||||
variable "openstack_load_balancer_endpoint" {
|
variable "openstack_load_balancer_endpoint" {
|
||||||
type = string
|
type = string
|
||||||
description = "OpenStack load balancer endpoint."
|
description = "OpenStack load balancer endpoint."
|
||||||
|
Loading…
Reference in New Issue
Block a user