示例#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, 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)
示例#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='''
    Display Uplink Sets

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

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

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

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

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

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

    login(con, credential)
    acceptEULA(con)

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

    setrole(sec, args.name, 'Read only')
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Display Server Profile Connections

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

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

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

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

    login(con, credential)
    acceptEULA(con)

    # get a server profile's connection information
    get_profile_connections_list(con, srv, '', args.report)
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Set the 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)
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)
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)
示例#10
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''

    Retrieves a list of all Logical Interconnects

    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('-r',
                        dest='report',
                        required=False,
                        action='store_true',
                        help='''
    Format the output using a human readable report format''')

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

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

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

    login(con, credential)
    acceptEULA(con)

    get_logical_interconnects(con, net, args.report)
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Set the service access state

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

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

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

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

    login(con, credential)
    acceptEULA(con)

    if args.gets:
        getsa(sts)
    elif args.ena:
        setsa(sts, 'true')
    elif args.dis:
        setsa(sts, 'false')
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    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, 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)
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)
示例#15
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)
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)
示例#17
0
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
   Delete individual or ALL Logical Interconnect Groups

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

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

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

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

    login(con, credential)
    acceptEULA(con)

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

    del_lig_by_name(net, args.name)
示例#18
0
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Display the collection of network resources

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

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

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

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

    login(con, credential)
    acceptEULA(con)

    get_networks(net, args.ntype, args.name, args.report)
示例#19
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)
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)
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Obtain a collection of Enclosure Group resources, or a single Enclosure
    Group with the specified name.

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

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

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

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

    login(con, credential)
    acceptEULA(con)

    get_enclosure_groups(srv, net, args.name)
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Set the SNMP read community string

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

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

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

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

    login(con, credential)
    acceptEULA(con)

    define_string(sts, args.string)
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Retrieves a list of Logical Interconnect Groups

    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,
                        action='store_true',
                        help='''
    Output only the names of the Logical Interconnect Groups''')

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

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

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

    login(con, credential)
    acceptEULA(con)

    get_lig(net, 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)
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''

    Retrieves a list of all Logical Interconnects

    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('-r', dest='report',
                        required=False, action='store_true',
                        help='''
    Format the output using a human readable report format''')

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

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

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

    login(con, credential)
    acceptEULA(con)

    get_logical_interconnects(con, net, args.report)
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')
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)
示例#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('-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)
示例#29
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Define a OneView network connection list for use with defining a server
    profile with connections.

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

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

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

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

    login(con, credential)
    acceptEULA(con)

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

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

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

    define_connection_list(net, args.name, args.cid, args.network,
                           args.conn_list, args.append, args.portId, args.func,
                           args.mac, args.macType, args.net_set, args.reqGbps,
                           args.wwnn, args.wwpn, args.wwpnType, boot, args.spt)
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Define new Uplink Set

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    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='uplink_set_name', required=True,
                        help='''
    Name of the uplink  set''')
    parser.add_argument('-i', dest='logical_interconnect_group_name',
                        required=True,
                        help='''
    Name of the associated Logical Interconnect Group''')
    parser.add_argument('-l', dest='list_of_networks', required=False,
                        nargs='+',
                        help='''
    List of network names to add to the uplink set, encapsulated with quotes
    and seperated by spaces. For example:

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

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

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

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

    login(con, credential)
    acceptEULA(con)

    adduplinkset(con, net, args.uplink_set_name,
                 args.logical_interconnect_group_name, args.list_of_networks,
                 args.uplink_type, args.ethernet_type, args.native_network,
                 args.uplink_ports, args.lacp_mode, args.connection_mode)
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()
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Define new Network Set

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    HPE OneView Appliance hostname or IP address''')
    parser.add_argument('-u', dest='user', required=False,
                        default='Administrator',
                        help='''
    HPE OneView Username''')
    parser.add_argument('-p', dest='passwd', required=True,
                        help='''
    HPE OneView Password''')
    parser.add_argument('-c', dest='cert', required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y', dest='proxy', required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j', dest='domain', required=False,
                        default='Local',
                        help='''
    HPE OneView Authorized Login Domain''')
    parser.add_argument('-n', dest='network_set_name', required=True,
                        help='''
    Name of the network set''')
    parser.add_argument('-l', dest='list_of_networks', required=False,
                        nargs='+',
                        help='''
    List of network names to add to the network set, seperated by spaces.
    For example:
            -t "Net One" "Net Two" "Net Three"''')
    parser.add_argument('-b', dest='prefered_bandwidth', type=float,
                        required=False, default=2.5,
                        help='''
    Typical bandwidth between .1  and 20 Gb/s''')
    parser.add_argument('-m', dest='max_bandwidth', type=float, required=False,
                        default=10,
                        help='''
    Maximum bandwidth between .1 and 20 Gb/s''')

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

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

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

    login(con, credential)
    acceptEULA(con)

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

    add_network_set(net, args.network_set_name, args.list_of_networks,
                    args.prefered_bandwidth, args.max_bandwidth)
示例#33
0
parser.add_argument('--raid', dest='raid', required=False,
    choices=['NONE', 'RAID0', 'RAID1'],
    help='Choose raid level on local storage')
parser.add_argument('--drives', dest='drives', required=False,
    help='Number of local storage disks')

args = parser.parse_args()

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

# Get access to compute and network resources
compute =  ov.servers(con)
net = ov.networking(con)

selectedServer = ''

# We will loop over servers specified in input
print 'Creating servers...'
for server in args.servers:

    # Get list of unassigned servers and select first available
    unassignedServers = compute.get_available_servers()
    for unassignedServer in unassignedServers['targets']:
        if unassignedServer['serverHardwareTypeName'] == args.hardware:
            selectedServer = unassignedServer
            break

    # Check whether server is power on and if yes, power off
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Add Fibre Channel network

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    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='network_name', required=True,
                        help='''
    Name of the network''')
    parser.add_argument('-b', dest='prefered_bandwidth', type=float,
                        required=False, default=2.5,
                        help='''
    Typical bandwidth between .1  and 20 Gb/s''')
    parser.add_argument('-m', dest='max_bandwidth', type=float, required=False,
                        default=10,
                        help='''
    Maximum bandwidth between .1 and 20 Gb/s''')
    parser.add_argument('-s', dest='managed_san', required=False,
                        help='''
    URI of the associated managed SAN''')
    parser.add_argument('-l', dest='link_stability', type=int, required=False,
                        default=30,
                        help='''
    Link Stability Interval between 1 and 1800 seconds''')
    parser.add_argument('-x', dest='dist', required=False, action='store_true',
                        help='''
    Disable AUTO loging redistribution''')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-d', dest='direct', action='store_true',
                       help='''
    DirectAttach Fabric Type''')
    group.add_argument('-f', dest='fabric', action='store_true',
                       help='''
    FabricAttach Fabric Type''')

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

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

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

    login(con, credential)
    acceptEULA(con)

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

    add_network(net, args.network_name, args.prefered_bandwidth,
                args.max_bandwidth, args.managed_san, args.link_stability,
                args.dist, args.direct, args.fabric)
示例#35
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)
示例#36
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Display the collection of network resources

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

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

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

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

    login(con, credential)
    acceptEULA(con)

    get_networks(net, args.ntype, args.name, args.report)
示例#37
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)
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Add new Logical Interconnect Group

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    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='logical_interconnect_group_name',
                        required=True,
                        help='''
    Name of the logical interconnect group''')
    parser.add_argument('-i', dest='interconnects', required=True, nargs='+',
                        help='''
    List of interconnect modules specified as
    BAY:INTERCONNECT where INTERCONNECT must be one of
    the following [FlexFabric, Flex10, Flex1010D,
    Flex2040f8 VCFC20, VCFC24 and FEX] For example Virtual
    Connect Flex10 modules in bays and 2 with Virtual
    Connect 24 port Fibre Channel modules in bays 3 and 4
    would be specified as:

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

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

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

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

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

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

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

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

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

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

    Network loop protection uses two methods to detect
    loops:

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

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

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

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

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

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

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

    login(con, credential)
    acceptEULA(con)

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

    deflig(net, con,
           args.logical_interconnect_group_name,
           args.interconnects,
           ethernetSettings)
示例#39
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)
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()
示例#41
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Add Fibre Channel network

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

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

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

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

    login(con, credential)
    acceptEULA(con)

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

    add_network(net, args.network_name, args.prefered_bandwidth,
                args.max_bandwidth, args.managed_san, args.link_stability,
                args.dist, args.direct, args.fabric)
示例#42
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Add new Logical Interconnect Group

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

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

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

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

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

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

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

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

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

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

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

    Network loop protection uses two methods to detect
    loops:

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

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

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

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

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

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

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

    login(con, credential)
    acceptEULA(con)

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

    deflig(net, con, args.logical_interconnect_group_name, args.interconnects,
           ethernetSettings)
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description="""
    Define new Uplink Set

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

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

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

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

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

    login(con, credential)
    acceptEULA(con)

    adduplinkset(
        con,
        net,
        args.uplink_set_name,
        args.logical_interconnect_group_name,
        args.list_of_networks,
        args.uplink_type,
        args.ethernet_type,
        args.native_network,
        args.uplink_ports,
        args.lacp_mode,
        args.connection_mode,
    )
示例#44
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('-n',
                        dest='network_set_name',
                        required=True,
                        help='Name of the network set')
    parser.add_argument('-t',
                        dest='list_of_networks',
                        required=False,
                        nargs='+',
                        help='List of network names to add to the '
                        'network set, seperated by spaces. I.E. -t "Net One" '
                        '"Net Two" "Net Three"')
    parser.add_argument('-b',
                        dest='prefered_bandwidth',
                        type=float,
                        required=False,
                        default=2.5,
                        help='Typical '
                        'bandwidth between .1  and 20 Gb/s')
    parser.add_argument('-m',
                        dest='max_bandwidth',
                        type=float,
                        required=False,
                        default=10,
                        help='Maximum bandwidth between .1 and '
                        '20 Gb/s')

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

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

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

    login(con, credential)
    acceptEULA(con)

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

    addnetset(net, args.network_set_name, args.list_of_networks,
              args.prefered_bandwidth, args.max_bandwidth)
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Define new ethernet network

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    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='network_name', required=True,
                        help='''
    Name of the network''')
    parser.add_argument('-b', dest='prefered_bandwidth', type=float,
                        required=False, default=2.5,
                        help='''
    Typical bandwidth between .1  and 20 Gb/s''')
    parser.add_argument('-m', dest='max_bandwidth', type=float, required=False,
                        default=10,
                        help='''
    Maximum bandwidth between .1 and 20 Gb/s''')
    parser.add_argument('-v', dest='vlan', required=False,
                        help='''
    VLAN ID''')
    parser.add_argument('-z', dest='vlan_type',
                        choices=['Tagged', 'Untagged', 'Tunnel'],
                        required=False, default='Tagged',
                        help='''
    VLAN Type''')
    parser.add_argument('-o', dest='purpose', choices=['FaultTolerance',
                        'General', 'Management', 'VMMigration'],
                        required=False, default='General',
                        help='''
    A description to attach to a network to help categorize the purpose of
    the  network''')
    parser.add_argument('-s', dest='slink', required=False,
                        action='store_true',
                        help='''
    DISABLE Smart Link''')
    parser.add_argument('-x', dest='private', required=False,
                        action='store_true',
                        help='''
    ENABLE Private Network''')

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

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

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

    login(con, credential)
    acceptEULA(con)

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

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

    add_network(net, args.network_name, args.prefered_bandwidth,
                args.max_bandwidth, args.vlan, args.vlan_type,
                args.purpose, args.slink, args.private)
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description="""
    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)
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Define new Uplink Set

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

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

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

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

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

    login(con, credential)
    acceptEULA(con)

    adduplinkset(con, net, args.uplink_set_name,
                 args.logical_interconnect_group_name, args.list_of_networks,
                 args.uplink_type, args.ethernet_type, args.native_network,
                 args.uplink_ports, args.lacp_mode, args.connection_mode)
示例#48
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Define new ethernet network

    Usage: ''')
    parser.add_argument('-a',
                        dest='host',
                        required=True,
                        help='''
    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='network_name',
                        required=True,
                        help='''
    Name of the network''')
    parser.add_argument('-b',
                        dest='prefered_bandwidth',
                        type=float,
                        required=False,
                        default=2.5,
                        help='''
    Typical bandwidth between .1  and 20 Gb/s''')
    parser.add_argument('-m',
                        dest='max_bandwidth',
                        type=float,
                        required=False,
                        default=10,
                        help='''
    Maximum bandwidth between .1 and 20 Gb/s''')
    parser.add_argument('-v',
                        dest='vlan',
                        required=False,
                        help='''
    VLAN ID''')
    parser.add_argument('-z',
                        dest='vlan_type',
                        choices=['Tagged', 'Untagged', 'Tunnel'],
                        required=False,
                        default='Tagged',
                        help='''
    VLAN Type''')
    parser.add_argument(
        '-o',
        dest='purpose',
        choices=['FaultTolerance', 'General', 'Management', 'VMMigration'],
        required=False,
        default='General',
        help='''
    A description to attach to a network to help categorize the purpose of
    the  network''')
    parser.add_argument('-s',
                        dest='slink',
                        required=False,
                        action='store_true',
                        help='''
    DISABLE Smart Link''')
    parser.add_argument('-x',
                        dest='private',
                        required=False,
                        action='store_true',
                        help='''
    ENABLE Private Network''')

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

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

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

    login(con, credential)
    acceptEULA(con)

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

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

    add_network(net, args.network_name, args.prefered_bandwidth,
                args.max_bandwidth, args.vlan, args.vlan_type, args.purpose,
                args.slink, args.private)
def main():
    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()
示例#50
0
def main():
    parser = argparse.ArgumentParser(
        add_help=True,
        formatter_class=argparse.RawTextHelpFormatter,
        description='''
    Define new Network Set

    Usage: ''')
    parser.add_argument('-a',
                        dest='host',
                        required=True,
                        help='''
    HPE OneView Appliance hostname or IP address''')
    parser.add_argument('-u',
                        dest='user',
                        required=False,
                        default='Administrator',
                        help='''
    HPE OneView Username''')
    parser.add_argument('-p',
                        dest='passwd',
                        required=True,
                        help='''
    HPE OneView Password''')
    parser.add_argument('-c',
                        dest='cert',
                        required=False,
                        help='''
    Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''')
    parser.add_argument('-y',
                        dest='proxy',
                        required=False,
                        help='''
    Proxy (host:port format''')
    parser.add_argument('-j',
                        dest='domain',
                        required=False,
                        default='Local',
                        help='''
    HPE OneView Authorized Login Domain''')
    parser.add_argument('-n',
                        dest='network_set_name',
                        required=True,
                        help='''
    Name of the network set''')
    parser.add_argument('-l',
                        dest='list_of_networks',
                        required=False,
                        nargs='+',
                        help='''
    List of network names to add to the network set, seperated by spaces.
    For example:
            -t "Net One" "Net Two" "Net Three"''')
    parser.add_argument('-b',
                        dest='prefered_bandwidth',
                        type=float,
                        required=False,
                        default=2.5,
                        help='''
    Typical bandwidth between .1  and 20 Gb/s''')
    parser.add_argument('-m',
                        dest='max_bandwidth',
                        type=float,
                        required=False,
                        default=10,
                        help='''
    Maximum bandwidth between .1 and 20 Gb/s''')

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

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

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

    login(con, credential)
    acceptEULA(con)

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

    add_network_set(net, args.network_set_name, args.list_of_networks,
                    args.prefered_bandwidth, args.max_bandwidth)
def main():
    parser = argparse.ArgumentParser(add_help=True,
                        formatter_class=argparse.RawTextHelpFormatter,
                                     description='''
    Define a OneView network connection list for use with defining a server
    profile with connections.

    Usage: ''')
    parser.add_argument('-a', dest='host', required=True,
                        help='''
    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 network connection''')
    parser.add_argument('-i', dest='cid',
                        required=True,
                        help='''
    Unique ID for the network connection''')
    parser.add_argument('-net', dest='network',
                        required=True,
                        help='''
    The name of the Ethernet network, network set, or Fibre Channel network to
    use for this connection.''')
    parser.add_argument('-cl', dest='conn_list',
                        required=True,
                        help='''
    Name of file for connection list''')
    parser.add_argument('-app', dest='append',
                        required=False,
                        action='store_true',
                        help='''
    Causes connection list to be appended to the file''')
    parser.add_argument('-ns', dest='net_set',
                        required=False,
                        action='store_true',
                        help='''
    Required to mark the connection type as a Network Set''')
    parser.add_argument('-port', dest='portId',
                        required=False,
                        default='Auto',
                        help='''
    Identifies the port (FlexNIC) used for this connection, for example
    'Flb 1:1-a'. The port can be automatically selected by specifying 'Auto',
    'None', or a physical port when creating or editing the connection.
    If 'Auto' is specified, a port that provides access to the selected
    network (networkUri) will be selected. A physical port (e.g. 'Flb 1:2')
    can be specified if the choice of a specific FlexNIC on the physical
    port is not important. If 'None' is specified, the connection will not
    be configured on the server hardware.''')
    parser.add_argument('-func', dest='func',
                        required=False,
                        choices=['Ethernet', 'FibreChannel'],
                        default='Ethernet',
                        help='''
    Ethernet or FibreChannel''')
    parser.add_argument('-mac', dest='mac',
                        required=False,
                        help='''
    The MAC address that is currently programmed on the FlexNic. The value can
    be virtual, user defined or physical MAC address read from the device.''')
    parser.add_argument('-mt', dest='macType',
                        required=False,
                        choices=['Physical', 'UserDefined', 'Virtual'],
                        default='Virtual',
                        help='''
    Specifies the type of MAC address to be programmed into the IO Devices.''')
    parser.add_argument('-gbps', dest='reqGbps',
                        required=False,
                        type=float,
                        help='''
    Transmit thorougput for this connection in Gbps Must be between .1 and
    20 Gbps''')
    parser.add_argument('-wwnn', dest='wwnn',
                        required=False,
                        help='''
    The node WWN address that is currently programmed on the FlexNic. The
    value can be a virtual WWNN, user defined WWNN or physical WWNN read from
    the device.''')
    parser.add_argument('-wwpn', dest='wwpn',
                        required=False,
                        help='''
    The port WWN address that is currently programmed on the FlexNIC. The
    value can be a virtual WWPN, user defined WWPN or the physical WWPN read
    from the device.''')
    parser.add_argument('-wt', dest='wwpnType',
                        required=False,
                        choices=['Physical', 'UserDefined', 'Virtual'],
                        default='Virtual',
                        help='''
    Specifies the type of WWN address to be porgrammed on the FlexNIC. The
    value can be 'Virtual', 'Physical' or 'UserDefined'.''')
    parser.add_argument('-bp', dest='boot_priority',
                        required=False,
                        choices=['Primary', 'Secondary', 'NotBootable'],
                        default='NotBootable',
                        help='''
    Primary or Secondary or NotBootable''')
    parser.add_argument('-t', dest='boot_target',
                        required=False,
                        help='''
    The wwpn of the target device that provides access to the Boot Volume.
    This value must contain 16 HEX digits''')
    parser.add_argument('-l', dest='boot_lun',
                        required=False,
                        type=int,
                        help='''
    The LUN of the Boot Volume presented by the target device. This value can
    bein the range 0 to 255.''')


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

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

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

    login(con, credential)
    acceptEULA(con)

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

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


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

    define_connection_list(net, args.name, args.cid, args.network,
                           args.conn_list, args.append, args.portId, args.func,
                           args.mac, args.macType, args.net_set,
                           args.reqGbps, args.wwnn, args.wwpn, args.wwpnType,
                           boot)
	def setUp(self):
		super(NetworkingTest, self).setUp()
		self.host = 'http://1.2.3.4'
		self.connection = connection(self.host)
		self.networking = networking(self.connection)