コード例 #1
0
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')
コード例 #2
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Display connections information

    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''')

    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)

    getconn(srv)
コード例 #3
0
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)
    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)

    gettrapdst(sts)
コード例 #4
0
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')
コード例 #5
0
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('-d',
                        dest='delete',
                        required=False,
                        action='store_true',
                        help='Delete all Enclosure Groups and exit')
    parser.add_argument('-n',
                        '--name',
                        dest='lname',
                        required=False,
                        default='VC FlexFabric Production',
                        help='LIG to assign to enclosure group')

    args = parser.parse_args()
    credential = {'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)
    if args.delete:
        deleg(srv)
        sys.exit()

    defeg(net, srv, args.lname)
コード例 #6
0
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)
コード例 #7
0
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)
コード例 #8
0
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('-s',
                        dest='string',
                        required=True,
                        help='''
    Community Read String''')

    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)

    define_string(sts, args.string)
コード例 #9
0
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('-g',
                       dest='getstr',
                       action='store_true',
                       help='Display the community read string and exit')
    group.add_argument('-s', dest='string', help='Community Read String')

    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.getstr:
        getstring(sts)
        sys.exit()

    defstring(sts, args.string)
コード例 #10
0
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('-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 = {'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)
コード例 #11
0
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)
コード例 #12
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')
コード例 #13
0
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)
コード例 #14
0
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('-l',
                        dest='lname',
                        required=False,
                        help='LIG to assign to enclosure group')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-n', dest='name', help='Enclosure Group name')

    args = parser.parse_args()
    credential = {'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)

    defeg(net, srv, args.name, args.lname)
コード例 #15
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')
コード例 #16
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)
コード例 #17
0
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)
コード例 #18
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Display Sever Hardware Types

    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('-l',
                        dest='lst',
                        required=False,
                        action='store_true',
                        help='''
    Disply only a list of the server hardware type names''')
    args = parser.parse_args()
    credential = {'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_hw_types(srv, args.lst)
コード例 #19
0
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)
コード例 #20
0
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)
コード例 #21
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''')
    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)
コード例 #22
0
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='''
    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''')

    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)

    get_network_interfaces(sts)
コード例 #23
0
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)
コード例 #24
0
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)
コード例 #25
0
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='''
    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)
コード例 #27
0
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Display Sever Hardware Types

    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('-l', dest='lst', required=False,
                        action='store_true',
                        help='''
    Disply only a list of the server hardware type names''')
    args = parser.parse_args()
    credential = {'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_hw_types(srv, args.lst)
コード例 #28
0
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('-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 = {'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')
コード例 #29
0
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Display active user sessions

    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''')

    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)

    getaus(sec)
コード例 #30
0
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('-d', dest='delete', required=False,
                        action='store_true', help='Delete all Enclosure Groups and exit')
    parser.add_argument('-n', '--name', dest='lname', required=False,
                        default='VC FlexFabric Production', help='LIG to assign to enclosure group')

    args = parser.parse_args()
    credential = {'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)
    if args.delete:
        deleg(srv)
        sys.exit()

    defeg(net, srv, args.lname)
コード例 #31
0
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)
コード例 #32
0
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='''
    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('-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)
コード例 #33
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)
コード例 #34
0
 def setUp(self):
     super(ServersTest, self).setUp()
     self.host = 'http://1.2.3.4'
     self.connection = connection(self.host)
     self.servers = servers(self.connection)
     self.activity = activity(self.connection)
コード例 #35
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Define a server profile template''')
    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('-n',
                        dest='name',
                        required=True,
                        help='''
    Name of the profile template''')
    parser.add_argument('-d',
                        dest='desc',
                        required=False,
                        help='''
    Description for the server profile template''')
    parser.add_argument('-spd',
                        dest='sp_desc',
                        required=False,
                        help='''
    Server profile description''')
    parser.add_argument('-sht',
                        dest='server_hwt',
                        required=True,
                        help='''
    Server hardware type is required for defining an unassigned profile. Note
    the Server Hardware Type must be present in the HPE OneView appliance
    before it can be used. For example, a single 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
    argument can be used to get a list of server hardware types that have
    been imported into the OneView appliance''')
    parser.add_argument('-eg',
                        dest='enc_group',
                        required=True,
                        help='''
    Identifies the enclosure group for which the Server Profile Template
    was designed. The enclosureGroupUri is determined when the profile
    template is created and cannot be modified
                        ''')
    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('-hn',
                        dest='hide_flexnics',
                        required=False,
                        choices=['true', '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('-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('-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 option 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 separated by 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('-bm',
                        dest='boot_mode',
                        required=False,
                        choices=['UEFI', 'UEFIOptimized', 'BIOS'],
                        default='BIOS',
                        help='''
    Specify the Gen9 Boot Environment.

    Sets the boot mode as one of the following:

        . UEFI
        . UEFIOptimized
        . BIOS

    If you select UEFI or UEFI optimized for an HPE 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('-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''')

    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)

    eg_uri = get_eg_uri_from_arg(srv, args.enc_group)

    sht = get_sht_from_arg(srv, args.server_hwt)

    fw_settings = profile.make_firmware_dict(sts, args.baseline)

    boot, bootmode = profile.make_boot_settings_dict(srv, sht,
                                                     args.disable_manage_boot,
                                                     args.boot_order,
                                                     args.boot_mode, args.pxe)

    define_profile_template(srv, args.name, args.desc, args.sp_desc,
                            sht['uri'], eg_uri, args.affinity,
                            args.hide_flexnics, args.conn_list, fw_settings,
                            boot, bootmode, args.san_list)
コード例 #36
0
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Import a physical stand-alone rackmount server.

    This example script IS NOT USED to add a Blade Server to the appliance.
    A BL server will automatically be discovered once it inserted into an
    enclosure being managed by 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''')
    parser.add_argument('-sh', dest='hostname', required=True,
                        help='''
    Hostname or IP address  of the server iLO''')
    parser.add_argument('-su', dest='username', required=True,
                        help='''
    Administrative username for the server iLO''')
    parser.add_argument('-sp',  dest='password', required=True,
                        help='''
    Administrative password for the server iLO''')
    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',
                        help='''
    Force adding the server when currently managed by another OneView
    appliance.''')
    parser.add_argument('-m', dest='monitor',
                        action='store_true',
                        help='''
    Add the server as a monitored device.''')

    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)

    add_server(srv, args.hostname, args.username, args.password, args.force,
               args.license, args.monitor)
コード例 #37
0
ファイル: add-server.py プロジェクト: xod442/python-hpOneView
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description="""
    Import a physical stand-alone rackmount server.

    This exmaple script IS NOT USED to add a Blade Server to the appliance.
    A BL server will automatically be discovered once it inserted into an
    enclosure being managed by the 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(
        "-sh",
        dest="hostname",
        required=True,
        help="""
    Hostname or IP address  of the server iLO""",
    )
    parser.add_argument(
        "-su",
        dest="username",
        required=True,
        help="""
    Administrative username for the server iLO""",
    )
    parser.add_argument(
        "-sp",
        dest="password",
        required=True,
        help="""
    Administrative password for the server iLO""",
    )
    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",
        help="""
    Force adding the server when currently managed by another OneView
    appliance.""",
    )
    parser.add_argument(
        "-m",
        dest="monitor",
        action="store_true",
        help="""
    Add the server as a monitored device.""",
    )

    args = parser.parse_args()
    credential = {"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)

    add_server(srv, args.hostname, args.username, args.password, args.force, args.license, args.monitor)
コード例 #38
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
   Copy 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 EncodedDER) 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 source server profile''')
    parser.add_argument('-d',
                        dest='dest',
                        required=True,
                        help='''
    Name of the destination  server profile''')
    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('-s',
                        dest='server_id',
                        required=True,
                        help='''
    Destination  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 HPE OneView and is listed under Server Hardware
    . "UNASSIGNED" for creating an unassigned Server Profile''')
    args = parser.parse_args()
    credential = {
        'authLoginDomain': args.domain.upper(),
        'userName': args.user,
        'password': args.passwd
    }

    con = hpov.connection(args.host)
    srv = hpov.servers(con)
    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)

    server, sht = get_server(con, srv, args.server_id, args.forcePowerOff,
                             args.name)
    copy_profile(con, srv, sto, args.name, args.dest, server, sht)
