Skip to content

Commit

Permalink
list-deleting-volumes: new helper for case reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
praiskup committed Oct 13, 2023
1 parent 2b9c4ae commit d59a56f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ repository = "https://github.com/fedora-copr/resalloc-ibm-cloud"

[project.scripts]
resalloc-ibm-cloud-list-deleting-vms = "resalloc_ibm_cloud.ibm_cloud_list_deleting_vms:main"
resalloc-ibm-cloud-list-deleting-volumes = "resalloc_ibm_cloud.list_deleting_volumes:main"
resalloc-ibm-cloud-list-vms = "resalloc_ibm_cloud.ibm_cloud_list_vms:main"
resalloc-ibm-cloud-vm = "resalloc_ibm_cloud.ibm_cloud_vm:main"

Expand All @@ -38,4 +39,5 @@ manpages = [
"man/resalloc-ibm-cloud-vm.1:function=vm_arg_parser:pyfile=resalloc_ibm_cloud/argparsers.py",
"man/resalloc-ibm-cloud-list-vms.1:function=list_vms_parser:pyfile=resalloc_ibm_cloud/argparsers.py",
"man/resalloc-ibm-cloud-list-deleting-vms.1:function=list_deleting_vms_parser:pyfile=resalloc_ibm_cloud/argparsers.py",
"man/resalloc-ibm-cloud-list-deleting-volumes.1:function=list_deleting_volumes_parser:pyfile=resalloc_ibm_cloud/argparsers.py",
]
1 change: 1 addition & 0 deletions resalloc-ibm-cloud.spec
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ BuildRequires: pyproject-rpm-macros
%doc README.md
%_mandir/man1/resalloc-ibm-cloud*1*
%{_bindir}/resalloc-ibm-cloud-list-deleting-vms
%{_bindir}/resalloc-ibm-cloud-list-deleting-volumes
%{_bindir}/resalloc-ibm-cloud-list-vms
%{_bindir}/resalloc-ibm-cloud-vm

Expand Down
4 changes: 4 additions & 0 deletions resalloc_ibm_cloud/argparsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,7 @@ def list_deleting_vms_parser():
def list_vms_parser():
""" parser for listing deleting vms """
return _list_arg_parser(prog=_pfx("list-vms"))

def list_deleting_volumes_parser():
""" parser for listing vms """
return _default_arg_parser(prog=_pfx("list-deleting-volumes"))
28 changes: 28 additions & 0 deletions resalloc_ibm_cloud/list_deleting_volumes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
List all IBM Cloud volumes that are in Deleting state. This helps with
support-case reporting to IBM folks.
"""

from resalloc_ibm_cloud.helpers import get_service
from resalloc_ibm_cloud.argparsers import list_deleting_volumes_parser
from resalloc_ibm_cloud.constants import LIMIT


def main():
"""
Print ID:name pairs.
"""

opts = list_deleting_volumes_parser().parse_args()
# TODO: fix get_service

Check warning

Code scanning / vcs-diff-lint

TODO: fix get_service Warning

TODO: fix get_service
cmd = f"source {opts.token_file} ; echo $IBMCLOUD_API_KEY"
service = get_service(cmd, opts)

volumes = service.list_volumes(limit=LIMIT).result["volumes"]
for volume in volumes:
if volume["status"] in ["available"]:
continue
print(f"{volume['id']}({volume['name']}) -> {volume['status']}")

if __name__ == "__main__":
main()

0 comments on commit d59a56f

Please sign in to comment.