'Generate a command reply stanza based on the
provided session data.
Arguments:
iq      -- The command request stanza.
session -- A dictionary of relevant session data.'

def _process_command_response(self, iq, session):

    sessionid = session['id']
    payload = session['payload']
    if (payload is None):
        payload = []
    if (not isinstance(payload, list)):
        payload = [payload]
    interfaces = session.get('interfaces', set())
    payload_classes = session.get('payload_classes', set())
    interfaces.update(set([item.plugin_attrib for item in payload]))
    payload_classes.update(set([item.__class__ for item in payload]))
    session['interfaces'] = interfaces
    session['payload_classes'] = payload_classes
    self.sessions[sessionid] = session
    for item in payload:
        register_stanza_plugin(Command, item.__class__, iterable=True)
    iq.reply()
    iq['command']['node'] = session['node']
    iq['command']['sessionid'] = session['id']
    if (session['next'] is None):
        iq['command']['actions'] = []
        iq['command']['status'] = 'completed'
    elif session['has_next']:
        actions = ['next']
        if session['allow_complete']:
            actions.append('complete')
        if session['allow_prev']:
            actions.append('prev')
        iq['command']['actions'] = actions
        iq['command']['status'] = 'executing'
    else:
        iq['command']['actions'] = ['complete']
        iq['command']['status'] = 'executing'
    iq['command']['notes'] = session['notes']
    for item in payload:
        iq['command'].append(item)
    iq.send()
