<s> import sys <EOL> import os <EOL> import ast <EOL> import time <EOL> import daemon <EOL> import logging <EOL> import yaml <EOL> from UcsSdk import * <EOL> from passlib . apps import custom_app_context as pwd_context <EOL> from jinja2 import Template , Environment , FileSystemLoader <EOL> class AppName : <EOL> OPENSTACK = "<STR_LIT>" <EOL> COBBLER = "<STR_LIT>" <EOL> CLOUDSTACK = "<STR_LIT>" <EOL> pass <EOL> class UcsmHost : <EOL> def __init__ ( self , hostname , username , password , conf_template , debug ) : <EOL> self . hostname = hostname <EOL> self . username = username <EOL> self . password = password <EOL> self . conf_template = conf_template <EOL> self . debug = debug <EOL> pass <EOL> pass <EOL> def getRn ( dn ) : <EOL> return dn [ dn . rfind ( "<STR_LIT>" ) + <NUM_LIT:3> : ] <EOL> pass <EOL> def addObjectToUcs ( inUcsmHost , pDn , pClassId , classId , pList , inDn ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> handle = UcsHandle ( ) <EOL> login = handle . Login ( inUcsmHost . hostname , inUcsmHost . username , inUcsmHost . password ) <EOL> if ( login == False ) : <EOL> logging . debug ( '<STR_LIT>' ) <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> res = handle . GetManagedObject ( None , pClassId , { "<STR_LIT>" : pDn } , dumpXml = inUcsmHost . debug ) <EOL> moRes = handle . GetManagedObject ( None , classId , { "<STR_LIT>" : inDn } , dumpXml = inUcsmHost . debug ) <EOL> if not moRes : <EOL> result = handle . AddManagedObject ( res , classId , pList , dumpXml = inUcsmHost . debug ) <EOL> else : <EOL> logging . debug ( '<STR_LIT>' ) <EOL> result = handle . SetManagedObject ( moRes , classId , pList , dumpXml = inUcsmHost . debug , force = True ) <EOL> pass <EOL> handle . Logout ( ) <EOL> except Exception , err : <EOL> print "<STR_LIT>" , str ( err ) <EOL> import traceback , sys <EOL> print '<STR_LIT:->' * <NUM_LIT> <EOL> traceback . print_exc ( file = sys . stdout ) <EOL> print '<STR_LIT:->' * <NUM_LIT> <EOL> pass <EOL> pass <EOL> def getAdaptorHostEthIf ( inConnHandle , inCompServer , inVnicName ) : <EOL> inFilter = FilterFilter ( ) <EOL> andFilter0 = AndFilter ( ) <EOL> wcardFilter = WcardFilter ( ) <EOL> wcardFilter . Class = "<STR_LIT>" <EOL> wcardFilter . Property = "<STR_LIT>" <EOL> wcardFilter . Value = "<STR_LIT>" % inCompServer . Dn <EOL> andFilter0 . AddChild ( wcardFilter ) <EOL> eqFilter = EqFilter ( ) <EOL> eqFilter . Class = "<STR_LIT>" <EOL> eqFilter . Property = "<STR_LIT:name>" <EOL> eqFilter . Value = inVnicName <EOL> andFilter0 . AddChild ( eqFilter ) <EOL> inFilter . AddChild ( andFilter0 ) <EOL> adaptorHostEthIfs = inConnHandle . ConfigResolveClass ( AdaptorHostEthIf . ClassId ( ) , inFilter , YesOrNo . TRUE , dumpXml = False ) <EOL> if ( adaptorHostEthIfs . errorCode == <NUM_LIT:0> ) : <EOL> return adaptorHostEthIfs . OutConfigs . GetChild ( ) <EOL> return <EOL> pass <EOL> def getHostAdaptorEthIf ( handle , inComputeServer , inHostName , inImagePath , inAssignedToDn ) : <EOL> logging . debug ( '<STR_LIT>' ) <EOL> hostEthIfs = getAdaptorHostEthIf ( handle , inComputeServer , inImagePath . getattr ( "<STR_LIT>" ) ) <EOL> for hostEthIf in hostEthIfs : <EOL> isExists = isSystemExists ( hostEthIf . getattr ( "<STR_LIT>" ) ) <EOL> logging . debug ( '<STR_LIT>' + hostEthIf . getattr ( "<STR_LIT>" ) ) <EOL> if ( not isExists ) : <EOL> logging . debug ( '<STR_LIT>' + inHostName + '<STR_LIT>' + inImagePath . getattr ( "<STR_LIT>" ) + '<STR_LIT>' + hostEthIf . getattr ( "<STR_LIT>" ) + '<STR_LIT>' + getRn ( inAssignedToDn ) ) <EOL> if ( inImagePath . getattr ( "<STR_LIT>" ) == "<STR_LIT>" ) : <EOL> addSystem ( inHostName , getRn ( inAssignedToDn ) , hostEthIf . getattr ( "<STR_LIT>" ) ) <EOL> elif ( inImagePath . getattr ( "<STR_LIT>" ) == "<STR_LIT>" ) : <EOL> updateSystem ( inHostName , getRn ( inAssignedToDn ) , hostEthIf . getattr ( "<STR_LIT>" ) ) <EOL> else : <EOL> logging . debug ( '<STR_LIT>' ) <EOL> pass <EOL> pass <EOL> pass <EOL> def getLsbootDef ( connHandle , computeBlade ) : <EOL> logging . debug ( '<STR_LIT>' ) <EOL> inFilter = FilterFilter ( ) <EOL> wcardFilter = WcardFilter ( ) <EOL> wcardFilter . Class = "<STR_LIT>" <EOL> wcardFilter . Property = "<STR_LIT>" <EOL> wcardFilter . Value = "<STR_LIT>" % computeBlade . Dn <EOL> inFilter . AddChild ( wcardFilter ) <EOL> lsbootDef = connHandle . ConfigResolveClass ( LsbootDef . ClassId ( ) , inFilter , inHierarchical = YesOrNo . FALSE , dumpXml = False ) <EOL> return lsbootDef <EOL> pass <EOL> def getLsbootLan ( connHandle , lsbootDef ) : <EOL> logging . debug ( '<STR_LIT>' ) <EOL> inFilter = FilterFilter ( ) <EOL> wcardFilter = WcardFilter ( ) <EOL> wcardFilter . Class = "<STR_LIT>" <EOL> wcardFilter . Property = "<STR_LIT>" <EOL> wcardFilter . Value = "<STR_LIT>" % lsbootDef . getattr ( "<STR_LIT>" ) <EOL> inFilter . AddChild ( wcardFilter ) <EOL> lsbootLan = connHandle . ConfigResolveClass ( LsbootLan . ClassId ( ) , inFilter , YesOrNo . TRUE , dumpXml = False ) <EOL> if ( lsbootLan . errorCode == <NUM_LIT:0> ) : <EOL> return lsbootLan . OutConfigs . GetChild ( ) <EOL> else : <EOL> logging . debug ( '<STR_LIT>' ) <EOL> pass <EOL> pass <EOL> def getVnicEther ( connHandle , inVnicName , inLsServer ) : <EOL> logging . debug ( '<STR_LIT>' ) <EOL> inFilter = FilterFilter ( ) <EOL> andFilter0 = AndFilter ( ) <EOL> wcardFilter = WcardFilter ( ) <EOL> wcardFilter . Class = VnicEther . ClassId ( ) <EOL> wcardFilter . Property = "<STR_LIT>" <EOL> wcardFilter . Value = "<STR_LIT>" % inLsServer . Dn <EOL> andFilter0 . AddChild ( wcardFilter ) <EOL> eqFilter = EqFilter ( ) <EOL> eqFilter . Class = VnicEther . ClassId ( ) <EOL> eqFilter . Property = "<STR_LIT:name>" <EOL> eqFilter . Value = inVnicName <EOL> andFilter0 . AddChild ( eqFilter ) <EOL> inFilter . AddChild ( andFilter0 ) <EOL> vnicEther = connHandle . ConfigResolveClass ( VnicEther . ClassId ( ) , inFilter , YesOrNo . TRUE , dumpXml = False ) <EOL> if ( vnicEther . errorCode == <NUM_LIT:0> ) : <EOL> return vnicEther . OutConfigs . GetChild ( ) <EOL> return <NUM_LIT:0> <EOL> pass <EOL> def addHostsToCobbler ( connHandle , lsbootDef , inCompServer ) : <EOL> logging . debug ( '<STR_LIT>' ) <EOL> bootLan = getLsbootLan ( connHandle , lsbootDef ) <EOL> for lsbootLan in bootLan : <EOL> if ( ( lsbootLan != <NUM_LIT:0> ) and ( isinstance ( lsbootLan , ManagedObject ) == True ) and ( lsbootLan . classId == "<STR_LIT>" ) ) : <EOL> for imagePath in lsbootLan . GetChild ( ) : <EOL> if ( ( imagePath != <NUM_LIT:0> ) ) : <EOL> server_dn = inCompServer . Dn <EOL> actual_name = server_dn . replace ( '<STR_LIT:/>' , '<STR_LIT:_>' ) <EOL> hostEthIfs = getHostAdaptorEthIf ( connHandle , inCompServer , actual_name , imagePath , inCompServer . getattr ( "<STR_LIT>" ) ) <EOL> pass <EOL> pass <EOL> pass <EOL> pass <EOL> pass <EOL> pass <EOL> def getNodeType ( inHostName ) : <EOL> """<STR_LIT>""" <EOL> if ( inHostName . startswith ( "<STR_LIT>" ) ) : <EOL> return "<STR_LIT>" <EOL> elif ( inHostName . startswith ( "<STR_LIT>" ) ) : <EOL> return "<STR_LIT>" <EOL> pass <EOL> return "<STR_LIT:U+0020>" <EOL> pass <EOL> def createServerPort ( inUcsmHost , portsListStr ) : <EOL> """<STR_LIT>""" <EOL> portList = ast . literal_eval ( portsListStr ) <EOL> logging . debug ( '<STR_LIT>' ) <EOL> logging . debug ( portList [ FabricDceSwSrvEp . PORT_ID ] ) <EOL> logging . debug ( portList [ FabricDceSwSrvEp . SLOT_ID ] ) <EOL> dn = "<STR_LIT>" + portList [ FabricDceSwSrvEp . SWITCH_ID ] + "<STR_LIT>" + portList [ FabricDceSwSrvEp . SLOT_ID ] + "<STR_LIT>" + portList [ FabricDceSwSrvEp . PORT_ID ] <EOL> pDn = "<STR_LIT>" + portList [ EtherPIo . SWITCH_ID ] <EOL> res = { FabricDceSwSrvEp . PORT_ID : portList [ FabricDceSwSrvEp . PORT_ID ] , FabricDceSwSrvEp . ADMIN_STATE : FabricDceSwSrvEp . CONST_ADMIN_STATE_ENABLED , FabricDceSwSrvEp . SLOT_ID : portList [ FabricDceSwSrvEp . SLOT_ID ] } <EOL> addObjectToUcs ( inUcsmHost , pDn , FabricDceSwSrv . ClassId ( ) , FabricDceSwSrvEp . ClassId ( ) , res , dn ) <EOL> pass <EOL> def createMacPool ( inUcsmHost , macpoolListStr ) : <EOL> """<STR_LIT>""" <EOL> macpoolList = ast . literal_eval ( macpoolListStr ) <EOL> logging . debug ( '<STR_LIT>' ) <EOL> pDn = "<STR_LIT>" <EOL> dn = pDn + "<STR_LIT>" + macpoolList [ MacpoolPool . NAME ] <EOL> res = { MacpoolPool . NAME : macpoolList [ MacpoolPool . NAME ] } <EOL> addObjectToUcs ( inUcsmHost , pDn , OrgOrg . ClassId ( ) , MacpoolPool . ClassId ( ) , res , dn ) <EOL> blockDn = dn + "<STR_LIT>" + macpoolList [ MacpoolBlock . FROM ] + "<STR_LIT:->" + macpoolList [ MacpoolBlock . TO ] <EOL> blockStr = { MacpoolBlock . FROM : macpoolList [ MacpoolBlock . FROM ] , MacpoolBlock . TO : macpoolList [ MacpoolBlock . TO ] } <EOL> addObjectToUcs ( inUcsmHost , dn , MacpoolPool . ClassId ( ) , MacpoolBlock . ClassId ( ) , blockStr , blockDn ) <EOL> pass <EOL> def createServiceProfile ( inUcsmHost , serviceprofileListStr ) : <EOL> """<STR_LIT>""" <EOL> logging . debug ( '<STR_LIT>' ) <EOL> serviceprofileList = ast . literal_eval ( serviceprofileListStr ) <EOL> pDn = "<STR_LIT>" <EOL> dn = pDn + "<STR_LIT>" + serviceprofileList [ LsServer . NAME ] <EOL> addObjectToUcs ( inUcsmHost , pDn , OrgOrg . ClassId ( ) , LsServer . ClassId ( ) , serviceprofileList , dn ) <EOL> pass <EOL> def createLsBinding ( inUcsmHost , lsBindingListStr ) : <EOL> """<STR_LIT>""" <EOL> logging . debug ( '<STR_LIT>' ) <EOL> lsBindingList = ast . literal_eval ( lsBindingListStr ) <EOL> pDn = lsBindingList [ '<STR_LIT>' ] <EOL> lsServerDn = pDn + "<STR_LIT>" + lsBindingList [ LsServer . NAME ] <EOL> lsServerList = { LsServer . SRC_TEMPL_NAME : lsBindingList [ LsServer . SRC_TEMPL_NAME ] , LsServer . TYPE : "<STR_LIT>" , LsServer . NAME : lsBindingList [ LsServer . NAME ] } <EOL> addObjectToUcs ( inUcsmHost , pDn , OrgOrg . ClassId ( ) , LsServer . ClassId ( ) , lsServerList , lsServerDn ) <EOL> lsbindDn = lsServerDn + "<STR_LIT>" <EOL> lsbindList = { LsBinding . PN_DN : lsBindingList [ LsBinding . PN_DN ] } <EOL> addObjectToUcs ( inUcsmHost , lsServerDn , LsServer . ClassId ( ) , LsBinding . ClassId ( ) , lsbindList , lsbindDn ) <EOL> pass <EOL> def createComputeAutoconfigPolicy ( inUcsmHost , autoconfigPolicyStr ) : <EOL> """<STR_LIT>""" <EOL> logging . debug ( '<STR_LIT>' ) <EOL> autoconfigPolicyList = ast . literal_eval ( autoconfigPolicyStr ) <EOL> pDn = "<STR_LIT>" <EOL> dn = pDn + "<STR_LIT>" + autoconfigPolicyList [ ComputeAutoconfigPolicy . NAME ] <EOL> addObjectToUcs ( inUcsmHost , pDn , OrgOrg . ClassId ( ) , ComputeAutoconfigPolicy . ClassId ( ) , autoconfigPolicyList , dn ) <EOL> pass <EOL> def createIpPool ( inUcsmHost , ippoolStr ) : <EOL> """<STR_LIT>""" <EOL> logging . debug ( '<STR_LIT>' ) <EOL> poolList = ast . literal_eval ( ippoolStr ) <EOL> pDn = "<STR_LIT>" <EOL> dn = pDn + "<STR_LIT>" + poolList [ IppoolPool . NAME ] <EOL> ippoolList = { IppoolPool . NAME : poolList [ IppoolPool . NAME ] } <EOL> addObjectToUcs ( inUcsmHost , pDn , OrgOrg . ClassId ( ) , IppoolPool . ClassId ( ) , ippoolList , dn ) <EOL> ipblockDn = dn + "<STR_LIT>" + poolList [ IppoolBlock . FROM ] + "<STR_LIT:->" + poolList [ IppoolBlock . TO ] <EOL> ippoolBlockList = { IppoolBlock . DEF_GW : poolList [ IppoolBlock . DEF_GW ] , IppoolBlock . FROM : poolList [ IppoolBlock . FROM ] , IppoolBlock . TO : poolList [ IppoolBlock . TO ] , IppoolBlock . PRIM_DNS : poolList [ IppoolBlock . PRIM_DNS ] , IppoolBlock . SEC_DNS : poolList [ IppoolBlock . SEC_DNS ] , IppoolBlock . SUBNET : poolList [ IppoolBlock . SUBNET ] } <EOL> addObjectToUcs ( inUcsmHost , dn , IppoolPool . ClassId ( ) , IppoolBlock . ClassId ( ) , ippoolBlockList , ipblockDn ) <EOL> pass <EOL> def createVnicEther ( inUcsmHost , vnicInfoStr ) : <EOL> """<STR_LIT>""" <EOL> logging . debug ( '<STR_LIT>' ) <EOL> vnicInfoList = ast . literal_eval ( vnicInfoStr ) <EOL> pDn = "<STR_LIT>" + vnicInfoList [ "<STR_LIT>" ] <EOL> vnicEtherDn = pDn + "<STR_LIT>" + vnicInfoList [ VnicEther . NAME ] <EOL> vnicEtherOrder = VnicEther . CONST_ORDER_UNSPECIFIED <EOL> if VnicEther . ORDER in vnicInfoList . keys ( ) : <EOL> logging . debug ( '<STR_LIT>' % ( vnicInfoList [ VnicEther . ORDER ] ) ) <EOL> vnicEtherOrder = vnicInfoList [ VnicEther . ORDER ] <EOL> pass <EOL> vnicEtherList = { VnicEther . NAME : vnicInfoList [ VnicEther . NAME ] , VnicEther . SWITCH_ID : vnicInfoList [ VnicEther . SWITCH_ID ] , VnicEther . IDENT_POOL_NAME : vnicInfoList [ VnicEther . IDENT_POOL_NAME ] , VnicEther . ORDER : vnicEtherOrder } <EOL> addObjectToUcs ( inUcsmHost , pDn , LsServer . ClassId ( ) , VnicEther . ClassId ( ) , vnicEtherList , vnicEtherDn ) <EOL> vnicEtherIfDn = vnicEtherDn + "<STR_LIT>" + vnicInfoList [ "<STR_LIT>" ] <EOL> vnicEtherIfList = { VnicEtherIf . NAME : vnicInfoList [ "<STR_LIT>" ] , VnicEtherIf . DEFAULT_NET : vnicInfoList [ VnicEtherIf . DEFAULT_NET ] } <EOL> addObjectToUcs ( inUcsmHost , vnicEtherDn , VnicEther . ClassId ( ) , VnicEtherIf . ClassId ( ) , vnicEtherIfList , vnicEtherIfDn ) <EOL> pass <EOL> def createServerPool ( inUcsmHost , serverPoolStr ) : <EOL> """<STR_LIT>""" <EOL> logging . debug ( '<STR_LIT>' ) <EOL> serverPoolList = ast . literal_eval ( serverPoolStr ) <EOL> pDn = "<STR_LIT>" <EOL> serverPoolDn = pDn + "<STR_LIT>" + serverPoolList [ ComputePool . NAME ] <EOL> poolList = { ComputePool . NAME : serverPoolList [ ComputePool . NAME ] } <EOL> addObjectToUcs ( inUcsmHost , pDn , OrgOrg . ClassId ( ) , ComputePool . ClassId ( ) , poolList , serverPoolDn ) <EOL> pass <EOL> def createComputeQual ( inUcsmHost , computeQualStr ) : <EOL> """<STR_LIT>""" <EOL> logging . debug ( '<STR_LIT>' ) <EOL> computeQualList = ast . literal_eval ( computeQualStr ) <EOL> pDn = "<STR_LIT>" <EOL> computeQualDn = pDn + "<STR_LIT>" + computeQualList [ ComputeQual . NAME ] <EOL> computeQualStr = { ComputeQual . NAME : computeQualList [ ComputeQual . NAME ] } <EOL> addObjectToUcs ( inUcsmHost , pDn , OrgOrg . ClassId ( ) , ComputeQual . ClassId ( ) , computeQualStr , computeQualDn ) <EOL> computeChassisQualStr = { ComputeChassisQual . MIN_ID : computeQualList [ ComputeChassisQual . MIN_ID ] , ComputeChassisQual . MAX_ID : computeQualList [ ComputeChassisQual . MAX_ID ] } <EOL> computeChassisQualDn = computeQualDn + "<STR_LIT>" + computeQualList [ ComputeChassisQual . MIN_ID ] + "<STR_LIT>" + computeQualList [ ComputeChassisQual . MAX_ID ] <EOL> addObjectToUcs ( inUcsmHost , computeQualDn , ComputeQual . ClassId ( ) , ComputeChassisQual . ClassId ( ) , computeChassisQualStr , computeChassisQualDn ) <EOL> logging . debug ( "<STR_LIT>" + computeQualDn ) <EOL> i = int ( computeQualList [ ComputeChassisQual . MIN_ID ] ) <EOL> while i <= ( int ( computeQualList [ ComputeChassisQual . MAX_ID ] ) ) : <EOL> computeSlotQualDn = computeChassisQualDn + "<STR_LIT>" + computeQualList [ "<STR_LIT>" ] + "<STR_LIT>" + computeQualList [ "<STR_LIT>" ] <EOL> computeSlotQualList = { ComputeSlotQual . MIN_ID : computeQualList [ "<STR_LIT>" ] , ComputeSlotQual . MAX_ID : computeQualList [ "<STR_LIT>" ] } <EOL> logging . debug ( "<STR_LIT>" + computeChassisQualDn ) <EOL> addObjectToUcs ( inUcsmHost , computeChassisQualDn , ComputeChassisQual . ClassId ( ) , ComputeSlotQual . ClassId ( ) , computeSlotQualList , computeSlotQualDn ) <EOL> i += <NUM_LIT:1> <EOL> pass <EOL> pass <EOL> def createComputeQualRack ( inUcsmHost , computeQualRackStr ) : <EOL> """<STR_LIT>""" <EOL> logging . debug ( '<STR_LIT>' ) <EOL> computeQualRackList = ast . literal_eval ( computeQualRackStr ) <EOL> pDn = "<STR_LIT>" <EOL> computeQualRackDn = pDn + "<STR_LIT>" + computeQualRackList [ ComputeQual . NAME ] <EOL> computeQualRackStr = { ComputeQual . NAME : computeQualRackList [ ComputeQual . NAME ] } <EOL> addObjectToUcs ( inUcsmHost , pDn , OrgOrg . ClassId ( ) , ComputeQual . ClassId ( ) , computeQualRackStr , computeQualRackDn ) <EOL> computeChassisQualRackStr = { ComputeRackQual . MIN_ID : computeQualRackList [ ComputeRackQual . MIN_ID ] , ComputeRackQual . MAX_ID : computeQualRackList [ ComputeRackQual . MAX_ID ] } <EOL> computeChassisQualRackDn = computeQualRackDn + "<STR_LIT>" + computeQualRackList [ "<STR_LIT>" ] + "<STR_LIT>" + computeQualRackList [ "<STR_LIT>" ] <EOL> addObjectToUcs ( inUcsmHost , computeQualRackDn , ComputeQual . ClassId ( ) , ComputeRackQual . ClassId ( ) , computeChassisQualRackStr , computeChassisQualRackDn ) <EOL> pass <EOL> def createComputePoolingPolicy ( inUcsmHost , computePoolingPolicyStr ) : <EOL> """<STR_LIT>""" <EOL> logging . debug ( '<STR_LIT>' ) <EOL> computePoolingPolicyList = ast . literal_eval ( computePoolingPolicyStr ) <EOL> pDn = "<STR_LIT>" <EOL> computePoolingPolicyDn = pDn + "<STR_LIT>" + computePoolingPolicyList [ ComputePoolingPolicy . NAME ] <EOL> addObjectToUcs ( inUcsmHost , pDn , OrgOrg . ClassId ( ) , ComputePoolingPolicy . ClassId ( ) , computePoolingPolicyList , computePoolingPolicyDn ) <EOL> pass <EOL> def createComputeScrubPolicy ( inUcsmHost , computeScrubgPolicyStr ) : <EOL> """<STR_LIT>""" <EOL> logging . debug ( '<STR_LIT>' ) <EOL> computeScrubPolicyList = ast . literal_eval ( computeScrubgPolicyStr ) <EOL> pDn = "<STR_LIT>" <EOL> computeScrubgPolicyDn = pDn + "<STR_LIT>" + computeScrubPolicyList [ ComputeScrubPolicy . NAME ] <EOL> addObjectToUcs ( inUcsmHost , pDn , OrgOrg . ClassId ( ) , ComputeScrubPolicy . ClassId ( ) , computeScrubPolicyList , computeScrubgPolicyDn ) <EOL> pass <EOL> def createVlan ( inUcsmHost , fabricVlanStr ) : <EOL> """<STR_LIT>""" <EOL> logging . debug ( '<STR_LIT>' ) <EOL> fabricVlanList = ast . literal_eval ( fabricVlanStr ) <EOL> pDn = "<STR_LIT>" <EOL> fabricVlanDn = pDn + "<STR_LIT>" + fabricVlanList [ FabricVlan . NAME ] <EOL> vlanIds = fabricVlanList [ FabricVlan . ID ] <EOL> ids = vlanIds . rsplit ( '<STR_LIT:->' ) <EOL> if ( len ( ids ) == <NUM_LIT:2> ) : <EOL> for i in range ( int ( ids [ <NUM_LIT:0> ] ) , int ( ids [ <NUM_LIT:1> ] ) ) : <EOL> fabricVlanRes = { FabricVlan . NAME : "<STR_LIT>" + str ( i ) , FabricVlan . ID : i , FabricVlan . SHARING : '<STR_LIT:none>' , FabricVlan . DEFAULT_NET : '<STR_LIT>' } <EOL> addObjectToUcs ( inUcsmHost , pDn , FabricLanCloud . ClassId ( ) , FabricVlan . ClassId ( ) , fabricVlanRes , fabricVlanDn ) <EOL> pass <EOL> else : <EOL> fabricVlanRes = { FabricVlan . NAME : fabricVlanList [ FabricVlan . NAME ] , FabricVlan . ID : fabricVlanList [ FabricVlan . ID ] , FabricVlan . SHARING : fabricVlanList [ FabricVlan . SHARING ] , FabricVlan . DEFAULT_NET : fabricVlanList [ FabricVlan . DEFAULT_NET ] } <EOL> addObjectToUcs ( inUcsmHost , pDn , FabricLanCloud . ClassId ( ) , FabricVlan . ClassId ( ) , fabricVlanRes , fabricVlanDn ) <EOL> pass <EOL> pass <EOL> def createSPInstance ( inUcsmHost , lsServerInstancesStr ) : <EOL> """<STR_LIT>""" <EOL> logging . debug ( '<STR_LIT>' ) <EOL> lsServerInstancesList = ast . literal_eval ( lsServerInstancesStr ) <EOL> handle = UcsHandle ( ) <EOL> login = handle . Login ( inUcsmHost . hostname , inUcsmHost . username , inUcsmHost . password ) <EOL> if ( login == False ) : <EOL> logging . debug ( '<STR_LIT>' ) <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> resMos = handle . GetManagedObject ( None , LsServer . ClassId ( ) , { "<STR_LIT:Name>" : lsServerInstancesList [ '<STR_LIT>' ] } , dumpXml = inUcsmHost . debug ) <EOL> if resMos : <EOL> for spMo in resMos : <EOL> handle . LsInstantiateNTemplate ( spMo . getattr ( LsServer . DN ) , lsServerInstancesList [ '<STR_LIT>' ] , lsServerInstancesList [ '<STR_LIT>' ] , lsServerInstancesList [ '<STR_LIT>' ] , dumpXml = True ) <EOL> pass <EOL> pass <EOL> pass <EOL> handle . Logout ( ) <EOL> pass <EOL> def createOrgOrg ( inUcsmHost , orgOrgStr ) : <EOL> """<STR_LIT>""" <EOL> logging . debug ( '<STR_LIT>' ) <EOL> orgOrgList = ast . literal_eval ( orgOrgStr ) <EOL> orgOrgListRes = { OrgOrg . NAME : orgOrgList [ '<STR_LIT:Name>' ] } <EOL> pDn = orgOrgList [ '<STR_LIT>' ] <EOL> orgOrgDn = pDn + "<STR_LIT>" + orgOrgList [ '<STR_LIT:Name>' ] <EOL> addObjectToUcs ( inUcsmHost , pDn , OrgOrg . ClassId ( ) , OrgOrg . ClassId ( ) , orgOrgListRes , orgOrgDn ) <EOL> pass <EOL> def createUplink ( inUcsmHost , fabricEthLanEpStr ) : <EOL> """<STR_LIT>""" <EOL> logging . debug ( '<STR_LIT>' ) <EOL> fabricEthLanEpList = ast . literal_eval ( fabricEthLanEpStr ) <EOL> pDn = "<STR_LIT>" + fabricEthLanEpList [ FabricEthLanEp . SWITCH_ID ] <EOL> fabricEthLanEpDn = pDn + "<STR_LIT>" + fabricEthLanEpList [ FabricEthLanEp . SLOT_ID ] + "<STR_LIT>" + fabricEthLanEpList [ FabricEthLanEp . PORT_ID ] <EOL> addObjectToUcs ( inUcsmHost , pDn , FabricEthLan . ClassId ( ) , FabricEthLanEp . ClassId ( ) , fabricEthLanEpList , fabricEthLanEpDn ) <EOL> pass <EOL> def createLsRequirement ( inUcsmHost , lsRequirementStr ) : <EOL> """<STR_LIT>""" <EOL> logging . debug ( '<STR_LIT>' ) <EOL> lsRequirementList = ast . literal_eval ( lsRequirementStr ) <EOL> lsRequirementListRes = { LsRequirement . NAME : lsRequirementList [ LsRequirement . NAME ] , <EOL> LsRequirement . QUALIFIER : lsRequirementList [ LsRequirement . QUALIFIER ] <EOL> } <EOL> pDn = lsRequirementList [ '<STR_LIT>' ] <EOL> lsRequirementDn = pDn + "<STR_LIT>" <EOL> inUcsmHost . debug = True <EOL> addObjectToUcs ( inUcsmHost , pDn , LsServer . ClassId ( ) , LsRequirement . ClassId ( ) , lsRequirementListRes , lsRequirementDn ) <EOL> pass <EOL> def createStorageLocalDiskConfigPolicy ( inUcsmHost , storageLocalDiskConfigPolicyStr ) : <EOL> """<STR_LIT>""" <EOL> logging . debug ( '<STR_LIT>' ) <EOL> storageLocalDiskConfigPolicyList = ast . literal_eval ( storageLocalDiskConfigPolicyStr ) <EOL> pDn = '<STR_LIT>' <EOL> storageLocalDiskConfigPolicyDn = pDn + "<STR_LIT>" + storageLocalDiskConfigPolicyList [ StorageLocalDiskConfigPolicy . NAME ] <EOL> inUcsmHost . debug = True <EOL> addObjectToUcs ( inUcsmHost , pDn , OrgOrg . ClassId ( ) , StorageLocalDiskConfigPolicy . ClassId ( ) , storageLocalDiskConfigPolicyList , storageLocalDiskConfigPolicyDn ) <EOL> pass <EOL> def getClassId ( lsbootPolicyList ) : <EOL> """<STR_LIT>""" <EOL> lClassId = '<STR_LIT:None>' <EOL> if '<STR_LIT>' == lsbootPolicyList [ '<STR_LIT:type>' ] : <EOL> lClassId = LsbootVirtualMedia . ClassId ( ) <EOL> elif '<STR_LIT>' == lsbootPolicyList [ '<STR_LIT:type>' ] : <EOL> lClassId = LsbootStorage . ClassId ( ) <EOL> elif '<STR_LIT>' == lsbootPolicyList [ '<STR_LIT:type>' ] : <EOL> lClassId = LsbootLan . ClassId ( ) <EOL> pass <EOL> logging . debug ( '<STR_LIT>' + lClassId ) <EOL> return lClassId <EOL> pass <EOL> def createLsbootPolicy ( inUcsmHost , lsbootPolicyStr ) : <EOL> """<STR_LIT>""" <EOL> logging . debug ( '<STR_LIT>' + lsbootPolicyStr ) <EOL> lsbootPolicyList = ast . literal_eval ( lsbootPolicyStr ) <EOL> pDn = lsbootPolicyList [ '<STR_LIT>' ] <EOL> lsbootPolicyDn = pDn + "<STR_LIT>" + lsbootPolicyList [ LsbootPolicy . NAME ] <EOL> inUcsmHost . debug = True <EOL> lsbootPolicyResList = { <EOL> LsbootPolicy . NAME : lsbootPolicyList [ LsbootPolicy . NAME ] , LsbootPolicy . PURPOSE : lsbootPolicyList [ LsbootPolicy . PURPOSE ] , LsbootPolicy . REBOOT_ON_UPDATE : lsbootPolicyList [ LsbootPolicy . REBOOT_ON_UPDATE ] , LsbootPolicy . ENFORCE_VNIC_NAME : lsbootPolicyList [ LsbootPolicy . ENFORCE_VNIC_NAME ] , LsbootPolicy . DESCR : lsbootPolicyList [ LsbootPolicy . DESCR ] <EOL> } <EOL> addObjectToUcs ( inUcsmHost , pDn , OrgOrg . ClassId ( ) , LsbootPolicy . ClassId ( ) , lsbootPolicyResList , lsbootPolicyDn ) <EOL> if '<STR_LIT>' in lsbootPolicyList . keys ( ) : <EOL> rnPrefix = lsbootPolicyList [ '<STR_LIT>' ] [ '<STR_LIT>' ] + "<STR_LIT:->" + lsbootPolicyList [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> lsbootVirtualMediaDn = lsbootPolicyDn + "<STR_LIT:/>" + rnPrefix <EOL> lsbootVirtualMediaList = lsbootPolicyList [ '<STR_LIT>' ] <EOL> addObjectToUcs ( inUcsmHost , lsbootPolicyDn , LsbootPolicy . ClassId ( ) , LsbootVirtualMedia . ClassId ( ) , lsbootVirtualMediaList , lsbootVirtualMediaDn ) <EOL> pass <EOL> if '<STR_LIT>' in lsbootPolicyList . keys ( ) : <EOL> rnPrefix = lsbootPolicyList [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> lsbootLanDn = lsbootPolicyDn + "<STR_LIT:/>" + rnPrefix <EOL> lsbootLanImagePathList = lsbootPolicyList [ '<STR_LIT>' ] . pop ( '<STR_LIT>' ) <EOL> lsbootLanList = lsbootPolicyList [ '<STR_LIT>' ] <EOL> addObjectToUcs ( inUcsmHost , lsbootPolicyDn , LsbootPolicy . ClassId ( ) , LsbootLan . ClassId ( ) , lsbootLanList , lsbootLanDn ) <EOL> lsbootLanImagePathDn = lsbootLanDn + "<STR_LIT>" + lsbootLanImagePathList [ '<STR_LIT>' ] <EOL> addObjectToUcs ( inUcsmHost , lsbootLanDn , LsbootLan . ClassId ( ) , LsbootLanImagePath . ClassId ( ) , lsbootLanImagePathList , lsbootLanImagePathDn ) <EOL> pass <EOL> if '<STR_LIT>' in lsbootPolicyList . keys ( ) : <EOL> rnPrefix = lsbootPolicyList [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> lsbootStorageDn = lsbootPolicyDn + "<STR_LIT:/>" + rnPrefix <EOL> lsbootStorageList = lsbootPolicyList [ '<STR_LIT>' ] <EOL> addObjectToUcs ( inUcsmHost , lsbootPolicyDn , LsbootPolicy . ClassId ( ) , LsbootStorage . ClassId ( ) , lsbootStorageList , lsbootStorageDn ) <EOL> lsbootLocalStorageDn = lsbootStorageDn + "<STR_LIT:/>" + "<STR_LIT>" <EOL> addObjectToUcs ( inUcsmHost , lsbootStorageDn , LsbootStorage . ClassId ( ) , LsbootLocalStorage . ClassId ( ) , { } , lsbootLocalStorageDn ) <EOL> pass <EOL> if '<STR_LIT>' in lsbootPolicyList . keys ( ) : <EOL> rnPrefix = lsbootPolicyList [ '<STR_LIT>' ] [ '<STR_LIT>' ] + "<STR_LIT:->" + lsbootPolicyList [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> lsbootVirtualMediaDn = lsbootPolicyDn + "<STR_LIT:/>" + rnPrefix <EOL> lsbootVirtualMediaList = lsbootPolicyList [ '<STR_LIT>' ] <EOL> addObjectToUcs ( inUcsmHost , lsbootPolicyDn , LsbootPolicy . ClassId ( ) , LsbootVirtualMedia . ClassId ( ) , lsbootVirtualMediaList , lsbootVirtualMediaDn ) <EOL> pass <EOL> pass </s>
