feat: region field change to optional in login API

region filed default value is CONF.openstack.default_region

Change-Id: I11be6339d5f0d74499f0dd3b28664c27ace43b36
This commit is contained in:
Wu Wenxiang 2024-08-21 15:11:09 +08:00
parent 2a3a08e328
commit 4e06ed4a5a
4 changed files with 8 additions and 6 deletions

View File

@ -173,9 +173,10 @@ async def login(
regex=constants.INBOUND_HEADER_REGEX,
),
) -> schemas.Profile:
region = credential.region or CONF.openstack.default_region
try:
project_scope, unscope_token, default_project_id = await _get_projects_and_unscope_token(
region=credential.region,
region=region,
domain=credential.domain,
username=credential.username,
password=credential.password,
@ -186,13 +187,13 @@ async def login(
default_project_id = None
project_scope_token = await get_project_scope_token(
keystone_token=unscope_token,
region=credential.region,
region=region,
project_id=default_project_id or project_scope[0].id,
)
profile = await generate_profile(
keystone_token=project_scope_token,
region=credential.region,
region=region,
)
profile = await _patch_profile(profile, x_openstack_request_id)

View File

@ -24,7 +24,7 @@ from skyline_apiserver.types import constants
class Credential(BaseModel):
region: str = Field(..., description="Credential user region")
region: Optional[str] = Field(None, description="Credential identity service region")
domain: str = Field(..., description="Credential user domain")
username: str = Field(..., description="Credential username")
password: str = Field(..., description="Credential password for user")

View File

@ -2229,7 +2229,6 @@
"Credential": {
"title": "Credential",
"required": [
"region",
"domain",
"username",
"password"
@ -2239,7 +2238,7 @@
"region": {
"title": "Region",
"type": "string",
"description": "Credential user region"
"description": "Credential identity service region"
},
"domain": {
"title": "Domain",

View File

@ -106,6 +106,7 @@ commands =
description =
Generate swagger files.
envdir = {toxworkdir}/shared
allowlist_externals = skyline-swagger-generator
commands =
skyline-swagger-generator -o swagger.json
@ -113,6 +114,7 @@ commands =
description =
Generate config files.
envdir = {toxworkdir}/shared
allowlist_externals = skyline-sample-config-generator
commands =
skyline-sample-config-generator -o etc/skyline.yaml.sample