# Buggy code
def __execute_cmd(name, xml):
    """
    Execute ilom commands
    """
    ret = {name.replace("_", " "): {}}
    id_num = 0

    tmp_dir = os.path.join(__opts__["cachedir"], "tmp")
    if not os.path.isdir(tmp_dir):
        os.mkdir(tmp_dir)
    with tempfile.NamedTemporaryFile(
        dir=tmp_dir, prefix=name, suffix=os.getpid(), delete=False
    ) as fh:
        tmpfilename = fh.name
        fh.write(xml)

    cmd = __salt__["cmd.run_all"]("hponcfg -f {0}".format(tmpfilename))

    # Clean up the temp file
    __salt__["file.remove"](tmpfilename)

    if cmd["retcode"] != 0:
        for i in cmd["stderr"].splitlines():
            if i.startswith("     MESSAGE="):
                return {"Failed": i.split("=")[-1]}
        return False

    try:
        for i in ET.fromstring("".join(cmd["stdout"].splitlines()[3:-1])):
            # Make sure dict keys dont collide
            if ret[name.replace("_", " ")].get(i.tag, False):
                ret[name.replace("_", " ")].update(
                    {i.tag + "_" + str(id_num): i.attrib}
                )
                id_num += 1
            else:
                ret[name.replace("_", " ")].update({i.tag: i.attrib})
    except SyntaxError:
        return True

    return ret


# Traceback (TypeError)
[root@dbserver tmp]# salt-call   --log-level=debug   ilo.create_user test1 secretagent REMOTE_CONS_PRIV RESET_SERVER_PRIV CONFIG_ILO_PRIV
[DEBUG   ] Reading configuration from /etc/salt/minion
[DEBUG   ] Including configuration from '/etc/salt/minion.d/_schedule.conf'
[DEBUG   ] Reading configuration from /etc/salt/minion.d/_schedule.conf
[DEBUG   ] Using cached minion ID from /etc/salt/minion_id: dbserver.internal.dc.com
[DEBUG   ] Configuration file path: /etc/salt/minion
[DEBUG   ] Reading configuration from /etc/salt/minion
[DEBUG   ] Including configuration from '/etc/salt/minion.d/_schedule.conf'
[DEBUG   ] Reading configuration from /etc/salt/minion.d/_schedule.conf
[DEBUG   ] Initializing new SAuth for ('/etc/salt/pki/minion', 'dbserver.internal.dc.com', 'tcp://192.168.55.230:4506')
[DEBUG   ] Decrypting the current master AES key
[DEBUG   ] Loaded minion key: /etc/salt/pki/minion/minion.pem
[DEBUG   ] Loaded minion key: /etc/salt/pki/minion/minion.pem
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[DEBUG   ] LazyLoaded ilo.create_user
Passed invalid arguments: cannot concatenate 'str' and 'int' objects
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/salt/cli/caller.py", line 138, in call
ret['return'] = func(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/salt/modules/ilo.py", line 381, in create_user
return __execute_cmd('Create_user', _xml)
File "/usr/lib/python2.6/site-packages/salt/modules/ilo.py", line 42, in __execute_cmd
delete=False) as fh:
File "/usr/lib64/python2.6/tempfile.py", line 444, in NamedTemporaryFile
(fd, name) = _mkstemp_inner(dir, prefix, suffix, flags)
File "/usr/lib64/python2.6/tempfile.py", line 226, in _mkstemp_inner
file = _os.path.join(dir, pre + name + suf)
TypeError: cannot concatenate 'str' and 'int' objects
[root@dbserver tmp]#

# Fixed code
def __execute_cmd(name, xml):
    """
    Execute ilom commands
    """
    ret = {name.replace("_", " "): {}}
    id_num = 0

    tmp_dir = os.path.join(__opts__["cachedir"], "tmp")
    if not os.path.isdir(tmp_dir):
        os.mkdir(tmp_dir)
    with tempfile.NamedTemporaryFile(
        dir=tmp_dir, prefix=name + str(os.getpid()), suffix=".xml", delete=False
    ) as fh:
        tmpfilename = fh.name
        fh.write(xml)

    cmd = __salt__["cmd.run_all"]("hponcfg -f {0}".format(tmpfilename))

    # Clean up the temp file
    __salt__["file.remove"](tmpfilename)

    if cmd["retcode"] != 0:
        for i in cmd["stderr"].splitlines():
            if i.startswith("     MESSAGE="):
                return {"Failed": i.split("=")[-1]}
        return False

    try:
        for i in ET.fromstring("".join(cmd["stdout"].splitlines()[3:-1])):
            # Make sure dict keys dont collide
            if ret[name.replace("_", " ")].get(i.tag, False):
                ret[name.replace("_", " ")].update(
                    {i.tag + "_" + str(id_num): i.attrib}
                )
                id_num += 1
            else:
                ret[name.replace("_", " ")].update({i.tag: i.attrib})
    except SyntaxError:
        return True

    return ret