createResourceAdapterEntry.py.erb 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import random
  2. wlsUser = '<%= @wlsUser %>'
  3. password = '<%= @password %>'
  4. machine = '<%= @address %>'
  5. portNumber = '<%= @port %>'
  6. eisName = '<%= @adapterEntry %>'
  7. cfName = '<%= @adapterEntryValue %>'
  8. propertyName = '<%= @adapterEntryProperty %>'
  9. connectionFactoryInterface = '<%= @connectionFactoryInterface %>'
  10. appName = '<%= @adapterName %>'
  11. appPath = '<%= @adapterPath %>'
  12. planPath = '<%= @adapterPlanDir %>/<%= @adapterPlan %>'
  13. useStoreConfig = '<%= @useStoreConfig %>'
  14. moduleOverrideName=appName+'.rar'
  15. moduleDescriptorName='META-INF/weblogic-ra.xml'
  16. idRandom=random.randint(10000,100000)
  17. connectionInstance='ConnectionInstance_eis/wls/MyCF_JNDIName_'+str(idRandom)
  18. configProperty='ConfigProperty_ConnectionFactoryLocation_Value_'+str(idRandom)
  19. def makeDeploymentPlanVariable(wlstPlan, name, value, xpath, origin='planbased'):
  20. while wlstPlan.getVariableAssignment(name, moduleOverrideName, moduleDescriptorName):
  21. wlstPlan.destroyVariableAssignment(name, moduleOverrideName, moduleDescriptorName)
  22. while wlstPlan.getVariable(name):
  23. wlstPlan.destroyVariable(name)
  24. variableAssignment = wlstPlan.createVariableAssignment( name, moduleOverrideName, moduleDescriptorName )
  25. variableAssignment.setXpath( xpath )
  26. variableAssignment.setOrigin( origin )
  27. wlstPlan.createVariable( name, value )
  28. def main():
  29. edit()
  30. try:
  31. startEdit()
  32. myPlan=loadApplication(appPath, planPath)
  33. print '___ BEGIN change plan'
  34. makeDeploymentPlanVariable(myPlan, connectionInstance, eisName, '/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="'+connectionFactoryInterface+'"]/connection-instance/[jndi-name="'+ eisName + '"]/jndi-name')
  35. makeDeploymentPlanVariable(myPlan, configProperty, cfName, '/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="'+connectionFactoryInterface+'"]/connection-instance/[jndi-name="'+ eisName + '"]/connection-properties/properties/property/[name="'+propertyName+'"]/value')
  36. print '___ DONE change plan'
  37. myPlan.save();
  38. save();
  39. activate(block='true');
  40. except:
  41. stopEdit('y')
  42. if useStoreConfig != "true":
  43. connect(wlsUser,password,'t3://'+machine+':'+portNumber)
  44. else:
  45. connect(userConfigFile='<%= @userConfigFile %>', userKeyFile='<%= @userKeyFile %>', url='t3://'+machine+':'+portNumber)
  46. main()