From 71e3bedf58d01e66e3c8e0bb3279dfca14c7e8e1 Mon Sep 17 00:00:00 2001 From: ImMin5 Date: Mon, 23 Oct 2023 22:14:50 +0900 Subject: [PATCH 1/5] build: add python-dateutil package at pip_requirements.txt Signed-off-by: ImMin5 --- pkg/pip_requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/pip_requirements.txt b/pkg/pip_requirements.txt index bdfe56c..b262926 100644 --- a/pkg/pip_requirements.txt +++ b/pkg/pip_requirements.txt @@ -1,8 +1,8 @@ spaceone-core spaceone-api -schematics azure-identity azure-mgmt-billing azure-mgmt-costmanagement +schematics pandas - +python-dateutil From 8683c9899a1cf925678fc2dc9c6765f4b348dbaa Mon Sep 17 00:00:00 2001 From: ImMin5 Date: Mon, 23 Oct 2023 22:17:05 +0900 Subject: [PATCH 2/5] feat: modify logic for empty last_sync date to start 10 months prior to the current date Signed-off-by: ImMin5 --- src/cloudforet/cost_analysis/manager/job_manager.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cloudforet/cost_analysis/manager/job_manager.py b/src/cloudforet/cost_analysis/manager/job_manager.py index 001baa7..b40d6b5 100644 --- a/src/cloudforet/cost_analysis/manager/job_manager.py +++ b/src/cloudforet/cost_analysis/manager/job_manager.py @@ -1,5 +1,6 @@ import logging from datetime import datetime, timedelta +from dateutil.relativedelta import relativedelta from spaceone.core.manager import BaseManager from cloudforet.cost_analysis.connector.azure_cost_mgmt_connector import AzureCostMgmtConnector @@ -72,7 +73,7 @@ def _get_start_month(self, start, last_synchronized_at=None): start_time: datetime = last_synchronized_at - timedelta(days=7) start_time = start_time.replace(day=1) else: - start_time: datetime = datetime.utcnow() - timedelta(days=365) + start_time: datetime = datetime.utcnow() - relativedelta(months=9) start_time = start_time.replace(day=1) start_time = start_time.replace(hour=0, minute=0, second=0, microsecond=0, tzinfo=None) From 1389186f3ca6065fd67832ffa17982291cbd0b36 Mon Sep 17 00:00:00 2001 From: ImMin5 Date: Mon, 23 Oct 2023 22:19:36 +0900 Subject: [PATCH 3/5] feat: modify get 'Department Name' condition of additional info Signed-off-by: ImMin5 --- src/cloudforet/cost_analysis/manager/cost_manager.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cloudforet/cost_analysis/manager/cost_manager.py b/src/cloudforet/cost_analysis/manager/cost_manager.py index b1540a1..8356087 100644 --- a/src/cloudforet/cost_analysis/manager/cost_manager.py +++ b/src/cloudforet/cost_analysis/manager/cost_manager.py @@ -130,10 +130,11 @@ def _get_additional_info(self, result, options, tenant_id=None): if result.get('pricingmodel') == 'OnDemand' and result.get('metercategory') == '': result['metercategory'] = result.get('metercategory') - if result.get('invoicesectionname') != '' and result.get('invoicesectionname'): - additional_info['Department Name'] = result.get('invoicesectionname') - elif result.get('departmentname') != '' and result.get('departmentname'): - additional_info['Department Name'] = result['departmentname'] + if result.get('customername') is None: + if result.get('invoicesectionname') != '' and result.get('invoicesectionname'): + additional_info['Department Name'] = result.get('invoicesectionname') + elif result.get('departmentname') != '' and result.get('departmentname'): + additional_info['Department Name'] = result['departmentname'] if result.get('accountname') != '' and result.get('accountname'): additional_info['Enrollment Account Name'] = result['accountname'] From b8a8907a48cd747bb6e8afbf3c7c3ecab8d39adf Mon Sep 17 00:00:00 2001 From: ImMin5 Date: Mon, 23 Oct 2023 22:27:32 +0900 Subject: [PATCH 4/5] build: modify base image to 'cloudforet/python-core:2' Signed-off-by: ImMin5 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 462e262..c9f282e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3-slim +FROM cloudforet/python-core:2 ENV PYTHONUNBUFFERED 1 ENV SPACEONE_PORT 50051 From 6956ddf681e7af311b91719a22fa2bb838ebde9d Mon Sep 17 00:00:00 2001 From: ImMin5 Date: Mon, 23 Oct 2023 22:28:25 +0900 Subject: [PATCH 5/5] docs: update README.md for 1.1.3 Signed-off-by: ImMin5 --- README.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bb1c6aa..e681d1d 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,38 @@ # plugin-azure-cost-mgmt-cost-datasource Plugin for collecting Azure Cost management data + --- +## Azure Service Endpoint(in use) +
+https://*.blob.core.windows.net
+https://management.azure.com
+https://login.microsoftonline.com
+
+---- ## Schema Data *Schema* - billing_account_id (str): - tenant_id (str): - client_id (str): - client_secret (str): +- customer_tenants (list):(Optional) Customer's tenant id list + +*Example for EA* +
+
+{
+    "billing_account_id": "*****",
+    "tenant_id": "*****",
+    "client_id": "*****",
+    "client_secret": "*****"
+}
+
+
-*Example* +*Example for CSP*
 
 {
@@ -19,6 +40,9 @@ Plugin for collecting Azure Cost management data
     "tenant_id": "*****",
     "client_id": "*****",
     "client_secret": "*****"
+    "customer_tenants":
+        - "*****"
+     
 }