pmcf 6.40.4 → 6.40.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/cluster.mjs +27 -19
package/package.json
CHANGED
package/src/cluster.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { FileContentProvider } from "npm-pkgbuild";
|
|
3
3
|
import { FAMILY_IPV4 } from "ip-utilties";
|
|
4
|
-
import {
|
|
4
|
+
import { duration_attribute_writable } from "pacc";
|
|
5
5
|
import { Host } from "./host.mjs";
|
|
6
6
|
import { addType, serviceEndpoints } from "pmcf";
|
|
7
7
|
import {
|
|
@@ -14,7 +14,6 @@ export class Cluster extends Host {
|
|
|
14
14
|
static name = "cluster";
|
|
15
15
|
static priority = 1.5;
|
|
16
16
|
static attributes = {
|
|
17
|
-
routerId: { ...number_attribute_writable, name: "routerId", default: 100 },
|
|
18
17
|
masters: {
|
|
19
18
|
...networkInterfaces_attribute,
|
|
20
19
|
name: "masters",
|
|
@@ -45,9 +44,8 @@ export class Cluster extends Host {
|
|
|
45
44
|
routerId = 100;
|
|
46
45
|
checkInterval = 60;
|
|
47
46
|
|
|
48
|
-
get content()
|
|
49
|
-
|
|
50
|
-
return this.masters.map(m=>m.host)[0]?.content;
|
|
47
|
+
get content() {
|
|
48
|
+
return this.masters.map(m => m.host)[0]?.content;
|
|
51
49
|
}
|
|
52
50
|
|
|
53
51
|
get members() {
|
|
@@ -60,16 +58,18 @@ export class Cluster extends Host {
|
|
|
60
58
|
new Set()
|
|
61
59
|
)) {
|
|
62
60
|
const host = ni.host;
|
|
63
|
-
const packageStagingDir = join(stagingDir, host.name);
|
|
64
|
-
const name = `${this.owner.name}-${host.name}`;
|
|
65
61
|
|
|
62
|
+
const packageStagingDir = join(stagingDir, host.name);
|
|
66
63
|
const packageData = await host.packageData;
|
|
64
|
+
|
|
67
65
|
packageData.sources.push(
|
|
68
|
-
|
|
66
|
+
await Array.fromAsync(this.templateContent()),
|
|
67
|
+
new FileContentProvider({
|
|
68
|
+
dir: packageStagingDir,
|
|
69
|
+
pattern: "**/*",
|
|
70
|
+
permissions: this.content.permissions
|
|
71
|
+
})
|
|
69
72
|
);
|
|
70
|
-
packageData.properties.name = `keepalived-${name}`;
|
|
71
|
-
packageData.properties.description = `${this.typeName} definitions for ${this.fullName}`;
|
|
72
|
-
packageData.properties.groups.push("config", name, "keepalived");
|
|
73
73
|
|
|
74
74
|
const extra = [];
|
|
75
75
|
|
|
@@ -118,7 +118,7 @@ export class Cluster extends Host {
|
|
|
118
118
|
cfg.push(" }");
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
cfg.push(` virtual_router_id ${cluster.
|
|
121
|
+
cfg.push(` virtual_router_id ${cluster.id}`);
|
|
122
122
|
|
|
123
123
|
let reducedPrio = cluster.masters.indexOf(ni);
|
|
124
124
|
if (reducedPrio < 0) {
|
|
@@ -126,7 +126,7 @@ export class Cluster extends Host {
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
const credential = name.toUpperCase() + "_PASSWORD";
|
|
129
|
-
credentials.set(credential,name);
|
|
129
|
+
credentials.set(credential, name);
|
|
130
130
|
cfg.push(` priority ${host.priority - reducedPrio}`);
|
|
131
131
|
cfg.push(" smtp_alert");
|
|
132
132
|
cfg.push(" advert_int 5");
|
|
@@ -157,9 +157,15 @@ export class Cluster extends Host {
|
|
|
157
157
|
cfg.push(` protocol ${endpoint.protocol.toUpperCase()}`);
|
|
158
158
|
|
|
159
159
|
for (const member of this.members) {
|
|
160
|
-
const memberService = member.expression(
|
|
160
|
+
const memberService = member.expression(
|
|
161
|
+
`services[types[${endpoint.type}]][0]`
|
|
162
|
+
);
|
|
161
163
|
|
|
162
|
-
console.log(
|
|
164
|
+
console.log(
|
|
165
|
+
member.fullName,
|
|
166
|
+
endpoint.type,
|
|
167
|
+
memberService?.fullName
|
|
168
|
+
);
|
|
163
169
|
cfg.push(` real_server ${member.address} ${memberService.port} {`);
|
|
164
170
|
cfg.push(` weight ${memberService.weight}`);
|
|
165
171
|
|
|
@@ -228,10 +234,12 @@ export class Cluster extends Host {
|
|
|
228
234
|
"credentials.conf",
|
|
229
235
|
[
|
|
230
236
|
"[Service]",
|
|
231
|
-
...credentials
|
|
232
|
-
(
|
|
233
|
-
|
|
234
|
-
|
|
237
|
+
...credentials
|
|
238
|
+
.entries()
|
|
239
|
+
.map(
|
|
240
|
+
([credName, instance]) =>
|
|
241
|
+
`LoadCredentialEncrypted=${credName}:/etc/credstore.encrypted/keepalived.${instance}.password`
|
|
242
|
+
)
|
|
235
243
|
]
|
|
236
244
|
);
|
|
237
245
|
}
|