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

View File

@ -24,7 +24,7 @@ from skyline_apiserver.types import constants
class Credential(BaseModel): 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") domain: str = Field(..., description="Credential user domain")
username: str = Field(..., description="Credential username") username: str = Field(..., description="Credential username")
password: str = Field(..., description="Credential password for user") password: str = Field(..., description="Credential password for user")

View File

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

View File

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