Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions blazarclient/v1/floatingips.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 16 additions & 0 deletions blazarclient/v1/shell_commands/floatingips.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="<floatingip_allocation_column>",
help='column name used to sort result',
default='resource_id'
)
return parser
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading