def add_license(key):
    '''
    Add a license
    '''
    result = {
        'result': False,
        'retcode': -1,
        'output': ''
    }

    if not has_powerpath():
        result['output'] = 'PowerPath is not installed'
        return result

    cmd = '/sbin/emcpreg -add {0}'.format(key)
    ret = __salt__['cmd.run_all'](cmd, python_shell=True)

    result['retcode'] = ret['retcode']

    if ret['retcode'] != 0:
        result['output'] = ret['stderr']
    else:
        result['output'] = ret['stdout']
        result['result'] = True

    return result
Add a license