-
Notifications
You must be signed in to change notification settings - Fork 7
/
deploy.js
51 lines (42 loc) · 1.34 KB
/
deploy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright 2020 Canonical Ltd.
// Licensed under the LGPLv3, see LICENSE.txt file for details.
// Allow connecting endpoints using self-signed certs.
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
import websocket from "websocket";
import * as jujulib from "../api/client.js";
import ApplicationV12 from "../api/facades/application/ApplicationV12.js";
import ClientV2 from "../api/facades/client/ClientV2.js";
const options = {
debug: true,
facades: [ApplicationV12, ClientV2],
wsclass: websocket.w3cwebsocket,
};
const url =
"wss://10.223.241.216:17070/model/7236b7b8-5458-4d3e-8a9a-1c8f1a0046b1/api";
async function connectAndDeploy() {
try {
const juju = await jujulib.connect(url, options);
const conn = await juju.login({
username: "admin",
password: "ca83f25a8fd8e162641b60f7a5fd1049",
});
const application = conn.facades.application;
const client = conn.facades.client;
await client.addCharm({ url: "cs:haproxy-60" });
const app = await application.deploy({
applications: [
{
application: "h4",
"charm-url": "cs:haproxy-60",
series: "focal",
},
],
});
console.log(JSON.stringify(app, null, 2));
process.exit();
} catch (error) {
console.log("unable to connect and deploy:", error);
process.exit(1);
}
}
connectAndDeploy();