def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Define User Roles

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    HPE OneView Appliance hostname or IP address''')
    parser.add_argument('-u', dest='user', required=False,
                        default='Administrator',
                        help='''
    HPE OneView Username''')
    parser.add_argument('-p', dest='passwd', required=True,
                        help='''
    HPE OneView Password''')
    parser.add_argument('-c', dest='cert', required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y', dest='proxy', required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j', dest='domain', required=False,
                        default='Local',
                        help='''
    HPE OneView Authorized Login Domain''')
    parser.add_argument('-x', dest='upass', required=False,
                        help='''
    New user password''')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-g', dest='getrole', action='store_true',
                       help='''
    Display the users and exit''')
    group.add_argument('-n', dest='name',
                       help='''
    Username to add''')

    args = parser.parse_args()
    credential = {'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    srv = hpov.servers(con)
    net = hpov.networking(con)
    sec = hpov.security(con)
    sts = hpov.settings(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    if args.getrole:
        getrole(sec)
        sys.exit()

    setrole(sec, args.name, 'Read only')
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Display the startup progress of the HP OneView appliance

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    HP OneView Appliance hostname or IP address''')
    parser.add_argument('-c', dest='cert', required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y', dest='proxy', required=False,
                        help='''
    Proxy (host:port format''')

    args = parser.parse_args()

    con = hpov.connection(args.host)
    sts = hpov.settings(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    getprogress(sts)
def try_connect(ip):
    con = hpOneView.connection(ip)
    if applianceProxy:
        con.set_proxy(applianceProxy.split(":")[0], applianceProxy.split(":")[1])
    if applianceCerts:
        con.set_trusted_ssl_bundle(applianceCerts)
    # See if we need to accept the EULA before we try to log in
    try:
        con.get_eula_status()
    except OSError as ex:
        print("ex: %s" % ex)
        if "503" in ex:
            switchToDHCP()
    try:
        if con.get_eula_status() is True:
            print("EULA display needed")
            con.set_eula("no")
        else:
            print("EULA display NOT needed")
    except Exception as e:
        print("EXCEPTION:")
        print(e)
    # First try to log in with the initial credentials
    try:
        credential = {"userName": applianceUser, "password": "******"}
        con.login(credential)
    except hpOneView.exceptions.HPOneViewException as ex:
        if ex.errorCode == "PASSWORD_CHANGE_REQUIRED":
            con.change_initial_password("password")
        elif ex.errorCode == "AUTHN_AUTH_FAUL":
            print("Initial login failed so assume password already changed")
    credential = {"userName": applianceUser, "password": appliancePassword}
    con.login(credential)
    return con
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Retrieve EULA (End User License Agreement) status from the
    HP OneView appliance. The output is "True" if the appliance requires
    the EULA to be accepted and "False" if the EULA has already been
    accepted.

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    HP OneView Appliance hostname or IP address''')
    parser.add_argument('-c', dest='cert', required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y', dest='proxy', required=False,
                        help='''
    Proxy (host:port format''')

    args = parser.parse_args()

    con = hpov.connection(args.host)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    checkEULA(con)
Example #5
0
def volume():
    data = request.body.read()
    volume = json.loads(data)['volume_name']

    # Get connection and log into OneView
    con = ov.connection(oneview_server)
    login = {'userName':username,'password':password}
    con.login(login)

    # Get access to storage resources
    storage = ov.storage(con)
    pools = storage.get_storage_pools()
    for pool in pools['members']:

        # Find specified storage pool
        if pool['name'] == storage_pool:
            storagePoolUri = pool['uri']
            newvolume = ov.common.make_storage_volume(volume,
                                                 102410241024,
                                                 True,
                                                 storagePoolUri,
                                                 'Created via script',
                                                 'thin')
            result = storage.add_storage_volume(newvolume)

    response.headers['Content-Type'] = 'application/json'
    response.headers['Access-Control-Allow-Origin'] = '*'
    response.status = 200
    print json.dumps({'state': result['state']})
    return json.dumps({'state': result['state']})
def main():
    parser = argparse.ArgumentParser(add_help=True, description='Usage')
    parser.add_argument('-a', '--appliance', dest='host', required=True,
                        help='HP OneView Appliance hostname or IP')
    parser.add_argument('-u', '--user', dest='user', required=False,
                        default='Administrator', help='HP OneView Username')
    parser.add_argument('-p', '--pass', dest='passwd', required=False,
                        help='HP OneView Password')
    parser.add_argument('-c', '--certificate', dest='cert', required=False,
                        help='Trusted SSL Certificate Bundle in PEM '
                        '(Base64 Encoded DER) Format')
    parser.add_argument('-r', '--proxy', dest='proxy', required=False,
                        help='Proxy (host:port format')

    args = parser.parse_args()
    credential = {'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    sec = hpov.security(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    getcatactions(sec)
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Delete individual or ALL Storage Pools

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    HP OneView Appliance hostname or IP address''')
    parser.add_argument('-u', dest='user', required=False,
                        default='Administrator',
                        help='''
    HP OneView Username''')
    parser.add_argument('-p', dest='passwd', required=True,
                        help='''
    HP OneView Password''')
    parser.add_argument('-c', dest='cert', required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y', dest='proxy', required=False,
                        help='''
    Proxy (host:port format''')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-s', dest='sto_name',
                       help='''
    Name of storage system. This option requires the pool name option "-n"
    to be specified''')
    group.add_argument('-d', dest='delete_all',
                       action='store_true',
                       help='''
    Remove ALL storage pools and exit''')
    parser.add_argument('-n', dest='pool_name', required=False,
                        help='''
    Storage pool name''')

    args = parser.parse_args()
    credential = {'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    sto = hpov.storage(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    if args.sto_name:
        if args.pool_name:
            del_pool_by_name(sto, args.sto_name, args.pool_name)
        else:
            print ('Storage system MUST be accompanied by storage pool name')
        sys.exit()

    if args.delete_all:
        del_all_pools(sto)
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Delete server profile

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    HPE OneView Appliance hostname or IP address''')
    parser.add_argument('-u', dest='user', required=False,
                        default='Administrator',
                        help='''
    HPE OneView Username''')
    parser.add_argument('-p', dest='passwd', required=True,
                        help='''
    HPE OneView Password''')
    parser.add_argument('-c', dest='cert', required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y', dest='proxy', required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j', dest='domain', required=False,
                        default='Local',
                        help='''
    HPE OneView Authorized Login Domain''')
    parser.add_argument('-f', dest='force', required=False,
                        action='store_true',
                        help='''
    Force the removal of the server profile''')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-n', dest='name',
                       help='''
    Name of the server profile to delete''')
    group.add_argument('-d', dest='delete_all',
                       action='store_true',
                       help='''
    Remove ALL server profiles and exit''')

    args = parser.parse_args()
    credential = {'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    srv = hpov.servers(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    if args.delete_all:
        del_all_profiles(srv, args.force)
        sys.exit()

    del_profile_by_name(con, srv, args.name, args.force)
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Display Storage Systems

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    HP OneView Appliance hostname or IP address''')
    parser.add_argument('-u', dest='user', required=False,
                        default='Administrator',
                        help='''
    HP OneView Username''')
    parser.add_argument('-p', dest='passwd', required=True,
                        help='''
    HP OneView Password''')
    parser.add_argument('-c', dest='cert', required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y', dest='proxy', required=False,
                        help='''
    Proxy (host:port format''')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-n', dest='name',
                       help='''
    Name of the storage system to get''')
    group.add_argument('-s', dest='serialNo',
                       help='''
    Serial number of the storage system to get''')
    group.add_argument('-g', dest='get',
                       action='store_true',
                       help='''
    Get all storage systems''')

    args = parser.parse_args()
    credential = {'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    sto = hpov.storage(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    if args.name:
        get_storage_system_by_name(sto, args.name)
        sys.exit()

    if args.serialNo:
        get_storage_system_by_serial(sto, args.serialNo)
        sys.exit()

    if args.get:
        get_all_storage_systems(sto)
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Download appliance audit log

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    HP OneView Appliance hostname or IP address''')
    parser.add_argument('-u', dest='user', required=False,
                        default='Administrator',
                        help='''
    HP OneView Username''')
    parser.add_argument('-p', dest='passwd', required=True,
                        help='''
    HP OneView Password''')
    parser.add_argument('-c', dest='cert', required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y', dest='proxy', required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j', dest='domain', required=False,
                        default='Local',
                        help='''
    HP OneView Authorized Login Domain''')

    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-f', dest='filename',
                       help='''
    Filename to save audit log zip archive as, for example:

           -f audit_logs.zip
                       ''')
    group.add_argument('-g', dest='getlogs', action='store_true',
                       help='''
    Display the audit logs and exit''')

    args = parser.parse_args()
    credential = {'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    act = hpov.activity(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    if args.getlogs:
        get_audit_logs(act)
        sys.exit()

    download_audit_logs(act, args.filename)
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Display Server Profile Connections

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    HPE OneView Appliance hostname or IP address''')
    parser.add_argument('-u', dest='user', required=False,
                        default='Administrator',
                        help='''
    HPE OneView Username''')
    parser.add_argument('-p', dest='passwd', required=True,
                        help='''
    HPE OneView Password''')
    parser.add_argument('-c', dest='cert', required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y', dest='proxy', required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j', dest='domain', required=False,
                        default='Local',
                        help='''
    HPE OneView Authorized Login Domain''')
    parser.add_argument('-r', dest='report',
                        required=False, action='store_true',
                        help='''
    Format the output using a human readable report format''')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-n', dest='name',
                       help='''
    Name of the server profile to get''')
    group.add_argument('-g', dest='get_all',
                       action='store_true',
                       help='''
    Get ALL server profiles and exit''')

    args = parser.parse_args()
    credential = {'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    srv = hpov.servers(con)
    net = hpov.networking(con)
    sts = hpov.settings(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    # get a server profile's connection information
    get_profile_connections_list(con, srv, '', args.report)
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Set the service access state

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    HP OneView Appliance hostname or IP address''')
    parser.add_argument('-u', dest='user', required=False,
                        default='Administrator',
                        help='''
    HP OneView Username''')
    parser.add_argument('-p', dest='passwd', required=True,
                        help='''
    HP OneView Password''')
    parser.add_argument('-c', dest='cert', required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y', dest='proxy', required=False,
                        help='''
    Proxy (host:port format''')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-e', dest='ena', action='store_true',
                       help='''
    Enable service access''')
    group.add_argument('-d', dest='dis', action='store_true',
                       help='''
    Disable service access''')
    group.add_argument('-g', dest='gets', action='store_true',
                       help='''
    Get current service access state''')

    args = parser.parse_args()
    credential = {'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    srv = hpov.servers(con)
    net = hpov.networking(con)
    sec = hpov.security(con)
    sts = hpov.settings(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    if args.gets:
        getsa(sts)
    elif args.ena:
        setsa(sts, 'true')
    elif args.dis:
        setsa(sts, 'false')
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Delete individual or ALL enclosures

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    HP OneView Appliance hostname or IP address''')
    parser.add_argument('-u', dest='user', required=False,
                        default='Administrator',
                        help='''
    HP OneView Username''')
    parser.add_argument('-p', dest='passwd', required=True,
                        help='''
    HP OneView Password''')
    parser.add_argument('-c', dest='cert', required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y', dest='proxy', required=False,
                        help='''
    Proxy (host:port format''')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-d', dest='delete_all', action='store_true',
                       help='''
    Delete all Enclosures and exit''')
    group.add_argument('-en', '--enc_name', dest='ename',
                       help='''
    Name of enclosure to be deleted''')
    group.add_argument('-es', '--enc_serial', dest='serialNo',
                       help='''
    SerialNumber of enclosure to be deleted''')

    args = parser.parse_args()
    credential = {'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    srv = hpov.servers(con)
    sts = hpov.settings(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)
    if args.delete_all:
        del_all_enclosures(srv)
        sys.exit()

    if args.serialNo:
        del_enclosure_by_serial(srv, args.serialNo)
        sys.exit()

    del_enclosure_by_name(srv, args.ename)
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Add new Storage Pools (i.e. HPE 3PAR Common Provisioning Group [CPG]) for
    volumes to be provisioned from.  The Storage System must be imported
    prior to adding Storage Pools.

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    HPE OneView Appliance hostname or IP address''')
    parser.add_argument('-u', dest='user', required=False,
                        default='Administrator',
                        help='''
    HPE OneView Username''')
    parser.add_argument('-p', dest='passwd', required=True,
                        help='''
    HPE OneView Password''')
    parser.add_argument('-c', dest='cert', required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y', dest='proxy', required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j', dest='domain', required=False,
                        default='Local',
                        help='''
    HPE OneView Authorized Login Domain''')
    parser.add_argument('-sp', dest='pool_name', required=True,
                        help='''
    Storage Pool Name''')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-ss', dest='sto_name',
                        help='''
    Name of the Storage System to use''')
    group.add_argument('-f', dest='first_avaliable',
                        action='store_true',
                        help='''
    Use the first avaliable storage system''')

    args = parser.parse_args()
    credential = {'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    sto = hpov.storage(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    add_storage_pool(sto, args.pool_name, args.sto_name, args.first_avaliable)
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Display the avilable and configured Address Pools, and their associated
    Ranges from the appliance.  Currently, the appliance supports the
    following Address Pools:

        - VMAC
        - VWWN
        - VSN

    You can specify one or all of the Pool types.

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    HPE OneView Appliance hostname or IP address''')
    parser.add_argument('-u', dest='user', required=False,
                        default='Administrator',
                        help='''
    HPE OneView Username''')
    parser.add_argument('-p', dest='passwd', required=True,
                        help='''
    HPE OneView Password''')
    parser.add_argument('-c', dest='cert', required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y', dest='proxy', required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j', dest='domain', required=False,
                        default='Local',
                        help='''
    HPE OneView Authorized Login Domain''')
    parser.add_argument('-t', dest='types', required=False,
                        choices=['VMAC', 'VWWN', 'VSN', 'ALL'], default='ALL',
                        help='''
    Address Pool type.  Accepted values are VMAC, VWWN, VSN, or All''')

    args = parser.parse_args()
    credential = {'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    srv = hpov.servers(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    get_address_pools(con, srv, args.types)
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Define a new enclosure group

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    HP OneView Appliance hostname or IP address''')
    parser.add_argument('-u', dest='user', required=False,
                        default='Administrator',
                        help='''
    HP OneView Username''')
    parser.add_argument('-p', dest='passwd', required=True,
                        help='''
    HP OneView Password''')
    parser.add_argument('-c', dest='cert', required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y', dest='proxy', required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j', dest='domain', required=False,
                        default='Local',
                        help='''
    HP OneView Authorized Login Domain''')
    parser.add_argument('-l', dest='lname', required=False,
                        help='''
    LIG to assign to enclosure group''')
    parser.add_argument('-n',  dest='name', required=True,
                        help='''
    Enclosure Group name''')

    args = parser.parse_args()
    credential = {'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    srv = hpov.servers(con)
    net = hpov.networking(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    if args.name:
        if not args.lname:
            print('Error, the Logical Interconnect Group must be specified')
            sys.exit()

    login(con, credential)
    acceptEULA(con)

    define_enclosure_group(net, srv, args.name, args.lname)
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Display the collection of enclosure hardware resources.

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    HPE OneView Appliance hostname or IP address''')
    parser.add_argument('-u', dest='user', required=False,
                        default='Administrator',
                        help='''
    HPE OneView Username''')
    parser.add_argument('-p', dest='passwd', required=True,
                        help='''
    HPE OneView Password''')
    parser.add_argument('-c', dest='cert', required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y', dest='proxy', required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j', dest='domain', required=False,
                        default='Local',
                        help='''
    HPE OneView Authorized Login Domain''')
    parser.add_argument('-n', dest='name',
                        required=False,
                        help='''
    The name of the enclosure hardware resource to be returned.
    All enclosure hardware resources will be returned if omitted.''')
    parser.add_argument('-r', dest='report',
                        required=False, action='store_true',
                        help='''
    Generate report of enclosure, including device bays, interconnect bays,
    and reported firmware for components. ''')

    args = parser.parse_args()

    credential = {'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    srv = hpov.servers(con)
    net = hpov.networking(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    get_enclosures(con, srv, net, args.name, args.report)
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Display Volume Templates

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    HPE OneView Appliance hostname or IP address''')
    parser.add_argument('-u', dest='user', required=False,
                        default='Administrator',
                        help='''
    HPE OneView Username''')
    parser.add_argument('-p', dest='passwd', required=True,
                        help='''
    HPE OneView Password''')
    parser.add_argument('-c', dest='cert', required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y', dest='proxy', required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j', dest='domain', required=False,
                        default='Local',
                        help='''
    HPE OneView Authorized Login Domain''')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-n', dest='name',
                       help='''
    Name of the storage volume template''')
    group.add_argument('-g', dest='get_all',
                       action='store_true',
                       help='''
    Get all storage volume templates''')

    args = parser.parse_args()
    credential = {'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    sto = hpov.storage(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    if args.get_all:
        get_all_vol_templates(sto)
        sys.exit()

    get_vol_template_by_name(sto, args.name)
Example #19
0
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Add a new license

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    HP OneView Appliance hostname or IP address''')
    parser.add_argument('-u', dest='user', required=False,
                        default='Administrator',
                        help='''
    HP OneView Username''')
    parser.add_argument('-p', dest='passwd', required=True,
                        help='''
    HP OneView Password''')
    parser.add_argument('-c', dest='cert', required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y', dest='proxy', required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j', dest='domain', required=False,
                        default='Local',
                        help='''
    HP OneView Authorized Login Domain''')
    parser.add_argument('-f', dest='file', required=True,
                        help='''
    HP OneView license file 1 key per license file''')

    args = parser.parse_args()
    credential = {'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    sts = hpov.settings(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    try:
        f = open(args.file, 'r')
        lic = f.read()
        f.close()
    except IOError:
        print('Error reading license file')
        sys.exit()

    addlic(sts, lic.rstrip('\n'))
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Display the datacenter resources

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    HP OneView Appliance hostname or IP address''')
    parser.add_argument('-u', dest='user', required=False,
                        default='Administrator',
                        help='''
    HP OneView Username''')
    parser.add_argument('-p', dest='passwd', required=True,
                        help='''
    HP OneView Password''')
    parser.add_argument('-c', dest='cert', required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y', dest='proxy', required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-f', dest='force', action='store_true',
                        required=False,
                        help='''
    Force rack deletion''')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-d', dest='delete_all', action='store_true',
                        help='''
    Delete ALL racks''')
    group.add_argument('-n', dest='name',
                        help='''
    Rack name to delete''')

    args = parser.parse_args()
    credential = {'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    fac = hpov.facilities(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    if args.delete_all:
        del_all_racks(fac, args.force)
        sys.exit()

    del_rack(fac, args.name, args.force)
Example #21
0
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Display the collection of network resources

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    HP OneView Appliance hostname or IP address''')
    parser.add_argument('-u', dest='user', required=False,
                        default='Administrator',
                        help='''
    HP OneView Username''')
    parser.add_argument('-p', dest='passwd', required=True,
                        help='''
    HP OneView Password''')
    parser.add_argument('-c', dest='cert', required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y', dest='proxy', required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j', dest='domain', required=False,
                        default='Local',
                        help='''
    HP OneView Authorized Login Domain''')
    parser.add_argument('-t', dest='ntype', required=False,
                        choices=['Ethernet', 'FC'],
                        help='''
    The type of the network resource to be returned''')
    parser.add_argument('-n', dest='name', required=False,
                        help='''
    The name of the network resource to be returned''')
    parser.add_argument('-r', dest='report',
                        required=False, action='store_true',
                        help='''
    Format the output using a human readable report format''')

    args = parser.parse_args()
    credential = {'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    net = hpov.networking(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    get_networks(net, args.ntype, args.name, args.report)
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Display Server Profiles

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    HP OneView Appliance hostname or IP address''')
    parser.add_argument('-u', dest='user', required=False,
                        default='Administrator',
                        help='''
    HP OneView Username''')
    parser.add_argument('-p', dest='passwd', required=True,
                        help='''
    HP OneView Password''')
    parser.add_argument('-c', dest='cert', required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y', dest='proxy', required=False,
                        help='''
    Proxy (host:port format''')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-n', dest='name',
                       help='''
    Name of the server profile to get''')
    group.add_argument('-g', dest='get_all',
                       action='store_true',
                       help='''
    Get ALL server profiles and exit''')

    args = parser.parse_args()
    credential = {'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    srv = hpov.servers(con)
    net = hpov.networking(con)
    sts = hpov.settings(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    if args.get_all:
        get_all_profiles(srv)
        sys.exit()

    get_profile_by_name(srv, args.name)
Example #23
0
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Shutdown or Reboot the HPE OneView Appliance

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    HPE OneView Appliance hostname or IP address''')
    parser.add_argument('-u', dest='user', required=False,
                        default='Administrator',
                        help='''
    HPE OneView Username''')
    parser.add_argument('-p', dest='passwd', required=True,
                        help='''
    HPE OneView Password''')
    parser.add_argument('-c', dest='cert', required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y', dest='proxy', required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j', dest='domain', required=False,
                        default='Local',
                        help='''
    HPE OneView Authorized Login Domain''')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-r', dest='reboot', action='store_true',
                       help='''
    Shutdown and restart/reboot the appliance''')
    group.add_argument('-s', dest='halt', action='store_true',
                       help='''
    Shutdown and halt the appliance''')

    args = parser.parse_args()
    credential = {'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    sts = hpov.settings(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    if args.reboot:
        shutdown(sts, 'REBOOT')
    elif args.halt:
        shutdown(sts, 'HALT')
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Add an iPDU Power Device

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    HPE OneView Appliance hostname or IP address''')
    parser.add_argument('-u', dest='user', required=False,
                        default='Administrator',
                        help='''
    HPE OneView Username''')
    parser.add_argument('-p', dest='passwd', required=True,
                        help='''
    HPE OneView Password''')
    parser.add_argument('-c', dest='cert', required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y', dest='proxy', required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j', dest='domain', required=False,
                        default='Local',
                        help='''
    HPE OneView Authorized Login Domain''')
    parser.add_argument('-ih', dest='ipdu', required=True,
                        help='''
    Hostname or IP address of the iPDU to add''')
    parser.add_argument('-iu', dest='username', required=True,
                        help='''
    Administrative username for the iPDU''')
    parser.add_argument('-ip', dest='password', required=True,
                        help='''
    Administrative password for the iPDU''')

    args = parser.parse_args()
    credential = {'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    fac = hpov.facilities(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    add_iPDU(fac, args.ipdu, args.username, args.password)
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Delete individual or ALL Network Sets

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    HP OneView Appliance hostname or IP address''')
    parser.add_argument('-u', dest='user', required=False,
                        default='Administrator',
                        help='''
    HP OneView Username''')
    parser.add_argument('-p', dest='passwd', required=True,
                        help='''
    HP OneView Password''')
    parser.add_argument('-c', dest='cert', required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y', dest='proxy', required=False,
                        help='''
    Proxy (host:port format''')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-d', dest='delete_all', action='store_true',
                       help='''
    Delete ALL Network-sets''')
    group.add_argument('-n', dest='name',
                       help='''
    Name of the Network-set to delete''')

    args = parser.parse_args()
    credential = {'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    net = hpov.networking(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    if args.delete_all:
        del_all_network_sets(net)
        sys.exit()

    del_network_set_by_name(net, args.name)
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Obtain a collection of Enclosure Group resources, or a single Enclosure
    Group with the specified name.

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    HP OneView Appliance hostname or IP address''')
    parser.add_argument('-u', dest='user', required=False,
                        default='Administrator',
                        help='''
    HP OneView Username''')
    parser.add_argument('-p', dest='passwd', required=True,
                        help='''
    HP OneView Password''')
    parser.add_argument('-c', dest='cert', required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y', dest='proxy', required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j', dest='domain', required=False,
                        default='Local',
                        help='''
    HP OneView Authorized Login Domain''')
    parser.add_argument('-n', dest='name',
                        required=False,
                        help='''
    The name of the enclosure group resource to be returned.
    All enclosure group resources will be returned if omitted.''')

    args = parser.parse_args()
    credential = {'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    srv = hpov.servers(con)
    net = hpov.networking(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    get_enclosure_groups(srv, net, args.name)
def main():
    parser = argparse.ArgumentParser(add_help=True, description='Usage')
    parser.add_argument('-a', '--appliance', dest='host', required=True,
                        help='HP OneView Appliance hostname or IP')
    parser.add_argument('-u', '--user', dest='user', required=False,
                        default='Administrator', help='HP OneView Username')
    parser.add_argument('-p', '--pass', dest='passwd', required=False,
                        help='HP OneView Password')
    parser.add_argument('-c', '--certificate', dest='cert', required=False,
                        help='Trusted SSL Certificate Bundle in PEM '
                        '(Base64 Encoded DER) Format')
    parser.add_argument('-r', '--proxy', dest='proxy', required=False,
                        help='Proxy (host:port format')
    parser.add_argument('-su', '--sto_user', dest='stousr', required=False,
                        help='Administrative username for the storage system')
    parser.add_argument('-sp', '--sto_pass', dest='stopass', required=False,
                        help='Administrative password for the storage system')
    parser.add_argument('-sd', '--sto_dom', dest='stodom', required=False, default='NewDomain',
                        help='Storage Domain on the storage system')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-s', dest='storage',
                       help='IP address of the storage system to add')
    group.add_argument('-d', dest='delete',
                       action='store_true', help='Remove ALL storage systems and exit')
    group.add_argument('-g', dest='get',
                       action='store_true', help='Get storage systems and exit')

    args = parser.parse_args()
    credential = {'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    sto = hpov.storage(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    if args.get:
        getsto(sto)
        sys.exit()

    if args.delete:
        delsto(sto)
        sys.exit()

    addsto(sto, args.storage, args.stousr, args.stopass, args.stodom)
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Set the SNMP read community string

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    HP OneView Appliance hostname or IP address''')
    parser.add_argument('-u', dest='user', required=False,
                        default='Administrator',
                        help='''
    HP OneView Username''')
    parser.add_argument('-p', dest='passwd', required=True,
                        help='''
    HP OneView Password''')
    parser.add_argument('-c', dest='cert', required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y', dest='proxy', required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j', dest='domain', required=False,
                        default='Local',
                        help='''
    HP OneView Authorized Login Domain''')
    parser.add_argument('-s', dest='string', required=True,
                        help='''
    Community Read String''')

    args = parser.parse_args()
    credential = {'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    srv = hpov.servers(con)
    net = hpov.networking(con)
    sec = hpov.security(con)
    sts = hpov.settings(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    define_string(sts, args.string)
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Display Server Resources

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    HPE OneView Appliance hostname or IP address''')
    parser.add_argument('-u', dest='user', required=False,
                        default='Administrator',
                        help='''
    HPE OneView Username''')
    parser.add_argument('-p', dest='passwd', required=True,
                        help='''
    HPE OneView Password''')
    parser.add_argument('-n', dest='name',
                        required=False,
                        help='''
    The name of the specific server type to be returned.
    ''')
    parser.add_argument('-c', dest='cert', required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y', dest='proxy', required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j', dest='domain', required=False,
                        default='Local',
                        help='''
    HPE OneView Authorized Login Domain''')

    args = parser.parse_args()
    credential = {'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    srv = hpov.servers(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    pprint(getservers(srv, args.name))
def main():
    parser = argparse.ArgumentParser(add_help=True,
                                     formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Retrieve licenses installed on the appliance. You can use this to get an
    inventory of what's installed and what licenses are consumed.

                                     Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    HPE OneView Appliance hostname or IP address''')
    parser.add_argument('-u', dest='user', required=False,
                        default='Administrator',
                        help='''
    HPE OneView Username''')
    parser.add_argument('-p', dest='passwd', required=True,
                        help='''
    HPE OneView Password''')
    parser.add_argument('-c', dest='cert', required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y', dest='proxy', required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j', dest='domain', required=False,
                        default='Local',
                        help='''
    HPE OneView Authorized Login Domain''')
    parser.add_argument('-r', dest='report',
                        required=False, action='store_true',
                        help='''
    Format the output using a human readable report format''')

    args = parser.parse_args()
    credential = {'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    sts = hpov.settings(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
        if args.cert:
            con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    get_license_info(con, sts, args.report)
Example #31
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Set the service access state

    Usage: ''')
    parser.add_argument('-a',
                        dest='host',
                        required=True,
                        help='''
    HP OneView Appliance hostname or IP address''')
    parser.add_argument('-u',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='''
    HP OneView Username''')
    parser.add_argument('-p',
                        dest='passwd',
                        required=True,
                        help='''
    HP OneView Password''')
    parser.add_argument('-c',
                        dest='cert',
                        required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y',
                        dest='proxy',
                        required=False,
                        help='''
    Proxy (host:port format''')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-e',
                       dest='ena',
                       action='store_true',
                       help='''
    Enable service access''')
    group.add_argument('-d',
                       dest='dis',
                       action='store_true',
                       help='''
    Disable service access''')
    group.add_argument('-g',
                       dest='gets',
                       action='store_true',
                       help='''
    Get current service access state''')

    args = parser.parse_args()
    credential = {'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    srv = hpov.servers(con)
    net = hpov.networking(con)
    sec = hpov.security(con)
    sts = hpov.settings(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    if args.gets:
        getsa(sts)
    elif args.ena:
        setsa(sts, 'true')
    elif args.dis:
        setsa(sts, 'false')
Example #32
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Add new Logical Interconnect Group

    Usage: ''')
    parser.add_argument('-a',
                        dest='host',
                        required=True,
                        help='''
    HPE OneView Appliance hostname or IP address''')
    parser.add_argument('-u',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='''
    HPE OneView Username''')
    parser.add_argument('-p',
                        dest='passwd',
                        required=True,
                        help='''
    HPE OneView Password''')
    parser.add_argument('-c',
                        dest='cert',
                        required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y',
                        dest='proxy',
                        required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j',
                        dest='domain',
                        required=False,
                        default='Local',
                        help='''
    HPE OneView Authorized Login Domain''')
    parser.add_argument('-n',
                        dest='logical_interconnect_group_name',
                        required=True,
                        help='''
    Name of the logical interconnect group''')
    parser.add_argument('-i',
                        dest='interconnects',
                        required=True,
                        nargs='+',
                        help='''
    List of interconnect modules specified as
    BAY:INTERCONNECT where INTERCONNECT must be one of
    the following [FlexFabric, Flex10, Flex1010D,
    Flex2040f8 VCFC20, VCFC24 and FEX] For example Virtual
    Connect Flex10 modules in bays and 2 with Virtual
    Connect 24 port Fibre Channel modules in bays 3 and 4
    would be specified as:

        -i 1:Flex10 2:Flex10 3:VCFC24 4:VCFC24''')
    parser.add_argument('-g',
                        dest='igmp_snooping',
                        action='store_true',
                        required=False,
                        help='''
    Enable IGMP Snooping

    The Group Membership Interval value, as specified by
    the IGMP v2 specification(RFC 2236).  For optimum
    network resource usage, set the timeout interval to
    match your network\'s multicast router settings.''')
    parser.add_argument('-t',
                        dest='igmp_idle_timeout',
                        required=False,
                        default=260,
                        type=int,
                        help='''
    The Group Membership Interval value, as
    specified by the IGMP v2 specification(RFC 2236).
    For optimum network resource usage, set the timeout
    interval to match your network\'s multicast router
    settings.''')
    parser.add_argument('-m',
                        dest='fast_mac_cache_failover',
                        action='store_true',
                        required=False,
                        help='''
    Disable Fast MAC Cache Failover.

    When an uplink that was in standby mode becomes
    active, it can take several minutes for external
    Ethernet interconnects to recognize that the server
    blades can now be reached on this newly active
    connection.  Enabling Fast MAC Cache Failover causes
    Ethernet packets to be transmitted on the newly
    active connection, which enables the external
    Ethernet interconnects to identify the new
    connection(and update their MAC caches) The
    transmission sequence is repeated a few times at the
    MAC refresh interval and completes in about 1
    minute.''')
    parser.add_argument('-e',
                        dest='mac_refresh_interval',
                        required=False,
                        default=5,
                        type=int,
                        help='''
    The time interval at which MAC caches are refreshed
    in seconds''')
    parser.add_argument('-o',
                        dest='pause_flood_protection',
                        action='store_true',
                        required=False,
                        help='''
    Disable pause flood protection:

    Ethernet switch interfaces use pause frame based flow
    control mechanisms to control data flow. When a pause
    frame is received on a flow control enabled interface,
    the transmit operation is stopped for the pause
    duration specified in the pause frame. All other
    frames destined for this interface are queued up.  If
    another pause frame is received before the previous
    pause timer expires, the pause timer is refreshed to
    the new pause duration value. If a steady stream of
    pause frames is received for extended periods of time,
    the transmit queue for that interface continues to
    grow until all queuing resources are exhausted.  This
    condition severely impacts the switch operation on
    other interfaces. In addition, all protocol operations
    on the switch are impacted because of the inability to
    transmit protocol frames. Both port pause and
    priority-based pause frames can cause the same
    resource exhaustion condition.

    VC interconnects provide the ability to monitor server
    downlink ports for pause flood conditions and take
    protective action by disabling the port. The default
    polling interval is 10 seconds and is not customer
    configurable. The SNMP agent supports trap generation
    when a pause flood condition is detected or cleared.

    This feature operates at the physical port level. When
    a pause flood condition is detected on a Flex-10
    physical port, all Flex-10 logical ports associated
    with physical ports are disabled. When the pause flood
    protection feature is enabled, this feature detects
    pause flood conditions on server downlink ports and
    disables the port. The port remains disabled until an
    administrative action is taken. The administrative
    action involves the following steps:

    1. Resolve the issue with the NIC on the server
    causing the continuous pause generation. This might
    include updating the NIC firmware and device drivers.

    Rebooting the server might not clear the pause flood
    condition if the cause of the pause flood condition is
    in the NIC firmware. In this case, the server must be
    completely disconnected from the power source to reset
    the NIC firmware.

    2. Re-enable the disabled ports on the VC interconnect
    modules.''')
    parser.add_argument('-l',
                        dest='network_loop_protection',
                        action='store_true',
                        required=False,
                        help='''
    Disable Network loop protection:

    The loop protection feature enables detection of loops
    on downlink ports, which can be Flex-10 logical ports
    or physical ports. The feature applies when Device
    Control Channel (DCC) protocol is running on the
    Flex-10 port. If DCC is not available, the feature
    applies to the physical downlink port.

    Network loop protection uses two methods to detect
    loops:

    1. It periodically injects a special probe frame into
    the VC domain and monitors downlink ports for the
    looped back probe frame. If this special probe frame
    is detected on downlink ports, the port is considered
    to cause the loop condition.

    2. It monitors and intercepts common loop detection
    frames used in other switches. In network environments
    where the upstream switches send loop detection
    frames, the VC interconnects must ensure that any
    downlink loops do not cause these frames to be sent
    back to the uplink ports. Even though the probe frames
    ensure loops are detected, there is a small time
    window depending on the probe frame transmission
    interval in which the loop detection frames from the
    external switch might loop through down link ports and
    reach uplink ports. By intercepting the external loop
    detection frames on downlinks, the possibility of
    triggering loop protection on the upstream switch is
    eliminated. When network loop protection is enabled,
    VC interconnects intercept loop detection frames from
    various switch vendors, such as Cisco and HPE
    Networking.

    When the network loop protection feature is enabled,
    any probe frame or other supported loop detection
    frame received on a downlink port is considered to be
    causing the network loop, and the port is disabled
    immediately until an administrative action is taken.
    The administrative action involves resolving the loop
    condition and clearing the loop protection error
    condition. The loop detected status on a port can be
    cleared by un-assigning all networks from the profile
    connect corresponding to the port in the loop detected
    state.

    The SNMP agent supports trap generation when a loop
    condition is detected or cleared.''')

    args = parser.parse_args()
    credential = {
        'authLoginDomain': args.domain.upper(),
        'userName': args.user,
        'password': args.passwd
    }

    con = hpov.connection(args.host)
    net = hpov.networking(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    ethernetSettings = defethernet(args.igmp_snooping, args.igmp_idle_timeout,
                                   args.fast_mac_cache_failover,
                                   args.mac_refresh_interval,
                                   args.pause_flood_protection,
                                   args.network_loop_protection)

    deflig(net, con, args.logical_interconnect_group_name, args.interconnects,
           ethernetSettings)
def main():
    parser = argparse.ArgumentParser(add_help=True, description='Usage')
    parser.add_argument('-a',
                        '--appliance',
                        dest='host',
                        required=True,
                        help='HP OneView Appliance hostname or IP')
    parser.add_argument('-u',
                        '--user',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='HP OneView Username')
    parser.add_argument('-p',
                        '--pass',
                        dest='passwd',
                        required=False,
                        help='HP OneView Password')
    parser.add_argument('-c',
                        '--certificate',
                        dest='cert',
                        required=False,
                        help='Trusted SSL Certificate Bundle in PEM '
                        '(Base64 Encoded DER) Format')
    parser.add_argument('-r',
                        '--proxy',
                        dest='proxy',
                        required=False,
                        help='Proxy (host:port format')
    parser.add_argument(
        '-eu',
        '--enc_user',
        dest='encusr',
        required=False,
        help='Administrative username for the c7000 enclosure OA')
    parser.add_argument(
        '-ep',
        '--enc_pass',
        dest='encpass',
        required=False,
        help='Administrative password for the c7000 enclosure OA')
    parser.add_argument(
        '-e',
        dest='enc',
        required=True,
        help='IP address of the c7000 to import into HP OneView')
    parser.add_argument('-n',
                        '--name',
                        dest='egroup',
                        required=False,
                        default='Prod VC FlexFabric Group 1',
                        help='Enclosure Group to add the enclosure to')
    parser.add_argument('-s',
                        '--spp',
                        dest='spp',
                        required=False,
                        help='SPP file name to use as the firmware baseline')
    parser.add_argument('-l',
                        '--license',
                        dest='license',
                        required=False,
                        help='Apply OneView or OneView w/o iLO license to '
                        'servers in the enclosure specify either OneView or '
                        'OneViewNoiLO')

    args = parser.parse_args()
    credential = {'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    srv = hpov.servers(con)
    sts = hpov.settings(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    impenc(srv, sts, args.egroup, args.enc, args.encusr, args.encpass,
           args.license, args.spp)
Example #34
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Display the datacenter resources

    Usage: ''')
    parser.add_argument('-a',
                        dest='host',
                        required=True,
                        help='''
    HPE OneView Appliance hostname or IP address''')
    parser.add_argument('-u',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='''
    HPE OneView Username''')
    parser.add_argument('-p',
                        dest='passwd',
                        required=True,
                        help='''
    HPE OneView Password''')
    parser.add_argument('-c',
                        dest='cert',
                        required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y',
                        dest='proxy',
                        required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j',
                        dest='domain',
                        required=False,
                        default='Local',
                        help='''
    HPE OneView Authorized Login Domain''')
    parser.add_argument('-f',
                        dest='force',
                        action='store_true',
                        required=False,
                        help='''
    Force Power Device deletion''')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-d',
                       dest='delete_all',
                       action='store_true',
                       help='''
    Delete ALL Power Devices''')
    group.add_argument('-n',
                       dest='name',
                       help='''
    Power Device  name to delete''')

    args = parser.parse_args()
    credential = {
        'authLoginDomain': args.domain.upper(),
        'userName': args.user,
        'password': args.passwd
    }

    con = hpov.connection(args.host)
    fac = hpov.facilities(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    if args.delete_all:
        del_all_powerdevices(fac, args.force)
        sys.exit()

    del_powerdevice(fac, args.name, args.force)
Example #35
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Add a new license

    Usage: ''')
    parser.add_argument('-a',
                        dest='host',
                        required=True,
                        help='''
    HP OneView Appliance hostname or IP address''')
    parser.add_argument('-u',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='''
    HP OneView Username''')
    parser.add_argument('-p',
                        dest='passwd',
                        required=True,
                        help='''
    HP OneView Password''')
    parser.add_argument('-c',
                        dest='cert',
                        required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y',
                        dest='proxy',
                        required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j',
                        dest='domain',
                        required=False,
                        default='Local',
                        help='''
    HP OneView Authorized Login Domain''')
    parser.add_argument('-f',
                        dest='file',
                        required=True,
                        help='''
    HP OneView license file 1 key per license file''')

    args = parser.parse_args()
    credential = {
        'authLoginDomain': args.domain.upper(),
        'userName': args.user,
        'password': args.passwd
    }

    con = hpov.connection(args.host)
    sts = hpov.settings(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    try:
        f = open(args.file, 'r')
        lic = f.read()
        f.close()
    except IOError:
        print('Error reading license file')
        sys.exit()

    addlic(sts, lic.rstrip('\n'))
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Obtain a collection of Enclosure Group resources, or a single Enclosure
    Group with the specified name.

    Usage: ''')
    parser.add_argument('-a',
                        dest='host',
                        required=True,
                        help='''
    HPE OneView Appliance hostname or IP address''')
    parser.add_argument('-u',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='''
    HPE OneView Username''')
    parser.add_argument('-p',
                        dest='passwd',
                        required=True,
                        help='''
    HPE OneView Password''')
    parser.add_argument('-c',
                        dest='cert',
                        required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y',
                        dest='proxy',
                        required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j',
                        dest='domain',
                        required=False,
                        default='Local',
                        help='''
    HPE OneView Authorized Login Domain''')
    parser.add_argument('-n',
                        dest='name',
                        required=False,
                        help='''
    The name of the enclosure group resource to be returned.
    All enclosure group resources will be returned if omitted.''')

    args = parser.parse_args()
    credential = {
        'authLoginDomain': args.domain.upper(),
        'userName': args.user,
        'password': args.passwd
    }

    con = hpov.connection(args.host)
    srv = hpov.servers(con)
    net = hpov.networking(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    get_enclosure_groups(srv, net, args.name)
Example #37
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Display Storage Systems

    Usage: ''')
    parser.add_argument('-a',
                        dest='host',
                        required=True,
                        help='''
    HP OneView Appliance hostname or IP address''')
    parser.add_argument('-u',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='''
    HP OneView Username''')
    parser.add_argument('-p',
                        dest='passwd',
                        required=True,
                        help='''
    HP OneView Password''')
    parser.add_argument('-c',
                        dest='cert',
                        required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y',
                        dest='proxy',
                        required=False,
                        help='''
    Proxy (host:port format''')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-n',
                       dest='name',
                       help='''
    Name of the storage system to get''')
    group.add_argument('-s',
                       dest='serialNo',
                       help='''
    Serial number of the storage system to get''')
    group.add_argument('-g',
                       dest='get',
                       action='store_true',
                       help='''
    Get all storage systems''')

    args = parser.parse_args()
    credential = {'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    sto = hpov.storage(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    if args.name:
        get_storage_system_by_name(sto, args.name)
        sys.exit()

    if args.serialNo:
        get_storage_system_by_serial(sto, args.serialNo)
        sys.exit()

    if args.get:
        get_all_storage_systems(sto)
Example #38
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Add new user

    Usage: ''')
    parser.add_argument('-a',
                        dest='host',
                        required=True,
                        help='''
    HP OneView Appliance hostname or IP address''')
    parser.add_argument('-u',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='''
    HP OneView Username''')
    parser.add_argument('-p',
                        dest='passwd',
                        required=True,
                        help='''
    HP OneView Password''')
    parser.add_argument('-c',
                        dest='cert',
                        required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y',
                        dest='proxy',
                        required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j',
                        dest='domain',
                        required=False,
                        default='Local',
                        help='''
    HP OneView Authorized Login Domain''')
    parser.add_argument('-n',
                        dest='name',
                        required=True,
                        help='''
    The name of the new user account to be created''')
    parser.add_argument('-x',
                        dest='user_pass',
                        required=True,
                        help='''
    The initial password to be assigned to the new user.

    Passwords must be at least 8 characters and not contain any of these
    characters:
              < > ; , \" ' & \\/ | + : = and space ''')
    parser.add_argument('-o',
                        dest='roles',
                        required=True,
                        nargs='+',
                        help='''
    A list of roles to assign the user to. Allowed values are:

        * Full = Full Infrastructure Administrator
        * RO = Read Only
        * Specialized (select one or more roles):
            - Backup = Backup Administrator
            - Network = Network Administrator
            - Server = Server Administrator
            - Storage = Storage Administrator

    For example the user can be assigned as the Infrastructure Administrator
    with full access OR as a user with Read Only access OR as a Specialized
    user with one for more of the specialized roles listed above, encapsulated
    with quotes and seperated by spaces. For example to assign the user to
    the Storage and Network administrator roles it would be specified as:

        -o "Network" "Storage"

    To assign the user to the Infrastructure Administrator role it would be
    specified as:

        -o "Full"''')
    parser.add_argument('-l',
                        dest='full_name',
                        required=False,
                        help='''
    Full name for the user''')
    parser.add_argument('-e',
                        dest='email',
                        required=False,
                        help='''
    Email address of the user''')
    parser.add_argument('-z',
                        dest='ophone',
                        required=False,
                        help='''
    Office phone number''')
    parser.add_argument('-m',
                        dest='mphone',
                        required=False,
                        help='''
    Mobile phone number''')
    parser.add_argument('-d',
                        dest='disable',
                        required=False,
                        action='store_true',
                        help='''
    Disable the account, preventing the user from logging into the
    appliance''')

    args = parser.parse_args()
    credential = {
        'authLoginDomain': args.domain.upper(),
        'userName': args.user,
        'password': args.passwd
    }

    con = hpov.connection(args.host)
    sec = hpov.security(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    add_user(sec, args.name, args.user_pass, args.roles, args.full_name,
             args.email, args.ophone, args.mphone, args.disable)
Example #39
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Define a OneView network connection list for use with defining a server
    profile with connections.

    Usage: ''')
    parser.add_argument('-a',
                        dest='host',
                        required=True,
                        help='''
    HPE OneView Appliance hostname or IP address''')
    parser.add_argument('-u',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='''
    HPE OneView Username''')
    parser.add_argument('-p',
                        dest='passwd',
                        required=True,
                        help='''
    HPE OneView Password''')
    parser.add_argument('-c',
                        dest='cert',
                        required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y',
                        dest='proxy',
                        required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j',
                        dest='domain',
                        required=False,
                        default='Local',
                        help='''
    HPE OneView Authorized Login Domain''')
    parser.add_argument('-n',
                        dest='name',
                        required=True,
                        help='''
    Name of the network connection''')
    parser.add_argument('-i',
                        dest='cid',
                        required=True,
                        help='''
    Unique ID for the network connection''')
    parser.add_argument('-net',
                        dest='network',
                        required=True,
                        help='''
    The name of the Ethernet network, network set, or Fibre Channel network to
    use for this connection.''')
    parser.add_argument('-cl',
                        dest='conn_list',
                        required=True,
                        help='''
    Name of file for connection list''')
    parser.add_argument('-app',
                        dest='append',
                        required=False,
                        action='store_true',
                        help='''
    Causes connection list to be appended to the file''')
    parser.add_argument('-ns',
                        dest='net_set',
                        required=False,
                        action='store_true',
                        help='''
    Required to mark the connection type as a Network Set''')
    parser.add_argument('-port',
                        dest='portId',
                        required=False,
                        default='Auto',
                        help='''
    Identifies the port (FlexNIC) used for this connection, for example
    'Flb 1:1-a'. The port can be automatically selected by specifying 'Auto',
    'None', or a physical port when creating or editing the connection.
    If 'Auto' is specified, a port that provides access to the selected
    network (networkUri) will be selected. A physical port (e.g. 'Flb 1:2')
    can be specified if the choice of a specific FlexNIC on the physical
    port is not important. If 'None' is specified, the connection will not
    be configured on the server hardware.''')
    parser.add_argument('-func',
                        dest='func',
                        required=False,
                        choices=['Ethernet', 'FibreChannel'],
                        default='Ethernet',
                        help='''
    Ethernet or FibreChannel''')
    parser.add_argument('-mac',
                        dest='mac',
                        required=False,
                        help='''
    The MAC address that is currently programmed on the FlexNic. The value can
    be virtual, user defined or physical MAC address read from the device.''')
    parser.add_argument('-mt',
                        dest='macType',
                        required=False,
                        choices=['Physical', 'UserDefined', 'Virtual'],
                        default='Virtual',
                        help='''
    Specifies the type of MAC address to be programmed into the IO Devices.''')
    parser.add_argument('-gbps',
                        dest='reqGbps',
                        required=False,
                        type=float,
                        help='''
    Transmit thorougput for this connection in Gbps Must be between .1 and
    20 Gbps''')
    parser.add_argument('-wwnn',
                        dest='wwnn',
                        required=False,
                        help='''
    The node WWN address that is currently programmed on the FlexNic. The
    value can be a virtual WWNN, user defined WWNN or physical WWNN read from
    the device.''')
    parser.add_argument('-wwpn',
                        dest='wwpn',
                        required=False,
                        help='''
    The port WWN address that is currently programmed on the FlexNIC. The
    value can be a virtual WWPN, user defined WWPN or the physical WWPN read
    from the device.''')
    parser.add_argument('-wt',
                        dest='wwpnType',
                        required=False,
                        choices=['Physical', 'UserDefined', 'Virtual'],
                        default='Virtual',
                        help='''
    Specifies the type of WWN address to be porgrammed on the FlexNIC. The
    value can be 'Virtual', 'Physical' or 'UserDefined'.''')
    parser.add_argument('-bp',
                        dest='boot_priority',
                        required=False,
                        choices=['Primary', 'Secondary', 'NotBootable'],
                        default='NotBootable',
                        help='''
    Primary or Secondary or NotBootable''')
    parser.add_argument('-t',
                        dest='boot_target',
                        required=False,
                        help='''
    The wwpn of the target device that provides access to the Boot Volume.
    This value must contain 16 HEX digits''')
    parser.add_argument('-l',
                        dest='boot_lun',
                        required=False,
                        type=int,
                        help='''
    The LUN of the Boot Volume presented by the target device. This value can
    bein the range 0 to 255.''')
    parser.add_argument('-spt',
                        dest='spt',
                        required=False,
                        action='store_true',
                        help='''
    Specifies if the connection list is to be used in defining a server profile 
    template.''')

    args = parser.parse_args()
    credential = {
        'authLoginDomain': args.domain.upper(),
        'userName': args.user,
        'password': args.passwd
    }

    con = hpov.connection(args.host)
    net = hpov.networking(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    if args.boot_lun:
        if args.boot_lun < 0 or args.boot_lun > 255:
            print('Error: boot lun value must be between 0 and 255')
            sys.exit(1)

    if args.cid:
        if int(args.cid) < 1 or int(args.cid) > 999:
            print('Error: connection ID value must be between 1 and 999')
            sys.exit(2)

    boot = define_boot_list(args.func, args.boot_priority, args.boot_target,
                            args.boot_lun)

    define_connection_list(net, args.name, args.cid, args.network,
                           args.conn_list, args.append, args.portId, args.func,
                           args.mac, args.macType, args.net_set, args.reqGbps,
                           args.wwnn, args.wwpn, args.wwpnType, boot, args.spt)
Example #40
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Display Server Profiles

    Usage: ''')
    parser.add_argument('-a',
                        dest='host',
                        required=True,
                        help='''
    HP OneView Appliance hostname or IP address''')
    parser.add_argument('-u',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='''
    HP OneView Username''')
    parser.add_argument('-p',
                        dest='passwd',
                        required=True,
                        help='''
    HP OneView Password''')
    parser.add_argument('-c',
                        dest='cert',
                        required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y',
                        dest='proxy',
                        required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j',
                        dest='domain',
                        required=False,
                        default='Local',
                        help='''
    HP OneView Authorized Login Domain''')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-n',
                       dest='name',
                       help='''
    Name of the server profile to get''')
    group.add_argument('-g',
                       dest='get_all',
                       action='store_true',
                       help='''
    Get ALL server profiles and exit''')

    args = parser.parse_args()
    credential = {
        'authLoginDomain': args.domain.upper(),
        'userName': args.user,
        'password': args.passwd
    }

    con = hpov.connection(args.host)
    srv = hpov.servers(con)
    net = hpov.networking(con)
    sts = hpov.settings(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    if args.get_all:
        get_all_profiles(srv)
        sys.exit()

    get_profile_by_name(srv, args.name)
Example #41
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Shutdown or Reboot the HP OneView Appliance

    Usage: ''')
    parser.add_argument('-a',
                        dest='host',
                        required=True,
                        help='''
    HP OneView Appliance hostname or IP address''')
    parser.add_argument('-u',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='''
    HP OneView Username''')
    parser.add_argument('-p',
                        dest='passwd',
                        required=True,
                        help='''
    HP OneView Password''')
    parser.add_argument('-c',
                        dest='cert',
                        required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y',
                        dest='proxy',
                        required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j',
                        dest='domain',
                        required=False,
                        default='Local',
                        help='''
    HP OneView Authorized Login Domain''')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-r',
                       dest='reboot',
                       action='store_true',
                       help='''
    Shutdown and restart/reboot the appliance''')
    group.add_argument('-s',
                       dest='halt',
                       action='store_true',
                       help='''
    Shutdown and halt the appliance''')

    args = parser.parse_args()
    credential = {
        'authLoginDomain': args.domain.upper(),
        'userName': args.user,
        'password': args.passwd
    }

    con = hpov.connection(args.host)
    sts = hpov.settings(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    if args.reboot:
        shutdown(sts, 'REBOOT')
    elif args.halt:
        shutdown(sts, 'HALT')
Example #42
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    This example script will import an enclosure into HPE OneView as a
    managed device.  The Onboard Administrator needs to have IP Address
    configured for each module, and a valid Administrator account with a
    password.

    Usage: ''')
    parser.add_argument('-a',
                        dest='host',
                        required=True,
                        help='''
    HPE OneView Appliance hostname or IP address''')
    parser.add_argument('-u',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='''
    HPE OneView Username''')
    parser.add_argument('-p',
                        dest='passwd',
                        required=True,
                        help='''
    HPE OneView Password''')
    parser.add_argument('-c',
                        dest='cert',
                        required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y',
                        dest='proxy',
                        required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j',
                        dest='domain',
                        required=False,
                        default='Local',
                        help='''
    HPE OneView Authorized Login Domain''')
    parser.add_argument('-eu',
                        dest='encusr',
                        required=True,
                        help='''
    Administrative username for the c7000 enclosure OA''')
    parser.add_argument('-ep',
                        dest='encpass',
                        required=True,
                        help='''
    Administrative password for the c7000 enclosure OA''')
    parser.add_argument('-oa',
                        dest='enc',
                        required=True,
                        help='''
    IP address of the c7000 to import into HPE OneView''')
    parser.add_argument('-s',
                        dest='spp',
                        required=False,
                        help='''
    SPP Baseline file name. e.g. SPP2013090_2013_0830_30.iso''')
    parser.add_argument('-l',
                        dest='license',
                        required=False,
                        choices=['OneView', 'OneViewNoiLO'],
                        default='OneView',
                        help='''
    Specifies whether the intent is to apply either OneView or
    OneView w/o iLO licenses to the servers in the enclosure
    being imported.

    Accepted values are:

        - OneView
        - OneViewNoiLO ''')
    parser.add_argument('-f',
                        dest='force',
                        action='store_true',
                        required=False,
                        help='''
    When attempting to add an Enclosure to the appliance, the appliance will
    validate the target Enclosure is not already claimed.  If it is, this
    parameter is used when the Enclosure has been claimed by another appliance
    to bypass the confirmation prompt, and force add the import of the
    Enclosure ''')
    parser.add_argument('-fw',
                        dest='forcefw',
                        action='store_true',
                        required=False,
                        help='''
    Force the installation of the provided Firmware Baseline. ''')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-eg',
                       dest='egroup',
                       help='''
    Enclosure Group to add the enclosure to''')
    group.add_argument('-m',
                       dest='monitor',
                       action='store_true',
                       help='''
    Import the enclosure as a Monitored enclosure. ''')
    args = parser.parse_args()
    credential = {
        'authLoginDomain': args.domain.upper(),
        'userName': args.user,
        'password': args.passwd
    }

    con = hpov.connection(args.host)
    srv = hpov.servers(con)
    sts = hpov.settings(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    import_enclosure(srv, sts, args.egroup, args.enc, args.encusr,
                     args.encpass, args.license, args.spp, args.force,
                     args.forcefw, args.monitor)
Example #43
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Define new ethernet network

    Usage: ''')
    parser.add_argument('-a',
                        dest='host',
                        required=True,
                        help='''
    HPE OneView Appliance hostname or IP address''')
    parser.add_argument('-u',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='''
    HPE OneView Username''')
    parser.add_argument('-p',
                        dest='passwd',
                        required=True,
                        help='''
    HPE OneView Password''')
    parser.add_argument('-c',
                        dest='cert',
                        required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y',
                        dest='proxy',
                        required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j',
                        dest='domain',
                        required=False,
                        default='Local',
                        help='''
    HPE OneView Authorized Login Domain''')
    parser.add_argument('-n',
                        dest='network_name',
                        required=True,
                        help='''
    Name of the network''')
    parser.add_argument('-b',
                        dest='prefered_bandwidth',
                        type=float,
                        required=False,
                        default=2.5,
                        help='''
    Typical bandwidth between .1  and 20 Gb/s''')
    parser.add_argument('-m',
                        dest='max_bandwidth',
                        type=float,
                        required=False,
                        default=10,
                        help='''
    Maximum bandwidth between .1 and 20 Gb/s''')
    parser.add_argument('-v',
                        dest='vlan',
                        required=False,
                        help='''
    VLAN ID''')
    parser.add_argument('-z',
                        dest='vlan_type',
                        choices=['Tagged', 'Untagged', 'Tunnel'],
                        required=False,
                        default='Tagged',
                        help='''
    VLAN Type''')
    parser.add_argument(
        '-o',
        dest='purpose',
        choices=['FaultTolerance', 'General', 'Management', 'VMMigration'],
        required=False,
        default='General',
        help='''
    A description to attach to a network to help categorize the purpose of
    the  network''')
    parser.add_argument('-s',
                        dest='slink',
                        required=False,
                        action='store_true',
                        help='''
    DISABLE Smart Link''')
    parser.add_argument('-x',
                        dest='private',
                        required=False,
                        action='store_true',
                        help='''
    ENABLE Private Network''')

    args = parser.parse_args()
    credential = {
        'authLoginDomain': args.domain.upper(),
        'userName': args.user,
        'password': args.passwd
    }

    con = hpov.connection(args.host)
    net = hpov.networking(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    if args.vlan_type == 'Tagged' and not args.vlan:
        print('Error, you must specify a VLAN ID for a Tagged network')
        sys.exit()

    if args.prefered_bandwidth < .1 or args.prefered_bandwidth > 20:
        print('Error, prefered bandwidth must be between .1 and 20 Gb/s')
        sys.exit()
    if args.max_bandwidth < .1 or args.max_bandwidth > 20:
        print('Error, max bandwidth must be between .1 and 20 Gb/s')
        sys.exit()
    if args.prefered_bandwidth > args.max_bandwidth:
        print('Error, prefered bandwidth must be less than or equal '
              'to the maximum bandwidth')
        sys.exit()

    add_network(net, args.network_name, args.prefered_bandwidth,
                args.max_bandwidth, args.vlan, args.vlan_type, args.purpose,
                args.slink, args.private)
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Retrieve licenses installed on the appliance. You can use this to get an
    inventory of what's installed and what licenses are consumed.

                                     Usage: ''')
    parser.add_argument('-a',
                        dest='host',
                        required=True,
                        help='''
    HPE OneView Appliance hostname or IP address''')
    parser.add_argument('-u',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='''
    HPE OneView Username''')
    parser.add_argument('-p',
                        dest='passwd',
                        required=True,
                        help='''
    HPE OneView Password''')
    parser.add_argument('-c',
                        dest='cert',
                        required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y',
                        dest='proxy',
                        required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j',
                        dest='domain',
                        required=False,
                        default='Local',
                        help='''
    HPE OneView Authorized Login Domain''')
    parser.add_argument('-r',
                        dest='report',
                        required=False,
                        action='store_true',
                        help='''
    Format the output using a human readable report format''')

    args = parser.parse_args()
    credential = {
        'authLoginDomain': args.domain.upper(),
        'userName': args.user,
        'password': args.passwd
    }

    con = hpov.connection(args.host)
    sts = hpov.settings(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
        if args.cert:
            con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    get_license_info(con, sts, args.report)
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Provision a new storage volume from the managed Storage System.

    Usage: ''')
    parser.add_argument('-a',
                        dest='host',
                        required=True,
                        help='''
    HPE OneView Appliance hostname or IP address''')
    parser.add_argument('-u',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='''
    HPE OneView Username''')
    parser.add_argument('-p',
                        dest='passwd',
                        required=True,
                        help='''
    HPE OneView Password''')
    parser.add_argument('-c',
                        dest='cert',
                        required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y',
                        dest='proxy',
                        required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j',
                        dest='domain',
                        required=False,
                        default='Local',
                        help='''
    HPE OneView Authorized Login Domain''')
    parser.add_argument('-n',
                        dest='name',
                        required=True,
                        help='''
    Name of the storage volume to add''')
    parser.add_argument('-sp',
                        dest='sto_pool',
                        required=True,
                        help='''
    Name of the storage pool to use''')
    parser.add_argument('-cap',
                        dest='size',
                        required=True,
                        help='''
    Size of volume in GiB''')
    parser.add_argument('-sh',
                        dest='shareable',
                        required=False,
                        default=False,
                        action='store_true',
                        help='''
    sets volume to shareable, omit for private''')
    parser.add_argument('-pt',
                        dest='provType',
                        required=False,
                        default='Thin',
                        help='''
    Thin or Full provisioning''')
    parser.add_argument('-des',
                        dest='desc',
                        required=False,
                        default='Example Volume',
                        help='''
    Description of volume''')

    args = parser.parse_args()
    credential = {
        'authLoginDomain': args.domain.upper(),
        'userName': args.user,
        'password': args.passwd
    }

    con = hpov.connection(args.host)
    sto = hpov.storage(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    add_volume(sto, args.name, args.sto_pool, args.size, args.shareable,
               args.desc, args.provType)
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Define new Uplink Set

    Usage: ''')
    parser.add_argument('-a',
                        dest='host',
                        required=True,
                        help='''
    HP OneView Appliance hostname or IP address''')
    parser.add_argument('-u',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='''
    HP OneView Username''')
    parser.add_argument('-p',
                        dest='passwd',
                        required=True,
                        help='''
    HP OneView Password''')
    parser.add_argument('-c',
                        dest='cert',
                        required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y',
                        dest='proxy',
                        required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-n',
                        dest='uplink_set_name',
                        required=True,
                        help='''
    Name of the uplink  set''')
    parser.add_argument('-i',
                        dest='logical_interconnect_group_name',
                        required=True,
                        help='''
    Name of the associated Logical Interconnect Group''')
    parser.add_argument('-l',
                        dest='list_of_networks',
                        required=False,
                        nargs='+',
                        help='''
    List of network names to add to the uplink set, encapsulated with quotes
    and seperated by spaces. For example:

                -l "Net One" "Net Two" "Net Three"''')
    parser.add_argument('-t',
                        dest='uplink_type',
                        choices=['Ethernet', 'FibreChannel'],
                        required=True,
                        help='''
    Uplink Type''')
    parser.add_argument('-e',
                        dest='ethernet_type',
                        choices=['Tagged', 'Tunnel', 'Untagged'],
                        required=False,
                        default='Tagged',
                        help='''
    Ethernet Type''')
    parser.add_argument('-x',
                        dest='native_network',
                        required=False,
                        help='''
    Name of the network to be marked as native''')
    parser.add_argument('-o',
                        dest='uplink_ports',
                        required=False,
                        nargs='+',
                        help='''
    List of uplink ports connected to the uplink sets specified as BAY:PORT
    and seperated by spaces. For example BAY 1 PORT X2 and BAY 1 PORT X3
    would be specified as:
                        -o 1:2 1:3''')
    parser.add_argument('-m',
                        dest='lacp_mode',
                        required=False,
                        choices=['Long', 'Short'],
                        default='Long',
                        help='''
    LACP mode on ETHERNET uplink ports''')
    parser.add_argument('-g',
                        dest='connection_mode',
                        choices=['Auto', 'FailOver'],
                        required=False,
                        default='Auto',
                        help='''
    Ethernet connection mode''')

    args = parser.parse_args()
    credential = {'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    net = hpov.networking(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    adduplinkset(con, net, args.uplink_set_name,
                 args.logical_interconnect_group_name, args.list_of_networks,
                 args.uplink_type, args.ethernet_type, args.native_network,
                 args.uplink_ports, args.lacp_mode, args.connection_mode)
Example #47
0
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Define a OneView SAN Storage connection list for use with defining a
    server profile with managed SAN storage connections.

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    HP OneView Appliance hostname or IP address''')
    parser.add_argument('-u', dest='user', required=False,
                        default='Administrator',
                        help='''
    HP OneView Username''')
    parser.add_argument('-p', dest='passwd', required=True,
                        help='''
    HP OneView Password''')
    parser.add_argument('-c', dest='cert', required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y', dest='proxy', required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-sl', dest='san_list',
                        required=True,
                        help='''
    Name of file for SAN storage list''')
    parser.add_argument('-cl', dest='conn_list',
                        required=True,
                        help='''
    Name of server profile connection list file to import''')
    parser.add_argument('-app', dest='append',
                        required=False,
                        action='store_true',
                        help='''
    Causes SAN list to be appended to the file''')
    parser.add_argument('-o', dest='hostos',
                        required=True,
                        choices=['CitrixXen', 'AIX', 'IBMVIO', 'RHEL4',
                                 'RHEL3', 'RHEL', 'RHEV', 'VMware', 'Win2k3',
                                 'Win2k8', 'Win2k12', 'OpenVMS', 'Egenera',
                                 'Exanet', 'Solaris9', 'Solaris10',
                                 'Solaris11', 'ONTAP', 'OEL', 'HPUX11iv1',
                                 'HPUX11iv2', 'HPUX11iv3', 'SUSE', 'SUSE9',
                                 'Inform'],
                        help='''
    Specify the Host OS type, which will set the Host OS value when HP OneView
    created the Host object on the Storage System. Accepted values:

         . CitrixXen = "Citrix Xen Server 5.x/6.x"
         . AIX       = "AIX"
         . IBMVIO    = "IBM VIO Server"
         . RHEL4     = "RHE Linux (Pre RHEL 5)"
         . RHEL3     = "RHE Linux (Pre RHEL 5)"
         . RHEL      = "RHE Linux (5.x, 6.x)"
         . RHEV      = "RHE Virtualization (5.x, 6.x)"
         . VMware    = "ESX 4.x/5.x"
         . Win2k3    = "Windows 2003"
         . Win2k8    = "Windows 2008/2008 R2"
         . Win2k12   = "Windows 2012 / WS2012 R2"
         . OpenVMS   = "OpenVMS"
         . Egenera   = "Egenera"
         . Exanet    = "Exanet"
         . Solaris9  = "Solaris 9/10"
         . Solaris10 = "Solaris 9/10"
         . Solaris11 = "Solaris 11"
         . ONTAP     = "NetApp/ONTAP"
         . OEL       = "OE Linux UEK (5.x, 6.x)"
         . HPUX11iv1 = "HP-UX (11i v1, 11i v2)"
         . HPUX11iv2 = "HP-UX (11i v1, 11i v2)"
         . HPUX11iv3 = "HP-UX (11i v3)"
         . SUSE      = "SuSE (10.x, 11.x)"
         . SUSE9     = "SuSE Linux (Pre SLES 10)"
         . Inform    = "InForm"

    ''')
    parser.add_argument('-n', dest='name', required=True,
                        help='''
    Name of the exsisting storage volume to attach''')
    parser.add_argument('-l', dest='lun_id', required=False,
                        type=int,
                        help='''
    Manual entry for the LUN number. Auto, will be used if this
    value is not specified.''')
    parser.add_argument('-del', dest='del_vol', required=False,
                        action='store_false',
                        help='''
    Indicates that the volume will be deleted when the profile is deleted.''')

    args = parser.parse_args()
    credential = {'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    sto = hpov.storage(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    if args.lun_id:
        if args.lun_id < 0 or args.lun_id > 255:
            print('Error: boot lun value must be between 0 and 255')
            sys.exit(1)

    define_san(sto, args.name, args.san_list, args.conn_list, args.append,
               args.hostos, args.lun_id, args.del_vol)
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Display server bios settings

    Usage: ''')
    parser.add_argument('-a',
                        dest='host',
                        required=True,
                        help='''
    HP OneView Appliance hostname or IP address''')
    parser.add_argument('-u',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='''
    HP OneView Username''')
    parser.add_argument('-p',
                        dest='passwd',
                        required=True,
                        help='''
    HP OneView Password''')
    parser.add_argument('-n',
                        dest='name',
                        required=False,
                        help='''
    The name of the server hardware resource to be returned its bios settings.
    ''')
    parser.add_argument('-c',
                        dest='cert',
                        required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y',
                        dest='proxy',
                        required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j',
                        dest='domain',
                        required=False,
                        default='Local',
                        help='''
    HP OneView Authorized Login Domain''')

    args = parser.parse_args()
    credential = {
        'authLoginDomain': args.domain.upper(),
        'userName': args.user,
        'password': args.passwd
    }

    con = hpov.connection(args.host)
    srv = hpov.servers(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    getbios(srv, args.name)
Example #49
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Delete individual or ALL SAN Managers

    Usage: ''')
    parser.add_argument('-a',
                        dest='host',
                        required=True,
                        help='''
                        HP OneView Appliance hostname or IP address''')
    parser.add_argument('-u',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='''
                        HP OneView Username''')
    parser.add_argument('-p',
                        dest='passwd',
                        required=True,
                        help='''
                        HP OneView Password''')
    parser.add_argument('-c',
                        dest='cert',
                        required=False,
                        help='''
                        Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format'''
                        )
    parser.add_argument('-y',
                        dest='proxy',
                        required=False,
                        help='''
                        Proxy (host:port format''')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-d',
                       dest='delete_all',
                       action='store_true',
                       help='''
                       Delete ALL SAN Managers''')
    group.add_argument('-n',
                       dest='name',
                       help='''
                       Name of the SAN Manager to delete''')

    args = parser.parse_args()
    credential = {'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    fcs = hpov.fcsans(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
        if args.cert:
            con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    if args.delete_all:
        del_all_san_managers(fcs)
        sys.exit()

    del_san_manager_by_name(fcs, args.name)
Example #50
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Add an iPDU Power Device

    Usage: ''')
    parser.add_argument('-a',
                        dest='host',
                        required=True,
                        help='''
    HPE OneView Appliance hostname or IP address''')
    parser.add_argument('-u',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='''
    HPE OneView Username''')
    parser.add_argument('-p',
                        dest='passwd',
                        required=True,
                        help='''
    HPE OneView Password''')
    parser.add_argument('-c',
                        dest='cert',
                        required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y',
                        dest='proxy',
                        required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j',
                        dest='domain',
                        required=False,
                        default='Local',
                        help='''
    HPE OneView Authorized Login Domain''')
    parser.add_argument('-ih',
                        dest='ipdu',
                        required=True,
                        help='''
    Hostname or IP address of the iPDU to add''')
    parser.add_argument('-iu',
                        dest='username',
                        required=True,
                        help='''
    Administrative username for the iPDU''')
    parser.add_argument('-ip',
                        dest='password',
                        required=True,
                        help='''
    Administrative password for the iPDU''')

    args = parser.parse_args()
    credential = {
        'authLoginDomain': args.domain.upper(),
        'userName': args.user,
        'password': args.passwd
    }

    con = hpov.connection(args.host)
    fac = hpov.facilities(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    add_iPDU(fac, args.ipdu, args.username, args.password)
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Retrieves the configuration parameters of the primary network interface
    on the appliance

    Usage: ''')
    parser.add_argument('-a',
                        dest='host',
                        required=True,
                        help='''
    HPE OneView Appliance hostname or IP address''')
    parser.add_argument('-u',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='''
    HPE OneView Username''')
    parser.add_argument('-p',
                        dest='passwd',
                        required=True,
                        help='''
    HPE OneView Password''')
    parser.add_argument('-c',
                        dest='cert',
                        required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y',
                        dest='proxy',
                        required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j',
                        dest='domain',
                        required=False,
                        default='Local',
                        help='''
    HPE OneView Authorized Login Domain''')

    args = parser.parse_args()
    credential = {
        'authLoginDomain': args.domain.upper(),
        'userName': args.user,
        'password': args.passwd
    }

    con = hpov.connection(args.host)
    srv = hpov.servers(con)
    net = hpov.networking(con)
    sts = hpov.settings(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    get_network_interfaces(sts)
Example #52
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Display the HPE OneView appliance health status. This
    includes CPU, Memory and Disk Space.

    Usage: ''')
    parser.add_argument('-a',
                        dest='host',
                        required=True,
                        help='''
    HPE OneView Appliance hostname or IP address''')
    parser.add_argument('-u',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='''
    HPE OneView Username''')
    parser.add_argument('-p',
                        dest='passwd',
                        required=True,
                        help='''
    HPE OneView Password''')
    parser.add_argument('-c',
                        dest='cert',
                        required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y',
                        dest='proxy',
                        required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j',
                        dest='domain',
                        required=False,
                        default='Local',
                        help='''
    HPE OneView Authorized Login Domain''')

    args = parser.parse_args()
    credential = {
        'authLoginDomain': args.domain.upper(),
        'userName': args.user,
        'password': args.passwd
    }

    con = hpov.connection(args.host)
    sts = hpov.settings(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    gethelth(sts)
Example #53
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Upload and restore a HP OneView backup file

    Usage: ''')
    parser.add_argument('-a',
                        dest='host',
                        required=True,
                        help='''
    HP OneView Appliance hostname or IP address''')
    parser.add_argument('-u',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='''
    HP OneView Username''')
    parser.add_argument('-p',
                        dest='passwd',
                        required=True,
                        help='''
    HP OneView Password''')
    parser.add_argument('-c',
                        dest='cert',
                        required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y',
                        dest='proxy',
                        required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j',
                        dest='domain',
                        required=False,
                        default='Local',
                        help='''
    HP OneView Authorized Login Domain''')
    parser.add_argument('-f',
                        dest='file',
                        required=True,
                        help='''
    Backup file to restore''')

    args = parser.parse_args()
    credential = {
        'authLoginDomain': args.domain.upper(),
        'userName': args.user,
        'password': args.passwd
    }

    con = hpov.connection(args.host)
    sts = hpov.settings(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    (path, name) = os.path.split(args.file)
    restore_backup(sts, args.file, name)
Example #54
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Add Fibre Channel network

    Usage: ''')
    parser.add_argument('-a',
                        dest='host',
                        required=True,
                        help='''
    HPE OneView Appliance hostname or IP address''')
    parser.add_argument('-u',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='''
    HPE OneView Username''')
    parser.add_argument('-p',
                        dest='passwd',
                        required=True,
                        help='''
    HPE OneView Password''')
    parser.add_argument('-c',
                        dest='cert',
                        required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y',
                        dest='proxy',
                        required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j',
                        dest='domain',
                        required=False,
                        default='Local',
                        help='''
    HPE OneView Authorized Login Domain''')
    parser.add_argument('-n',
                        dest='network_name',
                        required=True,
                        help='''
    Name of the network''')
    parser.add_argument('-b',
                        dest='prefered_bandwidth',
                        type=float,
                        required=False,
                        default=2.5,
                        help='''
    Typical bandwidth between .1  and 20 Gb/s''')
    parser.add_argument('-m',
                        dest='max_bandwidth',
                        type=float,
                        required=False,
                        default=10,
                        help='''
    Maximum bandwidth between .1 and 20 Gb/s''')
    parser.add_argument('-s',
                        dest='managed_san',
                        required=False,
                        help='''
    URI of the associated managed SAN''')
    parser.add_argument('-l',
                        dest='link_stability',
                        type=int,
                        required=False,
                        default=30,
                        help='''
    Link Stability Interval between 1 and 1800 seconds''')
    parser.add_argument('-x',
                        dest='dist',
                        required=False,
                        action='store_true',
                        help='''
    Disable AUTO loging redistribution''')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-d',
                       dest='direct',
                       action='store_true',
                       help='''
    DirectAttach Fabric Type''')
    group.add_argument('-f',
                       dest='fabric',
                       action='store_true',
                       help='''
    FabricAttach Fabric Type''')

    args = parser.parse_args()
    credential = {
        'authLoginDomain': args.domain.upper(),
        'userName': args.user,
        'password': args.passwd
    }

    con = hpov.connection(args.host)
    net = hpov.networking(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    if args.prefered_bandwidth < .1 or args.prefered_bandwidth > 20:
        print('Error, prefered bandwidth must be between .1 and 20 Gb/s')
        sys.exit()
    if args.max_bandwidth < .1 or args.max_bandwidth > 20:
        print('Error, max bandwidth must be between .1 and 20 Gb/s')
        sys.exit()
    if args.prefered_bandwidth > args.max_bandwidth:
        print('Error, prefered bandwidth must be less than or equal '
              'to the maximum bandwidth')
        sys.exit()
    if args.link_stability < 1 or args.link_stability > 1800:
        print('Error, prefered bandwidth must be between .1 and 20 Gb/s')
        sys.exit()

    add_network(net, args.network_name, args.prefered_bandwidth,
                args.max_bandwidth, args.managed_san, args.link_stability,
                args.dist, args.direct, args.fabric)
Example #55
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Display alerts

    Usage: ''')
    parser.add_argument('-a',
                        dest='host',
                        required=True,
                        help='''
    HP OneView Appliance hostname or IP address''')
    parser.add_argument('-u',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='''
    HP OneView Username''')
    parser.add_argument('-p',
                        dest='passwd',
                        required=True,
                        help='''
    HP OneView Password''')
    parser.add_argument('-c',
                        dest='cert',
                        required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y',
                        dest='proxy',
                        required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-s',
                        dest='status',
                        required=False,
                        choices=['Active', 'Cleared'],
                        help='''
    Alerts with given alert state will be returned.  State values include
    Active and Cleared''')
    parser.add_argument(
        '-v',
        dest='severity',
        required=False,
        choices=['Unknown', 'OK', 'Disabled', 'Warning', 'Critical'],
        help='''
    Alerts with given severity will be returned.''')
    parser.add_argument('-t',
                        dest='category',
                        required=False,
                        choices=[
                            'Appliance', 'ConnectionInstance', 'DeviceBay',
                            'Enclosure', 'Fan', 'fc-device-managers',
                            'Firmware', 'Host', 'Instance', 'interconnect',
                            'InterconnectBay', 'licenses',
                            'logical-interconnect', 'LogicalSwitch', 'Logs',
                            'ManagementProcessor', 'Memory', 'Network', 'None',
                            'Operational', 'Power', 'Processor',
                            'RemoteSupport', 'Storage', 'Thermal', 'Unknown'
                        ],
                        help='''
    Alerts with given health category will be returned.''')

    args = parser.parse_args()
    credential = {'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    act = hpov.activity(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    get_alerts(act, args.status, args.severity, args.category)
Example #56
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Display Storage Pools

    Usage: ''')
    parser.add_argument('-a',
                        dest='host',
                        required=True,
                        help='''
    HPE OneView Appliance hostname or IP address''')
    parser.add_argument('-u',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='''
    HPE OneView Username''')
    parser.add_argument('-p',
                        dest='passwd',
                        required=True,
                        help='''
    HPE OneView Password''')
    parser.add_argument('-c',
                        dest='cert',
                        required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y',
                        dest='proxy',
                        required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j',
                        dest='domain',
                        required=False,
                        default='Local',
                        help='''
    HPE OneView Authorized Login Domain''')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-s',
                       dest='sto_name',
                       help='''
    Name of storage system. This option requires the pool name option "-n"
    to be specified''')
    group.add_argument('-g',
                       dest='get_all',
                       action='store_true',
                       help='''
    Display ALL storage pools and exit''')
    parser.add_argument('-n',
                        dest='pool_name',
                        required=False,
                        help='''
    Storage pool name''')

    args = parser.parse_args()
    credential = {
        'authLoginDomain': args.domain.upper(),
        'userName': args.user,
        'password': args.passwd
    }

    con = hpov.connection(args.host)
    sto = hpov.storage(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    if args.sto_name:
        if args.pool_name:
            get_pool_by_name(sto, args.sto_name, args.pool_name)
        else:
            print('Storage system MUST be accompanied by storage pool name')
        sys.exit()

    if args.get_all:
        get_all_pools(sto)
Example #57
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Display the avilable and configured Address Pools, and their associated
    Ranges from the appliance.  Currently, the appliance supports the
    following Address Pools:

        - VMAC
        - VWWN
        - VSN

    You can specify one or all of the Pool types.

    Usage: ''')
    parser.add_argument('-a',
                        dest='host',
                        required=True,
                        help='''
    HPE OneView Appliance hostname or IP address''')
    parser.add_argument('-u',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='''
    HPE OneView Username''')
    parser.add_argument('-p',
                        dest='passwd',
                        required=True,
                        help='''
    HPE OneView Password''')
    parser.add_argument('-c',
                        dest='cert',
                        required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y',
                        dest='proxy',
                        required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j',
                        dest='domain',
                        required=False,
                        default='Local',
                        help='''
    HPE OneView Authorized Login Domain''')
    parser.add_argument('-t',
                        dest='types',
                        required=False,
                        choices=['VMAC', 'VWWN', 'VSN', 'ALL'],
                        default='ALL',
                        help='''
    Address Pool type.  Accepted values are VMAC, VWWN, VSN, or All''')

    args = parser.parse_args()
    credential = {
        'authLoginDomain': args.domain.upper(),
        'userName': args.user,
        'password': args.passwd
    }

    con = hpov.connection(args.host)
    srv = hpov.servers(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    get_address_pools(con, srv, args.types)
def main():
    parser = argparse.ArgumentParser(add_help=True, description='Usage')
    parser.add_argument('-a',
                        '--appliance',
                        dest='host',
                        required=True,
                        help='HP OneView Appliance hostname or IP')
    parser.add_argument('-u',
                        '--user',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='HP OneView Username')
    parser.add_argument('-p',
                        '--pass',
                        dest='passwd',
                        required=False,
                        help='HP OneView Password')
    parser.add_argument('-c',
                        '--certificate',
                        dest='cert',
                        required=False,
                        help='Trusted SSL Certificate Bundle in PEM '
                        '(Base64 Encoded DER) Format')
    parser.add_argument('-r',
                        '--proxy',
                        dest='proxy',
                        required=False,
                        help='Proxy (host:port format')
    parser.add_argument(
        '-eu',
        '--enc_user',
        dest='encusr',
        required=False,
        help='Administrative username for the c7000 enclosure OA')
    parser.add_argument(
        '-ep',
        '--enc_pass',
        dest='encpass',
        required=False,
        help='Administrative password for the c7000 enclosure OA')
    parser.add_argument('-n',
                        '--name',
                        dest='egroup',
                        required=False,
                        default='Prod VC FlexFabric Group 1',
                        help='Enclosure Group to add the enclosure to')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument(
        '-e',
        dest='enc',
        help='IP address of the c7000 to import into HP OneView')
    group.add_argument('-d',
                       dest='delete',
                       action='store_true',
                       help='Delete all Enclosures and exit')

    args = parser.parse_args()
    credential = {'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    srv = hpov.servers(con)
    sts = hpov.settings(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)
    if args.delete:
        delenc(srv)
        sys.exit()

    impenc(srv, sts, args.egroup, args.enc, args.encusr, args.encpass)
def main():
    parser = argparse.ArgumentParser(add_help=True, description='Usage')
    parser.add_argument('-a',
                        '--appliance',
                        dest='host',
                        required=True,
                        help='HP OneView Appliance hostname or IP')
    parser.add_argument('-u',
                        '--user',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='HP OneView Username')
    parser.add_argument('-p',
                        '--pass',
                        dest='passwd',
                        required=False,
                        help='HP OneView Password')
    parser.add_argument('-c',
                        '--certificate',
                        dest='cert',
                        required=False,
                        help='Trusted SSL Certificate Bundle in PEM '
                        '(Base64 Encoded DER) Format')
    parser.add_argument('-r',
                        '--proxy',
                        dest='proxy',
                        required=False,
                        help='Proxy (host:port format')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-n',
                       dest='name',
                       help='Name of the volume template to add')
    group.add_argument('-d',
                       dest='delete',
                       action='store_true',
                       help='Remove ALL storage volume'
                       ' teamplates and exit')
    group.add_argument('-g',
                       dest='get',
                       action='store_true',
                       help='Get storage systems and exit')

    args = parser.parse_args()
    credential = {'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    sto = hpov.storage(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    if args.get:
        getsto(sto)
        sys.exit()

    if args.delete:
        delsto(sto)
        sys.exit()

    addsto(sto, args.name)
Example #60
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Define a server profile''')
    parser.add_argument('-a',
                        dest='host',
                        required=True,
                        help='''
    HP OneView Appliance hostname or IP address''')
    parser.add_argument('-u',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='''
    HP OneView Username''')
    parser.add_argument('-p',
                        dest='passwd',
                        required=True,
                        help='''
    HP OneView Password''')
    parser.add_argument('-c',
                        dest='cert',
                        required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y',
                        dest='proxy',
                        required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-n',
                        dest='name',
                        required=True,
                        help='''
    Name of the profile''')
    parser.add_argument('-d',
                        dest='desc',
                        required=False,
                        help='''
    Description for the server profile''')
    parser.add_argument('-af',
                        dest='affinity',
                        required=False,
                        choices=['Bay', 'BayAndServer'],
                        default='Bay',
                        help='''
    This identifies the behavior of the server profile when the server
    hardware is removed or replaced.

        . Bay:  This profile remains with the device bay when the server
                hardware is removed or replaced.

        . BayAndServer This profile is pinned to both the device bay and
          specific server hardware.''')
    parser.add_argument('-f',
                        dest='forcePowerOff',
                        required=False,
                        action='store_true',
                        help='''
    When set, forces power off of target server.
    Avoids error exit if server is up''')
    parser.add_argument('-fw',
                        dest='baseline',
                        required=False,
                        help='''
    SPP Baseline file name. e.g. SPP2013090_2013_0830_30.iso''')
    parser.add_argument('-mb',
                        dest='disable_manage_boot',
                        action='store_true',
                        help='''
    Explicitly DISABLE Boot Order Management. This value is enabled by
    default and required for Connection boot enablement. If this optoin is
    disabled, then  PXE and FC BfS settings are disabled within the entire
    Server Profile.''')
    parser.add_argument('-bo',
                        dest='boot_order',
                        required=False,
                        nargs='+',
                        help='''
    Defines the order in which boot will be attempted on the available
    devices. Please NOTE the supported boot order is server hardware type
    specific. For Gen7 and Gen8 server hardware the possible values are 'CD',
    'Floppy', 'USB', 'HardDisk', and 'PXE'. For Gen9 BL server hardware in
    Legacy BIOS boot mode, the possible values are 'CD', 'USB', 'HardDisk',
    and 'PXE'. For Gen9 BL server hardware in UEFI or UEFI Optimized boot
    mode, only one value is allowed and must be either 'HardDisk' or 'PXE'.
    For Gen9 DL server hardware in Legacy BIOS boot mode, the possible
    values are 'CD', 'USB', 'HardDisk', and 'PXE'. For Gen9 DL server
    hardware in UEFI or UEFI Optimized boot mode, boot order configuration
    is not supported.

    Server boot order defined as a list seperatedby spaces. For example:

    Gen7/8 BIOS Default Boot Order:
                            -bo CD Floppy USB HardDisk PXE
    Gen9 Legacy BIOS Boot Order:
                            -bo CD USB HardDisk PXE
    Gen9 UEFI Default Boot Order:
                            -bo HardDisk
    ''')
    parser.add_argument('-cl',
                        dest='conn_list',
                        required=False,
                        help='''
    File with list of connections for this profile in JSON format. This file
    can be created with multiple calls to define-connection-list.py''')
    parser.add_argument('-sl',
                        dest='san_list',
                        required=False,
                        help='''
    File with list of SAN Storage connections for this profile in JSON format.
    This file can be created with multiple calls to
    define-san-storage-list.py''')
    parser.add_argument('-bm',
                        dest='boot_mode',
                        required=False,
                        choices=['UEFI', 'UEFIOptimized', 'BIOS'],
                        default='BIOS',
                        help='''
    Specify the Gen9 Boot Envrionment.

    Sets the boot mode as one of the following:

        . UEFI
        . UEFIOptimized
        . BIOS

    If you select UEFI or UEFI optimized for an HP ProLiant DL Gen9 rack
    mount server, the remaining boot setting available is the PXE boot policy.

    For the UEFI or UEFI optimized boot mode options, the boot mode choice
    should be based on the expected OS and required boot features for the
    server hardware. UEFI optimized boot mode reduces the time the system
    spends in POST(Video driver initialization). In order to select the
    appropriate boot mode, consider the following:

        . If a secure boot is required, the boot mode must be set to UEFI
          or UEFI optimized .
        . For operating systems that do not support UEFI (such as DOS, or
          older versions of Windows and Linux), the boot mode must be set
          to BIOS.
        . When booting in UEFI mode, Windows 7, Server 2008, or 2008 R2
          should not be set to UEFIOptimized.''')
    parser.add_argument(
        '-px',
        dest='pxe',
        required=False,
        choices=['Auto', 'IPv4', 'IPv6', 'IPv4ThenIPv6', 'IPv6ThenIPv4'],
        default='IPv4',
        help='''
    Controls the ordering of the network modes available to the Flexible
    LOM (FLB); for example, IPv4 and IPv6.

    Select from the following policies:

        . Auto
        . IPv4 only
        . IPv6 only
        . IPv4 then IPv6
        . IPv6 then IPv4

    Setting the policy to Auto means the order of the existing network boot
    targets in the UEFI Boot Order list will not be modified, and any new
    network boot targets will be added to the end of the list using the
    System ROM's default policy.''')
    parser.add_argument('-rl',
                        dest='raidlevel',
                        required=False,
                        choices=['NONE', 'RAID0', 'RAID1'],
                        help='''
    Enable local storage to be managed via the server profile by defining the
    RAID level for the logical drive.''')
    parser.add_argument('-lb',
                        dest='logicalboot',
                        required=False,
                        action='store_true',
                        help='''
    Mark the logical drive as NOT bootable''')
    parser.add_argument('-is',
                        dest='init_storage',
                        required=False,
                        action='store_true',
                        help='''
    Indicates whether the local storage controller should be reset to factory
    defaults before applying the local storage settings from the server
    profile.

                  ***************** WARNING *****************

                Setting this will overwrite an existing logical
                 disk if present, and without further warning.

                  ***************** WARNING *****************''')
    parser.add_argument('-hn',
                        dest='hide_flexnics',
                        required=False,
                        action='store_false',
                        help='''
    This setting controls the enumeration of physical functions that do not
    correspond to connections in a profile. Using this flag will SHOW unused
    FlexNICs to the Operating System. Changing this setting may alter the order
    of network interfaces in the Operating System. This option sets the 'Hide
    Unused FlexNICs' to disabled, eight FlexNICs will be enumerated in the
    Operating System as network interfaces for each Flex-10 or FlexFabric
    adapter.  Configuring Fibre Channel connections on a FlexFabric adapter may
    enumerate two storage interfaces, reducing the number of network interfaces
    to six. The default (this option is not selected) enables 'Hide Unused
    FlexNICs' and may suppress enumeration of FlexNICs that do not correspond
    to profile connections. FlexNICs are hidden in pairs, starting with the 4th
    pair. For instance, if the 4th FlexNIC on either physical port corresponds
    to a profile connection, all eight physical functions are enumerated. If a
    profile connection corresponds to the 2nd FlexNIC on either physical port,
    but no connection corresponds to the 3rd or 4th FlexNIC on either physical
    port, only the 1st and 2nd physical functions are enumerated in the
    Operating System.''')
    parser.add_argument('-s',
                        dest='server_id',
                        required=True,
                        help='''
    Server identification. There are multiple ways to specify the server id:

        . Hostname or IP address of the stand-alone server iLO
        . Server Hardware name of a server than has already been imported
          into HP OneView and is listed under Server Hardware
        . "UNASSIGNED" for creating an unassigned Server Profile''')
    parser.add_argument('-sh',
                        dest='server_hwt',
                        required=False,
                        help='''
    Server harware type is required for defining an unassigned profile. Note
    the Server Hardware Type must be present in the HP OneView appliance
    before it can be uesd. For example, a sngle server with the specific server
    hardware type must have been added to OneView for that hardware type to
    be used. The example script get-server-hardware-types.py with the -l
    arguement can be used to get a list of server hardware types that have
    been imported into the OneView appliance''')
    args = parser.parse_args()
    credential = {'userName': args.user, 'password': args.passwd}

    con = hpov.connection(args.host)
    srv = hpov.servers(con)
    sts = hpov.settings(con)

    if args.proxy:
        con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1])
    if args.cert:
        con.set_trusted_ssl_bundle(args.cert)

    login(con, credential)
    acceptEULA(con)

    # Invert the boolean value
    args.logicalboot = not args.logicalboot

    if args.boot_order and args.disable_manage_boot:
        print('Error: Managed Boot must be enabled to define a boot order')
        sys.exit()

    if args.server_id.upper() == 'UNASSIGNED' and not args.server_hwt:
        print('Error: Server Hardware Type must be specified when defining an'
              'unassigned server profile')
        sys.exit()

    server, sht = get_server(con, srv, args.server_id, args.server_hwt,
                             args.forcePowerOff)
    boot, bootmode = boot_settings(srv, sht, args.disable_manage_boot,
                                   args.boot_order, args.boot_mode, args.pxe)
    local_storage = local_storage_settings(sht, args.raidlevel,
                                           args.logicalboot, args.init_storage)
    fw_settings = get_fw_settings(sts, args.baseline)
    define_profile(con, srv, args.affinity, args.name, args.desc, server, sht,
                   boot, bootmode, fw_settings, args.hide_flexnics,
                   local_storage, args.conn_list, args.san_list)