コード例 #39
0
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='''
    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('-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)
コード例 #40
0
def main():
    con = hpOneView.connection(applianceIP)
    srv = hpOneView.servers(con)
    net = hpOneView.networking(con)
    sec = hpOneView.security(con)
    settings = hpOneView.settings(con)
    act = hpOneView.activity(con)
    sear = hpOneView.search(con)

    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
    con.get_eula_status()
    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)

    # Get the appliance MAC address
    data = con.get_appliance_network_interfaces()
    macAddress = data['applianceNetworks'][0]['macAddress']
    hostName = data['applianceNetworks'][0]['hostname']

    interfaceConfig = hpOneView.common.make_appliance_network_config_dict(
                                        hostName,
                                        macAddress,
                                        ipv4Type='DHCP',
                                        ipv6Type='DHCP')
    con.set_appliance_network_interface(interfaceConfig)
    print("Network set")
    print('Sleep for 30 seconds in case we changed the IP')
    time.sleep(30)

    try:
        settings.add_license(licenseKey)
    except hpOneView.exceptions.HPOneViewException as ex:
        print('WARNING: License failed to add. Check message.')
        print('Message: ' + ex.message)
    licenses = settings.get_licenses()
    print(str(len(licenses)) + ' licenses installed')

    if doRackConfiguration is True:
        # Rack based support
        serverdict = hpOneView.common.make_add_server_dict(
                                        hostname=rackiLOIp,
                                        username=rackiLOUser,
                                        password=rackiLOPassword,
                                        force=False,
                                        licensingIntent='OneView')
        print('Adding rack server...')
        server = srv.add_server(serverdict)
        print('Removing rack server...')
        srv.delete_server(server)

    readCommunityString = insecure_random_string_generator()
    response = settings.set_dev_read_comm_string(readCommunityString)
    if response != readCommunityString:
        raise Exception("Community string not set")
    newCommString = settings.get_dev_read_comm_string()
    if newCommString != readCommunityString:
        raise Exception("Community strings differ")

    print('Generating Appliance Dump')
    dumpInfo = settings.generate_support_dump()
    print('Downloading Appliance Dump')
    settings.download_support_dump(dumpInfo)

    version = settings.get_version()
    print('Minimum API Version: ' + str(version['minimumVersion']))
    print('Current API Version: ' + str(version['currentVersion']))

    status = settings.get_health_status()
    for member in status:
        print(member['available'] + ' available ' + member['resourceType'])

    # Clean up everything before we start in case of aborted previous run
    servers = srv.get_servers()
    for server in servers:
        if server['powerState'] == 'On':
            srv.set_server_powerstate(server, 'Off', force=True)
    profiles = srv.get_server_profiles()
    for profile in profiles:
        print(("Removing Profile %s" % profile['name']))
        srv.remove_server_profile(profile)
    enclosures = srv.get_enclosures()
    for enclosure in enclosures:
        print(("Removing Enclosure %s" % enclosure['serialNumber']))
        srv.remove_enclosure(enclosure)
    egroups = srv.get_enclosure_groups()
    for egroup in egroups:
        srv.delete_enclosure_group(egroup)
    ligs = net.get_ligs()
    for lig in ligs:
        net.delete_lig(lig)
    networksets = net.get_networksets()
    for networkset in networksets:
        net.delete_networkset(networkset)
    fcnets = net.get_fc_networks()
    for fcnet in fcnets:
        net.delete_network(fcnet)
    enets = net.get_enet_networks()
    for enet in enets:
        net.delete_network(enet)

    # Check how many non-cleared alerts we have
    alerts = act.get_alerts('Active')
    startNumAlerts = len(alerts)
    print(("%d active alerts" % startNumAlerts))
    # Clear (or Delete) active alerts so we start clean
    if startNumAlerts > 0:
        for alert in alerts:
            alertMap = hpOneView.common.make_update_alert_dict(
                                            alertState='Cleared',
                                            assignedToUser='******')
            act.update_alert(alert, alertMap)
            # or Delete it - act.delete_alert(alert)
    alerts = act.get_alerts('Active')
    startNumAlerts = len(alerts)
    print(("%d active alerts" % startNumAlerts))
    # Delete active alerts so we start clean
    if startNumAlerts > 0:
        raise Exception("Still have active alerts")

    if doSppTests is True:
        print("Getting current SPPs")
        spps = settings.get_spps()
        startNumSpps = len(spps)
        print("Uploading SPP")
        spp = settings.upload_spp(firmwareBundlePath, firmwareBundleFileName)
        spps = settings.get_spps()
        if len(spps) == startNumSpps:
            raise Exception('Same number of SPPs found %d' % (len(spps)))
        print("Deleting SPP")
        settings.delete_spp(spp)
    con.set_service_access('false')

    roles = sec.get_roles()
    print(str(len(roles)) + " user roles")
    users = sec.get_users()
    numUsers = len(users)
    print(('Current Users (' + str(numUsers) + '):'))
    for user in users:
        print((' ' + (user['userName'])))
    testUser = insecure_random_string_generator()
    testPassword = insecure_random_string_generator()
    print(('Adding User ' + testUser))
    user = hpOneView.common.make_user_dict(testUser,
                            testPassword,
                            enabled=True,
                            fullName='Test User',
                            emailAddress='*****@*****.**',
                            roles=['Infrastructure administrator'])
    sec.create_user(user)
    users = sec.get_users()
    if len(users) != numUsers + 1:
        raise Exception('User not added')
    con.logout()
    print(('Testing user ' + testUser))
    testCredential = {'userName': testUser, 'password': testPassword}
    con.login(testCredential)
    con.logout()
    con.login(credential)
    print('Modifying User')
    updateUser = hpOneView.common.make_user_modify_dict(
                        userName=testUser,
                        fullName='Renamed Test User')
    updatedUser = sec.update_user(updateUser)
    updatedUser = sec.get_user(testUser)
    if updatedUser['fullName'] != 'Renamed Test User':
        raise Exception('User not renamed')
    print(('Deleting User ' + testUser))
    sec.delete_user(testUser)
    users = sec.get_users()
    if len(users) != numUsers:
        raise Exception('User not deleted')
    pool = srv.get_vsn_pool()
    print(('Current SN Pool Type: ' + (pool['poolType'])))
    pool = srv.get_vwwn_pool()
    print(('Current WWN Pool Type: ' + (pool['poolType'])))
    pool = srv.get_vmac_pool()
    print(('Current MAC Pool Type: ' + (pool['poolType'])))
    roles = sec.get_user_roles('administrator')
    print('Roles:')
    for role in roles:
        print((' ' + (role['roleName'])))
    user = sec.get_user('administrator')
    print('User Properties:')
    pprint(user, indent=4)
    # Create Network
    bandDict = hpOneView.common.make_bw_dict(maxbw=10000, minbw=1000)
    print('Creating Ethernet Network')
    enet = net.create_enet_network('RDP',
                                    1,
                                    smartLink=True,
                                    privateNetwork=False,
                                    bw=bandDict)
    print('Creating FC Networks')
    fcneta = net.create_fc_network('SAN-A',
                                    bw=bandDict)
    fcnetb = net.create_fc_network('SAN-B',
                                    bw=bandDict)
    print('Creating Network Set')
    nset = net.create_networkset('RDP Network Set',
                                    nets=[enet['uri']],
                                    bw=bandDict)
    print('Creating Logical Interconnect Group')
    lig = hpOneView.common.make_lig_dict('Test LIG')
    swtype = con.get_entity_byfield(hpOneView.common.uri['ictype'],
                                    'partNumber',
                                    '571956-B21')
    hpOneView.common.set_iobay_occupancy(lig['interconnectMapTemplate'],
                            [1, 2], swtype['uri'])
    net_uris = [enet['uri']]
    uplinkSet = hpOneView.common.make_uplink_set_dict(
                                    "RDPUplinkSet",
                                    net_uris)
    # Get Port Number
    pnum = -1
    for port in swtype['portInfos']:
        if port['portName'] == 'X5':
            pnum = port['portNumber']
            break
    uplinkSet['logicalPortConfigInfos'].append(
                                    hpOneView.common.make_port_config_info(
                                                    1, 1, pnum))
    lig['uplinkSets'].append(uplinkSet)

    net_uris = [fcneta['uri']]
    uplinkSet = hpOneView.common.make_uplink_set_dict(
                                            "SanAUplinkSet",
                                            net_uris,
                                            'FibreChannel')
    # Get Port Number
    pnum = -1
    for port in swtype['portInfos']:
        if port['portName'] == 'X1':
            pnum = port['portNumber']
            break
    uplinkSet['logicalPortConfigInfos'].append(
                                    hpOneView.common.make_port_config_info(
                                                    1, 1, pnum))
    lig['uplinkSets'].append(uplinkSet)

    net_uris = [fcnetb['uri']]
    uplinkSet = hpOneView.common.make_uplink_set_dict(
                                            "SanBUplinkSet",
                                            net_uris,
                                            'FibreChannel')
    # Use same port number
    uplinkSet['logicalPortConfigInfos'].append(
                                    hpOneView.common.make_port_config_info(
                                                    1, 2, pnum))
    lig['uplinkSets'].append(uplinkSet)

    lig = net.create_lig(lig)
    print('Creating Enclosure Group')
    egroup = hpOneView.common.make_egroup_dict("Enclosure Group", lig['uri'])
    egroup = srv.create_enclosure_group(egroup)
    print('Renaming Enclosure Group')
    egroup['name'] = 'Renamed Enclosure Group'
    egroup = srv.update_enclosure_group(egroup)
    print('Adding Enclosure')
    # Find the first Firmware Baseline
    spp = settings.get_spps()[0]
    add_enclosure = hpOneView.common.make_add_enclosure_dict(
                                    enclosureIP,
                                    enclosureUser,
                                    enclosurePassword,
                                    egroup['uri'],
                                    firmwareBaseLineUri=spp['uri'])
    enclosure = srv.add_enclosure(add_enclosure)
    print('Creating Profiles')
    # See if we need to turn any servers off
    servers = srv.get_servers()
    for server in servers:
        if server['powerState'] == 'On':
            srv.set_server_powerstate(server, 'Off', force=True)
    g7server = srv.get_server_by_bay(7)
    gen8server = srv.get_server_by_bay(13)
    connection1 = hpOneView.common.make_profile_connection_dict(enet,
                    boot=hpOneView.common.make_profile_connection_boot_dict(
                        priority='Primary'))
    connection2 = hpOneView.common.make_profile_connection_dict(fcneta,
                    functionType='FibreChannel',
                    boot=hpOneView.common.make_profile_connection_boot_dict(
                        priority='Primary',
                        arrayWwpn='5001438004C8E7F8',
                        lun='1'))
    connection3 = hpOneView.common.make_profile_connection_dict(fcnetb,
                    functionType='FibreChannel',
                    boot=hpOneView.common.make_profile_connection_boot_dict(
                        priority='Secondary',
                        arrayWwpn='5001438004C8E7FC',
                        lun='1'))
    connections = [connection1, connection2, connection3]
    firmwareBaseline = hpOneView.common.make_profile_firmware_baseline(
                                                spp['uri'])
    print('Creating G7 Profile')
    g7profile = hpOneView.common.make_add_profile_dict('G7 Profile',
                                                g7server,
                                                connections=connections)
    print('Creating Gen8 Profile')
    gen8profile = hpOneView.common.make_add_profile_dict('Gen8 Profile',
                                            gen8server,
                                            connections=connections,
                                            firmwareBaseline=firmwareBaseline)
    g7profile = srv.create_server_profile(g7profile)
    gen8profile = srv.create_server_profile(gen8profile)
    g7profile['name'] = 'Renamed G7 Profile'
    g7profile = srv.update_server_profile(g7profile)
    gen8profile['name'] = 'Renamed Gen8 Profile'
    gen8profile = srv.update_server_profile(gen8profile)

    # Try searching now that we have resources
    resources = sear.get_resources('category=interconnect-types')
    print(('%s Interconnect Types' % len(resources)))
    resources = sear.get_resources({'category': 'interconnect-types'})
    print(('%s Interconnect Types' % len(resources)))
    assoc = sear.get_associations('category=interconnect-types')
    print(('%s Associations' % len(assoc)))
    trees = sear.get_trees('category=interconnect-types')
    print(('%s Trees' % len(trees)))
    sugg = sear.get_search_suggestions('Flex')
    print(('%s Suggestions' % len(sugg['suggestions'])))

    #print('Generating LI Dump')
    #li = net.get_interconnects()
    #dumpInfo = settings.generate_support_dump(logicalInterconnect=li[0])
    #print('Downloading LI Dump')
    #settings.download_support_dump(dumpInfo)

    print('Generating appliance backup')
    backup = settings.generate_backup()
    print('Downloading appliance backup')
    settings.download_backup(backup)

    # Check and see if we have any new alerts
    alerts = act.get_alerts('Active')
    if len(alerts) > 0:
        print(('WARNING: You have %d active alerts' % (len(alerts))))
        for alert in alerts:
            print(('- ' + alert['description']))

    # Events
    events = act.get_events('filter="eventTypeID=\'Demo.Event\'"')
    numEvents = len(events)
    eventDetail = hpOneView.common.make_event_detail_dict('ipv4Address',
                                                            enclosureIP)
    eventRecord = hpOneView.common.make_event_dict(description='Test',
                                        eventTypeID='Demo.Event',
                                        eventDetails=[eventDetail])
    act.create_event(eventRecord)
    events = act.get_events('filter="eventTypeID=\'Demo.Event\'"')
    if len(events) is numEvents:
        print('WARNING: Event record not created')

    # Audit Logs
    logs = act.get_audit_logs('filter="componentId=\'Test\'"')
    numLogs = len(logs)
    auditRecord = hpOneView.common.make_audit_log_dict(componentId='Test',
                                                        userId='Administrator',
                                                        domain='Local',
                                                        objectType='SERVER',
                                                        msg='Test Log')
    act.create_audit_log(auditRecord)
    logs = act.get_audit_logs('filter="componentId=\'Test\'"')
    if len(logs) is numLogs:
        print('WARNING: Audit log not created')

    # Paging example
    #pages = hpOneView.common.pages(act.get_alerts(), act._con)
    #firstPage = pages.currentPage
    #firstRecord = firstPage[0]
    #for page in pages:
    #    for record in page:
    #        pass  # OR print(record)
    #lastPage = pages.currentPage
    #lastRecord = lastPage[len(lastPage) - 1]

    print()
    print('We have now created everything. Check the UI and if all is good.'
            ' Press Enter to clean up.')
    input()

    # Clean Up
    print('Removing Profiles')
    srv.remove_server_profile(g7profile)
    srv.remove_server_profile(gen8profile)
    print('Removing Enclosure')
    srv.remove_enclosure(enclosure)
    print('Deleting Enclosure Group')
    srv.delete_enclosure_group(egroup)
    print('Deleting Logical Interconnect Group')
    net.delete_lig(lig)
    print('Deleting Network Set')
    net.delete_networkset(nset)
    print('Deleting FC Network')
    net.delete_network(fcneta)
    net.delete_network(fcnetb)
    print('Deleting Ethernet Network')
    net.delete_network(enet)
    # Check and see if we have any new alerts
    alerts = act.get_alerts('Active')
    if len(alerts) > 0:
        print(('WARNING: You have %d active alerts' % (len(alerts))))
        for alert in alerts:
            print((alert['description']))
    con.logout()
コード例 #41
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Define the BIOS options of a OneView server profile. Use when defining a
    server profile with manage BIOS.  Server hardware name or server hardware
    type name can be used to create the BIOS list.

    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('-bl',
                        dest='bios_list',
                        required=True,
                        help='''
    Name of file for BIOS options list.  File will be created in JSON format
    and need to be edited to select the desired options to manage in the server
    profile.''')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-s',
                       dest='server_id',
                       help='''
    Server identification. There are multiple ways to specify the server id:

        . Hostname or IP address of the stand-alone server iLO
        . The "Server Hardware Name" of a server than has already been imported
          into HPE OneView and is listed under Server Hardware''')
    group.add_argument('-sh',
                       dest='server_hwt',
                       help='''
    Server hardware type is required for defining BIOS options without
    specifying a specific server identification. The Server Hardware Type must
    be present in the HPE OneView appliance before it can be used. For example,
    a single 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 argument 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)

    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_bios_options(con, srv, args.server_id, args.server_hwt, args.bios_list)
