Skip to content

Commit

Permalink
Merge branch 'issue1993' of github.com:caberos/softlayer-python into …
Browse files Browse the repository at this point in the history
…caberos-issue1993
  • Loading branch information
allmightyspiff committed Jul 13, 2023
2 parents 3f13fe8 + 7f33365 commit 52365ba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 7 additions & 3 deletions SoftLayer/CLI/image/list.py
Expand Up @@ -14,19 +14,23 @@
@click.option('--name', default=None, help='Filter on image name')
@click.option('--public/--private', is_flag=True, default=None,
help='Display only public or private images')
@click.option('--limit', '-l',
help='How many results to get in one api call',
default=100,
show_default=True)
@environment.pass_env
def cli(env, name, public):
def cli(env, name, public, limit):
"""List images."""

image_mgr = SoftLayer.ImageManager(env.client)

images = []
if public in [False, None]:
for image in image_mgr.list_private_images(name=name, mask=image_mod.MASK):
for image in image_mgr.list_private_images(name=name, limit=limit, mask=image_mod.MASK):
images.append(image)

if public in [True, None]:
for image in image_mgr.list_public_images(name=name, mask=image_mod.MASK):
for image in image_mgr.list_public_images(name=name, limit=limit, mask=image_mod.MASK):
images.append(image)

table = formatting.Table(['Id', 'Name', 'Type', 'Visibility', 'Account', 'OS', 'Created', 'Notes'])
Expand Down
6 changes: 3 additions & 3 deletions SoftLayer/managers/image.py
Expand Up @@ -46,7 +46,7 @@ def delete_image(self, image_id):
"""
self.vgbdtg.deleteObject(id=image_id)

def list_private_images(self, guid=None, name=None, **kwargs):
def list_private_images(self, guid=None, name=None, limit=100, **kwargs):
"""List all private images.
:param string guid: filter based on GUID
Expand All @@ -68,7 +68,7 @@ def list_private_images(self, guid=None, name=None, **kwargs):
kwargs['filter'] = _filter.to_dict()

account = self.client['Account']
return account.getPrivateBlockDeviceTemplateGroups(**kwargs)
return self.client.iter_call('Virtual_Guest_Block_Device_Template_Group' , 'getPrivateBlockDeviceTemplateGroups', **kwargs, limit=limit)

def list_public_images(self, guid=None, name=None, limit=100, **kwargs):
"""List all public images.
Expand All @@ -89,7 +89,7 @@ def list_public_images(self, guid=None, name=None, limit=100, **kwargs):

kwargs['filter'] = _filter.to_dict()

return self.vgbdtg.getPublicImages(**kwargs, limit=limit)
return self.client.iter_call('Virtual_Guest_Block_Device_Template_Group', 'getPublicImages', **kwargs, limit=limit)

def _get_ids_from_name_public(self, name):
"""Get public images which match the given name."""
Expand Down

0 comments on commit 52365ba

Please sign in to comment.