def createTopic(theJMSResource, topicname, jms_module_path):
    print "Creating Conn@ct Topic..."
    ref = wl.getMBean(jms_module_path + "/Topics/" + topicname.strip())
    if ref == None:
        jmstopic = theJMSResource.createTopic(topicname.strip())
        jmstopic.setJNDIName("jms." + topicname.strip())
    else:
        print "Topic " + topicname + " already exists in " + ref.toString()
def createQueue(theJMSResource, queuename, jms_module_path):
    print "Creating Conn@ct Queues..."
    ref = wl.getMBean(jms_module_path + "/Queues/" + queuename.strip())
    if ref == None:
        jmsqueue = theJMSResource.createQueue(queuename.strip())
        jmsqueue.setJNDIName("jms." + queuename.strip())
    else:
        print "Queue " + queuename + " already exists in " + ref.toString()
    topicList = topics.split(",")
    for t in topicList:
        createTopic(theJMSResource, t, jms_module_path)


print "Python version = " + sys.version
print "Connecting to the server ..."
wl.connect("weblogic", "welcome1", "t3://localhost:7021")
wl.edit()
wl.startEdit()
# set('CompatibilityMBeanServerEnabled', 'true')
print "Show command line arguments"
print "Argument List:", str(sys.argv)
checkParams()

servermb = wl.getMBean("Servers/" + adminServer)
if servermb is None:
    print "servermb Value is Null"

else:
    createJMS()

try:
    # wl.serverRuntime()
    wl.save()
    wl.activate(block="true")
    importSecuritySettings()
    print "script returns SUCCESS"
except:
    print "Error while trying to save and/or activate!!!"
    dumpStack()
	print "Creating OSBListenTopic..."
	jmsqueue1 = theJMSResource.createTopic('OSBListenTopic')
	jmsqueue1.setJNDIName('jms.OSBListenTopic')
	jmsqueue1.setSubDeploymentName('OSBSamplesJMSSubdeploy')
	
	print "Creating OSBWriteTopic..."
	jmsqueue1 = theJMSResource.createTopic('OSBWriteTopic')
	jmsqueue1.setJNDIName('jms.OSBWriteTopic')
	jmsqueue1.setSubDeploymentName('OSBSamplesJMSSubdeploy')
	
	
print "Connecting to the server ..."
wl.connect('weblogic','welcome1','t3://localhost:7021')
wl.edit()
wl.startEdit()
# set('CompatibilityMBeanServerEnabled', 'true')

servermb=wl.getMBean("Servers/ServiceBusSamples")
if servermb is None:
    print 'servermb Value is Null'

else:
	createJMS()
   
try:
    wl.save()
    wl.activate(block="true")
    print "script returns SUCCESS"   
except:
    print "Error while trying to save and/or activate!!!"
    dumpStack()