コード例 #42
0
def main():
    #    con = connect(newApp1Ipv4Addr)    # just here for debugging...
    con = connect(applianceIP)

    # Get the appliance MAC address
    data = con.get_appliance_network_interfaces()
    macAddress = data['applianceNetworks'][0]['macAddress']
    hostName = data['applianceNetworks'][0]['hostname']

    # Try changing appliance to static ip...
    if newApp1Ipv4Addr:
        quit = False
        if (not newIpv4Subnet):
            print("newIpv4Subnet required if newApp1Ipv4Addr supplied.")
            quit = True
        if (not newDomainName):
            print("newDomainName required if newApp1Ipv4Addr supplied.")
            quit = True
        if (not newIpv4Subnet):
            print("newIpv4Subnet required if newApp1Ipv4Addr supplied.")
            quit = True
        if (not newIpv4Gateway):
            print("newIpv4Gateway required if newApp1Ipv4Addr supplied.")
            quit = True
        if (quit):
            exit(2)
        print("Setting ipv4...")
        interfaceConfig = hpOneView.common.make_appliance_network_config_dict(
            newDomainName,
            macAddress,
            newApp1Ipv4Addr,
            newIpv4Subnet,
            newIpv4Gateway,
            newSearchDomain1,
            newSearchDomain2,
            ipv4Type='STATIC',
            ipv6Type='UNCONFIGURE',
        )
        con.set_appliance_network_interface(interfaceConfig)
        print("Network set to static ip: " + newApp1Ipv4Addr)

        # Connect via the new IP...
        con = connect(newApp1Ipv4Addr)

        print('Sleep for 60 seconds before reverting back to DHCP...')
        time.sleep(60)

        print('Sleep for 60 seconds before reverting back to DHCP...')
        time.sleep(60)

    # Change appliance to DHCP...
    interfaceConfig = hpOneView.common.make_appliance_network_config_dict(
        hostName, macAddress, ipv4Type='DHCP', ipv6Type='DHCP')
    con.set_appliance_network_interface(interfaceConfig)
    print("Network set to DHCP: " + applianceIP)

    con = connect(applianceIP)

    # IP should not change anymore--set variables from con:
    srv = hpOneView.servers(con)
    net = hpOneView.networking(con)
    sec = hpOneView.security(con)
    settings = hpOneView.settings(con)
    act = hpOneView.activity(con)
    sear = hpOneView.search(con)

    try:
        settings.add_license(licenseKey)
    except hpOneView.exceptions.HPOneViewException as ex:
        print('WARNING: License failed to add. Check message.')
        print('Message: ' + ex.message)
    licenses = settings.get_licenses()
    print(str(len(licenses)) + ' licenses installed')

    if doRackConfiguration is True:
        # Rack based support
        serverdict = hpOneView.common.make_add_server_dict(
            hostname=rackiLOIp,
            username=rackiLOUser,
            password=rackiLOPassword,
            force=False,
            licensingIntent='OneView')
        print('Adding rack server...')
        server = srv.add_server(serverdict)
        print('Removing rack server...')
        srv.delete_server(server)

    readCommunityString = insecure_random_string_generator()
    response = settings.set_dev_read_comm_string(readCommunityString)
    if response != readCommunityString:
        raise Exception("Community string not set")
    newCommString = settings.get_dev_read_comm_string()
    if newCommString != readCommunityString:
        raise Exception("Community strings differ")

    print('Generating Appliance Dump')
    dumpInfo = settings.generate_support_dump()
    print('Downloading Appliance Dump')
    settings.download_support_dump(dumpInfo)

    version = settings.get_version()
    print('Minimum API Version: ' + str(version['minimumVersion']))
    print('Current API Version: ' + str(version['currentVersion']))

    status = settings.get_health_status()
    for member in status:
        print(member['available'] + ' available ' + member['resourceType'])

    # Clean up everything before we start in case of aborted previous run
    servers = srv.get_servers()
    for server in servers:
        if server['powerState'] == 'On':
            srv.set_server_powerstate(server, 'Off', force=True)
    profiles = srv.get_server_profiles()
    for profile in profiles:
        print(("Removing Profile %s" % profile['name']))
        srv.remove_server_profile(profile)
    enclosures = srv.get_enclosures()
    for enclosure in enclosures:
        print(("Removing Enclosure %s" % enclosure['serialNumber']))
        srv.remove_enclosure(enclosure)
    egroups = srv.get_enclosure_groups()
    for egroup in egroups:
        srv.delete_enclosure_group(egroup)
    ligs = net.get_ligs()
    for lig in ligs:
        net.delete_lig(lig)
    networksets = net.get_networksets()
    for networkset in networksets:
        net.delete_networkset(networkset)
    fcnets = net.get_fc_networks()
    for fcnet in fcnets:
        net.delete_network(fcnet)
    enets = net.get_enet_networks()
    for enet in enets:
        net.delete_network(enet)

    # Check how many non-cleared alerts we have
    alerts = act.get_alerts('Active')
    startNumAlerts = len(alerts)
    print(("%d active alerts" % startNumAlerts))
    # Clear (or Delete) active alerts so we start clean
    if startNumAlerts > 0:
        for alert in alerts:
            alertMap = hpOneView.common.make_update_alert_dict(
                alertState='Cleared', assignedToUser='******')
            act.update_alert(alert, alertMap)
            # or Delete it - act.delete_alert(alert)
    alerts = act.get_alerts('Active')
    startNumAlerts = len(alerts)
    print(("%d active alerts" % startNumAlerts))
    # Delete active alerts so we start clean
    if startNumAlerts > 0:
        raise Exception("Still have active alerts")

    if doSppTests is True:
        print("Getting current SPPs")
        spps = settings.get_spps()
        startNumSpps = len(spps)
        print("Uploading SPP")
        spp = settings.upload_spp(firmwareBundlePath, firmwareBundleFileName)
        spps = settings.get_spps()
        if len(spps) == startNumSpps:
            raise Exception('Same number of SPPs found %d' % (len(spps)))
        print("Deleting SPP")
        settings.delete_spp(spp)
    con.set_service_access('false')

    roles = sec.get_roles()
    print(str(len(roles)) + " user roles")
    users = sec.get_users()
    numUsers = len(users)
    print(('Current Users (' + str(numUsers) + '):'))
    for user in users:
        print((' ' + (user['userName'])))
    testUser = insecure_random_string_generator()
    testPassword = insecure_random_string_generator()
    print(('Adding User ' + testUser))
    user = hpOneView.common.make_user_dict(
        testUser,
        testPassword,
        enabled=True,
        fullName='Test User',
        emailAddress='*****@*****.**',
        roles=['Infrastructure administrator'])
    sec.create_user(user)
    users = sec.get_users()
    if len(users) != numUsers + 1:
        raise Exception('User not added')
    con.logout()
    print(('Testing user ' + testUser))
    testCredential = {'userName': testUser, 'password': testPassword}
    con.login(testCredential)
    con.logout()
    con.login(credential)
    print('Modifying User')
    updateUser = hpOneView.common.make_user_modify_dict(
        userName=testUser, fullName='Renamed Test User')
    updatedUser = sec.update_user(updateUser)
    updatedUser = sec.get_user(testUser)
    if updatedUser['fullName'] != 'Renamed Test User':
        raise Exception('User not renamed')
    print(('Deleting User ' + testUser))
    sec.delete_user(testUser)
    users = sec.get_users()
    if len(users) != numUsers:
        raise Exception('User not deleted')
    pool = srv.get_vsn_pool()
    print(('Current SN Pool Type: ' + (pool['poolType'])))
    pool = srv.get_vwwn_pool()
    print(('Current WWN Pool Type: ' + (pool['poolType'])))
    pool = srv.get_vmac_pool()
    print(('Current MAC Pool Type: ' + (pool['poolType'])))
    roles = sec.get_user_roles('administrator')
    print('Roles:')
    for role in roles:
        print((' ' + (role['roleName'])))
    user = sec.get_user('administrator')
    print('User Properties:')
    pprint(user, indent=4)
    # Create Network
    bandDict = hpOneView.common.make_bw_dict(maxbw=10000, minbw=1000)
    print('Creating Ethernet Network')
    enet = net.create_enet_network('RDP',
                                   1,
                                   smartLink=True,
                                   privateNetwork=False,
                                   bw=bandDict)
    print('Creating FC Networks')
    fcneta = net.create_fc_network('SAN-A', bw=bandDict)
    fcnetb = net.create_fc_network('SAN-B', bw=bandDict)
    print('Creating Network Set')
    nset = net.create_networkset('RDP Network Set',
                                 nets=[enet['uri']],
                                 bw=bandDict)
    print('Creating Logical Interconnect Group')
    lig = hpOneView.common.make_lig_dict('Test LIG')
    swtype = con.get_entity_byfield(hpOneView.common.uri['ictype'],
                                    'partNumber', '571956-B21')
    hpOneView.common.set_iobay_occupancy(lig['interconnectMapTemplate'],
                                         [1, 2], swtype['uri'])
    net_uris = [enet['uri']]
    uplinkSet = hpOneView.common.make_uplink_set_dict("RDPUplinkSet", net_uris)
    # Get Port Number
    pnum = -1
    for port in swtype['portInfos']:
        if port['portName'] == 'X5':
            pnum = port['portNumber']
            break
    uplinkSet['logicalPortConfigInfos'].append(
        hpOneView.common.make_port_config_info(1, 1, pnum))
    lig['uplinkSets'].append(uplinkSet)

    net_uris = [fcneta['uri']]
    uplinkSet = hpOneView.common.make_uplink_set_dict("SanAUplinkSet",
                                                      net_uris, 'FibreChannel')
    # Get Port Number
    pnum = -1
    for port in swtype['portInfos']:
        if port['portName'] == 'X1':
            pnum = port['portNumber']
            break
    uplinkSet['logicalPortConfigInfos'].append(
        hpOneView.common.make_port_config_info(1, 1, pnum))
    lig['uplinkSets'].append(uplinkSet)

    net_uris = [fcnetb['uri']]
    uplinkSet = hpOneView.common.make_uplink_set_dict("SanBUplinkSet",
                                                      net_uris, 'FibreChannel')
    # Use same port number
    uplinkSet['logicalPortConfigInfos'].append(
        hpOneView.common.make_port_config_info(1, 2, pnum))
    lig['uplinkSets'].append(uplinkSet)

    lig = net.create_lig(lig)
    print('Creating Enclosure Group')
    egroup = hpOneView.common.make_egroup_dict("Enclosure Group", lig['uri'])
    egroup = srv.create_enclosure_group(egroup)
    print('Renaming Enclosure Group')
    egroup['name'] = 'Renamed Enclosure Group'
    egroup = srv.update_enclosure_group(egroup)
    print('Adding Enclosure')
    # Find the first Firmware Baseline
    spp = settings.get_spps()[0]
    add_enclosure = hpOneView.common.make_add_enclosure_dict(
        enclosureIP,
        enclosureUser,
        enclosurePassword,
        egroup['uri'],
        firmwareBaseLineUri=spp['uri'])
    enclosure = srv.add_enclosure(add_enclosure)
    print('Creating Profiles')
    # See if we need to turn any servers off
    servers = srv.get_servers()
    for server in servers:
        if server['powerState'] == 'On':
            srv.set_server_powerstate(server, 'Off', force=True)
    g7server = srv.get_server_by_bay(7)
    gen8server = srv.get_server_by_bay(13)
    connection1 = hpOneView.common.make_profile_connection_dict(
        enet,
        boot=hpOneView.common.make_profile_connection_boot_dict(
            priority='Primary'))
    connection2 = hpOneView.common.make_profile_connection_dict(
        fcneta,
        functionType='FibreChannel',
        boot=hpOneView.common.make_profile_connection_boot_dict(
            priority='Primary', arrayWwpn='5001438004C8E7F8', lun='1'))
    connection3 = hpOneView.common.make_profile_connection_dict(
        fcnetb,
        functionType='FibreChannel',
        boot=hpOneView.common.make_profile_connection_boot_dict(
            priority='Secondary', arrayWwpn='5001438004C8E7FC', lun='1'))
    connections = [connection1, connection2, connection3]
    firmwareBaseline = hpOneView.common.make_profile_firmware_baseline(
        spp['uri'])
    print('Creating G7 Profile')
    g7profile = hpOneView.common.make_add_profile_dict('G7 Profile',
                                                       g7server,
                                                       connections=connections)
    print('Creating Gen8 Profile')
    gen8profile = hpOneView.common.make_add_profile_dict(
        'Gen8 Profile',
        gen8server,
        connections=connections,
        firmwareBaseline=firmwareBaseline)
    g7profile = srv.create_server_profile(g7profile)
    gen8profile = srv.create_server_profile(gen8profile)
    g7profile['name'] = 'Renamed G7 Profile'
    g7profile = srv.update_server_profile(g7profile)
    gen8profile['name'] = 'Renamed Gen8 Profile'
    gen8profile = srv.update_server_profile(gen8profile)

    # Try searching now that we have resources
    resources = sear.get_resources('category=interconnect-types')
    print(('%s Interconnect Types' % len(resources)))
    resources = sear.get_resources({'category': 'interconnect-types'})
    print(('%s Interconnect Types' % len(resources)))
    assoc = sear.get_associations('category=interconnect-types')
    print(('%s Associations' % len(assoc)))
    trees = sear.get_trees('category=interconnect-types')
    print(('%s Trees' % len(trees)))
    sugg = sear.get_search_suggestions('Flex')
    print(('%s Suggestions' % len(sugg['suggestions'])))

    #print('Generating LI Dump')
    #li = net.get_interconnects()
    #dumpInfo = settings.generate_support_dump(logicalInterconnect=li[0])
    #print('Downloading LI Dump')
    #settings.download_support_dump(dumpInfo)

    print('Generating appliance backup')
    backup = settings.generate_backup()
    print('Downloading appliance backup')
    settings.download_backup(backup)

    # Check and see if we have any new alerts
    alerts = act.get_alerts('Active')
    if len(alerts) > 0:
        print(('WARNING: You have %d active alerts' % (len(alerts))))
        for alert in alerts:
            print(('- ' + alert['description']))

    # Events
    events = act.get_events('filter="eventTypeID=\'Demo.Event\'"')
    numEvents = len(events)
    eventDetail = hpOneView.common.make_event_detail_dict(
        'ipv4Address', enclosureIP)
    eventRecord = hpOneView.common.make_event_dict(description='Test',
                                                   eventTypeID='Demo.Event',
                                                   eventDetails=[eventDetail])
    act.create_event(eventRecord)
    events = act.get_events('filter="eventTypeID=\'Demo.Event\'"')
    if len(events) is numEvents:
        print('WARNING: Event record not created')

    # Audit Logs
    logs = act.get_audit_logs('filter="componentId=\'Test\'"')
    numLogs = len(logs)
    auditRecord = hpOneView.common.make_audit_log_dict(componentId='Test',
                                                       userId='Administrator',
                                                       domain='Local',
                                                       objectType='SERVER',
                                                       msg='Test Log')
    act.create_audit_log(auditRecord)
    logs = act.get_audit_logs('filter="componentId=\'Test\'"')
    if len(logs) is numLogs:
        print('WARNING: Audit log not created')

    # Paging example
    #pages = hpOneView.common.pages(act.get_alerts(), act._con)
    #firstPage = pages.currentPage
    #firstRecord = firstPage[0]
    #for page in pages:
    #    for record in page:
    #        pass  # OR print(record)
    #lastPage = pages.currentPage
    #lastRecord = lastPage[len(lastPage) - 1]

    print()
    print('We have now created everything. Check the UI and if all is good.'
          ' Press Enter to clean up.')
    input()

    # Clean Up
    print('Removing Profiles')
    srv.remove_server_profile(g7profile)
    srv.remove_server_profile(gen8profile)
    print('Removing Enclosure')
    srv.remove_enclosure(enclosure)
    print('Deleting Enclosure Group')
    srv.delete_enclosure_group(egroup)
    print('Deleting Logical Interconnect Group')
    net.delete_lig(lig)
    print('Deleting Network Set')
    net.delete_networkset(nset)
    print('Deleting FC Network')
    net.delete_network(fcneta)
    net.delete_network(fcnetb)
    print('Deleting Ethernet Network')
    net.delete_network(enet)
    # Check and see if we have any new alerts
    alerts = act.get_alerts('Active')
    if len(alerts) > 0:
        print(('WARNING: You have %d active alerts' % (len(alerts))))
        for alert in alerts:
            print((alert['description']))
    con.logout()
