<s> from uforge . objects . uforge import * <EOL> from ussclicore . utils import printer <EOL> def generate_vcd ( image , builder , installProfile , api , login ) : <EOL> installProfile = get_memory_amount ( builder , installProfile , True ) <EOL> if installProfile == <NUM_LIT:2> : <EOL> return None , None , None <EOL> if "<STR_LIT>" in builder [ "<STR_LIT>" ] : <EOL> installProfile . hwType = builder [ "<STR_LIT>" ] [ "<STR_LIT>" ] <EOL> image . compress = False <EOL> return image , installProfile <EOL> def generate_nimbula ( image , builder , installProfile , api , login ) : <EOL> installProfile = get_memory_amount ( builder , installProfile , True ) <EOL> if installProfile == <NUM_LIT:2> : <EOL> return None , None , None <EOL> image . compress = True <EOL> return image , installProfile <EOL> def generate_nimbulaesx ( image , builder , installProfile , api , login ) : <EOL> return generate_nimbula ( image , builder , installProfile , api , login ) <EOL> def generate_nimbulakvm ( image , builder , installProfile , api , login ) : <EOL> return generate_nimbula ( image , builder , installProfile , api , login ) <EOL> def generate_openstackqcow2 ( image , builder , installProfile , api , login ) : <EOL> image . compress = False <EOL> return image , installProfile <EOL> def generate_openstackvhd ( image , builder , installProfile , api , login ) : <EOL> image . compress = False <EOL> return image , installProfile <EOL> def generate_openstackvmdk ( image , builder , installProfile , api , login ) : <EOL> image . compress = False <EOL> return image , installProfile <EOL> def generate_openstackvdi ( image , builder , installProfile , api , login ) : <EOL> image . compress = False <EOL> return image , installProfile <EOL> def generate_susecloud ( image , builder , installProfile , api , login ) : <EOL> image . compress = False <EOL> return image , installProfile <EOL> def generate_eucalyptus ( image , builder , installProfile , api , login ) : <EOL> if not "<STR_LIT>" in builder : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return None , None , None <EOL> accounts = api . Users ( login ) . Accounts . Getall ( ) <EOL> if accounts is None or not accounts . get_credAccount ( ) : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return None , None , None <EOL> else : <EOL> for account in accounts . get_credAccount ( ) : <EOL> if account . name == builder [ "<STR_LIT>" ] [ "<STR_LIT:name>" ] : <EOL> image . credAccount = account <EOL> break <EOL> if "<STR_LIT>" in builder : <EOL> myrootUser = osUser ( ) <EOL> if builder [ "<STR_LIT>" ] == "<STR_LIT:true>" : <EOL> val = True <EOL> elif builder [ "<STR_LIT>" ] == "<STR_LIT:false>" : <EOL> val = False <EOL> else : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return None , None , None <EOL> myrootUser . disablePasswordLogin = val <EOL> installProfile . rootUser = myrootUser <EOL> image . compress = False <EOL> return image , installProfile <EOL> def generate_eucalyptusxen ( image , builder , installProfile , api , login ) : <EOL> return generate_eucalyptus ( image , builder , installProfile , api , login ) <EOL> def generate_eucalyptuskvm ( image , builder , installProfile , api , login ) : <EOL> return generate_eucalyptus ( image , builder , installProfile , api , login ) <EOL> def generate_flexiant ( image , builder , installProfile , api , login ) : <EOL> installProfile = get_memory_amount ( builder , installProfile , True ) <EOL> image . compress = True <EOL> return image , installProfile <EOL> def generate_flexiantraw ( image , builder , installProfile , api , login ) : <EOL> return generate_flexiant ( image , builder , installProfile , api , login ) <EOL> def generate_flexiantova ( image , builder , installProfile , api , login ) : <EOL> return generate_flexiant ( image , builder , installProfile , api , login ) <EOL> def generate_flexiantkvm ( image , builder , installProfile , api , login ) : <EOL> return generate_flexiant ( image , builder , installProfile , api , login ) <EOL> def generate_cloudstackqcow2 ( image , builder , installProfile , api , login ) : <EOL> installProfile = get_memory_amount ( builder , installProfile , True ) <EOL> if installProfile == <NUM_LIT:2> : <EOL> return None , None , None <EOL> image . compress = True <EOL> return image , installProfile <EOL> def generate_cloudstackvhd ( image , builder , installProfile , api , login ) : <EOL> installProfile = get_memory_amount ( builder , installProfile , True ) <EOL> if installProfile == <NUM_LIT:2> : <EOL> return None , None , None <EOL> image . compress = True <EOL> return image , installProfile <EOL> def generate_cloudstackova ( image , builder , installProfile , api , login ) : <EOL> installProfile = get_memory_amount ( builder , installProfile , True ) <EOL> if installProfile == <NUM_LIT:2> : <EOL> return None , None , None <EOL> image . compress = True <EOL> return image , installProfile <EOL> def generate_abiquo ( image , builder , installProfile , api , login ) : <EOL> installProfile = get_memory_amount ( builder , installProfile , True ) <EOL> if installProfile == <NUM_LIT:2> : <EOL> return None , None , None <EOL> if "<STR_LIT>" in builder [ "<STR_LIT>" ] : <EOL> installProfile . hwType = builder [ "<STR_LIT>" ] [ "<STR_LIT>" ] <EOL> image . compress = False <EOL> return image , installProfile <EOL> def generate_azure ( image , builder , installProfile , api , login ) : <EOL> image . compress = False <EOL> return image , installProfile <EOL> def generate_ami ( image , builder , installProfile , api , login ) : <EOL> if not "<STR_LIT>" in builder : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return None , None , None <EOL> if not "<STR_LIT:name>" in builder [ "<STR_LIT>" ] : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return None , None , None <EOL> accounts = api . Users ( login ) . Accounts . Getall ( ) <EOL> if accounts is None or not hasattr ( accounts , '<STR_LIT>' ) : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return None , None , None <EOL> for account in accounts . get_credAccount ( ) : <EOL> if account . name == builder [ "<STR_LIT>" ] [ "<STR_LIT:name>" ] : <EOL> image . credAccount = account <EOL> break <EOL> if "<STR_LIT>" in builder : <EOL> myrootUser = osUser ( ) <EOL> if builder [ "<STR_LIT>" ] == "<STR_LIT:true>" : <EOL> val = True <EOL> elif builder [ "<STR_LIT>" ] == "<STR_LIT:false>" : <EOL> val = False <EOL> else : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return None , None , None <EOL> myrootUser . disablePasswordLogin = val <EOL> installProfile . rootUser = myrootUser <EOL> if "<STR_LIT>" in builder : <EOL> image . update <EOL> if "<STR_LIT>" in builder : <EOL> if "<STR_LIT>" in builder and "<STR_LIT>" in builder [ "<STR_LIT>" ] : <EOL> installProfile . ebsVolumeSize = builder [ "<STR_LIT>" ] [ "<STR_LIT>" ] <EOL> else : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return None , None , None <EOL> image . compress = False <EOL> return image , installProfile <EOL> def generate_gce ( image , builder , installProfile , api , login ) : <EOL> image . compress = True <EOL> return image , installProfile <EOL> def generate_iso ( image , builder , installProfile , api = None , login = None ) : <EOL> image . compress = True <EOL> return image , installProfile <EOL> def generate_ovf ( image , builder , installProfile , api = None , login = None ) : <EOL> installProfile = get_memory_amount ( builder , installProfile , True ) <EOL> if installProfile == <NUM_LIT:2> : <EOL> return None , None , None <EOL> if "<STR_LIT>" in builder [ "<STR_LIT>" ] : <EOL> installProfile . hwType = builder [ "<STR_LIT>" ] [ "<STR_LIT>" ] <EOL> image . compress = True <EOL> return image , installProfile <EOL> def generate_kvm ( image , builder , installProfile , api = None , login = None ) : <EOL> installProfile = get_memory_amount ( builder , installProfile , True ) <EOL> if installProfile == <NUM_LIT:2> : <EOL> return None , None , None <EOL> image . compress = True <EOL> return image , installProfile <EOL> def generate_vbox ( image , builder , installProfile , api = None , login = None ) : <EOL> installProfile = get_memory_amount ( builder , installProfile , True ) <EOL> if installProfile == <NUM_LIT:2> : <EOL> return None , None , None <EOL> image . compress = True <EOL> return image , installProfile <EOL> def generate_raw ( image , builder , installProfile , api = None , login = None ) : <EOL> image . compress = True <EOL> return image , installProfile <EOL> def generate_hyper_v ( image , builder , installProfile , api = None , login = None ) : <EOL> installProfile = get_memory_amount ( builder , installProfile , True ) <EOL> if installProfile == <NUM_LIT:2> : <EOL> return None , None , None <EOL> image . compress = True <EOL> return image , installProfile <EOL> def generate_qcow2 ( image , builder , installProfile , api = None , login = None ) : <EOL> installProfile = get_memory_amount ( builder , installProfile , True ) <EOL> if installProfile == <NUM_LIT:2> : <EOL> return None , None , None <EOL> image . compress = True <EOL> return image , installProfile <EOL> def generate_vhd ( image , builder , installProfile , api = None , login = None ) : <EOL> installProfile = get_memory_amount ( builder , installProfile , True ) <EOL> if installProfile == <NUM_LIT:2> : <EOL> return None , None , None <EOL> image . compress = True <EOL> return image , installProfile <EOL> def generate_xen ( image , builder , installProfile , api = None , login = None ) : <EOL> installProfile = get_memory_amount ( builder , installProfile , True ) <EOL> if installProfile == <NUM_LIT:2> : <EOL> return None , None , None <EOL> image . compress = True <EOL> return image , installProfile <EOL> def generate_vagrant ( image , builder , installProfile , api = None , login = None ) : <EOL> installProfile = get_memory_amount ( builder , installProfile , True ) <EOL> if installProfile == <NUM_LIT:2> : <EOL> return None , None , None <EOL> if "<STR_LIT>" in builder and builder [ "<STR_LIT>" ] == "<STR_LIT:true>" : <EOL> if not "<STR_LIT>" in builder : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return None , None , None <EOL> if not "<STR_LIT>" in builder : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return None , None , None <EOL> sshkey = generics_utils . create_user_ssh_key ( self . api , self . login , builder [ "<STR_LIT>" ] ) <EOL> if sshkey == <NUM_LIT:2> : <EOL> return None , None , None <EOL> sshKeys = sshKeys ( ) <EOL> sshKeys . add_sshKey ( sshkey ) <EOL> vagrantUser = osUser ( ) <EOL> vagrantUser . name = builder [ "<STR_LIT>" ] <EOL> vagrantUser . sshKeys = sshKeys <EOL> installProfile . osusers . add_osUser ( vagrantUser ) <EOL> else : <EOL> pass <EOL> image . compress = True <EOL> return image , installProfile <EOL> def generate_xenserver ( image , builder , installProfile , api = None , login = None ) : <EOL> installProfile = get_memory_amount ( builder , installProfile , True ) <EOL> if installProfile == <NUM_LIT:2> : <EOL> return None , None , None <EOL> image . compress = True <EOL> return image , installProfile <EOL> def generate_vmware ( image , builder , installProfile , api = None , login = None ) : <EOL> installProfile = get_memory_amount ( builder , installProfile , True ) <EOL> if installProfile == <NUM_LIT:2> : <EOL> return None , None , None <EOL> if "<STR_LIT>" in builder [ "<STR_LIT>" ] : <EOL> installProfile . hwType = builder [ "<STR_LIT>" ] [ "<STR_LIT>" ] <EOL> image . compress = True <EOL> return image , installProfile <EOL> def generate_vcenter ( image , builder , installProfile , api = None , login = None ) : <EOL> installProfile = get_memory_amount ( builder , installProfile , True ) <EOL> if installProfile == <NUM_LIT:2> : <EOL> return None , None , None <EOL> if "<STR_LIT>" in builder [ "<STR_LIT>" ] : <EOL> installProfile . hwType = builder [ "<STR_LIT>" ] [ "<STR_LIT>" ] <EOL> image . compress = False <EOL> return image , installProfile <EOL> def generate_targz ( image , builder , installProfile , api = None , login = None ) : <EOL> image . compress = True <EOL> return image , installProfile <EOL> def generate_lxc ( image , builder , installProfile , api = None , login = None ) : <EOL> image . compress = True <EOL> return image , installProfile <EOL> def get_memory_amount ( builder , installProfile , is_mandatory ) : <EOL> if "<STR_LIT>" in builder and "<STR_LIT>" in builder [ "<STR_LIT>" ] : <EOL> installProfile . memorySize = builder [ "<STR_LIT>" ] [ "<STR_LIT>" ] <EOL> return installProfile <EOL> else : <EOL> if is_mandatory : <EOL> printer . out ( "<STR_LIT>" + builder [ "<STR_LIT:type>" ] + "<STR_LIT:]>" , printer . ERROR ) <EOL> return <NUM_LIT:2> <EOL> else : <EOL> return installProfile <EOL> def get_target_format_object ( api , login , targetFormatName ) : <EOL> targetFormatsUser = api . Users ( login ) . Targetformats . Getall ( ) <EOL> if targetFormatsUser is None or len ( targetFormatsUser . targetFormats . targetFormat ) == <NUM_LIT:0> : <EOL> return None <EOL> else : <EOL> for item in targetFormatsUser . targetFormats . targetFormat : <EOL> if ( item . name == targetFormatName ) : <EOL> return item <EOL> return None </s>
