首页 > 解决方案 > 如何卸载已停止的应用程序

问题描述

问题是,如果应用程序“停止”,这将不会返回任何内容。但我还是想卸载它。我不知道应用程序名称,我将所有应用程序安装在服务器上,然后将它们全部卸载。

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"

标签: webspherewsadmin

解决方案


您可以使用以下代码段卸载目标服务器上部署的所有应用程序:

#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"


推荐阅读