コード例 #43
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)
コード例 #44
0
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="""
    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""",
    )

    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)

    get_network_interfaces(sts)
コード例 #45
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('-j', dest='domain', required=False,
                        default='Local',
                        help='''
    HP OneView Authorized Login Domain''')
    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 option 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 separated by 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 Environment.

    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('-pn', dest='physnum', required=False,
                        help='''
    The number of physical drives to be used to build the logical drive.  The
    provided values must be consistent with the selected RAID level and cannot
    exceed the maximum supported number of drives for the selected server
    hardware type.''')
    parser.add_argument('-lb', dest='lboot', 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 hardware 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 used. For example, a single 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
    argument can be used to get a list of server hardware types that have
    been imported into the OneView appliance''')
    parser.add_argument('-bl', dest='bios_list',
                        required=False,
                        help='''
    File in JSON format with list of BIOS settings to override for this profile. This file
    can be created with a call to get-bios-options.py''')
    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)

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

    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 = profile.make_boot_settings_dict(srv, sht, args.disable_manage_boot,
                                   args.boot_order, args.boot_mode, args.pxe)

    fw_settings = profile.make_firmware_dict(sts, args.baseline)
    local_storage = profile.make_local_storage_dict(sht, args.raidlevel, args.lboot,
                            args.init_storage, args.physnum)
    bios = profile.make_bios_dict(args.bios_list)
    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, bios)
コード例 #46
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Define a server profile template''')
    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 template''')
    parser.add_argument('-d',
                        dest='desc',
                        required=False,
                        help='''
    Description for the server profile template''')
    parser.add_argument('-spd',
                        dest='sp_desc',
                        required=False,
                        help='''
    Server profile description''')
    parser.add_argument('-sht',
                        dest='server_hwt',
                        required=True,
                        help='''
    Server hardware 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 used. For example, a single 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
    argument can be used to get a list of server hardware types that have
    been imported into the OneView appliance''')
    parser.add_argument('-eg',
                        dest='enc_group',
                        required=True,
                        help='''
    Identifies the enclosure group for which the Server Profile Template
    was designed. The enclosureGroupUri is determined when the profile
    template is created and cannot be modified
                        ''')
    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('-hn',
                        dest='hide_flexnics',
                        required=False,
                        choices=['true', '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('-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''')

    args = parser.parse_args()
    credential = {'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)

    eg = get_eg_from_arg(srv, args.enc_group)

    sht = get_sht_from_arg(srv, args.server_hwt)

    define_profile_template(srv, args.name, args.desc, args.sp_desc, sht, eg,
                            args.affinity, args.hide_flexnics, args.conn_list)
コード例 #47
0
def main():
    parser = argparse.ArgumentParser(add_help=True,
                                     formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Define a server profile template''')
    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('-n', dest='name',
                        required=True,
                        help='''
    Name of the profile template''')
    parser.add_argument('-d', dest='desc',
                        required=False,
                        help='''
    Description for the server profile template''')
    parser.add_argument('-spd', dest='sp_desc',
                        required=False,
                        help='''
    Server profile description''')
    parser.add_argument('-sht', dest='server_hwt', required=True,
                        help='''
    Server hardware type is required for defining an unassigned profile. Note
    the Server Hardware Type must be present in the HPE OneView appliance
    before it can be used. For example, a single 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
    argument can be used to get a list of server hardware types that have
    been imported into the OneView appliance''')
    parser.add_argument('-eg', dest='enc_group', required=True,
                        help='''
    Identifies the enclosure group for which the Server Profile Template
    was designed. The enclosureGroupUri is determined when the profile
    template is created and cannot be modified
                        ''')
    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('-hn', dest='hide_flexnics',
                        required=False, choices=['true', '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('-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('-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 option 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 separated by 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('-bm', dest='boot_mode', required=False,
                        choices=['UEFI', 'UEFIOptimized', 'BIOS'],
                        default='BIOS',
                        help='''
    Specify the Gen9 Boot Environment.

    Sets the boot mode as one of the following:

        . UEFI
        . UEFIOptimized
        . BIOS

    If you select UEFI or UEFI optimized for an HPE 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('-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''')

    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)

    eg_uri = get_eg_uri_from_arg(srv, args.enc_group)

    sht = get_sht_from_arg(srv, args.server_hwt)

    fw_settings = profile.make_firmware_dict(sts, args.baseline)

    boot, bootmode = profile.make_boot_settings_dict(srv, sht, args.disable_manage_boot,
                                                     args.boot_order, args.boot_mode, args.pxe)

    define_profile_template(srv,
                            args.name,
                            args.desc,
                            args.sp_desc,
                            sht['uri'],
                            eg_uri,
                            args.affinity,
                            args.hide_flexnics,
                            args.conn_list,
                            fw_settings,
                            boot,
                            bootmode,
                            args.san_list)
コード例 #48
0
def main():
    con = hpOneView.connection(applianceIP)
    srv = hpOneView.servers(con)

    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
    con.get_eula_status()
    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)
    credential = {'userName': applianceUser, 'password': appliancePassword}
    con.login(credential)

    encNum = 1
    for enclosure in srv.get_enclosures():
        print('Enclosure ' + str(encNum))
        print('\tName ' + enclosure['name'])
        print('\tType: ' + enclosure['enclosureType'])
        print('\tSerial Number: ' + enclosure['serialNumber'])
        for oa in enclosure['oa']:
            print('\tOA Bay ' + str(oa['bayNumber']))
            print('\t\tIP Address: ' + oa['ipAddress'])
            print('\t\tRole: ' + oa['role'])
            print('\t\tVersion: ' + oa['fwVersion'] + ' ' + oa['fwBuildDate'])
        for blade in enclosure['deviceBays']:
            print('\tDevice Bay ' + str(blade['bayNumber']) + ' ' +
                  blade['devicePresence'])
            if blade['devicePresence'] != 'absent':
                hardware = con.get(blade['deviceUri'])
                print('\t\tSerial Number: ' + hardware['serialNumber'])
                print('\t\tName: ' + hardware['model'])
                if hardware['serverProfileUri'] is not None:
                    profile = con.get(hardware['serverProfileUri'])
                    print('\t\tProfile Name: ' + profile['name'])
                print('\t\tROM: ' + hardware['romVersion'])
                print('\t\tMezz Cards')
                for device in hardware['portMap']['deviceSlots']:
                    print('\t\t\t' + device['location'] + ' ' +
                          str(device['slotNumber']) + ': ' +
                          device['deviceName'])
                print('\t\tiLO')
                print('\t\t\tIP Address: ' + hardware['mpIpAddress'])
                print('\t\t\tFirmware Version: ' +
                      hardware['mpFirmwareVersion'])
                print('\t\t\tDNS Name: ' + hardware['mpDnsName'])
        for interconnect in enclosure['interconnectBays']:
            print('\tInterconnect Bay ' + str(interconnect['bayNumber']))
            if interconnect['interconnectUri'] is not None:
                hardware = con.get(interconnect['interconnectUri'])
                print('\t\tProduct Name: ' + hardware['productName'])
                print('\t\tSerial Number: ' + hardware['serialNumber'])
                print('\t\tIP Address: ' + hardware['interconnectIP'])
                print('\t\tFirmware Version: ' + hardware['firmwareVersion'])
        encNum = encNum + 1

    con.logout()
