websphere - WebSphere 8 获取 ClusterName,将 AppName 作为输入
问题描述
我有一些在 WebSphere - Java 8 上运行的应用程序。
有没有办法只使用 jython 命令来获取应用程序正在运行的集群,并将应用程序名称作为输入?
例如应用程序名称:myApp Cluster myApp 运行:?
目标是创建一个脚本来在集群上进行涟漪启动,只需将应用程序名称作为输入。
解决方案
正如 covener 所指出的,使用 wsadminlib.py 中的函数是最简单的选择。它还带有许多其他实用功能。
但是,如果您不想在项目中使用 wsadminlib.py 并且正在寻找快速解决方案,那么下面的代码段将起作用:
#Define the app name here or pass it as input
appName='DUMMY_APP_NAME'
#Get the app deployment ID
depId = AdminConfig.getid('/Deployment:%s/' % ( appName ))
#Get the deployment target details and convert it to a list
depTargetList = AdminUtilities.convertToList(AdminConfig.showAttribute(depId, 'deploymentTargets'))
#iterate the list and find the target details and print the result
for depTarget in depTargetList:
targetName = AdminConfig.showAttribute(depTarget, 'name')
print 'App %s is deployed to %s' %(appName, targetName)
#end for
您可以通过检查目标是集群还是服务器来进一步细化结果,如下所示:
for depTarget in depTargetList:
targetName = AdminConfig.showAttribute(depTarget, 'name')
if depTarget.find('ClusteredTarget') != -1:
targetType = 'Cluster'
else:
targetType = 'Server'
#end if
print 'App %s is deployed to %s: %s' %(appName, targetType, targetName)
#end for
推荐阅读
- javascript - 提交时验证失败
- c# - 你如何像按钮发送者一样制作keydown
- javascript - 如何使 jquery 滚动效果在多个元素/类上起作用?
- javascript - JS -> 从另一个函数访问变量
- ios - 错误:ITMS-90034:缺少或无效的签名未使用 Apple 提交证书进行签名
- opengl - GLSL片段着色器 - 绘制简单的粗曲线
- php - PHP 中 $var === 1 和 $var === TRUE 之间的区别
- java - 在二维数组中查找到拐角的最短路径
- sql-server - 更新 1 Sum + Value SQL Server vb.net
- json - 在 laravel 中以 json 数据的形式从验证器发出响应