Skip to content

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

Open

Description

@bsanders

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'

Activity

  1. bsanders commented on Oct 4, 2018

    @bsanders
    ContributorAuthor

    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".

  2. caladd commented on Oct 4, 2018

    @caladd
    Contributor

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions