Friday, 16 June 2017

WebSphere Liberty Collectives - Deploying Node.JS using REST

This is definitely a Work-In-Progress …..

Using this as input: -


I started by using a REST client within Chrome ( called Restlet ): -


with this JSON as input: -

{
  "rule":"Node.js Server Rule",
  "hosts":["wlpn.uk.ibm.com"],
  "variables": [
    { "name":"applicationPackage","value":"helloworld-1.0.0.tgz" },
    { "name":"serverName", "value":"Server1" },
    { "name":"clusterName", "value":"Cluster1" },
    { "name":"keystorePassword", "value":"passw0rd" },
    { "name":"applicationDir", "value":"/home/wasadmin/" }
  ]
}


to deploy a Node.JS server via this URL ( POST ): -


I went one step further and used this JSON: -

{
   "host": "wlpn.uk.ibm.com",
   "userDir":"/home/wasadmin/wlpn",
   "serverName":"Server1"
}


to undeploy the same.

I then translated that into command-line commands (!) using Curl: -

curl -d "@deploy.json" -H "Content-Type: application/json" -X POST https://wlpc.uk.ibm.com:9443/ibm/api/collective/v1/deployment/deploy --insecure -i -u wasadmin:passw0rd

and: -

curl -d "@undeploy.json" -H "Content-Type: application/json" -X POST https://wlpc.uk.ibm.com:9443/ibm/api/collective/v1/deployment/undeploy --insecure -i -u wasadmin:passw0rd

deploy.json

{
  "rule":"Node.js Server Rule",
  "hosts":["wlpn.uk.ibm.com"],
  "variables": [
    { "name":"applicationPackage","value":"helloworld-1.0.0.tgz" },
    { "name":"serverName", "value":"Server1" },
    { "name":"clusterName", "value":"Cluster1" },
    { "name":"keystorePassword", "value":"passw0rd" },
    { "name":"applicationDir", "value":"/home/wasadmin/" }
  ]
}


undeploy.json

{
   "host": "wlpn.uk.ibm.com",
   "userDir":"/home/wasadmin/wlpn",
   "serverName":"Server1"
}


Next I need to do the same to start and stop my servers …..

No comments: