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)
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 a list of SPP 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''') args = parser.parse_args() credential = { 'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd } con = hpov.connection(args.host) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) getspp(sts)
def main(): parser = argparse.ArgumentParser(add_help=True, formatter_class=argparse.RawTextHelpFormatter, description=''' Display the startup progress of the HP OneView appliance Usage: ''') parser.add_argument('-a', dest='host', required=True, help=''' HP OneView Appliance hostname or IP address''') parser.add_argument('-c', dest='cert', required=False, help=''' Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''') parser.add_argument('-y', dest='proxy', required=False, help=''' Proxy (host:port format''') args = parser.parse_args() con = hpov.connection(args.host) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) getprogress(sts)
def 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=''' Delete individual or ALL enclosures Usage: ''') parser.add_argument('-a', dest='host', required=True, help=''' HP OneView Appliance hostname or IP address''') parser.add_argument('-u', dest='user', required=False, default='Administrator', help=''' HP OneView Username''') parser.add_argument('-p', dest='passwd', required=True, help=''' HP OneView Password''') parser.add_argument('-c', dest='cert', required=False, help=''' Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''') parser.add_argument('-y', dest='proxy', required=False, help=''' Proxy (host:port format''') group = parser.add_mutually_exclusive_group(required=True) group.add_argument('-d', dest='delete_all', action='store_true', help=''' Delete all Enclosures and exit''') group.add_argument('-en', '--enc_name', dest='ename', help=''' Name of enclosure to be deleted''') group.add_argument('-es', '--enc_serial', dest='serialNo', help=''' SerialNumber of enclosure to be deleted''') args = parser.parse_args() credential = {'userName': args.user, 'password': args.passwd} con = hpov.connection(args.host) srv = hpov.servers(con) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) if args.delete_all: del_all_enclosures(srv) sys.exit() if args.serialNo: del_enclosure_by_serial(srv, args.serialNo) sys.exit() del_enclosure_by_name(srv, args.ename)
def main(): parser = argparse.ArgumentParser(add_help=True, formatter_class=argparse.RawTextHelpFormatter, description=''' 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, 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('-b', dest='reboot', action='store_true', help='Shutdown and reboot the appliance') group.add_argument('-s', dest='halt', action='store_true', help='Shutdown and hatl the appliance') args = parser.parse_args() credential = {'userName': args.user, 'password': args.passwd} con = hpov.connection(args.host) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) if args.reboot: shutdown(sts, 'REBOOT') elif args.halt: shutdown(sts, 'HALT')
def main(): parser = argparse.ArgumentParser( add_help=True, formatter_class=argparse.RawTextHelpFormatter, description=''' Retrieve licenses installed on the appliance. You can use this to get an inventory of what's installed and what licenses are consumed. Usage: ''') parser.add_argument('-a', dest='host', required=True, help=''' 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) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) get_license_info(con, sts, args.report)
def main(): parser = argparse.ArgumentParser( add_help=True, formatter_class=argparse.RawTextHelpFormatter, description=''' Upload and restore a HP OneView backup file Usage: ''') parser.add_argument('-a', dest='host', required=True, help=''' HP OneView Appliance hostname or IP address''') parser.add_argument('-u', dest='user', required=False, default='Administrator', help=''' HP OneView Username''') parser.add_argument('-p', dest='passwd', required=True, help=''' HP OneView Password''') parser.add_argument('-c', dest='cert', required=False, help=''' Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''') parser.add_argument('-y', dest='proxy', required=False, help=''' Proxy (host:port format''') parser.add_argument('-f', dest='file', required=True, help=''' Backup file to restore''') args = parser.parse_args() credential = {'userName': args.user, 'password': args.passwd} con = hpov.connection(args.host) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) (path, name) = os.path.split(args.file) restore_backup(sts, args.file, name)
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('-f', dest='file', help='Backup file ' 'to restore') group.add_argument('-g', dest='getbck', action='store_true', help='Generate and Download appliance backup') args = parser.parse_args() credential = {'userName': args.user, 'password': args.passwd} con = hpov.connection(args.host) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) if args.getbck: getbackup(sts) sys.exit() (path, name) = os.path.split(args.file) restore(sts, args.file, name)
def main(): parser = argparse.ArgumentParser( add_help=True, formatter_class=argparse.RawTextHelpFormatter, description=''' Displays the list of global settings or a specific global setting 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 global setting to be retrieved''') args = parser.parse_args() credential = {'userName': args.user, 'password': args.passwd} con = hpov.connection(args.host) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) get_global_settings(sts, args.name)
def main(): parser = argparse.ArgumentParser(add_help=True, formatter_class=argparse.RawTextHelpFormatter, description=''' Add a new license Usage: ''') parser.add_argument('-a', dest='host', required=True, help=''' HP OneView Appliance hostname or IP address''') parser.add_argument('-u', dest='user', required=False, default='Administrator', help=''' HP OneView Username''') parser.add_argument('-p', dest='passwd', required=True, help=''' HP OneView Password''') parser.add_argument('-c', dest='cert', required=False, help=''' Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''') parser.add_argument('-y', dest='proxy', required=False, help=''' Proxy (host:port format''') parser.add_argument('-j', dest='domain', required=False, default='Local', help=''' HP OneView Authorized Login Domain''') parser.add_argument('-f', dest='file', required=True, help=''' HP OneView license file 1 key per license file''') args = parser.parse_args() credential = {'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd} con = hpov.connection(args.host) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) try: f = open(args.file, 'r') lic = f.read() f.close() except IOError: print('Error reading license file') sys.exit() addlic(sts, lic.rstrip('\n'))
def main(): parser = argparse.ArgumentParser( add_help=True, formatter_class=argparse.RawTextHelpFormatter, description=''' 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=''' Shutdown or Reboot the HPE OneView Appliance Usage: ''') parser.add_argument('-a', dest='host', required=True, help=''' HPE OneView Appliance hostname or IP address''') parser.add_argument('-u', dest='user', required=False, default='Administrator', help=''' HPE OneView Username''') parser.add_argument('-p', dest='passwd', required=True, help=''' HPE OneView Password''') parser.add_argument('-c', dest='cert', required=False, help=''' Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''') parser.add_argument('-y', dest='proxy', required=False, help=''' Proxy (host:port format''') parser.add_argument('-j', dest='domain', required=False, default='Local', help=''' HPE OneView Authorized Login Domain''') group = parser.add_mutually_exclusive_group(required=True) group.add_argument('-r', dest='reboot', action='store_true', help=''' Shutdown and restart/reboot the appliance''') group.add_argument('-s', dest='halt', action='store_true', help=''' Shutdown and halt the appliance''') args = parser.parse_args() credential = {'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd} con = hpov.connection(args.host) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) if args.reboot: shutdown(sts, 'REBOOT') elif args.halt: shutdown(sts, 'HALT')
def main(): parser = argparse.ArgumentParser(add_help=True, formatter_class=argparse.RawTextHelpFormatter, description=''' 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=''' Display the HP OneView appliance health status. This includes CPU, Memory and Disk Space. 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) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) gethelth(sts)
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=''' Retrieve licenses installed on the appliance. You can use this to get an inventory of what's installed and what licenses are consumed. Usage: ''') parser.add_argument('-a', dest='host', required=True, help=''' HPE OneView Appliance hostname or IP address''') parser.add_argument('-u', dest='user', required=False, default='Administrator', help=''' HPE OneView Username''') parser.add_argument('-p', dest='passwd', required=True, help=''' HPE OneView Password''') parser.add_argument('-c', dest='cert', required=False, help=''' Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''') parser.add_argument('-y', dest='proxy', required=False, help=''' Proxy (host:port format''') parser.add_argument('-j', dest='domain', required=False, default='Local', help=''' HPE OneView Authorized Login Domain''') parser.add_argument('-r', dest='report', required=False, action='store_true', help=''' Format the output using a human readable report format''') args = parser.parse_args() credential = {'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd} con = hpov.connection(args.host) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) get_license_info(con, sts, args.report)
def main(): parser = argparse.ArgumentParser(add_help=True, formatter_class=argparse.RawTextHelpFormatter, description=''' Upload a OneView Appliance Firmware/Upgrade .bin file Usage: ''') parser.add_argument('-a', dest='host', required=True, help=''' HPE OneView Appliance hostname or IP address''') parser.add_argument('-u', dest='user', required=False, default='Administrator', help=''' HPE OneView Username''') parser.add_argument('-p', dest='passwd', required=True, help=''' HPE OneView Password''') parser.add_argument('-c', dest='cert', required=False, help=''' Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''') parser.add_argument('-y', dest='proxy', required=False, help=''' Proxy (host:port format''') parser.add_argument('-j', dest='domain', required=False, default='Local', help=''' HPE OneView Authorized Login Domain''') group = parser.add_mutually_exclusive_group(required=True) group.add_argument('-f', dest='file', help=''' Appliance FW bin file to upload''') args = parser.parse_args() credential = {'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd} con = hpov.connection(args.host) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) (path, name) = os.path.split(args.file) upload(sts, args.file, name)
def main(): parser = argparse.ArgumentParser(add_help=True, formatter_class=argparse.RawTextHelpFormatter, description=''' Displays the list of global settings or a specific global setting 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 global setting to be retrieved''') args = parser.parse_args() credential = {'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd} con = hpov.connection(args.host) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) get_global_settings(sts, args.name)
def main(): parser = argparse.ArgumentParser(add_help=True, formatter_class=argparse.RawTextHelpFormatter, description=''' Upload a SPP file to the HP OneView appliance firmware repository. Usage: ''') parser.add_argument('-a', dest='host', required=True, help=''' HP OneView Appliance hostname or IP address''') parser.add_argument('-u', dest='user', required=False, default='Administrator', help=''' HP OneView Username''') parser.add_argument('-p', dest='passwd', required=True, help=''' HP OneView Password''') parser.add_argument('-c', dest='cert', required=False, help=''' Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''') parser.add_argument('-y', dest='proxy', required=False, help=''' Proxy (host:port format''') parser.add_argument('-j', dest='domain', required=False, default='Local', help=''' HP OneView Authorized Login Domain''') parser.add_argument('-f', dest='filename', required=True, help=''' The full path and file name of the SPP file to upload. ''') args = parser.parse_args() credential = {'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd} con = hpov.connection(args.host) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) upload_spp(sts, args.filename)
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, 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('-f', dest='file', help='HP OneView license file ' '1 key per license file') group.add_argument('-g', dest='getlic', action='store_true', help='Display the currently installed licenses and exit') args = parser.parse_args() credential = {'userName': args.user, 'password': args.passwd} con = hpov.connection(args.host) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) if args.getlic: getlic(sts) sys.exit() try: f = open(args.file, 'r') lic = f.read() f.close() except IOError: print('Error reading license file') sys.exit() addlic(sts, lic.rstrip('\n'))
def main(): # Arguments supplied from getform function host, user, passwd, cert, proxy = getform() credential = {'userName': user, 'password': passwd} con = hpov.connection(host) sts = hpov.settings(con) if proxy: con.set_proxy(proxy.split(':')[0], proxy.split(':')[1]) if cert: con.set_trusted_ssl_bundle(cert) login(con, credential) acceptEULA(con) getapi(sts)
def main(): # Arguments supplied from command line if args: credential = {'userName': args.user, 'password': args.passwd} con = hpov.connection(args.host) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) getapi(sts) else: credential = "#"
def main(): parser = argparse.ArgumentParser(add_help=True, formatter_class=argparse.RawTextHelpFormatter, description=''' Upload and restore a HP OneView backup file Usage: ''') parser.add_argument('-a', dest='host', required=True, help=''' HP OneView Appliance hostname or IP address''') parser.add_argument('-u', dest='user', required=False, default='Administrator', help=''' HP OneView Username''') parser.add_argument('-p', dest='passwd', required=True, help=''' HP OneView Password''') parser.add_argument('-c', dest='cert', required=False, help=''' Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''') parser.add_argument('-y', dest='proxy', required=False, help=''' Proxy (host:port format''') parser.add_argument('-f', dest='file', required=True, help=''' Backup file to restore''') args = parser.parse_args() credential = {'userName': args.user, 'password': args.passwd} con = hpov.connection(args.host) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) (path, name) = os.path.split(args.file) restore_backup(sts, args.file, name)
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)
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, 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 LIGs and exit') group = parser.add_mutually_exclusive_group(required=True) group.add_argument('-f', dest='file', help='SPP file to upload') group.add_argument('-g', dest='getspp', action='store_true', help='Display currently loaded SPP information') args = parser.parse_args() credential = {'userName': args.user, 'password': args.passwd} con = hpov.connection(args.host) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) if args.getspp: getspp(sts) sys.exit() (path, name) = os.path.split(args.file) upload(sts, args.file, name)
def main(): parser = argparse.ArgumentParser(add_help=True, formatter_class=argparse.RawTextHelpFormatter, description=''' Define a server profile template''') parser.add_argument('-a', dest='host', required=True, help=''' HPE OneView Appliance hostname or IP address''') parser.add_argument('-u', dest='user', required=False, default='Administrator', help=''' HPE OneView Username''') parser.add_argument('-p', dest='passwd', required=True, help=''' HPE OneView Password''') parser.add_argument('-c', dest='cert', required=False, help=''' Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''') parser.add_argument('-y', dest='proxy', required=False, help=''' Proxy (host:port format''') parser.add_argument('-n', dest='name', required=True, help=''' Name of the profile template''') parser.add_argument('-d', dest='desc', required=False, help=''' Description for the server profile template''') parser.add_argument('-spd', dest='sp_desc', required=False, help=''' Server profile description''') parser.add_argument('-sht', dest='server_hwt', required=True, help=''' Server hardware type is required for defining an unassigned profile. Note the Server Hardware Type must be present in the HPE OneView appliance before it can be used. For example, a single server with the specific server hardware type must have been added to OneView for that hardware type to be used. The example script get-server-hardware-types.py with the -l argument can be used to get a list of server hardware types that have been imported into the OneView appliance''') parser.add_argument('-eg', dest='enc_group', required=True, help=''' Identifies the enclosure group for which the Server Profile Template was designed. The enclosureGroupUri is determined when the profile template is created and cannot be modified ''') parser.add_argument('-af', dest='affinity', required=False, choices=['Bay', 'BayAndServer'], default='Bay', help=''' This identifies the behavior of the server profile when the server hardware is removed or replaced. . Bay: This profile remains with the device bay when the server hardware is removed or replaced. . BayAndServer This profile is pinned to both the device bay and specific server hardware.''') parser.add_argument('-hn', dest='hide_flexnics', required=False, choices=['true', 'false'], help=''' This setting controls the enumeration of physical functions that do not correspond to connections in a profile. Using this flag will SHOW unused FlexNICs to the Operating System. Changing this setting may alter the order of network interfaces in the Operating System. This option sets the 'Hide Unused FlexNICs' to disabled, eight FlexNICs will be enumerated in the Operating System as network interfaces for each Flex-10 or FlexFabric adapter. Configuring Fibre Channel connections on a FlexFabric adapter may enumerate two storage interfaces, reducing the number of network interfaces to six. The default (this option is not selected) enables 'Hide Unused FlexNICs' and may suppress enumeration of FlexNICs that do not correspond to profile connections. FlexNICs are hidden in pairs, starting with the 4th pair. For instance, if the 4th FlexNIC on either physical port corresponds to a profile connection, all eight physical functions are enumerated. If a profile connection corresponds to the 2nd FlexNIC on either physical port, but no connection corresponds to the 3rd or 4th FlexNIC on either physical port, only the 1st and 2nd physical functions are enumerated in the Operating System.''') parser.add_argument('-cl', dest='conn_list', required=False, help=''' File with list of connections for this profile in JSON format. This file can be created with multiple calls to define-connection-list.py''') parser.add_argument('-fw', dest='baseline', required=False, help=''' SPP Baseline file name. e.g. SPP2013090_2013_0830_30.iso''') parser.add_argument('-mb', dest='disable_manage_boot', action='store_true', help=''' Explicitly DISABLE Boot Order Management. This value is enabled by default and required for Connection boot enablement. If this option is disabled, then PXE and FC BfS settings are disabled within the entire Server Profile.''') parser.add_argument('-bo', dest='boot_order', required=False, nargs='+', help=''' Defines the order in which boot will be attempted on the available devices. Please NOTE the supported boot order is server hardware type specific. For Gen7 and Gen8 server hardware the possible values are 'CD', 'Floppy', 'USB', 'HardDisk', and 'PXE'. For Gen9 BL server hardware in Legacy BIOS boot mode, the possible values are 'CD', 'USB', 'HardDisk', and 'PXE'. For Gen9 BL server hardware in UEFI or UEFI Optimized boot mode, only one value is allowed and must be either 'HardDisk' or 'PXE'. For Gen9 DL server hardware in Legacy BIOS boot mode, the possible values are 'CD', 'USB', 'HardDisk', and 'PXE'. For Gen9 DL server hardware in UEFI or UEFI Optimized boot mode, boot order configuration is not supported. Server boot order defined as a list separated by spaces. For example: Gen7/8 BIOS Default Boot Order: -bo CD Floppy USB HardDisk PXE Gen9 Legacy BIOS Boot Order: -bo CD USB HardDisk PXE Gen9 UEFI Default Boot Order: -bo HardDisk ''') parser.add_argument('-bm', dest='boot_mode', required=False, choices=['UEFI', 'UEFIOptimized', 'BIOS'], default='BIOS', help=''' Specify the Gen9 Boot Environment. Sets the boot mode as one of the following: . UEFI . UEFIOptimized . BIOS If you select UEFI or UEFI optimized for an HPE ProLiant DL Gen9 rack mount server, the remaining boot setting available is the PXE boot policy. For the UEFI or UEFI optimized boot mode options, the boot mode choice should be based on the expected OS and required boot features for the server hardware. UEFI optimized boot mode reduces the time the system spends in POST(Video driver initialization). In order to select the appropriate boot mode, consider the following: . If a secure boot is required, the boot mode must be set to UEFI or UEFI optimized . . For operating systems that do not support UEFI (such as DOS, or older versions of Windows and Linux), the boot mode must be set to BIOS. . When booting in UEFI mode, Windows 7, Server 2008, or 2008 R2 should not be set to UEFIOptimized.''') parser.add_argument('-px', dest='pxe', required=False, choices=['Auto', 'IPv4', 'IPv6', 'IPv4ThenIPv6', 'IPv6ThenIPv4'], default='IPv4', help=''' Controls the ordering of the network modes available to the Flexible LOM (FLB); for example, IPv4 and IPv6. Select from the following policies: . Auto . IPv4 only . IPv6 only . IPv4 then IPv6 . IPv6 then IPv4 Setting the policy to Auto means the order of the existing network boot targets in the UEFI Boot Order list will not be modified, and any new network boot targets will be added to the end of the list using the System ROM's default policy.''') parser.add_argument('-sl', dest='san_list', required=False, help=''' File with list of SAN Storage connections for this profile in JSON format. This file can be created with multiple calls to define-san-storage-list.py''') args = parser.parse_args() credential = {'userName': args.user, 'password': args.passwd} con = hpov.connection(args.host) srv = hpov.servers(con) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) eg_uri = get_eg_uri_from_arg(srv, args.enc_group) sht = get_sht_from_arg(srv, args.server_hwt) fw_settings = profile.make_firmware_dict(sts, args.baseline) boot, bootmode = profile.make_boot_settings_dict(srv, sht, args.disable_manage_boot, args.boot_order, args.boot_mode, args.pxe) define_profile_template(srv, args.name, args.desc, args.sp_desc, sht['uri'], eg_uri, args.affinity, args.hide_flexnics, args.conn_list, fw_settings, boot, bootmode, args.san_list)
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('-f', dest='file', help='HP OneView license file ' '1 key per license file') group.add_argument( '-g', dest='getlic', action='store_true', help='Display the currently installed licenses and exit') args = parser.parse_args() credential = {'userName': args.user, 'password': args.passwd} con = hpov.connection(args.host) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) if args.getlic: getlic(sts) sys.exit() try: f = open(args.file, 'r') lic = f.read() f.close() except IOError: print('Error reading license file') sys.exit() addlic(sts, lic.rstrip('\n'))
def main(): parser = argparse.ArgumentParser(add_help=True, formatter_class=argparse.RawTextHelpFormatter, description=''' This example script will import an enclosure into HP OneView as a managed device. The Onboard Administrator needs to have IP Address configured for each module, and a valid Administrator account with a password. Usage: ''') parser.add_argument('-a', dest='host', required=True, help=''' HP OneView Appliance hostname or IP address''') parser.add_argument('-u', dest='user', required=False, default='Administrator', help=''' HP OneView Username''') parser.add_argument('-p', dest='passwd', required=True, help=''' HP OneView Password''') parser.add_argument('-c', dest='cert', required=False, help=''' Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''') parser.add_argument('-y', dest='proxy', required=False, help=''' Proxy (host:port format''') parser.add_argument('-j', dest='domain', required=False, default='Local', help=''' HP OneView Authorized Login Domain''') parser.add_argument('-eu', dest='encusr', required=True, help=''' Administrative username for the c7000 enclosure OA''') parser.add_argument('-ep', dest='encpass', required=True, help=''' Administrative password for the c7000 enclosure OA''') parser.add_argument('-oa', dest='enc', required=True, help=''' IP address of the c7000 to import into HP OneView''') parser.add_argument('-s', dest='spp', required=False, help=''' SPP Baseline file name. e.g. SPP2013090_2013_0830_30.iso''') parser.add_argument('-l', dest='license', required=False, choices=['OneView', 'OneViewNoiLO'], default='OneView', help=''' Specifies whether the intent is to apply either OneView or OneView w/o iLO licenses to the servers in the enclosure being imported. Accepted values are: - OneView - OneViewNoiLO ''') parser.add_argument('-f', dest='force', action='store_true', required=False, help=''' When attempting to add an Enclosure to the appliance, the appliance will validate the target Enclosure is not already claimed. If it is, this parameter is used when the Enclosure has been claimed by another appliance to bypass the confirmation prompt, and force add the import of the Enclosure ''') parser.add_argument('-fw', dest='forcefw', action='store_true', required=False, help=''' Force the installation of the provided Firmware Baseline. ''') group = parser.add_mutually_exclusive_group(required=True) group.add_argument('-eg', dest='egroup', help=''' Enclosure Group to add the enclosure to''') group.add_argument('-m', dest='monitor', action='store_true', help=''' Import the enclosure as a Monitored enclosure. ''') args = parser.parse_args() credential = {'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd} con = hpov.connection(args.host) srv = hpov.servers(con) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) import_enclosure(srv, sts, args.egroup, args.enc, args.encusr, args.encpass, args.license, args.spp, args.force, args.forcefw, args.monitor)
def main(): parser = argparse.ArgumentParser(add_help=True, formatter_class=argparse.RawTextHelpFormatter, description=''' Define a server profile''') parser.add_argument('-a', dest='host', required=True, help=''' HP OneView Appliance hostname or IP address''') parser.add_argument('-u', dest='user', required=False, default='Administrator', help=''' HP OneView Username''') parser.add_argument('-p', dest='passwd', required=True, help=''' HP OneView Password''') parser.add_argument('-c', dest='cert', required=False, help=''' Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''') parser.add_argument('-y', dest='proxy', required=False, help=''' Proxy (host:port format''') parser.add_argument('-j', dest='domain', required=False, default='Local', help=''' HP OneView Authorized Login Domain''') parser.add_argument('-n', dest='name', required=True, help=''' Name of the profile''') parser.add_argument('-d', dest='desc', required=False, help=''' Description for the server profile''') parser.add_argument('-af', dest='affinity', required=False, choices=['Bay', 'BayAndServer'], default='Bay', help=''' This identifies the behavior of the server profile when the server hardware is removed or replaced. . Bay: This profile remains with the device bay when the server hardware is removed or replaced. . BayAndServer This profile is pinned to both the device bay and specific server hardware.''') parser.add_argument('-f', dest='forcePowerOff', required=False, action='store_true', help=''' When set, forces power off of target server. Avoids error exit if server is up''') parser.add_argument('-fw', dest='baseline', required=False, help=''' SPP Baseline file name. e.g. SPP2013090_2013_0830_30.iso''') parser.add_argument('-mb', dest='disable_manage_boot', action='store_true', help=''' Explicitly DISABLE Boot Order Management. This value is enabled by default and required for Connection boot enablement. If this option is disabled, then PXE and FC BfS settings are disabled within the entire Server Profile.''') parser.add_argument('-bo', dest='boot_order', required=False, nargs='+', help=''' Defines the order in which boot will be attempted on the available devices. Please NOTE the supported boot order is server hardware type specific. For Gen7 and Gen8 server hardware the possible values are 'CD', 'Floppy', 'USB', 'HardDisk', and 'PXE'. For Gen9 BL server hardware in Legacy BIOS boot mode, the possible values are 'CD', 'USB', 'HardDisk', and 'PXE'. For Gen9 BL server hardware in UEFI or UEFI Optimized boot mode, only one value is allowed and must be either 'HardDisk' or 'PXE'. For Gen9 DL server hardware in Legacy BIOS boot mode, the possible values are 'CD', 'USB', 'HardDisk', and 'PXE'. For Gen9 DL server hardware in UEFI or UEFI Optimized boot mode, boot order configuration is not supported. Server boot order defined as a list separated by spaces. For example: Gen7/8 BIOS Default Boot Order: -bo CD Floppy USB HardDisk PXE Gen9 Legacy BIOS Boot Order: -bo CD USB HardDisk PXE Gen9 UEFI Default Boot Order: -bo HardDisk ''') parser.add_argument('-cl', dest='conn_list', required=False, help=''' File with list of connections for this profile in JSON format. This file can be created with multiple calls to define-connection-list.py''') parser.add_argument('-sl', dest='san_list', required=False, help=''' File with list of SAN Storage connections for this profile in JSON format. This file can be created with multiple calls to define-san-storage-list.py''') parser.add_argument('-bm', dest='boot_mode', required=False, choices=['UEFI', 'UEFIOptimized', 'BIOS'], default='BIOS', help=''' Specify the Gen9 Boot Environment. Sets the boot mode as one of the following: . UEFI . UEFIOptimized . BIOS If you select UEFI or UEFI optimized for an HP ProLiant DL Gen9 rack mount server, the remaining boot setting available is the PXE boot policy. For the UEFI or UEFI optimized boot mode options, the boot mode choice should be based on the expected OS and required boot features for the server hardware. UEFI optimized boot mode reduces the time the system spends in POST(Video driver initialization). In order to select the appropriate boot mode, consider the following: . If a secure boot is required, the boot mode must be set to UEFI or UEFI optimized . . For operating systems that do not support UEFI (such as DOS, or older versions of Windows and Linux), the boot mode must be set to BIOS. . When booting in UEFI mode, Windows 7, Server 2008, or 2008 R2 should not be set to UEFIOptimized.''') parser.add_argument('-px', dest='pxe', required=False, choices=['Auto', 'IPv4', 'IPv6', 'IPv4ThenIPv6', 'IPv6ThenIPv4'], default='IPv4', help=''' Controls the ordering of the network modes available to the Flexible LOM (FLB); for example, IPv4 and IPv6. Select from the following policies: . Auto . IPv4 only . IPv6 only . IPv4 then IPv6 . IPv6 then IPv4 Setting the policy to Auto means the order of the existing network boot targets in the UEFI Boot Order list will not be modified, and any new network boot targets will be added to the end of the list using the System ROM's default policy.''') parser.add_argument('-rl', dest='raidlevel', required=False, choices=['NONE', 'RAID0', 'RAID1'], help=''' Enable local storage to be managed via the server profile by defining the RAID level for the logical drive.''') parser.add_argument('-pn', dest='physnum', required=False, help=''' The number of physical drives to be used to build the logical drive. The provided values must be consistent with the selected RAID level and cannot exceed the maximum supported number of drives for the selected server hardware type.''') parser.add_argument('-lb', dest='lboot', required=False, action='store_true', help=''' Mark the logical drive as NOT bootable''') parser.add_argument('-is', dest='init_storage', required=False, action='store_true', help=''' Indicates whether the local storage controller should be reset to factory defaults before applying the local storage settings from the server profile. ***************** WARNING ***************** Setting this will overwrite an existing logical disk if present, and without further warning. ***************** WARNING *****************''') parser.add_argument('-hn', dest='hide_flexnics', required=False, action='store_false', help=''' This setting controls the enumeration of physical functions that do not correspond to connections in a profile. Using this flag will SHOW unused FlexNICs to the Operating System. Changing this setting may alter the order of network interfaces in the Operating System. This option sets the 'Hide Unused FlexNICs' to disabled, eight FlexNICs will be enumerated in the Operating System as network interfaces for each Flex-10 or FlexFabric adapter. Configuring Fibre Channel connections on a FlexFabric adapter may enumerate two storage interfaces, reducing the number of network interfaces to six. The default (this option is not selected) enables 'Hide Unused FlexNICs' and may suppress enumeration of FlexNICs that do not correspond to profile connections. FlexNICs are hidden in pairs, starting with the 4th pair. For instance, if the 4th FlexNIC on either physical port corresponds to a profile connection, all eight physical functions are enumerated. If a profile connection corresponds to the 2nd FlexNIC on either physical port, but no connection corresponds to the 3rd or 4th FlexNIC on either physical port, only the 1st and 2nd physical functions are enumerated in the Operating System.''') parser.add_argument('-s', dest='server_id', required=True, help=''' Server identification. There are multiple ways to specify the server id: . Hostname or IP address of the stand-alone server iLO . Server Hardware name of a server than has already been imported into HP OneView and is listed under Server Hardware . "UNASSIGNED" for creating an unassigned Server Profile''') parser.add_argument('-sh', dest='server_hwt', required=False, help=''' Server hardware type is required for defining an unassigned profile. Note the Server Hardware Type must be present in the HP OneView appliance before it can be used. For example, a single server with the specific server hardware type must have been added to OneView for that hardware type to be used. The example script get-server-hardware-types.py with the -l argument can be used to get a list of server hardware types that have been imported into the OneView appliance''') parser.add_argument('-bl', dest='bios_list', required=False, help=''' File in JSON format with list of BIOS settings to override for this profile. This file can be created with a call to get-bios-options.py''') args = parser.parse_args() credential = {'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd} con = hpov.connection(args.host) srv = hpov.servers(con) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) # Invert the boolean value args.lboot = not args.lboot if args.boot_order and args.disable_manage_boot: print('Error: Managed Boot must be enabled to define a boot order') sys.exit() if args.server_id.upper() == 'UNASSIGNED' and not args.server_hwt: print('Error: Server Hardware Type must be specified when defining an' 'unassigned server profile') sys.exit() server, sht = get_server(con, srv, args.server_id, args.server_hwt, args.forcePowerOff) boot, bootmode = profile.make_boot_settings_dict(srv, sht, args.disable_manage_boot, args.boot_order, args.boot_mode, args.pxe) fw_settings = profile.make_firmware_dict(sts, args.baseline) local_storage = profile.make_local_storage_dict(sht, args.raidlevel, args.lboot, args.init_storage, args.physnum) bios = profile.make_bios_dict(args.bios_list) define_profile(con, srv, args.affinity, args.name, args.desc, server, sht, boot, bootmode, fw_settings, args.hide_flexnics, local_storage, args.conn_list, args.san_list, bios)
def main(): parser = argparse.ArgumentParser(add_help=True, description='Usage') parser.add_argument('-a', '--appliance', dest='host', required=True, help='HP OneView Appliance hostname or IP') parser.add_argument('-u', '--user', dest='user', required=False, default='Administrator', help='HP OneView Username') parser.add_argument('-p', '--pass', dest='passwd', required=False, help='HP OneView Password') parser.add_argument('-c', '--certificate', dest='cert', required=False, help='Trusted SSL Certificate Bundle in PEM ' '(Base64 Encoded DER) Format') parser.add_argument('-r', '--proxy', dest='proxy', required=False, help='Proxy (host:port format') parser.add_argument( '-eu', '--enc_user', dest='encusr', required=False, help='Administrative username for the c7000 enclosure OA') parser.add_argument( '-ep', '--enc_pass', dest='encpass', required=False, help='Administrative password for the c7000 enclosure OA') parser.add_argument('-n', '--name', dest='egroup', required=False, default='Prod VC FlexFabric Group 1', help='Enclosure Group to add the enclosure to') group = parser.add_mutually_exclusive_group(required=True) group.add_argument( '-e', dest='enc', help='IP address of the c7000 to import into HP OneView') group.add_argument('-d', dest='delete', action='store_true', help='Delete all Enclosures and exit') args = parser.parse_args() credential = {'userName': args.user, 'password': args.passwd} con = hpov.connection(args.host) srv = hpov.servers(con) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) if args.delete: delenc(srv) sys.exit() impenc(srv, sts, args.egroup, args.enc, args.encusr, args.encpass)
def main(): parser = argparse.ArgumentParser( add_help=True, 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)
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()
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=""" Generate and download a support dump from the HP OneView Appliance Usage: """, ) parser.add_argument( "-a", dest="host", required=True, help=""" HP OneView Appliance hostname or IP address""", ) parser.add_argument( "-u", dest="user", required=False, default="Administrator", help=""" HP OneView Username""", ) parser.add_argument( "-p", dest="passwd", required=True, help=""" HP OneView Password""", ) parser.add_argument( "-c", dest="cert", required=False, help=""" Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format""", ) parser.add_argument( "-y", dest="proxy", required=False, help=""" Proxy (host:port format""", ) args = parser.parse_args() credential = {"userName": args.user, "password": args.passwd} con = hpov.connection(args.host) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(":")[0], args.proxy.split(":")[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) getsupportdmp(sts)
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=""" Shutdown or Reboot the HP OneView Appliance Usage: """, ) parser.add_argument( "-a", dest="host", required=True, help=""" HP OneView Appliance hostname or IP address""", ) parser.add_argument( "-u", dest="user", required=False, default="Administrator", help=""" HP OneView Username""", ) parser.add_argument( "-p", dest="passwd", required=True, help=""" HP OneView Password""", ) parser.add_argument( "-c", dest="cert", required=False, help=""" Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format""", ) parser.add_argument( "-y", dest="proxy", required=False, help=""" Proxy (host:port format""", ) group = parser.add_mutually_exclusive_group(required=True) group.add_argument( "-r", dest="reboot", action="store_true", help=""" Shutdown and restart/reboot the appliance""", ) group.add_argument( "-s", dest="halt", action="store_true", help=""" Shutdown and halt the appliance""", ) args = parser.parse_args() credential = {"userName": args.user, "password": args.passwd} con = hpov.connection(args.host) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(":")[0], args.proxy.split(":")[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) if args.reboot: shutdown(sts, "REBOOT") elif args.halt: shutdown(sts, "HALT")
def main(): parser = argparse.ArgumentParser( add_help=True, formatter_class=argparse.RawTextHelpFormatter, description=''' This example script will import an enclosure into HPE OneView as a managed device. The Onboard Administrator needs to have IP Address configured for each module, and a valid Administrator account with a password. Usage: ''') parser.add_argument('-a', dest='host', required=True, help=''' HPE OneView Appliance hostname or IP address''') parser.add_argument('-u', dest='user', required=False, default='Administrator', help=''' HPE OneView Username''') parser.add_argument('-p', dest='passwd', required=True, help=''' HPE OneView Password''') parser.add_argument('-c', dest='cert', required=False, help=''' Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''') parser.add_argument('-y', dest='proxy', required=False, help=''' Proxy (host:port format''') parser.add_argument('-j', dest='domain', required=False, default='Local', help=''' HPE OneView Authorized Login Domain''') parser.add_argument('-eu', dest='encusr', required=True, help=''' Administrative username for the c7000 enclosure OA''') parser.add_argument('-ep', dest='encpass', required=True, help=''' Administrative password for the c7000 enclosure OA''') parser.add_argument('-oa', dest='enc', required=True, help=''' IP address of the c7000 to import into HPE OneView''') parser.add_argument('-s', dest='spp', required=False, help=''' SPP Baseline file name. e.g. SPP2013090_2013_0830_30.iso''') parser.add_argument('-l', dest='license', required=False, choices=['OneView', 'OneViewNoiLO'], default='OneView', help=''' Specifies whether the intent is to apply either OneView or OneView w/o iLO licenses to the servers in the enclosure being imported. Accepted values are: - OneView - OneViewNoiLO ''') parser.add_argument('-f', dest='force', action='store_true', required=False, help=''' When attempting to add an Enclosure to the appliance, the appliance will validate the target Enclosure is not already claimed. If it is, this parameter is used when the Enclosure has been claimed by another appliance to bypass the confirmation prompt, and force add the import of the Enclosure ''') parser.add_argument('-fw', dest='forcefw', action='store_true', required=False, help=''' Force the installation of the provided Firmware Baseline. ''') group = parser.add_mutually_exclusive_group(required=True) group.add_argument('-eg', dest='egroup', help=''' Enclosure Group to add the enclosure to''') group.add_argument('-m', dest='monitor', action='store_true', help=''' Import the enclosure as a Monitored enclosure. ''') args = parser.parse_args() credential = { 'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd } con = hpov.connection(args.host) srv = hpov.servers(con) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) import_enclosure(srv, sts, args.egroup, args.enc, args.encusr, args.encpass, args.license, args.spp, args.force, args.forcefw, args.monitor)
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=''' Add a new license Usage: ''') parser.add_argument('-a', dest='host', required=True, help=''' HP OneView Appliance hostname or IP address''') parser.add_argument('-u', dest='user', required=False, default='Administrator', help=''' HP OneView Username''') parser.add_argument('-p', dest='passwd', required=True, help=''' HP OneView Password''') parser.add_argument('-c', dest='cert', required=False, help=''' Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''') parser.add_argument('-y', dest='proxy', required=False, help=''' Proxy (host:port format''') parser.add_argument('-j', dest='domain', required=False, default='Local', help=''' HP OneView Authorized Login Domain''') parser.add_argument('-f', dest='file', required=True, help=''' HP OneView license file 1 key per license file''') args = parser.parse_args() credential = { 'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd } con = hpov.connection(args.host) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) try: f = open(args.file, 'r') lic = f.read() f.close() except IOError: print('Error reading license file') sys.exit() addlic(sts, lic.rstrip('\n'))
def main(): parser = argparse.ArgumentParser( add_help=True, formatter_class=argparse.RawTextHelpFormatter, description=''' Define a server profile template''') parser.add_argument('-a', dest='host', required=True, help=''' HPE OneView Appliance hostname or IP address''') parser.add_argument('-u', dest='user', required=False, default='Administrator', help=''' HPE OneView Username''') parser.add_argument('-p', dest='passwd', required=True, help=''' HPE OneView Password''') parser.add_argument('-c', dest='cert', required=False, help=''' Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''') parser.add_argument('-y', dest='proxy', required=False, help=''' Proxy (host:port format''') parser.add_argument('-n', dest='name', required=True, help=''' Name of the profile template''') parser.add_argument('-d', dest='desc', required=False, help=''' Description for the server profile template''') parser.add_argument('-spd', dest='sp_desc', required=False, help=''' Server profile description''') parser.add_argument('-sht', dest='server_hwt', required=True, help=''' Server hardware type is required for defining an unassigned profile. Note the Server Hardware Type must be present in the HPE OneView appliance before it can be used. For example, a single server with the specific server hardware type must have been added to OneView for that hardware type to be used. The example script get-server-hardware-types.py with the -l argument can be used to get a list of server hardware types that have been imported into the OneView appliance''') parser.add_argument('-eg', dest='enc_group', required=True, help=''' Identifies the enclosure group for which the Server Profile Template was designed. The enclosureGroupUri is determined when the profile template is created and cannot be modified ''') parser.add_argument('-af', dest='affinity', required=False, choices=['Bay', 'BayAndServer'], default='Bay', help=''' This identifies the behavior of the server profile when the server hardware is removed or replaced. . Bay: This profile remains with the device bay when the server hardware is removed or replaced. . BayAndServer This profile is pinned to both the device bay and specific server hardware.''') parser.add_argument('-hn', dest='hide_flexnics', required=False, choices=['true', 'false'], help=''' This setting controls the enumeration of physical functions that do not correspond to connections in a profile. Using this flag will SHOW unused FlexNICs to the Operating System. Changing this setting may alter the order of network interfaces in the Operating System. This option sets the 'Hide Unused FlexNICs' to disabled, eight FlexNICs will be enumerated in the Operating System as network interfaces for each Flex-10 or FlexFabric adapter. Configuring Fibre Channel connections on a FlexFabric adapter may enumerate two storage interfaces, reducing the number of network interfaces to six. The default (this option is not selected) enables 'Hide Unused FlexNICs' and may suppress enumeration of FlexNICs that do not correspond to profile connections. FlexNICs are hidden in pairs, starting with the 4th pair. For instance, if the 4th FlexNIC on either physical port corresponds to a profile connection, all eight physical functions are enumerated. If a profile connection corresponds to the 2nd FlexNIC on either physical port, but no connection corresponds to the 3rd or 4th FlexNIC on either physical port, only the 1st and 2nd physical functions are enumerated in the Operating System.''') parser.add_argument('-cl', dest='conn_list', required=False, help=''' File with list of connections for this profile in JSON format. This file can be created with multiple calls to define-connection-list.py''') parser.add_argument('-fw', dest='baseline', required=False, help=''' SPP Baseline file name. e.g. SPP2013090_2013_0830_30.iso''') parser.add_argument('-mb', dest='disable_manage_boot', action='store_true', help=''' Explicitly DISABLE Boot Order Management. This value is enabled by default and required for Connection boot enablement. If this option is disabled, then PXE and FC BfS settings are disabled within the entire Server Profile.''') parser.add_argument('-bo', dest='boot_order', required=False, nargs='+', help=''' Defines the order in which boot will be attempted on the available devices. Please NOTE the supported boot order is server hardware type specific. For Gen7 and Gen8 server hardware the possible values are 'CD', 'Floppy', 'USB', 'HardDisk', and 'PXE'. For Gen9 BL server hardware in Legacy BIOS boot mode, the possible values are 'CD', 'USB', 'HardDisk', and 'PXE'. For Gen9 BL server hardware in UEFI or UEFI Optimized boot mode, only one value is allowed and must be either 'HardDisk' or 'PXE'. For Gen9 DL server hardware in Legacy BIOS boot mode, the possible values are 'CD', 'USB', 'HardDisk', and 'PXE'. For Gen9 DL server hardware in UEFI or UEFI Optimized boot mode, boot order configuration is not supported. Server boot order defined as a list separated by spaces. For example: Gen7/8 BIOS Default Boot Order: -bo CD Floppy USB HardDisk PXE Gen9 Legacy BIOS Boot Order: -bo CD USB HardDisk PXE Gen9 UEFI Default Boot Order: -bo HardDisk ''') parser.add_argument('-bm', dest='boot_mode', required=False, choices=['UEFI', 'UEFIOptimized', 'BIOS'], default='BIOS', help=''' Specify the Gen9 Boot Environment. Sets the boot mode as one of the following: . UEFI . UEFIOptimized . BIOS If you select UEFI or UEFI optimized for an HPE ProLiant DL Gen9 rack mount server, the remaining boot setting available is the PXE boot policy. For the UEFI or UEFI optimized boot mode options, the boot mode choice should be based on the expected OS and required boot features for the server hardware. UEFI optimized boot mode reduces the time the system spends in POST(Video driver initialization). In order to select the appropriate boot mode, consider the following: . If a secure boot is required, the boot mode must be set to UEFI or UEFI optimized . . For operating systems that do not support UEFI (such as DOS, or older versions of Windows and Linux), the boot mode must be set to BIOS. . When booting in UEFI mode, Windows 7, Server 2008, or 2008 R2 should not be set to UEFIOptimized.''') parser.add_argument( '-px', dest='pxe', required=False, choices=['Auto', 'IPv4', 'IPv6', 'IPv4ThenIPv6', 'IPv6ThenIPv4'], default='IPv4', help=''' Controls the ordering of the network modes available to the Flexible LOM (FLB); for example, IPv4 and IPv6. Select from the following policies: . Auto . IPv4 only . IPv6 only . IPv4 then IPv6 . IPv6 then IPv4 Setting the policy to Auto means the order of the existing network boot targets in the UEFI Boot Order list will not be modified, and any new network boot targets will be added to the end of the list using the System ROM's default policy.''') parser.add_argument('-sl', dest='san_list', required=False, help=''' File with list of SAN Storage connections for this profile in JSON format. This file can be created with multiple calls to define-san-storage-list.py''') args = parser.parse_args() credential = {'userName': args.user, 'password': args.passwd} con = hpov.connection(args.host) srv = hpov.servers(con) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) eg_uri = get_eg_uri_from_arg(srv, args.enc_group) sht = get_sht_from_arg(srv, args.server_hwt) fw_settings = profile.make_firmware_dict(sts, args.baseline) boot, bootmode = profile.make_boot_settings_dict(srv, sht, args.disable_manage_boot, args.boot_order, args.boot_mode, args.pxe) define_profile_template(srv, args.name, args.desc, args.sp_desc, sht['uri'], eg_uri, args.affinity, args.hide_flexnics, args.conn_list, fw_settings, boot, bootmode, args.san_list)
def main(): parser = argparse.ArgumentParser( add_help=True, formatter_class=argparse.RawTextHelpFormatter, description=''' Define a server profile''') parser.add_argument('-a', dest='host', required=True, help=''' HPE OneView Appliance hostname or IP address''') parser.add_argument('-u', dest='user', required=False, default='Administrator', help=''' HPE OneView Username''') parser.add_argument('-p', dest='passwd', required=True, help=''' HPE OneView Password''') parser.add_argument('-c', dest='cert', required=False, help=''' Trusted SSL Certificate Bundle in PEM (Base64 Encoded DER) Format''') parser.add_argument('-y', dest='proxy', required=False, help=''' Proxy (host:port format''') parser.add_argument('-j', dest='domain', required=False, default='Local', help=''' HPE OneView Authorized Login Domain''') parser.add_argument('-n', dest='name', required=True, help=''' Name of the profile''') parser.add_argument('-d', dest='desc', required=False, help=''' Description for the server profile''') parser.add_argument('-af', dest='affinity', required=False, choices=['Bay', 'BayAndServer'], default='Bay', help=''' This identifies the behavior of the server profile when the server hardware is removed or replaced. . Bay: This profile remains with the device bay when the server hardware is removed or replaced. . BayAndServer This profile is pinned to both the device bay and specific server hardware.''') parser.add_argument('-f', dest='forcePowerOff', required=False, action='store_true', help=''' When set, forces power off of target server. Avoids error exit if server is up''') parser.add_argument('-fw', dest='baseline', required=False, help=''' SPP Baseline file name. e.g. SPP2013090_2013_0830_30.iso''') parser.add_argument('-mb', dest='disable_manage_boot', action='store_true', help=''' Explicitly DISABLE Boot Order Management. This value is enabled by default and required for Connection boot enablement. If this option is disabled, then PXE and FC BfS settings are disabled within the entire Server Profile.''') parser.add_argument('-bo', dest='boot_order', required=False, nargs='+', help=''' Defines the order in which boot will be attempted on the available devices. Please NOTE the supported boot order is server hardware type specific. For Gen7 and Gen8 server hardware the possible values are 'CD', 'Floppy', 'USB', 'HardDisk', and 'PXE'. For Gen9 BL server hardware in Legacy BIOS boot mode, the possible values are 'CD', 'USB', 'HardDisk', and 'PXE'. For Gen9 BL server hardware in UEFI or UEFI Optimized boot mode, only one value is allowed and must be either 'HardDisk' or 'PXE'. For Gen9 DL server hardware in Legacy BIOS boot mode, the possible values are 'CD', 'USB', 'HardDisk', and 'PXE'. For Gen9 DL server hardware in UEFI or UEFI Optimized boot mode, boot order configuration is not supported. Server boot order defined as a list separated by spaces. For example: Gen7/8 BIOS Default Boot Order: -bo CD Floppy USB HardDisk PXE Gen9 Legacy BIOS Boot Order: -bo CD USB HardDisk PXE Gen9 UEFI Default Boot Order: -bo HardDisk ''') parser.add_argument('-cl', dest='conn_list', required=False, help=''' File with list of connections for this profile in JSON format. This file can be created with multiple calls to define-connection-list.py''') parser.add_argument('-sl', dest='san_list', required=False, help=''' File with list of SAN Storage connections for this profile in JSON format. This file can be created with multiple calls to define-san-storage-list.py''') parser.add_argument('-bm', dest='boot_mode', required=False, choices=['UEFI', 'UEFIOptimized', 'BIOS'], default='BIOS', help=''' Specify the Gen9 Boot Environment. Sets the boot mode as one of the following: . UEFI . UEFIOptimized . BIOS If you select UEFI or UEFI optimized for an HPE ProLiant DL Gen9 rack mount server, the remaining boot setting available is the PXE boot policy. For the UEFI or UEFI optimized boot mode options, the boot mode choice should be based on the expected OS and required boot features for the server hardware. UEFI optimized boot mode reduces the time the system spends in POST(Video driver initialization). In order to select the appropriate boot mode, consider the following: . If a secure boot is required, the boot mode must be set to UEFI or UEFI optimized . . For operating systems that do not support UEFI (such as DOS, or older versions of Windows and Linux), the boot mode must be set to BIOS. . When booting in UEFI mode, Windows 7, Server 2008, or 2008 R2 should not be set to UEFIOptimized.''') parser.add_argument( '-px', dest='pxe', required=False, choices=['Auto', 'IPv4', 'IPv6', 'IPv4ThenIPv6', 'IPv6ThenIPv4'], default='IPv4', help=''' Controls the ordering of the network modes available to the Flexible LOM (FLB); for example, IPv4 and IPv6. Select from the following policies: . Auto . IPv4 only . IPv6 only . IPv4 then IPv6 . IPv6 then IPv4 Setting the policy to Auto means the order of the existing network boot targets in the UEFI Boot Order list will not be modified, and any new network boot targets will be added to the end of the list using the System ROM's default policy.''') parser.add_argument('-dn', dest='driveName', required=False, help=''' The name of the logical drive.''') parser.add_argument('-rl', dest='raidlevel', required=False, choices=['NONE', 'RAID0', 'RAID1'], help=''' Enable local storage to be managed via the server profile by defining the RAID level for the logical drive.''') parser.add_argument('-pn', dest='physnum', required=False, help=''' The number of physical drives to be used to build the logical drive. The provided values must be consistent with the selected RAID level and cannot exceed the maximum supported number of drives for the selected server hardware type.''') parser.add_argument('-lb', dest='lboot', required=False, action='store_true', help=''' Mark the logical drive as NOT bootable''') parser.add_argument('-is', dest='init_storage', required=False, action='store_true', help=''' Indicates whether the local storage controller should be reset to factory defaults before applying the local storage settings from the server profile. ***************** WARNING ***************** Setting this will overwrite an existing logical disk if present, and without further warning. ***************** WARNING *****************''') parser.add_argument('-hn', dest='hide_flexnics', required=False, action='store_false', help=''' This setting controls the enumeration of physical functions that do not correspond to connections in a profile. Using this flag will SHOW unused FlexNICs to the Operating System. Changing this setting may alter the order of network interfaces in the Operating System. This option sets the 'Hide Unused FlexNICs' to disabled, eight FlexNICs will be enumerated in the Operating System as network interfaces for each Flex-10 or FlexFabric adapter. Configuring Fibre Channel connections on a FlexFabric adapter may enumerate two storage interfaces, reducing the number of network interfaces to six. The default (this option is not selected) enables 'Hide Unused FlexNICs' and may suppress enumeration of FlexNICs that do not correspond to profile connections. FlexNICs are hidden in pairs, starting with the 4th pair. For instance, if the 4th FlexNIC on either physical port corresponds to a profile connection, all eight physical functions are enumerated. If a profile connection corresponds to the 2nd FlexNIC on either physical port, but no connection corresponds to the 3rd or 4th FlexNIC on either physical port, only the 1st and 2nd physical functions are enumerated in the Operating System.''') parser.add_argument('-s', dest='server_id', required=True, help=''' Server identification. There are multiple ways to specify the server id: . Hostname or IP address of the stand-alone server iLO . Server Hardware name of a server than has already been imported into HPE OneView and is listed under Server Hardware . "UNASSIGNED" for creating an unassigned Server Profile''') parser.add_argument('-sh', dest='server_hwt', required=False, help=''' Server hardware type is required for defining an unassigned profile. Note the Server Hardware Type must be present in the HPE OneView appliance before it can be used. For example, a single server with the specific server hardware type must have been added to OneView for that hardware type to be used. The example script get-server-hardware-types.py with the -l argument can be used to get a list of server hardware types that have been imported into the OneView appliance''') parser.add_argument('-bl', dest='bios_list', required=False, help=''' File in JSON format with list of BIOS settings to override for this profile. This file can be created with a call to get-bios-options.py''') args = parser.parse_args() credential = { 'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd } con = hpov.connection(args.host) srv = hpov.servers(con) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) # Invert the boolean value args.lboot = not args.lboot if args.boot_order and args.disable_manage_boot: print('Error: Managed Boot must be enabled to define a boot order') sys.exit() if args.server_id.upper() == 'UNASSIGNED' and not args.server_hwt: print('Error: Server Hardware Type must be specified when defining an' 'unassigned server profile') sys.exit() server, sht = get_server(con, srv, args.server_id, args.server_hwt, args.forcePowerOff) boot, bootmode = profile.make_boot_settings_dict(srv, sht, args.disable_manage_boot, args.boot_order, args.boot_mode, args.pxe) fw_settings = profile.make_firmware_dict(sts, args.baseline) local_storage = profile.make_local_storage_dict(sht, args.raidlevel, args.lboot, args.init_storage, args.physnum, args.driveName) bios = profile.make_bios_dict(args.bios_list) define_profile(con, srv, args.affinity, args.name, args.desc, server, sht, boot, bootmode, fw_settings, args.hide_flexnics, local_storage, args.conn_list, args.san_list, bios)
def main(): parser = argparse.ArgumentParser(add_help=True, description='Usage') parser.add_argument('-a', '--appliance', dest='host', required=True, help='HP OneView Appliance hostname or IP') parser.add_argument('-u', '--user', dest='user', required=False, default='Administrator', help='HP OneView Username') parser.add_argument('-p', '--pass', dest='passwd', required=False, help='HP OneView Password') parser.add_argument('-c', '--certificate', dest='cert', required=False, help='Trusted SSL Certificate Bundle in PEM ' '(Base64 Encoded DER) Format') parser.add_argument('-r', '--proxy', dest='proxy', required=False, help='Proxy (host:port format') parser.add_argument( '-eu', '--enc_user', dest='encusr', required=False, help='Administrative username for the c7000 enclosure OA') parser.add_argument( '-ep', '--enc_pass', dest='encpass', required=False, help='Administrative password for the c7000 enclosure OA') parser.add_argument( '-e', dest='enc', required=True, help='IP address of the c7000 to import into HP OneView') parser.add_argument('-n', '--name', dest='egroup', required=False, default='Prod VC FlexFabric Group 1', help='Enclosure Group to add the enclosure to') parser.add_argument('-s', '--spp', dest='spp', required=False, help='SPP file name to use as the firmware baseline') parser.add_argument('-l', '--license', dest='license', required=False, help='Apply OneView or OneView w/o iLO license to ' 'servers in the enclosure specify either OneView or ' 'OneViewNoiLO') args = parser.parse_args() credential = {'userName': args.user, 'password': args.passwd} con = hpov.connection(args.host) srv = hpov.servers(con) sts = hpov.settings(con) if args.proxy: con.set_proxy(args.proxy.split(':')[0], args.proxy.split(':')[1]) if args.cert: con.set_trusted_ssl_bundle(args.cert) login(con, credential) acceptEULA(con) impenc(srv, sts, args.egroup, args.enc, args.encusr, args.encpass, args.license, args.spp)