-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
f928f68 OS-7847. Fixed motor+pymongo version in arcee and bulldozer bc64d6a OS-7841. Additional live_demo runs fixes c45c292 OS-7846. Fixed discount fields for aws raw expenses c049b0d OS-7799. Use accessorFn to resolve null tag to a string
- Loading branch information
Showing
10 changed files
with
66 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
diworker/diworker/migrations/202409171620000_fix_discount_fields_names.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import logging | ||
from optscale_client.rest_api_client.client_v2 import Client as RestClient | ||
from diworker.diworker.migrations.base import BaseMigration | ||
""" | ||
Fixed names for discount fields in AWS expenses | ||
""" | ||
LOG = logging.getLogger(__name__) | ||
|
||
|
||
class Migration(BaseMigration): | ||
@property | ||
def rest_cl(self): | ||
if self._rest_cl is None: | ||
self._rest_cl = RestClient( | ||
url=self.config_cl.restapi_url(), | ||
secret=self.config_cl.cluster_secret()) | ||
return self._rest_cl | ||
|
||
@property | ||
def mongo_raw(self): | ||
return self.db.raw_expenses | ||
|
||
def get_cloud_accs(self): | ||
cloud_accounts_ids = set() | ||
_, organizations = self.rest_cl.organization_list({ | ||
'with_connected_accounts': True, 'is_demo': False}) | ||
for org in organizations['organizations']: | ||
_, accounts = self.rest_cl.cloud_account_list( | ||
org['id'], type='aws_cnr') | ||
for cloud_account in accounts['cloud_accounts']: | ||
if cloud_account['auto_import']: | ||
cloud_accounts_ids.add(cloud_account['id']) | ||
return cloud_accounts_ids | ||
|
||
def upgrade(self): | ||
cloud_accs = self.get_cloud_accs() | ||
for i, cloud_acc_id in enumerate(cloud_accs): | ||
LOG.info('Starting processing for cloud account %s (%s/%s)' % ( | ||
cloud_acc_id, i+1, len(cloud_accs))) | ||
self.db.raw_expenses.update_many( | ||
{'bill/BillingPeriodStartDate': {'$exists': True}, | ||
'cloud_account_id': cloud_acc_id}, | ||
{'$rename': { | ||
'discount_total_discount': 'discount/TotalDiscount', | ||
'discount_bundled_discount': 'discount/BundledDiscount'}}) | ||
|
||
def downgrade(self): | ||
pass |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters