<s> import ntpath <EOL> from uforge . objects . uforge import * <EOL> import ussclicore . utils . printer <EOL> def openstack ( account ) : <EOL> myCredAccount = CredAccountOpenStack ( ) <EOL> if not "<STR_LIT:username>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT:password>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT:name>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> myCredAccount . login = account [ "<STR_LIT:username>" ] <EOL> myCredAccount . password = account [ "<STR_LIT:password>" ] <EOL> myCredAccount . serverUrl = account [ "<STR_LIT>" ] <EOL> myCredAccount . keystoneUrl = account [ "<STR_LIT>" ] <EOL> myCredAccount . name = account [ "<STR_LIT:name>" ] <EOL> return myCredAccount <EOL> def susecloud ( account ) : <EOL> myCredAccount = SuseCloud ( ) <EOL> if not "<STR_LIT:username>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT:password>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT:name>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> myCredAccount . login = account [ "<STR_LIT:username>" ] <EOL> myCredAccount . password = account [ "<STR_LIT:password>" ] <EOL> myCredAccount . serverUrl = account [ "<STR_LIT>" ] <EOL> myCredAccount . keystoneUrl = account [ "<STR_LIT>" ] <EOL> myCredAccount . name = account [ "<STR_LIT:name>" ] <EOL> return myCredAccount <EOL> def cloudstack ( account ) : <EOL> myCredAccount = CloudCom ( ) <EOL> if not "<STR_LIT>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT:name>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> myCredAccount . publicAPIKey = account [ "<STR_LIT>" ] <EOL> myCredAccount . secretAPIKey = account [ "<STR_LIT>" ] <EOL> myCredAccount . serverUrl = account [ "<STR_LIT>" ] <EOL> myCredAccount . name = account [ "<STR_LIT:name>" ] <EOL> return myCredAccount <EOL> def ami ( account ) : <EOL> myCredAccount = CredAccountAws ( ) <EOL> if not "<STR_LIT>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT:name>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> myCredAccount . accountNumber = account [ "<STR_LIT>" ] <EOL> myCredAccount . secretAccessKeyID = account [ "<STR_LIT>" ] <EOL> myCredAccount . accessKeyID = account [ "<STR_LIT>" ] <EOL> myCredAccount . name = account [ "<STR_LIT:name>" ] <EOL> myCertificates = certificates ( ) <EOL> myCredAccount . certificates = myCertificates <EOL> try : <EOL> myCertificate = certificate ( ) <EOL> with open ( account [ "<STR_LIT>" ] , "<STR_LIT:r>" ) as myfile : <EOL> myCertificate . certStr = myfile . read ( ) <EOL> myCertificate . type_ = "<STR_LIT>" <EOL> myCertificate . name = ntpath . basename ( account [ "<STR_LIT>" ] ) <EOL> myCertificates . add_certificate ( myCertificate ) <EOL> myCertificate = certificate ( ) <EOL> with open ( account [ "<STR_LIT>" ] , "<STR_LIT:r>" ) as myfile : <EOL> myCertificate . certStr = myfile . read ( ) <EOL> myCertificate . type_ = "<STR_LIT>" <EOL> myCertificate . name = ntpath . basename ( account [ "<STR_LIT>" ] ) <EOL> myCertificates . add_certificate ( myCertificate ) <EOL> if "<STR_LIT>" in account : <EOL> myCertificate = certificate ( ) <EOL> with open ( account [ "<STR_LIT>" ] , "<STR_LIT:r>" ) as myfile : <EOL> myCertificate . certStr = myfile . read ( ) <EOL> myCertificate . type_ = "<STR_LIT>" <EOL> myCertificate . name = ntpath . basename ( account [ "<STR_LIT>" ] ) <EOL> myCertificates . add_certificate ( myCertificate ) <EOL> myCredAccount . keyPairName = os . path . splitext ( myCertificate . name ) [ <NUM_LIT:0> ] <EOL> except IOError as e : <EOL> printer . out ( "<STR_LIT>" + str ( e ) , printer . ERROR ) <EOL> return <EOL> return myCredAccount <EOL> def azure ( account ) : <EOL> myCredAccount = CredAccountAzure ( ) <EOL> if not "<STR_LIT>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT:name>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> myCredAccount . accountNumber = account [ "<STR_LIT>" ] <EOL> myCredAccount . name = account [ "<STR_LIT:name>" ] <EOL> myCertificates = certificates ( ) <EOL> myCredAccount . certificates = myCertificates <EOL> try : <EOL> myCertificate = certificate ( ) <EOL> with open ( account [ "<STR_LIT>" ] , "<STR_LIT:r>" ) as myfile : <EOL> myCertificate . certStr = myfile . read ( ) <EOL> myCertificate . type_ = "<STR_LIT>" <EOL> myCertificate . name = ntpath . basename ( account [ "<STR_LIT>" ] ) <EOL> myCertificates . add_certificate ( myCertificate ) <EOL> myCertificate = certificate ( ) <EOL> with open ( account [ "<STR_LIT>" ] , "<STR_LIT:r>" ) as myfile : <EOL> myCertificate . certStr = myfile . read ( ) <EOL> myCertificate . type_ = "<STR_LIT>" <EOL> myCertificate . name = ntpath . basename ( account [ "<STR_LIT>" ] ) <EOL> myCertificates . add_certificate ( myCertificate ) <EOL> except IOError as e : <EOL> printer . out ( "<STR_LIT>" + str ( e ) , printer . ERROR ) <EOL> return <EOL> return myCredAccount <EOL> def eucalyptus ( account ) : <EOL> myCredAccount = CredAccountEws ( ) <EOL> if not "<STR_LIT>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT:name>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> myCredAccount . accountNumber = account [ "<STR_LIT>" ] <EOL> myCredAccount . name = account [ "<STR_LIT:name>" ] <EOL> myCredAccount . hostname = account [ "<STR_LIT>" ] <EOL> myCredAccount . secretAccessKeyID = account [ "<STR_LIT>" ] <EOL> myCredAccount . accessKeyID = account [ "<STR_LIT>" ] <EOL> myCertificates = certificates ( ) <EOL> myCredAccount . certificates = myCertificates <EOL> try : <EOL> myCertificate = certificate ( ) <EOL> with open ( account [ "<STR_LIT>" ] , "<STR_LIT:r>" ) as myfile : <EOL> myCertificate . certStr = myfile . read ( ) <EOL> myCertificate . type_ = "<STR_LIT>" <EOL> myCertificate . name = ntpath . basename ( account [ "<STR_LIT>" ] ) <EOL> myCertificates . add_certificate ( myCertificate ) <EOL> myCertificate = certificate ( ) <EOL> with open ( account [ "<STR_LIT>" ] , "<STR_LIT:r>" ) as myfile : <EOL> myCertificate . certStr = myfile . read ( ) <EOL> myCertificate . type_ = "<STR_LIT>" <EOL> myCertificate . name = ntpath . basename ( account [ "<STR_LIT>" ] ) <EOL> myCertificates . add_certificate ( myCertificate ) <EOL> myCertificate = certificate ( ) <EOL> with open ( account [ "<STR_LIT>" ] , "<STR_LIT:r>" ) as myfile : <EOL> myCertificate . certStr = myfile . read ( ) <EOL> myCertificate . type_ = "<STR_LIT>" <EOL> myCertificate . name = ntpath . basename ( account [ "<STR_LIT>" ] ) <EOL> myCertificates . add_certificate ( myCertificate ) <EOL> except IOError as e : <EOL> printer . out ( "<STR_LIT>" + str ( e ) , printer . ERROR ) <EOL> return <EOL> return myCredAccount <EOL> def abiquo ( account ) : <EOL> myCredAccount = CredAccountAbiquo ( ) <EOL> if not "<STR_LIT:password>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT:username>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT:name>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> myCredAccount . login = account [ "<STR_LIT:username>" ] <EOL> myCredAccount . password = account [ "<STR_LIT:password>" ] <EOL> myCredAccount . hostname = account [ "<STR_LIT>" ] <EOL> myCredAccount . name = account [ "<STR_LIT:name>" ] <EOL> return myCredAccount <EOL> def nimbula ( account ) : <EOL> myCredAccount = CredAccountNimbula ( ) <EOL> if not "<STR_LIT:password>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT:username>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT:name>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> myCredAccount . login = account [ "<STR_LIT:username>" ] <EOL> myCredAccount . password = account [ "<STR_LIT:password>" ] <EOL> myCredAccount . serverUrl = account [ "<STR_LIT>" ] <EOL> myCredAccount . name = account [ "<STR_LIT:name>" ] <EOL> return myCredAccount <EOL> def flexiant ( account ) : <EOL> myCredAccount = CredAccountFlexiant ( ) <EOL> if not "<STR_LIT:password>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT:username>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT:name>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> myCredAccount . login = account [ "<STR_LIT:username>" ] <EOL> myCredAccount . password = account [ "<STR_LIT:password>" ] <EOL> try : <EOL> myCredAccount . userUUID = ( myCredAccount . login ) . split ( '<STR_LIT:/>' ) [ <NUM_LIT:1> ] <EOL> except : <EOL> printer . out ( account [ "<STR_LIT:username>" ] + "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> myCredAccount . wsdlLocation = account [ "<STR_LIT>" ] <EOL> myCredAccount . name = account [ "<STR_LIT:name>" ] <EOL> return myCredAccount <EOL> def vcd ( account ) : <EOL> myCredAccount = CredAccountVCloudDirector ( ) <EOL> if not "<STR_LIT>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT:username>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT:password>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT:name>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if "<STR_LIT>" in account : <EOL> myCredAccount . proxyHost = account [ "<STR_LIT>" ] <EOL> if "<STR_LIT>" in account : <EOL> myCredAccount . proxyPort = account [ "<STR_LIT>" ] <EOL> if "<STR_LIT:port>" in account : <EOL> port = int ( account [ "<STR_LIT:port>" ] ) <EOL> else : <EOL> port = <NUM_LIT> <EOL> myCredAccount . name = account [ "<STR_LIT:name>" ] <EOL> myCredAccount . login = account [ "<STR_LIT:username>" ] <EOL> myCredAccount . password = account [ "<STR_LIT:password>" ] <EOL> myCredAccount . hostname = account [ "<STR_LIT>" ] <EOL> myCredAccount . port = port <EOL> return myCredAccount <EOL> def vsphere ( account ) : <EOL> myCredAccount = CredAccountVSphere ( ) <EOL> if not "<STR_LIT>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT:username>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT:password>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT:name>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if "<STR_LIT>" in account : <EOL> myCredAccount . proxyHost = account [ "<STR_LIT>" ] <EOL> if "<STR_LIT>" in account : <EOL> myCredAccount . proxyPort = account [ "<STR_LIT>" ] <EOL> if "<STR_LIT:port>" in account : <EOL> port = int ( account [ "<STR_LIT:port>" ] ) <EOL> else : <EOL> port = <NUM_LIT> <EOL> myCredAccount . name = account [ "<STR_LIT:name>" ] <EOL> myCredAccount . login = account [ "<STR_LIT:username>" ] <EOL> myCredAccount . password = account [ "<STR_LIT:password>" ] <EOL> myCredAccount . hostname = account [ "<STR_LIT>" ] <EOL> myCredAccount . port = port <EOL> return myCredAccount <EOL> def gce ( account ) : <EOL> myCredAccount = CredAccountGoogle ( ) <EOL> if not "<STR_LIT:username>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> if not "<STR_LIT:name>" in account : <EOL> printer . out ( "<STR_LIT>" , printer . ERROR ) <EOL> return <EOL> myCredAccount . type_ = "<STR_LIT>" <EOL> myCredAccount . login = account [ "<STR_LIT:username>" ] <EOL> myCredAccount . password = account [ "<STR_LIT>" ] <EOL> myCredAccount . name = account [ "<STR_LIT:name>" ] <EOL> myCertificates = certificates ( ) <EOL> myCredAccount . certificates = myCertificates <EOL> try : <EOL> myCertificate = certificate ( ) <EOL> with open ( account [ "<STR_LIT>" ] , "<STR_LIT:r>" ) as myfile : <EOL> myCertificate . certStr = myfile . read ( ) <EOL> myCertificate . type_ = "<STR_LIT>" <EOL> myCertificate . name = ntpath . basename ( account [ "<STR_LIT>" ] ) <EOL> myCertificates . add_certificate ( myCertificate ) <EOL> except IOError as e : <EOL> printer . out ( "<STR_LIT>" + str ( e ) , printer . ERROR ) <EOL> return <EOL> return myCredAccount <EOL> def get_target_platform_object ( api , login , targetPlatformName ) : <EOL> targetPlatformsUser = api . Users ( login ) . Targetplatforms . Getall ( ) <EOL> if targetPlatformsUser is None or len ( targetPlatformsUser . targetPlatforms . targetPlatform ) == <NUM_LIT:0> : <EOL> return None <EOL> else : <EOL> for item in targetPlatformsUser . targetPlatforms . targetPlatform : <EOL> if ( item . name == targetPlatformName ) : <EOL> return item <EOL> return None <EOL> def assign_target_platform_account ( credAccount , targetPlatformName ) : <EOL> myTargetPlatform = targetPlatform ( ) <EOL> myTargetPlatform . name = targetPlatformName <EOL> credAccount . targetPlatform = myTargetPlatform <EOL> return credAccount </s>
