Does Glu Agent support REST Call to start, stop or bounce a service?

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Does Glu Agent support REST Call to start, stop or bounce a service?

BhagatSingh
Does Glu Agent support REST Call to start, stop or bounce a service without involving console/orchestration-engine in between?

I searched in the forum and found one related link but it doesn't talk about direct agent call:
http://glu.977617.n3.nabble.com/how-to-start-stop-one-service-in-PLAN-GLU-using-REST-td4025078.html#a4025079

Yan please assist.

Thanks!
Bhagat
Reply | Threaded
Open this post in threaded view
|

Re: Does Glu Agent support REST Call to start, stop or bounce a service?

frenchyan
Administrator
The console is only invoking the rest api on the agent: but a lower level api (installScript, clearError, executeAction, waitForState) (this code is the one that translates a high level call to a low level call (https://github.com/pongasoft/glu/blob/master/orchestration/org.linkedin.glu.orchestration-engine/src/main/groovy/org/linkedin/glu/orchestration/engine/core/action/execution/ActionExecutionFactoryImpl.groovy#L100)

So there is no direct equivalent call, but you can still do it yourself:

a) figure out the current state of the mountPoint
b) execute action (ex: install, configure,...)
c) wait for state
d) repeat b) until you are done


I guess the catch is that you end up reimplementing the orchestration piece yourself, but it is possible.

Yan
Reply | Threaded
Open this post in threaded view
|

Re: Does Glu Agent support REST Call to start, stop or bounce a service?

BhagatSingh
Thank you Yan for the detailed information. Much appreciated.

Thanks!
Bhagat
Reply | Threaded
Open this post in threaded view
|

Re: Does Glu Agent support REST Call to start, stop or bounce a service?

BhagatSingh
This post was updated on .
It looks like I have to do lot of extra work to make it happen. So, I will go with existing flow.

I am trying to stop a service through REST call, but it is not going through. Here are what I am passing to the REST Call:

ENDPOINT_ADDRESS=http://devpmapp1:8181/console/rest/v1/fabric-dev/plans?state=stopped&planType=transition&systemFilter=mountPoint%3D%27%2Fsample%2Fi001%27

HTTP METHOD=POST

Request Content_Type=application/x-www-form-urlencoded

Request Payload = ""

I am getting 201 response code, but service is still running in agent. No error/exception in agent log.

What I am missing here?

is this something related to my problem?
http://pongasoft.github.io/glu/docs/latest/html/orchestration-engine.html
Warning
Currently, the /plans* APIs are only dealing with the plans that have been created through the REST API. The plans created and executed from the web interface use a different mechanism and won’t appear in those calls. This will be adressed in an upcoming release. The /deployments* calls work whether the REST API or the web interface was used.


Thanks!
Bhagat
Reply | Threaded
Open this post in threaded view
|

Re: Does Glu Agent support REST Call to start, stop or bounce a service?

frenchyan
Administrator
Reply | Threaded
Open this post in threaded view
|

Re: Does Glu Agent support REST Call to start, stop or bounce a service?

BhagatSingh
Hi Yan,

My question still remain same

"
I am trying to stop a service through REST call, but it is not going through. Here are what I am passing to the REST Call:

ENDPOINT_ADDRESS=http://devpmapp1:8181/console/rest/v1/fabric-dev/plans?state=stopped&planType=transition&systemFilter=mountPoint%3D%27%2Fsample%2Fi001%27

HTTP METHOD=POST

Request Content_Type=application/x-www-form-urlencoded

Request Payload = ""

I am getting 201 response code, but service is still running in agent. No error/exception in agent log.

What I am missing here?

"

Please assist.

Thanks!
Bhagat
Reply | Threaded
Open this post in threaded view
|

Re: Does Glu Agent support REST Call to start, stop or bounce a service?

frenchyan
Administrator
Reply | Threaded
Open this post in threaded view
|

Re: Does Glu Agent support REST Call to start, stop or bounce a service?

BhagatSingh
frenchyan wrote
And my answer still remain the same... please read it

....

The API POST /plans creates the plan (you get 201 which means created... see http://pongasoft.github.io/glu/docs/latest/html/orchestration-engine.html#create-deployment-plan)
 - I am not creating and deploying plan so this is not my answer
You then need to execute the plan that was created for you: http://pongasoft.github.io/glu/docs/latest/html/orchestration-engine.html#execute-a-deployment-plan
- I want to execute a plan( basically Start, Stop, or Bounce). But this link talks very generic about execute a plan. How to tell to orchestration engine that I want start or stop or bounce a service. That is my doubt.
Then check its status: http://pongasoft.github.io/glu/docs/latest/html/orchestration-engine.html#check-status-of-plan-execution
 Status check is optional for now
The console-cli does exactly that (in python): https://github.com/pongasoft/glu/blob/master/console/org.linkedin.glu.console-cli/src/cmdline/resources/lib/python/gluconsole/rest.py#L158
 - Not sure about this link

Yan

Please assist.

Thanks!
Bhagat
Reply | Threaded
Open this post in threaded view
|

Re: Does Glu Agent support REST Call to start, stop or bounce a service?

frenchyan
Administrator
In a previous post you said the following:

I am trying to stop a service through REST call, but it is not going through. Here are what I am passing to the REST Call: 


HTTP METHOD=POST 

Request Content_Type=application/x-www-form-urlencoded 

Request Payload = ""

I am getting 201 response code, but service is still running in agent. No error/exception in agent log. 

So my answer is answering your question. I do not know what else to tell you.

So I am going to repeat it: this are the steps using the REST api to do what you said you wanted to do which unless I don't understand what you are trying to do is stop a service

Step 1: create a plan which will stop your service and this is explained here and is also the content of your POST (the one I just quoted)!


You get 201 back and the location header tell you what to do

Step 2: you then need to EXECUTE the plan you just created in step 1 and this is explained here:  http://pongasoft.github.io/glu/docs/latest/html/orchestration-engine.html#execute-a-deployment-plan

Step 3: you need to check that the plan execute properly as Step 2 is asynchronous and you do this with the following API:  http://pongasoft.github.io/glu/docs/latest/html/orchestration-engine.html#check-status-of-plan-execution If you don't do this you will never know when or whether Step 2 completes (or even if it fails!)


Finally the last link is giving you some examples in python on how to implement Step 1, 2 and 3 The console-cli does exactly that (in python): https://github.com/pongasoft/glu/blob/master/console/org.linkedin.glu.console-cli/src/cmdline/resources/lib/python/gluconsole/rest.py#L158

Again I am not too sure what else to tell you... You are asking how to do something with the REST api and I am telling you exactly how to do it.

Yan


Reply | Threaded
Open this post in threaded view
|

Re: Does Glu Agent support REST Call to start, stop or bounce a service?

BhagatSingh
Oh boy I was in different world. This is step by step process, not in just one hit. In fact I did try this and so far it is working fine for start and stop. Working on bounce.

Thank you for being patient.

Thanks!
Bhagat
Reply | Threaded
Open this post in threaded view
|

Re: Does Glu Agent support REST Call to start, stop or bounce a service?

frenchyan
Administrator
Yes. I suppose the confusion came from the fact that there is not a single REST call for executing "stop" but it is a multiple steps process which involves the creation of a deployment plan which will execute the stop command, and then executing it. If you think about it it is exactly what you do in the console/ui: first you "create" the plan (it is displayed only), then you click "execute" (the execution starts after confirmation), then the page refreshes on a regular basis to check on the "status" of the deployment until it completes...

Note that you can leave the deployment page opened while you invoke the REST api and you will see your deployment popping up as is described in the tutorial (http://pongasoft.github.io/glu/docs/latest/html/tutorial.html#using-the-console-cli)

Yan
Reply | Threaded
Open this post in threaded view
|

Re: Does Glu Agent support REST Call to start, stop or bounce a service?

BhagatSingh
Yeah I got you. I didn't visualize in that sense, otherwise it could had been easy to understand.  

   So, our glu console extension UI is almost ready. I have developed it in AngularJS and Websockets. I will share all information once it is ready.

Thanks for everything Yan.

Thanks!
Bhagat
Reply | Threaded
Open this post in threaded view
|

Re: Does Glu Agent support REST Call to start, stop or bounce a service?

frenchyan
Administrator
Sweet!

Yan