用于weblogic rest api的python客户机
wls-rest-python的Python项目详细描述
这是一个用于weblogics restful管理服务的python客户端。 它使用api来处理一些怪癖,而不必如此接近 联系到它变成了限制。
它根据服务器的响应动态创建python对象, 这样就很容易快速编写有用的pythonic脚本。
它是根据12.2.1.3进行测试的,但在所有12C R2版本中都可以正常工作。
安装
$ pipenv install wls-rest-python
示例用法
浏览API,更改属性并取消部署应用程序:
>>>fromwls_rest_pythonimportWLS>>>>>>wls=WLS('https://wls.example.com:7001','weblogic','welcome1')>>>>>>dir(wls.edit.batchConfig)['canonical','dynamicallyCreated','id','identity','name','notes','parent','schemaName','self','tags','type']>>>>>>wls.edit.servers.myServer.nativeIOEnabledTrue>>>wls.edit.servers.myServer.update(nativeIOEnabled=False)>>>wls.edit.servers.myServer.nativeIOEnabledFalse>>>wls.domainRuntime.deploymentManager.appDeploymentRuntimes.myApp.getState(...target='myServer'){'return':'STATE_ACTIVE'}>>>>>>wls.domainRuntime.deploymentManager.appDeploymentRuntimes.myApp.undeploy()>>>
异步启动所有托管服务器:
fromwls_rest_pythonimportWLSwls=WLS('https://wls.example.com:7001','weblogic','welcome1')admin_server_name=wls.edit.adminServerNamerunning_jobs=[]forserverinwls.domainRuntime.serverLifeCycleRuntimes:ifserver.name!=admin_server_name:running_jobs.append(server.start(prefer_async=True))whilerunning_jobs:forjobinrunning_jobs:ifjob.completed:running_jobs.remove(job)time.sleep(10)
取消部署所有应用程序并部署新的应用程序:
importjsonfromwls_rest_pythonimportWLSwls=WLS('https://wls.example.com:7001','weblogic','welcome1')fordeploymentinwls.edit.appDeployments:deployment.delete()deployment_model={'name':'myWebApp','targets':[{'identity':['servers','myServer']}]}deployment_info={'model':(None,json.dumps(deployment_model)),'sourcePath':open('/u01/wars/myWebApp.war','rb'),'planPath':open('/u01/wars/myWebAppPlan.xml','rb')}wls.edit.appDeployments.create(files=deployment_info)