The problem is that if the application is "stopped" this will return nothing. But i still want to uninstall it anyway. I don't know the application name, i'm getting all applications installed on a Server and then uninstalling them all.
apps = AdminControl.queryNames('type=Application,node=' + nodeName + ',process=' + serverName + ',*').split()
Here is my code.
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"
You can use the below snippet to uninstall all Apps deployed on the target server:
#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"
You can use AdminApp.list() to obtain the list of apps for a target scope. So for server scope:
AdminApp.list("WebSphere:cell=yourCellName,node=yourNodeName,servers=yourServerName”)
With that information, you can then use AdminApp.uninstall() to uninstall the app, for example:
AdminApp.uninstall('NameOfApp')
Related
I'm using WebSphere 7.0.0.37 and jython
I need to change the 'Container-managed authentication alias', unfortunatelly I can't find anything in API, inspecting attributes of existing DataSources or any example for that task.
I have succesfully changed the 'composant-managed authentication alias' with:
AdminConfig.modify(DataSourceProvider, '[[name "basename"] [authDataAlias "' + nameNode + '/' + aliasJaas + '" ] ')
How can i do that?
thank you!
Here is some logic which you could use to solve your problem.
# Create new alias
cellName = AdminConfig.showAttribute(AdminConfig.list("Cell"), "name")
security = AdminConfig.getid('/Cell:' + cellName + '/Security:/')
myAlias = 'blahAlias'
user = 'blah'
pswd = 'blah'
jaasAttrs = [['alias', myAlias], ['userId', user], ['password', pswd ]]
print AdminConfig.create('JAASAuthData', security, jaasAttrs)
print "Alias = " + myAlias + " was created."
# Get a reference to your DataSource (assume you know how to do this):
myDS = ...
# Set new alias on DataSource
AdminConfig.modify('MappingModule', myDS, '[[authDataAlias ' + myAlias + '] [mappingConfigAlias DefaultPrincipalMapping]]')
Note that if you can figure out how to do a given task in the Admin Console, you can use the "Command Assist" function to get a Jython snippet to do the equivalent via wsadmin. See here.
How can I get a list of installed VisualStudio extensions? Somehow through DTE? Just the names would be fair enough.
Does this help:
System.IServiceProvider serviceProvider = package as System.IServiceProvider;
Microsoft.VisualStudio.ExtensionManager.IVsExtensionManager em =
(Microsoft.VisualStudio.ExtensionManager.IVsExtensionManager)serviceProvider.GetService(
typeof(Microsoft.VisualStudio.ExtensionManager.SVsExtensionManager));
string result = "";
foreach(Microsoft.VisualStudio.ExtensionManager.IInstalledExtension i in em.GetInstalledExtensions())
{
Microsoft.VisualStudio.ExtensionManager.IExtensionHeader h = i.Header;
if (!h.SystemComponent)
result += h.Name + " (by " + h.Author + ") v" + h.Version + " " + h.MoreInfoUrl + System.Environment.NewLine;
}
Copied from https://vlasovstudio.com/visual-commander/commands.html #20.
Another possibility, if you don't want DTE, because you are not running from within Visual Studio or are concerned about performance you can query the extensions from the file system / registry:
For User Extensions
%LocalAppData%\Microsoft\VisualStudio*.vsix
For General Extensions
\Common7\IDE\Extensions*.vsix
IF you want to be 100% correct you can look up the paths in
\Common7\IDE\devenv.pkgdef
NOTE: There can be additional paths in the PkgDefSearchPath.
To check wether a User Extensions is enabled or not you have to query the registry:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\ExtensionManager\EnabledExtensions
There are some other rules that apply, which you can find in this blog from Microsoft:
http://blogs.msdn.com/b/visualstudio/archive/2010/02/19/how-vsix-extensions-are-discovered-and-loaded-in-vs-2010.aspx
Based on IBM documentation, I wrote a jython script that adds shared libs to an existing application.
# Application name
app = sys.argv[0]
dep = AdminConfig.getid('/Deployment:' + app + '/')
depObject = AdminConfig.showAttribute(dep, 'deployedObject')
classldr = AdminConfig.showAttribute(depObject, 'classloader')
for x in range(1, len(sys.argv)):
AdminConfig.create('LibraryRef', classldr,
[['libraryName', sys.argv[x]], ['sharedClassloader', 'true']])
AdminConfig.save()
Unfortunately, this is setting the shared library only for the application and not for the modules. How could I achieve setting the libraries for both ?
I tried to get the modules of an application but I cannot get the classloader of it.
BTW, what is the sharedClassloader attributes used for ?
Note: I know this is bad practice, but I inherited a bunch of legacy applications, so please don't advice to get rid of shared libs or to add a deployment.xml
Well, here is the working script addSharedLibrary.py <application-name> shared-lib [shared-lib...]
def addSharedLibrary(holder):
classldr = AdminConfig.showAttribute(holder, 'classloader')
for x in range(1, len(sys.argv)):
AdminConfig.create('LibraryRef', classldr, [['libraryName', sys.argv[x]], ['sharedClassloader', 'true']])
def handleWebModules(applicationName):
webModules = AdminConfig.list('WebModuleDeployment').split('\n')
for webModule in webModules:
if (webModule.find(applicationName) != -1):
print 'Setting for ' + webModule
addSharedLibrary(webModule)
dep = AdminConfig.getid('/Deployment:' + sys.argv[0] + '/')
addSharedLibrary(AdminConfig.showAttribute(dep, 'deployedObject'))
handleWebModules(app)
AdminConfig.save()
I think a good way to accomplish this is to create a shared library at the server level, and then create a classloader also on the server level in order to load the libraries.
set serv [$AdminConfig getid /Cell:mycell/Node:mynode/Server:server1/]
print AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'], ['classPath',
'home/myProfile/mySharedLibraryClasspath']])
AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'],
['classPath','test1.jar;test2.jar;test3.jar']])
appServer = AdminConfig.list('ApplicationServer', serv)
print appServer
classLoad = AdminConfig.showAttribute(appServer, 'classloaders')
cleanClassLoaders = classLoad[1:len(classLoad)-1]
classLoader1 = cleanClassLoaders.split(' ')[0]
classLoader1 = AdminConfig.create('Classloader', appServer, [['mode', 'PARENT_FIRST']])
print AdminConfig.create('LibraryRef', classLoader1, [['libraryName', 'MyshareLibrary']])
AdminConfig.save()
AdminNodeManagement.syncActiveNodes()
Thanks poussma for your jython script, it works on the previous version of WAS...
so i adjusted your code to make it work also on WAS8 :
Run the cmd line with : addSharedLibrary.py <application-name> [shared-lib...]
def addSharedLibrary(holder):
classldr = AdminConfig.showAttribute(holder, 'classloader')
for x in range(1, len(sys.argv)):
AdminConfig.create('LibraryRef', classldr, [['libraryName', sys.argv[x]], ['sharedClassloader', 'true']])
def handleWebModules(applicationName):
webModules = AdminConfig.list('WebModuleDeployment').split('\r')
webModules = map(lambda s: s.strip(), webModules)
for webModule in webModules:
if (webModule.find(applicationName+'.ear') != -1):
print 'Setting for ' + webModule
addSharedLibrary(webModule)
dep = AdminConfig.getid('/Deployment:' + sys.argv[0] + '/')
addSharedLibrary(AdminConfig.showAttribute(dep, 'deployedObject'))
handleWebModules(sys.argv[0])
AdminConfig.save()
I have a jython script to create a server, deploy and application and then start the server.
But I am geeting the following exception while running it.
WASX7017E: Exception received while running file "myfile.py"; exception information: javax.management.MBeanException[[ com.ibm.websphere.management.exception.AdminException: Server, SERVERNAME, not found.
Here is the entire code... http://snipt.org/BMaf4
Update: He is the entire log http://snipt.org/BNZ1
Can't figure out where I am going wrong.
But When I am issuing a start all servers in wsadminlib.. the server gets started
The problem might be in the way how you deploying and/or configuring your application.
# Your script sample
# Deploy the WAR
APP_PATH= APP_HOME + '/MYAPP/CycleWAR/war/MYAPPCycle.war'
ARGS_LIST='.....'
AdminApp.install(APP_PATH, ARGS_LIST)
You need to add another parameter into your arguments list ARGS_LIST : args = "[-server " + SERVER_NAME + "]"
# Since 6.0.X version
# Server Deployment
args = "[-server " + serverName + "]"
# Cluster Deployment
# args = "[-cluster " + clusterName + "]"
AdminApp.install(applicationFilePath, args)
After the server configurations...
#Sync the Nodes
Sync1 = AdminControl.completeObjectName( "type=NodeSync,node="+ NODE_NAME +",*")
print "Getting Sync Info.. " + "\n" + Sync1
AdminControl.invoke(Sync1, 'sync')
print NODE_NAME + " Sync Completed.. "
We have to sync the nodes first before trying to start the server.
In my exisiting visual basic 6 application I was connecting to an ftp site. Now the other side changed protocol to ftps and changed the port to 22.
My code do not work properly. I get error vb FTP run-time error '35753' "protocol not supported for this method".
I only changed the port in my code and the url
my old url was like ftp.xxx.com.tr
I changed the url to
sftps://ftp.xxx.com.tr
I am trying to connect to the same location using filezilla and it changes the url to sftps://ftp.xxx.com.tr so I copied it. There are similar questions in stackover (Transfer PDF file to ftp server in MS access 2007) but not for ftps. This is my code
With xControl
.AccessType = icDirect
.Protocol = icFTP
.RemotePort = 22
.RequestTimeout = 50
.url = xURL
.UserName = xUserName
.Password = xPassword
.Cancel
.Execute , "DIR " & xFileName
Do While .StillExecuting
DoEvents: DoEvents: DoEvents
Loop
gLogonFtp = "Connected to Host"
End With
Thank you for your time,
Ferda
I used psftp as – wqw (Mar 11 at 13:53) suggested on his comment. Here is my new code.
This is my script file
cd to_remotedir
lcd C:\path2 'local dir
mget * *
quit
result = ChangeFileContent("*", xOnlyFileName) //here I change the content of my script file psftpcommand.bat to get a specific file
Sleep 1000
Shell "C:/path/psftp.exe -v -pw " & xPassword & " " & xUserName & "#" & xURL & ":22 -b C:/path/psftpcommands.bat"
Sleep 1000
result = ChangeFileContent(xOnlyFileName, "*")//here I rechanged the content of the file. Change file name to ->*
'In the below I check if the requested file has come
Sleep 1000
If Dir("C:\path2\" & xOnlyFileName) <> "" Then
gLogonFtp = "Successful"
frmDataTransfers.lblTransferInfoDownLoad.Caption = "Dosya Çekildi " & xOnlyFileName
frmDataTransfers.lblTransferInfoDownLoad.Refresh
End If
That's all.
Thank you for your help.
Ferda