Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get VSI details when last TXN is "Software install is finished" #1622

Closed
andrew-edgar opened this issue Apr 22, 2022 · 5 comments · Fixed by #1625
Closed

Unable to get VSI details when last TXN is "Software install is finished" #1622

andrew-edgar opened this issue Apr 22, 2022 · 5 comments · Fixed by #1625
Assignees
Labels

Comments

@andrew-edgar
Copy link

Unable to get VSI details.

➜ ~ slcli virtual detail 61354767
An unexpected error has occured:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/SoftLayer-5.9.8-py3.9.egg/SoftLayer/CLI/core.py", line 209, in main
cli.main(**kwargs)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/click/decorators.py", line 73, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/SoftLayer-5.9.8-py3.9.egg/SoftLayer/CLI/virt/detail.py", line 72, in cli
last_transaction = "{} ({})".format(utils.lookup(result, 'lastTransaction', 'transactionGroup', 'name'),
File "/usr/local/lib/python3.9/site-packages/SoftLayer-5.9.8-py3.9.egg/SoftLayer/utils.py", line 35, in lookup
return lookup(dic.get(key, {}), keys[0], *keys[1:])
File "/usr/local/lib/python3.9/site-packages/SoftLayer-5.9.8-py3.9.egg/SoftLayer/utils.py", line 35, in lookup
return lookup(dic.get(key, {}), keys[0], *keys[1:])
AttributeError: 'list' object has no attribute 'get'

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

Version
Include the output of slcli --version

➜ ~ slcli --version
Current: slcli (SoftLayer Command-line) v5.9.8
Latest: slcli (SoftLayer Command-line) v6.0.2

@andrew-edgar
Copy link
Author

I upgraded to v6.0.2 and got the SAME error ...

➜  ~ slcli virtual detail 61354767
An unexpected error has occured:
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/SoftLayer/CLI/core.py", line 209, in main
    cli.main(**kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/SoftLayer/CLI/virt/detail.py", line 72, in cli
    last_transaction = "{} ({})".format(utils.lookup(result, 'lastTransaction', 'transactionGroup', 'name'),
  File "/usr/local/lib/python3.9/site-packages/SoftLayer/utils.py", line 35, in lookup
    return lookup(dic.get(key, {}), keys[0], *keys[1:])
  File "/usr/local/lib/python3.9/site-packages/SoftLayer/utils.py", line 35, in lookup
    return lookup(dic.get(key, {}), keys[0], *keys[1:])
AttributeError: 'list' object has no attribute 'get'

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
➜  ~ slcli --version
Current: slcli (SoftLayer Command-line) v6.0.2
Latest:  slcli (SoftLayer Command-line) v6.0.2

@allmightyspiff
Copy link
Member

Can you provide the output of

slcli call-api SoftLayer_Virtual_Guest getObject --id=61354767 --mask="mask[id,lastTransaction[transactionGroup[name]]]"`

https://sldn.softlayer.com/reference/datatypes/SoftLayer_Virtual_Guest/#lastTransaction is supposed to be a single entry, so I'm curious what is causing this behavior. Having that raw data would be helpful.

@andrew-edgar
Copy link
Author

➜  jml-pub_wdcyp_278460 git:(master) ✗ slcli call-api SoftLayer_Virtual_Guest getObject --id=61354767 --mask="mask[id,lastTransaction[transactionGroup[name]]]"
:.................:............................................................................:
:            name : value                                                                      :
:.................:............................................................................:
:              id : 61354767                                                                   :
: lastTransaction : :...................:....................................................: :
:                 : :              name : value                                              : :
:                 : :...................:....................................................: :
:                 : :        createDate : 2022-04-22T21:53:23+01:00                          : :
:                 : :    elapsedSeconds : 3561                                               : :
:                 : :           guestId : 61354767                                           : :
:                 : :        hardwareId :                                                    : :
:                 : :                id : 280582464                                          : :
:                 : :        modifyDate : 2022-04-22T22:03:39+01:00                          : :
:                 : :  statusChangeDate : 2022-04-22T22:03:39+01:00                          : :
:                 : :  transactionGroup : :......:..........................:                : :
:                 : :                   : : name : value                    :                : :
:                 : :                   : :......:..........................:                : :
:                 : :                   : : name : Cloud Instance OS Reload :                : :
:                 : :                   : :......:..........................:                : :
:                 : : transactionStatus : :.................:..............................: : :
:                 : :                   : :            name : value                        : : :
:                 : :                   : :.................:..............................: : :
:                 : :                   : : averageDuration : .22                          : : :
:                 : :                   : :    friendlyName : Software install is finished : : :
:                 : :                   : :            name : INSTALL_COMPLETE             : : :
:                 : :                   : :.................:..............................: : :
:                 : :...................:....................................................: :
:.................:............................................................................:

@andrew-edgar
Copy link
Author

the slcli list works ...

➜  jml-pub_dalyp_278460 git:(master) slcli -v vs list -d dal10
...
:  61354767 :      yz-prod-core-20220304-060149-398     : 169.48.166.117 : 10.177.183.229 :   dal10    :  Software install is finished :
:  61354745 :      yz-prod-core-20220304-060150-758     : 169.48.166.114 : 10.177.183.222 :   dal10    : Setup provision configuration :
...

I only included the 2 that are giving me issues.

@allmightyspiff
Copy link
Member

Looks like the API is sending back an empty list for lastTransaction instead of None.

https://github.com/softlayer/softlayer-python/blob/issues1622/SoftLayer/fixtures/github_issues/1622.json#L83

I think the solution here should be to get the util.lookup function to handle bad input a little better.
https://github.com/softlayer/softlayer-python/blob/issues1622/SoftLayer/utils.py#L19

  • If the input is not a dict we should return None I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants