I am writing a Jelastic manifest where I deploy two nodes. On one node, I have an API that I need to query in order to setup the second. Something along these lines:
type: install
name: My test
nodes:
- count: 1
cloudlets: 4
nodeGroup: auth
nodeType: docker
image: my-api:latest
- count: 1
cloudlets: 16
nodeGroup: cp
nodeType: docker
image: some-service:latest
onInstall:
- script: |
import com.hivext.api.core.utils.Transport;
try {
const body = new Transport().get("http://${nodes.auth.master.intIP}:9011/api/key", {
"Authorization": "my-api-key"
});
return { result: 0, body: body };
} catch (e) {
return {
type: "error",
message: "unknown error: " + e
};
}
In my script, when I do
const body = new Transport().get("http://www.google.com");
it works, I get the body content of the google page. However,
const body = new Transport().get("http://${nodes.auth.master.intIP}:9011/api/key", {
"Authorization": "my-api-key"
});
returns
ERROR: script.response: {"type":"error","message":"unknown error: JavaException: java.io.IOException: Failed to select a proxy"}
What am I doing wrong? How can I query my service in a script like in the above snippet? When I curl
it through regular cmd
, then it works:
curl -s -H "Authorization: my-api-key" http://${nodes.auth.master.intIP}:9011/api/key
Also, incidentally, where can I find the documentation of com.hivext.api.core.utils.Transport
?