<s> from __future__ import print_function <EOL> from __future__ import unicode_literals <EOL> from __future__ import division <EOL> from __future__ import absolute_import <EOL> from builtins import range <EOL> from future import standard_library <EOL> standard_library . install_aliases ( ) <EOL> import sys <EOL> PYTHON_VERSION = sys . version_info [ : <NUM_LIT:3> ] <EOL> PY2 = ( PYTHON_VERSION [ <NUM_LIT:0> ] == <NUM_LIT:2> ) <EOL> if PY2 : <EOL> if PYTHON_VERSION < ( <NUM_LIT:2> , <NUM_LIT:7> , <NUM_LIT:9> ) : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> elif PYTHON_VERSION < ( <NUM_LIT:3> , <NUM_LIT:4> ) : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> import hpOneView as hpov <EOL> from pprint import pprint <EOL> import json <EOL> from hpOneView . common import uri <EOL> import hpOneView . profile as profile <EOL> def acceptEULA ( con ) : <EOL> con . get_eula_status ( ) <EOL> try : <EOL> if con . get_eula_status ( ) is True : <EOL> print ( '<STR_LIT>' ) <EOL> con . set_eula ( '<STR_LIT>' ) <EOL> except Exception as e : <EOL> print ( '<STR_LIT>' ) <EOL> print ( e ) <EOL> def login ( con , credential ) : <EOL> try : <EOL> con . login ( credential ) <EOL> except : <EOL> print ( '<STR_LIT>' ) <EOL> def get_eg_uri_from_arg ( srv , name ) : <EOL> if srv and name : <EOL> if name . startswith ( '<STR_LIT>' ) and uri [ '<STR_LIT>' ] in name : <EOL> return name <EOL> else : <EOL> egs = srv . get_enclosure_groups ( ) <EOL> for eg in egs : <EOL> if eg [ '<STR_LIT:name>' ] == name : <EOL> return eg [ '<STR_LIT>' ] <EOL> return None <EOL> def get_sht_from_arg ( srv , name ) : <EOL> if srv and name : <EOL> if name . startswith ( '<STR_LIT>' ) and uri [ '<STR_LIT>' ] in name : <EOL> return name <EOL> else : <EOL> shts = srv . get_server_hardware_types ( ) <EOL> for sht in shts : <EOL> if sht [ '<STR_LIT:name>' ] == name : <EOL> return sht <EOL> return None <EOL> def define_profile_template ( <EOL> srv , <EOL> name , <EOL> desc , <EOL> sp_desc , <EOL> server_hwt , <EOL> enc_group , <EOL> affinity , <EOL> hide_flexnics , <EOL> conn_list , <EOL> fw_settings , <EOL> boot , <EOL> bootmode ) : <EOL> if conn_list : <EOL> conn = json . loads ( open ( conn_list ) . read ( ) ) <EOL> else : <EOL> conn = [ ] <EOL> profile_template = srv . create_server_profile_template ( <EOL> name = name , <EOL> description = desc , <EOL> serverProfileDescription = sp_desc , <EOL> serverHardwareTypeUri = server_hwt , <EOL> enclosureGroupUri = enc_group , <EOL> affinity = affinity , <EOL> hideUnusedFlexNics = hide_flexnics , <EOL> profileConnectionV4 = conn , <EOL> firmwareSettingsV3 = fw_settings , <EOL> bootSettings = boot , <EOL> bootModeSetting = bootmode ) <EOL> if '<STR_LIT>' in profile_template : <EOL> print ( '<STR_LIT>' , profile_template [ '<STR_LIT:name>' ] ) <EOL> print ( '<STR_LIT>' , profile_template [ '<STR_LIT:type>' ] ) <EOL> print ( '<STR_LIT>' , profile_template [ '<STR_LIT:description>' ] ) <EOL> print ( '<STR_LIT>' , profile_template [ '<STR_LIT>' ] ) <EOL> print ( '<STR_LIT>' ) <EOL> for connection in profile_template [ '<STR_LIT>' ] : <EOL> print ( '<STR_LIT>' , connection [ '<STR_LIT:name>' ] ) <EOL> print ( '<STR_LIT>' , connection [ '<STR_LIT>' ] ) <EOL> print ( '<STR_LIT>' , connection [ '<STR_LIT>' ] ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' , profile_template [ '<STR_LIT>' ] [ '<STR_LIT>' ] ) <EOL> print ( '<STR_LIT>' , profile_template [ '<STR_LIT>' ] [ '<STR_LIT>' ] ) <EOL> print ( '<STR_LIT>' , profile_template [ '<STR_LIT>' ] [ '<STR_LIT>' ] ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' , profile_template [ '<STR_LIT>' ] [ '<STR_LIT>' ] ) <EOL> print ( '<STR_LIT>' , profile_template [ '<STR_LIT>' ] [ '<STR_LIT>' ] ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' , profile_template [ '<STR_LIT>' ] [ '<STR_LIT>' ] ) <EOL> print ( '<STR_LIT>' , profile_template [ '<STR_LIT>' ] [ '<STR_LIT>' ] , '<STR_LIT:\n>' ) <EOL> else : <EOL> pprint ( profile_template ) <EOL> def main ( ) : <EOL> parser = argparse . ArgumentParser ( add_help = True , <EOL> formatter_class = argparse . RawTextHelpFormatter , <EOL> description = '''<STR_LIT>''' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT:host>' , required = True , <EOL> help = '''<STR_LIT>''' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT:user>' , required = False , <EOL> default = '<STR_LIT>' , <EOL> help = '''<STR_LIT>''' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , required = True , <EOL> help = '''<STR_LIT>''' ) <EOL> parser . add_argument ( '<STR_LIT:-c>' , dest = '<STR_LIT>' , required = False , <EOL> help = '''<STR_LIT>''' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , required = False , <EOL> help = '''<STR_LIT>''' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT:name>' , <EOL> required = True , <EOL> help = '''<STR_LIT>''' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> required = False , <EOL> help = '''<STR_LIT>''' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> required = False , <EOL> help = '''<STR_LIT>''' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , required = True , <EOL> help = '''<STR_LIT>''' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , required = True , <EOL> help = '''<STR_LIT>''' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> required = False , choices = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> default = '<STR_LIT>' , <EOL> help = '''<STR_LIT>''' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> required = False , choices = [ '<STR_LIT:true>' , '<STR_LIT:false>' ] , <EOL> help = '''<STR_LIT>''' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> required = False , <EOL> help = '''<STR_LIT>''' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , required = False , <EOL> help = '''<STR_LIT>''' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> action = '<STR_LIT:store_true>' , <EOL> help = '''<STR_LIT>''' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , required = False , <EOL> nargs = '<STR_LIT:+>' , <EOL> help = '''<STR_LIT>''' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , required = False , <EOL> choices = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> default = '<STR_LIT>' , <EOL> help = '''<STR_LIT>''' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , required = False , <EOL> choices = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] , <EOL> default = '<STR_LIT>' , <EOL> help = '''<STR_LIT>''' ) <EOL> args = parser . parse_args ( ) <EOL> credential = { '<STR_LIT>' : args . user , '<STR_LIT:password>' : args . passwd } <EOL> con = hpov . connection ( args . host ) <EOL> srv = hpov . servers ( con ) <EOL> sts = hpov . settings ( con ) <EOL> if args . proxy : <EOL> con . set_proxy ( args . proxy . split ( '<STR_LIT::>' ) [ <NUM_LIT:0> ] , args . proxy . split ( '<STR_LIT::>' ) [ <NUM_LIT:1> ] ) <EOL> if args . cert : <EOL> con . set_trusted_ssl_bundle ( args . cert ) <EOL> login ( con , credential ) <EOL> acceptEULA ( con ) <EOL> eg_uri = get_eg_uri_from_arg ( srv , args . enc_group ) <EOL> sht = get_sht_from_arg ( srv , args . server_hwt ) <EOL> fw_settings = profile . make_firmware_dict ( sts , args . baseline ) <EOL> boot , bootmode = profile . make_boot_settings_dict ( srv , sht , args . disable_manage_boot , <EOL> args . boot_order , args . boot_mode , args . pxe ) <EOL> define_profile_template ( srv , <EOL> args . name , <EOL> args . desc , <EOL> args . sp_desc , <EOL> sht [ '<STR_LIT>' ] , <EOL> eg_uri , <EOL> args . affinity , <EOL> args . hide_flexnics , <EOL> args . conn_list , <EOL> fw_settings , <EOL> boot , <EOL> bootmode ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> import argparse <EOL> sys . exit ( main ( ) ) </s>
