Skip to content

Commit 52afd6b

Browse files
authored
Merge pull request #70 from omkarkhatavkar/add_version_support
added support for the version and listing important file paths
2 parents 3ca3420 + bb01508 commit 52afd6b

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

cloudwash/cli.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import click
22

3+
from cloudwash.config import settings
34
from cloudwash.config import validate_provider
45
from cloudwash.logger import logger
56
from cloudwash.providers.aws import cleanup as awsCleanup
@@ -34,13 +35,24 @@ def common_options(func):
3435
# Click Interactive for Cloud Resources Cleanup
3536

3637

37-
@click.group(help="A Cleanup Utility to remove the VMs, Discs and Nics from Providers!")
38+
@click.group(
39+
help="A Cleanup Utility to remove the VMs, Discs and Nics from Providers!",
40+
invoke_without_command=True,
41+
)
42+
@click.option("--version", is_flag=True, help="Get installed version of cloudwash in system")
3843
@click.option("-d", "--dry", is_flag=True, help="Only show what will be removed from Providers!")
39-
def cleanup_providers(dry):
40-
if dry:
41-
logger.info("\n<<<<<<< Running the cleanup script in DRY RUN mode >>>>>>> ")
42-
else:
43-
logger.info("\n<<<<<<< Running the cleanup script in ACTION mode >>>>>>> ")
44+
@click.pass_context
45+
def cleanup_providers(ctx, dry, version):
46+
if version:
47+
import pkg_resources
48+
49+
cloudwash_version = pkg_resources.get_distribution("cloudwash").version
50+
click.echo(f"Version: {cloudwash_version}")
51+
click.echo(f"Settings File: {settings.settings_file}")
52+
if ctx.invoked_subcommand:
53+
logger.info(
54+
f"\n<<<<<<< Running the cleanup script in {'DRY' if dry else 'ACTION'} RUN mode >>>>>>>"
55+
)
4456

4557

4658
@cleanup_providers.command(help="Cleanup GCE provider")
@@ -97,23 +109,23 @@ def aws(ctx, vms, discs, nics, pips, stacks, _all):
97109
@click.pass_context
98110
def vmware(ctx, vms, discs, nics, _all):
99111
validate_provider(ctx.command.name)
100-
# Further TO_BE_IMPLEMENTED
112+
# TODO: Further TO_BE_IMPLEMENTED
101113

102114

103115
@cleanup_providers.command(help="Cleanup RHEV provider")
104116
@common_options
105117
@click.pass_context
106118
def rhev(ctx, vms, discs, nics, _all):
107119
validate_provider(ctx.command.name)
108-
# Further TO_BE_IMPLEMENTED
120+
# TODO: Further TO_BE_IMPLEMENTED
109121

110122

111123
@cleanup_providers.command(help="Cleanup OSP provider")
112124
@common_options
113125
@click.pass_context
114126
def openstack(ctx, vms, discs, nics, _all):
115127
validate_provider(ctx.command.name)
116-
# Further TO_BE_IMPLEMENTED
128+
# TODO: Further TO_BE_IMPLEMENTED
117129

118130

119131
if __name__ == "__main__":

cloudwash/config.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1+
from pathlib import Path
2+
from pathlib import PurePath
3+
14
from dynaconf import Dynaconf
25
from dynaconf import Validator
36

47
from cloudwash.logger import logger
58

9+
CURRENT_DIRECTORY = Path().resolve()
10+
settings_file = PurePath(CURRENT_DIRECTORY, 'settings.yaml')
611
# Initialize and Configure Settings
712
settings = Dynaconf(
813
core_loaders=["YAML"],
914
envvar_prefix="CLEANUP",
10-
settings_file="settings.yaml",
15+
settings_file=settings_file,
1116
preload=["conf/*.yaml"],
1217
envless_mode=True,
1318
lowercase_read=True,

0 commit comments

Comments
 (0)