コード例 #49
0
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)
コード例 #50
0
def main():
    parser = argparse.ArgumentParser(add_help=True,
                                     formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    This example script will import an enclosure into HP 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='''
    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('-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 HP 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)
コード例 #51
0
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)
コード例 #52
0
def main():
    #    con = connect(newApp1Ipv4Addr)    # just here for debugging...
    con = connect(applianceIP)

    # Get the appliance MAC address
    data = con.get_appliance_network_interfaces()
    macAddress = data["applianceNetworks"][0]["macAddress"]
    hostName = data["applianceNetworks"][0]["hostname"]

    # Try changing appliance to static ip...
    if newApp1Ipv4Addr:
        quit = False
        if not newIpv4Subnet:
            print("newIpv4Subnet required if newApp1Ipv4Addr supplied.")
            quit = True
        if not newDomainName:
            print("newDomainName required if newApp1Ipv4Addr supplied.")
            quit = True
        if not newIpv4Subnet:
            print("newIpv4Subnet required if newApp1Ipv4Addr supplied.")
            quit = True
        if not newIpv4Gateway:
            print("newIpv4Gateway required if newApp1Ipv4Addr supplied.")
            quit = True
        if quit:
            exit(2)
        print("Setting ipv4...")
        interfaceConfig = hpOneView.common.make_appliance_network_config_dict(
            newDomainName,
            macAddress,
            newApp1Ipv4Addr,
            newIpv4Subnet,
            newIpv4Gateway,
            newSearchDomain1,
            newSearchDomain2,
            ipv4Type="STATIC",
            ipv6Type="UNCONFIGURE",
        )
        con.set_appliance_network_interface(interfaceConfig)
        print("Network set to static ip: " + newApp1Ipv4Addr)

        # Connect via the new IP...
        con = connect(newApp1Ipv4Addr)

        print("Sleep for 60 seconds before reverting back to DHCP...")
        time.sleep(60)

        print("Sleep for 60 seconds before reverting back to DHCP...")
        time.sleep(60)

    # Change appliance to DHCP...
    interfaceConfig = hpOneView.common.make_appliance_network_config_dict(
        hostName, macAddress, ipv4Type="DHCP", ipv6Type="DHCP"
    )
    con.set_appliance_network_interface(interfaceConfig)
    print("Network set to DHCP: " + applianceIP)

    con = connect(applianceIP)

    # IP should not change anymore--set variables from con:
    srv = hpOneView.servers(con)
    net = hpOneView.networking(con)
    sec = hpOneView.security(con)
    settings = hpOneView.settings(con)
    act = hpOneView.activity(con)
    sear = hpOneView.search(con)

    try:
        settings.add_license(licenseKey)
    except hpOneView.exceptions.HPOneViewException as ex:
        print("WARNING: License failed to add. Check message.")
        print("Message: " + ex.message)
    licenses = settings.get_licenses()
    print(str(len(licenses)) + " licenses installed")

    if doRackConfiguration is True:
        # Rack based support
        serverdict = hpOneView.common.make_add_server_dict(
            hostname=rackiLOIp, username=rackiLOUser, password=rackiLOPassword, force=False, licensingIntent="OneView"
        )
        print("Adding rack server...")
        server = srv.add_server(serverdict)
        print("Removing rack server...")
        srv.delete_server(server)

    readCommunityString = insecure_random_string_generator()
    response = settings.set_dev_read_comm_string(readCommunityString)
    if response != readCommunityString:
        raise Exception("Community string not set")
    newCommString = settings.get_dev_read_comm_string()
    if newCommString != readCommunityString:
        raise Exception("Community strings differ")

    print("Generating Appliance Dump")
    dumpInfo = settings.generate_support_dump()
    print("Downloading Appliance Dump")
    settings.download_support_dump(dumpInfo)

    version = settings.get_version()
    print("Minimum API Version: " + str(version["minimumVersion"]))
    print("Current API Version: " + str(version["currentVersion"]))

    status = settings.get_health_status()
    for member in status:
        print(member["available"] + " available " + member["resourceType"])

    # Clean up everything before we start in case of aborted previous run
    servers = srv.get_servers()
    for server in servers:
        if server["powerState"] == "On":
            srv.set_server_powerstate(server, "Off", force=True)
    profiles = srv.get_server_profiles()
    for profile in profiles:
        print(("Removing Profile %s" % profile["name"]))
        srv.remove_server_profile(profile)
    enclosures = srv.get_enclosures()
    for enclosure in enclosures:
        print(("Removing Enclosure %s" % enclosure["serialNumber"]))
        srv.remove_enclosure(enclosure)
    egroups = srv.get_enclosure_groups()
    for egroup in egroups:
        srv.delete_enclosure_group(egroup)
    ligs = net.get_ligs()
    for lig in ligs:
        net.delete_lig(lig)
    networksets = net.get_networksets()
    for networkset in networksets:
        net.delete_networkset(networkset)
    fcnets = net.get_fc_networks()
    for fcnet in fcnets:
        net.delete_network(fcnet)
    enets = net.get_enet_networks()
    for enet in enets:
        net.delete_network(enet)

    # Check how many non-cleared alerts we have
    alerts = act.get_alerts("Active")
    startNumAlerts = len(alerts)
    print(("%d active alerts" % startNumAlerts))
    # Clear (or Delete) active alerts so we start clean
    if startNumAlerts > 0:
        for alert in alerts:
            alertMap = hpOneView.common.make_update_alert_dict(alertState="Cleared", assignedToUser="******")
            act.update_alert(alert, alertMap)
            # or Delete it - act.delete_alert(alert)
    alerts = act.get_alerts("Active")
    startNumAlerts = len(alerts)
    print(("%d active alerts" % startNumAlerts))
    # Delete active alerts so we start clean
    if startNumAlerts > 0:
        raise Exception("Still have active alerts")

    if doSppTests is True:
        print("Getting current SPPs")
        spps = settings.get_spps()
        startNumSpps = len(spps)
        print("Uploading SPP")
        spp = settings.upload_spp(firmwareBundlePath, firmwareBundleFileName)
        spps = settings.get_spps()
        if len(spps) == startNumSpps:
            raise Exception("Same number of SPPs found %d" % (len(spps)))
        print("Deleting SPP")
        settings.delete_spp(spp)
    con.set_service_access("false")

    roles = sec.get_roles()
    print(str(len(roles)) + " user roles")
    users = sec.get_users()
    numUsers = len(users)
    print(("Current Users (" + str(numUsers) + "):"))
    for user in users:
        print((" " + (user["userName"])))
    testUser = insecure_random_string_generator()
    testPassword = insecure_random_string_generator()
    print(("Adding User " + testUser))
    user = hpOneView.common.make_user_dict(
        testUser,
        testPassword,
        enabled=True,
        fullName="Test User",
        emailAddress="*****@*****.**",
        roles=["Infrastructure administrator"],
    )
    sec.create_user(user)
    users = sec.get_users()
    if len(users) != numUsers + 1:
        raise Exception("User not added")
    con.logout()
    print(("Testing user " + testUser))
    testCredential = {"userName": testUser, "password": testPassword}
    con.login(testCredential)
    con.logout()
    con.login(credential)
    print("Modifying User")
    updateUser = hpOneView.common.make_user_modify_dict(userName=testUser, fullName="Renamed Test User")
    updatedUser = sec.update_user(updateUser)
    updatedUser = sec.get_user(testUser)
    if updatedUser["fullName"] != "Renamed Test User":
        raise Exception("User not renamed")
    print(("Deleting User " + testUser))
    sec.delete_user(testUser)
    users = sec.get_users()
    if len(users) != numUsers:
        raise Exception("User not deleted")
    pool = srv.get_vsn_pool()
    print(("Current SN Pool Type: " + (pool["poolType"])))
    pool = srv.get_vwwn_pool()
    print(("Current WWN Pool Type: " + (pool["poolType"])))
    pool = srv.get_vmac_pool()
    print(("Current MAC Pool Type: " + (pool["poolType"])))
    roles = sec.get_user_roles("administrator")
    print("Roles:")
    for role in roles:
        print((" " + (role["roleName"])))
    user = sec.get_user("administrator")
    print("User Properties:")
    pprint(user, indent=4)
    # Create Network
    bandDict = hpOneView.common.make_bw_dict(maxbw=10000, minbw=1000)
    print("Creating Ethernet Network")
    enet = net.create_enet_network("RDP", 1, smartLink=True, privateNetwork=False, bw=bandDict)
    print("Creating FC Networks")
    fcneta = net.create_fc_network("SAN-A", bw=bandDict)
    fcnetb = net.create_fc_network("SAN-B", bw=bandDict)
    print("Creating Network Set")
    nset = net.create_networkset("RDP Network Set", nets=[enet["uri"]], bw=bandDict)
    print("Creating Logical Interconnect Group")
    lig = hpOneView.common.make_lig_dict("Test LIG")
    swtype = con.get_entity_byfield(hpOneView.common.uri["ictype"], "partNumber", "571956-B21")
    hpOneView.common.set_iobay_occupancy(lig["interconnectMapTemplate"], [1, 2], swtype["uri"])
    net_uris = [enet["uri"]]
    uplinkSet = hpOneView.common.make_uplink_set_dict("RDPUplinkSet", net_uris)
    # Get Port Number
    pnum = -1
    for port in swtype["portInfos"]:
        if port["portName"] == "X5":
            pnum = port["portNumber"]
            break
    uplinkSet["logicalPortConfigInfos"].append(hpOneView.common.make_port_config_info(1, 1, pnum))
    lig["uplinkSets"].append(uplinkSet)

    net_uris = [fcneta["uri"]]
    uplinkSet = hpOneView.common.make_uplink_set_dict("SanAUplinkSet", net_uris, "FibreChannel")
    # Get Port Number
    pnum = -1
    for port in swtype["portInfos"]:
        if port["portName"] == "X1":
            pnum = port["portNumber"]
            break
    uplinkSet["logicalPortConfigInfos"].append(hpOneView.common.make_port_config_info(1, 1, pnum))
    lig["uplinkSets"].append(uplinkSet)

    net_uris = [fcnetb["uri"]]
    uplinkSet = hpOneView.common.make_uplink_set_dict("SanBUplinkSet", net_uris, "FibreChannel")
    # Use same port number
    uplinkSet["logicalPortConfigInfos"].append(hpOneView.common.make_port_config_info(1, 2, pnum))
    lig["uplinkSets"].append(uplinkSet)

    lig = net.create_lig(lig)
    print("Creating Enclosure Group")
    egroup = hpOneView.common.make_egroup_dict("Enclosure Group", lig["uri"])
    egroup = srv.create_enclosure_group(egroup)
    print("Renaming Enclosure Group")
    egroup["name"] = "Renamed Enclosure Group"
    egroup = srv.update_enclosure_group(egroup)
    print("Adding Enclosure")
    # Find the first Firmware Baseline
    spp = settings.get_spps()[0]
    add_enclosure = hpOneView.common.make_add_enclosure_dict(
        enclosureIP, enclosureUser, enclosurePassword, egroup["uri"], firmwareBaseLineUri=spp["uri"]
    )
    enclosure = srv.add_enclosure(add_enclosure)
    print("Creating Profiles")
    # See if we need to turn any servers off
    servers = srv.get_servers()
    for server in servers:
        if server["powerState"] == "On":
            srv.set_server_powerstate(server, "Off", force=True)
    g7server = srv.get_server_by_bay(7)
    gen8server = srv.get_server_by_bay(13)
    connection1 = hpOneView.common.make_profile_connection_dict(
        enet, boot=hpOneView.common.make_profile_connection_boot_dict(priority="Primary")
    )
    connection2 = hpOneView.common.make_profile_connection_dict(
        fcneta,
        functionType="FibreChannel",
        boot=hpOneView.common.make_profile_connection_boot_dict(
            priority="Primary", arrayWwpn="5001438004C8E7F8", lun="1"
        ),
    )
    connection3 = hpOneView.common.make_profile_connection_dict(
        fcnetb,
        functionType="FibreChannel",
        boot=hpOneView.common.make_profile_connection_boot_dict(
            priority="Secondary", arrayWwpn="5001438004C8E7FC", lun="1"
        ),
    )
    connections = [connection1, connection2, connection3]
    firmwareBaseline = hpOneView.common.make_profile_firmware_baseline(spp["uri"])
    print("Creating G7 Profile")
    g7profile = hpOneView.common.make_add_profile_dict("G7 Profile", g7server, connections=connections)
    print("Creating Gen8 Profile")
    gen8profile = hpOneView.common.make_add_profile_dict(
        "Gen8 Profile", gen8server, connections=connections, firmwareBaseline=firmwareBaseline
    )
    g7profile = srv.create_server_profile(g7profile)
    gen8profile = srv.create_server_profile(gen8profile)
    g7profile["name"] = "Renamed G7 Profile"
    g7profile = srv.update_server_profile(g7profile)
    gen8profile["name"] = "Renamed Gen8 Profile"
    gen8profile = srv.update_server_profile(gen8profile)

    # Try searching now that we have resources
    resources = sear.get_resources("category=interconnect-types")
    print(("%s Interconnect Types" % len(resources)))
    resources = sear.get_resources({"category": "interconnect-types"})
    print(("%s Interconnect Types" % len(resources)))
    assoc = sear.get_associations("category=interconnect-types")
    print(("%s Associations" % len(assoc)))
    trees = sear.get_trees("category=interconnect-types")
    print(("%s Trees" % len(trees)))
    sugg = sear.get_search_suggestions("Flex")
    print(("%s Suggestions" % len(sugg["suggestions"])))

    # print('Generating LI Dump')
    # li = net.get_interconnects()
    # dumpInfo = settings.generate_support_dump(logicalInterconnect=li[0])
    # print('Downloading LI Dump')
    # settings.download_support_dump(dumpInfo)

    print("Generating appliance backup")
    backup = settings.generate_backup()
    print("Downloading appliance backup")
    settings.download_backup(backup)

    # Check and see if we have any new alerts
    alerts = act.get_alerts("Active")
    if len(alerts) > 0:
        print(("WARNING: You have %d active alerts" % (len(alerts))))
        for alert in alerts:
            print(("- " + alert["description"]))

    # Events
    events = act.get_events("filter=\"eventTypeID='Demo.Event'\"")
    numEvents = len(events)
    eventDetail = hpOneView.common.make_event_detail_dict("ipv4Address", enclosureIP)
    eventRecord = hpOneView.common.make_event_dict(
        description="Test", eventTypeID="Demo.Event", eventDetails=[eventDetail]
    )
    act.create_event(eventRecord)
    events = act.get_events("filter=\"eventTypeID='Demo.Event'\"")
    if len(events) is numEvents:
        print("WARNING: Event record not created")

    # Audit Logs
    logs = act.get_audit_logs("filter=\"componentId='Test'\"")
    numLogs = len(logs)
    auditRecord = hpOneView.common.make_audit_log_dict(
        componentId="Test", userId="Administrator", domain="Local", objectType="SERVER", msg="Test Log"
    )
    act.create_audit_log(auditRecord)
    logs = act.get_audit_logs("filter=\"componentId='Test'\"")
    if len(logs) is numLogs:
        print("WARNING: Audit log not created")

    # Paging example
    # pages = hpOneView.common.pages(act.get_alerts(), act._con)
    # firstPage = pages.currentPage
    # firstRecord = firstPage[0]
    # for page in pages:
    #    for record in page:
    #        pass  # OR print(record)
    # lastPage = pages.currentPage
    # lastRecord = lastPage[len(lastPage) - 1]

    print()
    print("We have now created everything. Check the UI and if all is good." " Press Enter to clean up.")
    input()

    # Clean Up
    print("Removing Profiles")
    srv.remove_server_profile(g7profile)
    srv.remove_server_profile(gen8profile)
    print("Removing Enclosure")
    srv.remove_enclosure(enclosure)
    print("Deleting Enclosure Group")
    srv.delete_enclosure_group(egroup)
    print("Deleting Logical Interconnect Group")
    net.delete_lig(lig)
    print("Deleting Network Set")
    net.delete_networkset(nset)
    print("Deleting FC Network")
    net.delete_network(fcneta)
    net.delete_network(fcnetb)
    print("Deleting Ethernet Network")
    net.delete_network(enet)
    # Check and see if we have any new alerts
    alerts = act.get_alerts("Active")
    if len(alerts) > 0:
        print(("WARNING: You have %d active alerts" % (len(alerts))))
        for alert in alerts:
            print((alert["description"]))
    con.logout()
コード例 #53
0
def main():
    con = hpOneView.connection(applianceIP)
    srv = hpOneView.servers(con)

    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
    con.get_eula_status()
    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)
    credential = {'userName': applianceUser, 'password': appliancePassword}
    con.login(credential)

    encNum = 1
    for enclosure in srv.get_enclosures():
        print('Enclosure ' + str(encNum))
        print('\tName ' + enclosure['name'])
        print('\tType: ' + enclosure['enclosureType'])
        print('\tSerial Number: ' + enclosure['serialNumber'])
        for oa in enclosure['oa']:
            print('\tOA Bay ' + str(oa['bayNumber']))
            print('\t\tIP Address: ' + oa['ipAddress'])
            print('\t\tRole: ' + oa['role'])
            print('\t\tVersion: ' + oa['fwVersion'] + ' '
                                  + oa['fwBuildDate'])
        for blade in enclosure['deviceBays']:
            print('\tDevice Bay ' + str(blade['bayNumber']) + ' ' +
                            blade['devicePresence'])
            if blade['devicePresence'] != 'absent':
                hardware = con.get(blade['deviceUri'])
                print('\t\tSerial Number: ' + hardware['serialNumber'])
                print('\t\tName: ' + hardware['model'])
                if hardware['serverProfileUri'] is not None:
                    profile = con.get(hardware['serverProfileUri'])
                    print('\t\tProfile Name: ' + profile['name'])
                print('\t\tROM: ' + hardware['romVersion'])
                print('\t\tMezz Cards')
                for device in hardware['portMap']['deviceSlots']:
                    print('\t\t\t' + device['location'] +
                                ' ' + str(device['slotNumber']) + ': ' +
                                    device['deviceName'])
                print('\t\tiLO')
                print('\t\t\tIP Address: ' + hardware['mpIpAddress'])
                print('\t\t\tFirmware Version: ' +
                            hardware['mpFirmwareVersion'])
                print('\t\t\tDNS Name: ' + hardware['mpDnsName'])
        for interconnect in enclosure['interconnectBays']:
            print('\tInterconnect Bay ' + str(interconnect['bayNumber']))
            if interconnect['interconnectUri'] is not None:
                hardware = con.get(interconnect['interconnectUri'])
                print('\t\tProduct Name: ' + hardware['productName'])
                print('\t\tSerial Number: ' + hardware['serialNumber'])
                print('\t\tIP Address: ' + hardware['interconnectIP'])
                print('\t\tFirmware Version: ' + hardware['firmwareVersion'])
        encNum = encNum + 1

    con.logout()
コード例 #54
0
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Define the BIOS options of a OneView server profile. Use when defining a
    server profile with manage BIOS.  Server hardware name or server hardware
    type name can be used to create the BIOS list.

    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('-bl', dest='bios_list',
                        required=True,
                        help='''
    Name of file for BIOS options list.  File will be created in JSON format
    and need to be edited to select the desired options to manage in the server
    profile.''')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-s', dest='server_id',
                        help='''
    Server identification. There are multiple ways to specify the server id:

        . Hostname or IP address of the stand-alone server iLO
        . The "Server Hardware Name" of a server than has already been imported
          into HP OneView and is listed under Server Hardware''')
    group.add_argument('-sh', dest='server_hwt',
                        help='''
    Server hardware type is required for defining BIOS options without
    specifying a specific server identification. The Server Hardware Type must
    be present in the HP OneView appliance before it can be used. For example,
    a single 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 argument 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)

    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_bios_options(con, srv, args.server_id, args.server_hwt, args.bios_list)
