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

list host profile throws KeyError exception on hosts with no node attribute #182

Open
bsanders opened this issue Jul 5, 2017 · 2 comments

Comments

@bsanders
Copy link
Contributor

bsanders commented Jul 5, 2017

Create an appliance with no 'node' parameter set. Create a host of that appliance type, and try to list its profile. Kaboom.

list host profile/xml should probably catch this exception and bail out.

# stack add appliance foo
# stack add host foobar box=default appliance=foo rack=0 rank=33
# stack list host attr foobar | grep node
# stack list host profile foobar
  File "/opt/stack/bin/stack", line 245, in run_command
    rc = command.runWrapper(name, args[i:])
  File "/opt/stack/lib/python2.6/site-packages/stack/commands/command.py", line 2304, in runWrapper
    rc = self.run(self._params, self._args)
  File "/opt/stack/lib/python2.6/site-packages/stack/commands/list/host/profile/__init__.py", line 212, in run
    xmlinput = self.command('list.host.xml', [ host ])
  File "/opt/stack/lib/python2.6/site-packages/stack/commands/command.py", line 1728, in command
    self.rc = o.runWrapper(name, args, self.level + 1)
  File "/opt/stack/lib/python2.6/site-packages/stack/commands/command.py", line 2304, in runWrapper
    rc = self.run(self._params, self._args)
  File "/opt/stack/lib/python2.6/site-packages/stack/commands/list/host/xml/__init__.py", line 136, in run
    args = [ attrs['node'] ]
stack.commands.list.host.profile: KeyError -- 'node'
@bsanders
Copy link
Contributor Author

bsanders commented Oct 4, 2018

list host xml needs to check if the attributes for the provided host has a node key, and if not raise CommandError with something obvious like "{host} does not have a node attribute".

@caladd
Copy link
Contributor

caladd commented Oct 4, 2018

See the code in list appliance xml on how we are checking for the node attribute there: https://github.com/Teradata/stacki/blob/develop/common/src/stack/command/stack/commands/list/appliance/xml/__init__.py#L51

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants