Skip to content

Commit

Permalink
Merge pull request #11 from ImMin5/master
Browse files Browse the repository at this point in the history
Rollback function for 'settings' domain config for set 'default unified cost config'
  • Loading branch information
ImMin5 authored Oct 10, 2024
2 parents 6c6f4b9 + ba061b5 commit 76c5a44
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 29 deletions.
14 changes: 0 additions & 14 deletions src/spaceone/config/conf/global_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,3 @@

# System Token Settings
TOKEN = ""

# Default Domain Unified Cost Configuration
DEFAULT_UNIFIED_COST_CONFIG = {

"run_hour": 0,
"aggregation_day": 15,
"is_last_day": False,
"exchange_source": "Yahoo Finance!",
"exchange_date": 15,
"is_exchange_last_day": False,
"exchange_rate_mode": "AUTO",
# "custom_exchange_rate": {},
"currency": "KRW",
}
16 changes: 1 addition & 15 deletions src/spaceone/config/service/domain_config_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from spaceone.core.service import *

from spaceone.core import config
from spaceone.config.manager.domain_config_manager import DomainConfigManager
from spaceone.config.model import DomainConfig

Expand Down Expand Up @@ -118,15 +117,10 @@ def get(self, params: dict) -> DomainConfig:
domain_config_vo (object)
"""

domain_config_vo = self.domain_config_mgr.get_domain_config(
return self.domain_config_mgr.get_domain_config(
params["name"], params["domain_id"]
)

if domain_config_vo.name == "settings":
domain_config_vo = self._get_config_vo_with_default_unified_cost_config(domain_config_vo)

return domain_config_vo

@transaction(permission="config:DomainConfig.read", role_types=["DOMAIN_ADMIN"])
@check_required(["domain_id"])
@append_query_filter(["name", "domain_id"])
Expand Down Expand Up @@ -168,11 +162,3 @@ def stat(self, params: dict) -> dict:

query = params.get("query", {})
return self.domain_config_mgr.state_domain_configs(query)

def _get_config_vo_with_default_unified_cost_config(self, domain_config_vo) -> DomainConfig:
domain_config_data: dict = domain_config_vo.data
if not domain_config_data.get("unified_cost_config", {}):
domain_config_data["unified_cost_config"] = config.get_global("DEFAULT_UNIFIED_COST_CONFIG", {})
domain_config_vo = self.domain_config_mgr.update_domain_config_by_vo({"data": domain_config_data},
domain_config_vo)
return domain_config_vo

0 comments on commit 76c5a44

Please sign in to comment.