-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #336 from asmorodskyi/dump_state
Create dedicated command to collect public cloud stats
- Loading branch information
Showing
5 changed files
with
42 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import logging | ||
import traceback | ||
from webui.PCWConfig import PCWConfig | ||
from ocw.lib.azure import Azure | ||
from ocw.enums import ProviderChoice | ||
from ocw.lib.influx import Influx | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def dump_state(): | ||
for namespace in PCWConfig.get_namespaces_for('influxdb'): | ||
try: | ||
providers = PCWConfig.get_providers_for('influxdb', namespace) | ||
logger.info("[%s] Dump state %s", namespace, ','.join(providers)) | ||
if ProviderChoice.AZURE in providers: | ||
Influx().dump_resource(ProviderChoice.AZURE.value, Influx.VMS_QUANTITY, Azure(namespace).list_instances) | ||
Influx().dump_resource(ProviderChoice.AZURE.value, Influx.IMAGES_QUANTITY, Azure(namespace).list_images) | ||
Influx().dump_resource(ProviderChoice.AZURE.value, Influx.DISK_QUANTITY, Azure(namespace).list_disks) | ||
except Exception: | ||
logger.exception("[%s] Dump state failed!: \n %s", namespace, traceback.format_exc()) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from django.core.management.base import BaseCommand | ||
from ocw.lib.dump_state import dump_state | ||
|
||
|
||
class Command(BaseCommand): | ||
help = 'Dump current state (amount of all entities \ | ||
tracked by pcw) of all providers (according to pcw.ini)' | ||
|
||
def handle(self, *args, **options): | ||
dump_state() |