Hi Herman,
Thanks for giving script,let me check and get back to you.
Appreciate your quick response.
Thanks,
Satish
On Wed, Apr 18, 2018, 15:02 Hermann Huebler <
applicationserver-ws@lists.imwuc.org> wrote:
> Hello Satish,
>
> from you description I'm not 100% sure what you want to change but I
> assume it is the attribute marked in the attaches screen copy.
>
> Regarding you scripting requirements you asked for you have two
> requirements namely
>
> 1. Get the status about the application Servers
> 2. Set the autostart for the applications
>
> *Disclaimer: All code written here is for demonstration purposes only and
> was neither tested nor production ready! So usage is totally at your own
> risk!*
>
> The prototype code for the first requirement should be something like that:
>
> cellName = AdminControl.getCell()
> queryString='WebSphere:type=Server,cell=' + cellName + ',*'
> serverMBeans = AdminControl.queryNames(queryString).split('\n')
> for serverMBean in serverMBeans:
> serverName = AdminControl.getAttribute(serverMBean, 'name')
> serverState = AdminControl.getAttribute(serverMBean, 'state')
> print "Server: %20s ; State: %10s" % (serverName, serverState)
>
> For the second requirement you need to use ApplicationDeployment objects.
> Here I found a problem you might check with support. The problems is the
> following:
>
> print AdminConfig.attributes('ApplicationDeployment')
>
> Contains a *name* attribute .. however when retrieving the objects this
> attribute is always None. So you need to find another way to identify. But
> assuming the name is returned correctly the prototype should be similar to:
>
> appDeployments = AdminConfig.list('ApplicationDeployment').split('\n')
> ## appDeployment = appDeployments[0]
> for appDeployment in appDeployments:
> ## print AdminConfig.showall(appDeployment)
> deploymentTargetMappings = AdminConfig.showAttribute(appDeployment, 'targetMappings').split('\n')
> ## deploymentTargetMappings = AdminConfig.list('DeploymentTargetMapping').split('\n')
> ## deploymentTargetMapping = deploymentTargetMappings[0]
> for deploymentTargetMapping in deploymentTargetMappings:
> singleDeploymentTargetMappings = deploymentTargetMapping[1:-1].split(" ")
> ## singleDeploymentTargetMapping = singleDeploymentTargetMappings[0]
> for singleDeploymentTargetMapping in singleDeploymentTargetMappings:
> deployedObject = AdminConfig.showAttribute(singleDeploymentTargetMapping, 'DeployedObject')
> appName = AdminConfig.showAttribute(appDeployment, 'name')
> binariesURL = AdminConfig.showAttribute(deployedObject, 'binariesURL')
> appIsEnabled = AdminConfig.showAttribute(singleDeploymentTargetMapping, 'enable')
> print "AppName: %20s; binariesURL: %s; appIsEnabled: %5s" % (appName, binariesURL, appIsEnabled)
> ##
> ## Enable the application if it is the selected application
> if (appName == appNameToModify):
> AdminConfig.modify(deploymentTargetMapping, [['enable', 'true']])
>
> if (AdminConfig.hasChanges()):
> AdminConfig.save()
> else:
> print "No changes ... not saved!"
>
>
> -----End Original Message-----
>