createCoherenceCluster.py.erb 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # for weblogic 12.1.2
  2. wlsUser = '<%= @wlsUser %>'
  3. password = '<%= @password %>'
  4. machine = '<%= @address %>'
  5. portNumber = '<%= @port %>'
  6. # coherence_cluster_name,target,targetType,storage_enabled,unicast_address,unicast_port,multicast_address,multicast_port,machines
  7. <% @params.each do |param| -%>
  8. <%= param %>
  9. <% end -%>
  10. useStoreConfig = '<%= @useStoreConfig %>'
  11. if useStoreConfig != "true":
  12. connect(wlsUser,password,'t3://'+machine+':'+portNumber)
  13. else:
  14. connect(userConfigFile='<%= @userConfigFile %>', userKeyFile='<%= @userKeyFile %>', url='t3://'+machine+':'+portNumber)
  15. edit()
  16. startEdit()
  17. try:
  18. cd('/')
  19. print 'Create Coherence Cluster';
  20. coherence_cluster = cmo.createCoherenceClusterSystemResource(coherence_cluster_name);
  21. coherence_cluster_resource = coherence_cluster.getCoherenceClusterResource();
  22. coherence_cluster_params = coherence_cluster_resource.getCoherenceClusterParams();
  23. coherence_cluster_params.setUnicastListenAddress(unicast_address);
  24. coherence_cluster_params.setUnicastListenPort(unicast_port);
  25. coherence_cluster_params.setUnicastPortAutoAdjust(true);
  26. coherence_cluster_params.setMulticastListenAddress(multicast_address);
  27. coherence_cluster_params.setMulticastListenPort(multicast_port);
  28. print 'Add known Coherence Cluster addresses';
  29. for i in range(len(machines)):
  30. cd('/CoherenceClusterSystemResources/' + coherence_cluster_name + '/CoherenceClusterResource/' + coherence_cluster_name + '/CoherenceClusterParams/' + coherence_cluster_name + '/CoherenceClusterWellKnownAddresses/' + coherence_cluster_name);
  31. cmo.createCoherenceClusterWellKnownAddress('address_' + machines[i] + '_' + repr(unicast_port));
  32. address = cmo.lookupCoherenceClusterWellKnownAddress('address_' + machines[i] + '_' + repr(unicast_port));
  33. address.setListenPort(unicast_port);
  34. address.setListenAddress(machines[i]);
  35. cd('/');
  36. print 'target Coherence Cluster/Server';
  37. target_path = getPath('com.bea:Name=' + target + ',Type='+targetType);
  38. print target_path;
  39. target_mbean = getMBean(target_path);
  40. target_mbean.setCoherenceClusterSystemResource(coherence_cluster);
  41. target_mbean.getCoherenceTier().setLocalStorageEnabled(storage_enabled);
  42. coherence_cluster.addTarget(target_mbean);
  43. save()
  44. activate()
  45. except:
  46. print "Unexpected error:", sys.exc_info()[0]
  47. undo('true','y')
  48. stopEdit('y')
  49. raise