Skip to content

slcli image list should use an iterative call #1993

@allmightyspiff

Description

@allmightyspiff

https://github.com/softlayer/softlayer-python/blob/master/SoftLayer/managers/image.py#L73

The image list API calls should use self.client.iter_call to page through results. Also set the limit to maybe 50, the command takes a LONG time to execute as it is.

Also there is this error:

$> slcli image list
An unexpected error has occured:
Traceback (most recent call last):
  File "C:\Users\allmi\Code\py311\Lib\site-packages\SoftLayer\CLI\core.py", line 183, in main
    cli.main(**kwargs)
  File "C:\Users\allmi\Code\py311\Lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "C:\Users\allmi\Code\py311\Lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\allmi\Code\py311\Lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\allmi\Code\py311\Lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\allmi\Code\py311\Lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\allmi\Code\py311\Lib\site-packages\click\decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\allmi\Code\py311\Lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\allmi\Code\py311\Lib\site-packages\SoftLayer\CLI\image\list.py", line 36, in cli
    images = [image for image in images if not image['parentId']]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\allmi\Code\py311\Lib\site-packages\SoftLayer\CLI\image\list.py", line 36, in <listcomp>
    images = [image for image in images if not image['parentId']]
                                               ~~~~~^^^^^^^^^^^^
TypeError: string indices must be integers, not 'str'

Feel free to report this error as it is likely a bug:
    https://github.com/softlayer/softlayer-python/issues
The following snippet should be able to reproduce the error

TODO

  1. Image list API calls should use iter_call in smaller batches (say 10-25?)
  2. Image list CLI should return a MAX of 100 images I think, but break that up over several api calls
  3. Fix the error about parentId

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions