Server Not Found Exception in wsadmin - websphere

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.

Related

How do I use the results of an SSM port forwarding session started with ruby?

I'm having trouble reconciling the differences between using the aws cli and the ruby sdk to make ssm connections to an instance. For example, if I try using the command like like this:
aws ssm start-session \
--target 'i-abc123' \
--document-name AWS-StartPortForwardingSession \
--parameters '{
"portNumber": ["3000"],
"localPortNumber": ["13000"]
}'
Starting session with SessionId: username-def456
Port 13000 opened for sessionId username-def456.
Waiting for connections...
Connection accepted for session [username-def456]
the tool will pause as it opens up a port forwarding session from port 3000 on the destination instance to port 13000 on my local machine. I can then open up a web browser on my machine and point it at http://localhost:13000 to browse around an app running on the remote instance. Also, I can look at the AWS console UI and see that there's an active session until I Ctrl-C
The trouble I'm having is when I try to use the ruby sdk to do the same thing:
result = ssm.start_session(
target: 'i-abc123',
document_name: 'AWS-StartPortForwardingSession',
parameters: {
'portNumber' => %w[3000],
'localPortNumber' => %w[13000]
}
)
The result object is a struct that looks like the following:
=> #<struct Aws::SSM::Types::StartSessionResponse
session_id="username-def456",
token_value="...",
stream_url="wss://ssmmessages.us-east-1.amazonaws.com/v1/data-channel/username-def456?
role=publish_subscribe">
Again, I can see in the console UI that there is an active session. However, if I try to browse to http://localhost:13000 on my machine, the browser can't reach anything. How do I use the resulting stream url and token to actually create a connection to the ec2 instance?
additional details:
core gem version for the ruby sdk: 3.109.2
aws cli version - aws-cli/2.1.16
aws ssm agent version - amazon-ssm-agent-3.0.356.0-1.x86_64
What you get back from the API is a reference to a web socket.
So you either need to create your own web socket to local listener proxy or use the session-manager-plugin as the aws cli utility does.
I recently figured out how to use the session-manager-plugin, the following snippet is Python but should be obvious enough to figure it out.
def start_aws_ssm_plugin(self, create_session_response, parameters, profile, region):
print('start_aws_ssm_plugin() called: ' + str( create_session_response))
arg0 = '"' + self.config.get_ssm_plugin() + '"'
arg1 = '"' + str(create_session_response).replace('\'', '\\"') + '"'
arg2 = region
arg3 = 'StartSession'
arg4 = profile
arg5 = '"' + str(parameters).replace('\'', '\\"') + '"'
arg6 = 'https://ssm.{region}.amazonaws.com'.format(region=region)
command = arg0 + ' ' + arg1 + ' ' + arg2 + ' ' + arg3 + ' ' + arg4 + ' ' + arg5 + ' ' + arg6
print(command)
# print('session-manager-plugin', arg1, arg2, arg3, arg4, arg5, arg6)
pid = subprocess.Popen(command).pid
return pid
# end def
(And yes, this was just a quick and dirty prototype.;))

How to uninstall an application that is already stopped

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')

influxDB line protocol insert using nifi executeScript

I am getting an error on writing a script in an attempt to get data into influxDB. The following creates executeScript syntax error which seems to work fine sending the line through the API.
test_measurement,inputType=json
aID="102185",cType="text",pub="2018-07-24
20:17:13Z",fetch="2018-07-24 16:17:23-04:00" 1532541609
Inserted the following script in nifi ExecuteScript but it keeps throwing the following error:
Failed to process session due to javax.script.ScriptException: <eval> Missing space after numeric literal line = line + inputType="json" + " " + ",aID="2312321" + ",cType="text" + ",pub="2018-07-24 13:09:12" + ",fetch="2018-07-24 13:20:02" + " " + Date.now() * 1000000;
Any help or thoughts please.

How to know if preemption is happening on Yarn fair share scheduler?

Is there any way to know for sure if the preemption mechanism has been triggered on YARN?
In the YARN Resource Manager or the logs maybe?
If your log level is set to info you should see this in the YARN Resource Manager logs.
// Warn application about containers to be killed
for (RMContainer container : containers) {
FSAppAttempt app = scheduler.getSchedulerApp(
container.getApplicationAttemptId());
LOG.info("Preempting container " + container +
" from queue " + app.getQueueName());
app.trackContainerForPreemption(container);
}
at https://github.com/apache/hadoop/.../scheduler/fair/FSPreemptionThread.java#L143.
And if you have the log level to debug you will also see this:
if (LOG.isDebugEnabled()) {
LOG.debug(
"allocate: post-update" + " applicationAttemptId=" + appAttemptId
+ " #ask=" + ask.size() + " reservation= " + application
.getCurrentReservation());
LOG.debug("Preempting " + preemptionContainerIds.size()
+ " container(s)");
}
at https://github.com/apache/hadoop/.../scheduler/fair/FairScheduler.java#937

Changing container managed authentification alias

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.

Resources