コード例 #55
0
def main():
    parser = argparse.ArgumentParser(add_help=True,
                                     formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Define a server profile template''')
    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 template''')
    parser.add_argument('-d', dest='desc',
                        required=False,
                        help='''
    Description for the server profile template''')
    parser.add_argument('-spd', dest='sp_desc',
                        required=False,
                        help='''
    Server profile description''')
    parser.add_argument('-sht', dest='server_hwt', required=True,
                        help='''
    Server hardware 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 used. For example, a single 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
    argument can be used to get a list of server hardware types that have
    been imported into the OneView appliance''')
    parser.add_argument('-eg', dest='enc_group', required=True,
                        help='''
    Identifies the enclosure group for which the Server Profile Template
    was designed. The enclosureGroupUri is determined when the profile
    template is created and cannot be modified
                        ''')
    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('-hn', dest='hide_flexnics',
                        required=False, choices=['true', '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('-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''')
    
    args = parser.parse_args()
    credential = {'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)

    eg = get_eg_from_arg(srv, args.enc_group)
                
    sht = get_sht_from_arg(srv, args.server_hwt)

    define_profile_template(
                            srv,
                            args.name,
                            args.desc,
                            args.sp_desc,
                            sht,
                            eg,
                            args.affinity,
                            args.hide_flexnics,
                            args.conn_list)
コード例 #56
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''')
    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)
