如何卸载已经停止的应用程序
How to uninstall an application that is already stopped
问题是,如果应用程序是 "stopped",这将 return 什么都没有。但我还是想卸载它。我不知道应用程序名称,我正在将所有应用程序安装在服务器上,然后将它们全部卸载。
apps = AdminControl.queryNames('type=Application,node=' + nodeName + ',process=' + serverName + ',*').split()
这是我的代码。
serverObj = AdminControl.completeObjectName('type=Server,node=%s,name=%s,*' % (nodeName, serverName))
serverID = AdminConfig.getid('/Node:%s/Server:%s/' % (nodeName, serverName))
if serverID == "":
print "Can't find the server, exiting..."
sys.exit(1)
else:
cellName = AdminControl.getAttribute(serverObj, 'cellName')
#Uninstall Apps
apps = AdminControl.queryNames('type=Application,node=' + nodeName + ',process=' + serverName + ',*').split()
appManager=AdminControl.queryNames('type=ApplicationManager,node=' + nodeName + ',process=,*')
if len(apps) > 0:
for app in apps:
appName = AdminControl.getAttribute(app, 'name')
AdminControl.invoke(appManager,'stopApplication', appName)
print "Uninstalling application: " + appName
AdminApp.uninstall(appName)
else:
print "No applications to uninstall"
您可以使用 AdminApp.list() 获取目标范围的应用程序列表。所以对于服务器范围:
AdminApp.list("WebSphere:cell=yourCellName,node=yourNodeName,servers=yourServerName”)
有了这些信息,您就可以使用 AdminApp.uninstall() 卸载应用程序,例如:
AdminApp.uninstall('NameOfApp')
您可以使用以下代码片段卸载部署在目标服务器上的所有应用程序:
#Get the list of all Apps deployed in target server
installedApps=AdminApp.list("WebSphere:cell=%s,node=%s,server=%s" % (cellName, nodeName, serverName))
#Check if there are any installed Apps on the server
if len (installedApps) > 0:
#if there are installed Apps, iterate through the list and uninstall Apps one by one
for app in installedApps.splitlines():
print "uninstalling "+ app +" ...."
AdminApp.uninstall(app)
#Save the changes
AdminConfig.save()
else:
#if there are no installed Apps, do nothing
print "No applications to uninstall"
问题是,如果应用程序是 "stopped",这将 return 什么都没有。但我还是想卸载它。我不知道应用程序名称,我正在将所有应用程序安装在服务器上,然后将它们全部卸载。
apps = AdminControl.queryNames('type=Application,node=' + nodeName + ',process=' + serverName + ',*').split()
这是我的代码。
serverObj = AdminControl.completeObjectName('type=Server,node=%s,name=%s,*' % (nodeName, serverName))
serverID = AdminConfig.getid('/Node:%s/Server:%s/' % (nodeName, serverName))
if serverID == "":
print "Can't find the server, exiting..."
sys.exit(1)
else:
cellName = AdminControl.getAttribute(serverObj, 'cellName')
#Uninstall Apps
apps = AdminControl.queryNames('type=Application,node=' + nodeName + ',process=' + serverName + ',*').split()
appManager=AdminControl.queryNames('type=ApplicationManager,node=' + nodeName + ',process=,*')
if len(apps) > 0:
for app in apps:
appName = AdminControl.getAttribute(app, 'name')
AdminControl.invoke(appManager,'stopApplication', appName)
print "Uninstalling application: " + appName
AdminApp.uninstall(appName)
else:
print "No applications to uninstall"
您可以使用 AdminApp.list() 获取目标范围的应用程序列表。所以对于服务器范围:
AdminApp.list("WebSphere:cell=yourCellName,node=yourNodeName,servers=yourServerName”)
有了这些信息,您就可以使用 AdminApp.uninstall() 卸载应用程序,例如:
AdminApp.uninstall('NameOfApp')
您可以使用以下代码片段卸载部署在目标服务器上的所有应用程序:
#Get the list of all Apps deployed in target server
installedApps=AdminApp.list("WebSphere:cell=%s,node=%s,server=%s" % (cellName, nodeName, serverName))
#Check if there are any installed Apps on the server
if len (installedApps) > 0:
#if there are installed Apps, iterate through the list and uninstall Apps one by one
for app in installedApps.splitlines():
print "uninstalling "+ app +" ...."
AdminApp.uninstall(app)
#Save the changes
AdminConfig.save()
else:
#if there are no installed Apps, do nothing
print "No applications to uninstall"