pmcf 1.59.12 → 1.60.0
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 +32 -18
- package/types/cluster.d.mts +6 -0
package/package.json
CHANGED
package/src/cluster.mjs
CHANGED
|
@@ -11,6 +11,7 @@ const ClusterTypeDefinition = {
|
|
|
11
11
|
priority: 0.7,
|
|
12
12
|
extends: Owner.typeDefinition,
|
|
13
13
|
properties: {
|
|
14
|
+
routerId: { type: "number", collection: false, writeable: true },
|
|
14
15
|
masters: { type: "network_interface", collection: true, writeable: true },
|
|
15
16
|
backups: { type: "network_interface", collection: true, writeable: true }
|
|
16
17
|
}
|
|
@@ -19,6 +20,7 @@ const ClusterTypeDefinition = {
|
|
|
19
20
|
export class Cluster extends Host {
|
|
20
21
|
#masters = new Set();
|
|
21
22
|
#backups = new Set();
|
|
23
|
+
routerId = 100;
|
|
22
24
|
|
|
23
25
|
static {
|
|
24
26
|
addType(this);
|
|
@@ -50,6 +52,7 @@ export class Cluster extends Host {
|
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
async *preparePackages(stagingDir) {
|
|
55
|
+
|
|
53
56
|
const result = {
|
|
54
57
|
sources: [],
|
|
55
58
|
outputs: this.outputs,
|
|
@@ -58,26 +61,36 @@ export class Cluster extends Host {
|
|
|
58
61
|
access: "private"
|
|
59
62
|
}
|
|
60
63
|
};
|
|
64
|
+
|
|
65
|
+
let interfaces = new Set();
|
|
61
66
|
|
|
62
|
-
for
|
|
63
|
-
|
|
67
|
+
for(const cluster of this.owner.clusters()) {
|
|
68
|
+
interfaces = interfaces.union(cluster.masters.union(cluster.backups));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
for (const ni of interfaces) {
|
|
72
|
+
const name = `keepalived-${ni.host.name}`;
|
|
64
73
|
const packageStagingDir = join(stagingDir, name);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
"
|
|
73
|
-
|
|
74
|
-
"
|
|
75
|
-
|
|
76
|
-
"
|
|
77
|
-
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
|
|
74
|
+
|
|
75
|
+
const cfg = [];
|
|
76
|
+
|
|
77
|
+
for(const cluster of this.owner.clusters()) {
|
|
78
|
+
cfg.push(`vrrp_instance ${cluster.name} {`);
|
|
79
|
+
cfg.push(` state ${cluster.masters.has(ni) ? "MASTER" : "BACKUP"}`);
|
|
80
|
+
cfg.push(` interface ${ni.name}`,);
|
|
81
|
+
cfg.push(" virtual_ipaddress {");
|
|
82
|
+
cfg.push(` ${cluster.rawAddress}`);
|
|
83
|
+
cfg.push(" }");
|
|
84
|
+
cfg.push(` virtual_router_id ${this.routerId}`);
|
|
85
|
+
cfg.push(" priority 255");
|
|
86
|
+
cfg.push(" advert_int 1");
|
|
87
|
+
cfg.push(" authentication {");
|
|
88
|
+
cfg.push(" auth_type PASS");
|
|
89
|
+
cfg.push(" auth_pass pass1234");
|
|
90
|
+
cfg.push(" }");
|
|
91
|
+
cfg.push("}");
|
|
92
|
+
cfg.push("");
|
|
93
|
+
}
|
|
81
94
|
|
|
82
95
|
await writeLines(
|
|
83
96
|
join(packageStagingDir, "etc/keepalived"),
|
|
@@ -87,6 +100,7 @@ export class Cluster extends Host {
|
|
|
87
100
|
|
|
88
101
|
result.properties.name = name;
|
|
89
102
|
result.properties.dependencies = ["keepalived"];
|
|
103
|
+
result.properties.replaces = [`${this.typeName}-${this.owner.name}-${this.name}-${ni.host.name}`];
|
|
90
104
|
|
|
91
105
|
result.sources.push(
|
|
92
106
|
new FileContentProvider(packageStagingDir + "/")[Symbol.asyncIterator]()
|
package/types/cluster.d.mts
CHANGED
|
@@ -359,6 +359,11 @@ export class Cluster extends Host {
|
|
|
359
359
|
};
|
|
360
360
|
};
|
|
361
361
|
properties: {
|
|
362
|
+
routerId: {
|
|
363
|
+
type: string;
|
|
364
|
+
collection: boolean;
|
|
365
|
+
writeable: boolean;
|
|
366
|
+
};
|
|
362
367
|
masters: {
|
|
363
368
|
type: string;
|
|
364
369
|
collection: boolean;
|
|
@@ -371,6 +376,7 @@ export class Cluster extends Host {
|
|
|
371
376
|
};
|
|
372
377
|
};
|
|
373
378
|
};
|
|
379
|
+
routerId: number;
|
|
374
380
|
set masters(value: Set<any>);
|
|
375
381
|
get masters(): Set<any>;
|
|
376
382
|
set backups(value: Set<any>);
|