Skip to content

Commit

Permalink
Merge pull request #206 from ImMin5/master
Browse files Browse the repository at this point in the history
Fix job_id prefix 'pg' to 'job'
  • Loading branch information
ImMin5 authored Mar 8, 2024
2 parents 3b1c4d0 + 05bc916 commit 21f1e04
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/spaceone/identity/manager/job_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ def __init__(self, *args, **kwargs):
def create_job(
self,
resource_group: str,
plugin_id: str,
trusted_account_id: str,
domain_id: str,
workspace_id: str,
) -> Job:
data = {
"resource_group": resource_group,
"plugin_id": plugin_id,
"trusted_account_id": trusted_account_id,
"domain_id": domain_id,
"workspace_id": workspace_id,
Expand Down
2 changes: 1 addition & 1 deletion src/spaceone/identity/model/job/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


class Job(MongoModel):
job_id = StringField(max_length=40, generate_id="pg", unique=True)
job_id = StringField(max_length=40, generate_id="job", unique=True)
status = StringField(
choices=("PENDING", "IN_PROGRESS", "FAILURE", "SUCCESS", "CANCELED"),
default="PENDING",
Expand Down
2 changes: 2 additions & 0 deletions src/spaceone/identity/model/job/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class JobResponse(BaseModel):
def dict(self, *args, **kwargs):
data = super().dict(*args, **kwargs)
data["created_at"] = utils.datetime_to_iso8601(data["created_at"])
data["updated_at"] = utils.datetime_to_iso8601(data.get("updated_at"))
data["finished_at"] = utils.datetime_to_iso8601(data.get("finished_at"))
return data


Expand Down
9 changes: 5 additions & 4 deletions src/spaceone/identity/service/job_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def delete(self, params: JobDeleteRequest) -> None:
permission="identity:Job.read",
role_types=["DOMAIN_ADMIN", "WORKSPACE_OWNER"],
)
@convert_model
def get(self, params: JobGetRequest) -> JobResponse:
"""Get job
Args:
Expand Down Expand Up @@ -166,7 +167,6 @@ def stat(self, params: JobStatQueryRequest) -> dict:
return self.job_mgr.stat_jobs(query)

@transaction(exclude=["authentication", "authorization", "mutation"])
@check_required(["task_options", "job_task_id", "domain_id"])
def sync_service_accounts(self, params: dict):
"""Sync account data
Args:
Expand Down Expand Up @@ -204,12 +204,13 @@ def created_service_account_job(
domain_id = trusted_account_vo.domain_id

provider_vo = self.provider_mgr.get_provider(provider, domain_id)
plugin_id = provider_vo.plugin_info["plugin_id"]
ac_plugin_mgr = AccountCollectorPluginManager()
endpoint = ac_plugin_mgr.get_account_collector_plugin_endpoint_by_vo(
provider_vo
)

options = provider_vo.plugin_info.options
options = provider_vo.plugin_info.get("options")
schema_id = trusted_account_vo.secret_schema_id

ac_plugin_mgr.initialize(endpoint)
Expand All @@ -231,7 +232,7 @@ def created_service_account_job(

# Add Job Options
job_vo = self.job_mgr.create_job(
resource_group, trusted_account_id, workspace_id, domain_id
resource_group, plugin_id, trusted_account_id, workspace_id, domain_id
)

if self._check_duplicate_job(domain_id, trusted_account_id, job_vo):
Expand Down Expand Up @@ -298,7 +299,7 @@ def _check_duplicate_job(
]
}

job_vos, total_count = self.job_mgr.list_jobs(**query)
job_vos, total_count = self.job_mgr.list_jobs(query)

if total_count == 0:
return True
Expand Down
6 changes: 3 additions & 3 deletions src/spaceone/identity/service/trusted_account_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def delete(self, params: TrustedAccountDeleteRequest) -> None:
role_types=["DOMAIN_ADMIN", "WORKSPACE_OWNER"],
)
@convert_model
def sync(self, params: TrustedAccountSyncRequest) -> dict:
def sync(self, params: TrustedAccountSyncRequest) -> Union[JobResponse, dict]:
"""Sync trusted account
Args:
params (TrustedAccountSyncRequest): {
Expand All @@ -258,8 +258,8 @@ def sync(self, params: TrustedAccountSyncRequest) -> dict:
trusted_account_vo.provider, domain_id
)
self._check_provider_sync(provider_vo)

return job_service.created_service_account_job(trusted_account_vo, {})
job_vo = job_service.created_service_account_job(trusted_account_vo, {})
return JobResponse(**job_vo.to_dict())

@transaction(
permission="identity:TrustedAccount.read",
Expand Down

0 comments on commit 21f1e04

Please sign in to comment.