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 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":
+ - "*****"
+
}
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
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']
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)