コード例 #57
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='''
    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 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 option 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 separated by 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 Environment.

    Sets the boot mode as one of the following:

        . UEFI
        . UEFIOptimized
        . BIOS

    If you select UEFI or UEFI optimized for an HPE 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('-dn',
                        dest='driveName',
                        required=False,
                        help='''
        The name of the logical drive.''')
    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('-pn',
                        dest='physnum',
                        required=False,
                        help='''
    The number of physical drives to be used to build the logical drive.  The
    provided values must be consistent with the selected RAID level and cannot
    exceed the maximum supported number of drives for the selected server
    hardware type.''')
    parser.add_argument('-lb',
                        dest='lboot',
                        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 HPE 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 hardware type is required for defining an unassigned profile. Note
    the Server Hardware Type must be present in the HPE OneView appliance
    before it can be used. For example, a single 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
    argument can be used to get a list of server hardware types that have
    been imported into the OneView appliance''')
    parser.add_argument('-bl',
                        dest='bios_list',
                        required=False,
                        help='''
    File in JSON format with list of BIOS settings to override for this profile. This file
    can be created with a call to get-bios-options.py''')
    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)

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

    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 = profile.make_boot_settings_dict(srv, sht,
                                                     args.disable_manage_boot,
                                                     args.boot_order,
                                                     args.boot_mode, args.pxe)

    fw_settings = profile.make_firmware_dict(sts, args.baseline)
    local_storage = profile.make_local_storage_dict(sht, args.raidlevel,
                                                    args.lboot,
                                                    args.init_storage,
                                                    args.physnum,
                                                    args.driveName)
    bios = profile.make_bios_dict(args.bios_list)
    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, bios)
コード例 #58
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Import a physical stand-alone rackmount server.

    This example script IS NOT USED to add a Blade Server to the appliance.
    A BL server will automatically be discovered once it inserted into an
    enclosure being managed by 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''')
    parser.add_argument('-sh',
                        dest='hostname',
                        required=True,
                        help='''
    Hostname or IP address  of the server iLO''')
    parser.add_argument('-su',
                        dest='username',
                        required=True,
                        help='''
    Administrative username for the server iLO''')
    parser.add_argument('-sp',
                        dest='password',
                        required=True,
                        help='''
    Administrative password for the server iLO''')
    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',
                        help='''
    Force adding the server when currently managed by another OneView
    appliance.''')
    parser.add_argument('-m',
                        dest='monitor',
                        action='store_true',
                        help='''
    Add the server as a monitored device.''')

    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)

    add_server(srv, args.hostname, args.username, args.password, args.force,
               args.license, args.monitor)