From 99e3f5e6c71c7d79dfd4c6ac7d22d54d434d6532 Mon Sep 17 00:00:00 2001 From: Mark Powers Date: Fri, 3 Apr 2026 18:36:28 +0000 Subject: [PATCH] Add floatingip allocation list command --- blazarclient/v1/floatingips.py | 8 ++++++++ blazarclient/v1/shell_commands/floatingips.py | 16 ++++++++++++++++ setup.cfg | 1 + 3 files changed, 25 insertions(+) diff --git a/blazarclient/v1/floatingips.py b/blazarclient/v1/floatingips.py index 2a65329..021824e 100644 --- a/blazarclient/v1/floatingips.py +++ b/blazarclient/v1/floatingips.py @@ -45,3 +45,11 @@ def list(self, sort_by=None): if sort_by: floatingips = sorted(floatingips, key=lambda ip: ip[sort_by]) return floatingips + + def list_allocations(self, sort_by=None): + """List allocations for all floating IPs.""" + resp, body = self.request_manager.get('/floatingips/allocations') + allocations = body['allocations'] + if sort_by: + allocations = sorted(allocations, key=lambda alloc: alloc[sort_by]) + return allocations diff --git a/blazarclient/v1/shell_commands/floatingips.py b/blazarclient/v1/shell_commands/floatingips.py index 90720d9..8dbfe83 100644 --- a/blazarclient/v1/shell_commands/floatingips.py +++ b/blazarclient/v1/shell_commands/floatingips.py @@ -84,3 +84,19 @@ class DeleteFloatingIP(command.DeleteCommand): resource = 'floatingip' allow_names = False log = logging.getLogger(__name__ + '.DeleteFloatingIP') + + +class ListFloatingIPAllocations(command.ListAllocationCommand): + """Print a list of floating IP allocations.""" + resource = 'floatingip' + log = logging.getLogger(__name__ + '.ListFloatingIPAllocations') + list_columns = ['resource_id', 'reservations'] + + def get_parser(self, prog_name): + parser = super(ListFloatingIPAllocations, self).get_parser(prog_name) + parser.add_argument( + '--sort-by', metavar="", + help='column name used to sort result', + default='resource_id' + ) + return parser \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 9de0b4a..12f4b4c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -54,6 +54,7 @@ openstack.reservation.v1 = reservation_floatingip_delete = blazarclient.v1.shell_commands.floatingips:DeleteFloatingIP reservation_floatingip_list = blazarclient.v1.shell_commands.floatingips:ListFloatingIPs reservation_floatingip_show = blazarclient.v1.shell_commands.floatingips:ShowFloatingIP + reservation_floatingip_allocation_list = blazarclient.v1.shell_commands.floatingips:ListFloatingIPAllocations reservation_host_allocation_list = blazarclient.v1.shell_commands.hosts:ListHostAllocations reservation_host_allocation_show = blazarclient.v1.shell_commands.hosts:ShowHostAllocation reservation_host_create = blazarclient.v1.shell_commands.hosts:CreateHost