Ensure the RackSpace queue exists.

    name
        Name of the Rackspace queue.

    provider
        Salt Cloud Provider

def present(name, provider):
    '''
    Ensure the RackSpace queue exists.

    name
        Name of the Rackspace queue.

    provider
        Salt Cloud Provider
    '''
    ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}

    is_present = list(__salt__['cloud.action']('queues_exists', provider=provider, name=name)[provider].values())[0]

    if not is_present:
        if __opts__['test']:
            msg = 'Rackspace queue {0} is set to be created.'.format(name)
            ret['comment'] = msg
            ret['result'] = None
            return ret
        created = __salt__['cloud.action']('queues_create', provider=provider, name=name)
        if created:
            queue = __salt__['cloud.action']('queues_show', provider=provider, name=name)
            ret['changes']['old'] = {}
            ret['changes']['new'] = {'queue': queue}
        else:
            ret['result'] = False
            ret['comment'] = 'Failed to create {0} Rackspace queue.'.format(name)
            return ret
    else:
        ret['comment'] = '{0} present.'.format(name)

    return ret