|
1 | 1 | import click |
2 | 2 |
|
| 3 | +from cloudwash.config import settings |
3 | 4 | from cloudwash.config import validate_provider |
4 | 5 | from cloudwash.logger import logger |
5 | 6 | from cloudwash.providers.aws import cleanup as awsCleanup |
@@ -34,13 +35,24 @@ def common_options(func): |
34 | 35 | # Click Interactive for Cloud Resources Cleanup |
35 | 36 |
|
36 | 37 |
|
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") |
38 | 43 | @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 | + ) |
44 | 56 |
|
45 | 57 |
|
46 | 58 | @cleanup_providers.command(help="Cleanup GCE provider") |
@@ -97,23 +109,23 @@ def aws(ctx, vms, discs, nics, pips, stacks, _all): |
97 | 109 | @click.pass_context |
98 | 110 | def vmware(ctx, vms, discs, nics, _all): |
99 | 111 | validate_provider(ctx.command.name) |
100 | | - # Further TO_BE_IMPLEMENTED |
| 112 | + # TODO: Further TO_BE_IMPLEMENTED |
101 | 113 |
|
102 | 114 |
|
103 | 115 | @cleanup_providers.command(help="Cleanup RHEV provider") |
104 | 116 | @common_options |
105 | 117 | @click.pass_context |
106 | 118 | def rhev(ctx, vms, discs, nics, _all): |
107 | 119 | validate_provider(ctx.command.name) |
108 | | - # Further TO_BE_IMPLEMENTED |
| 120 | + # TODO: Further TO_BE_IMPLEMENTED |
109 | 121 |
|
110 | 122 |
|
111 | 123 | @cleanup_providers.command(help="Cleanup OSP provider") |
112 | 124 | @common_options |
113 | 125 | @click.pass_context |
114 | 126 | def openstack(ctx, vms, discs, nics, _all): |
115 | 127 | validate_provider(ctx.command.name) |
116 | | - # Further TO_BE_IMPLEMENTED |
| 128 | + # TODO: Further TO_BE_IMPLEMENTED |
117 | 129 |
|
118 | 130 |
|
119 | 131 | if __name__ == "__main__": |
|
0 commit comments