stacki
stacki copied to clipboard
`list host profile` throws KeyError exception on hosts with no node attribute
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'
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".
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