pmcf 1.59.11 → 1.59.13
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 +56 -38
- package/src/owner.mjs +3 -2
- package/types/cluster.d.mts +2 -2
- package/types/owner.d.mts +1 -1
package/package.json
CHANGED
package/src/cluster.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { FileContentProvider } from "npm-pkgbuild";
|
|
3
3
|
import { Owner } from "./owner.mjs";
|
|
4
|
+
import { Host } from "./host.mjs";
|
|
4
5
|
import { addType } from "./types.mjs";
|
|
5
6
|
import { writeLines } from "./utils.mjs";
|
|
6
7
|
|
|
@@ -15,7 +16,7 @@ const ClusterTypeDefinition = {
|
|
|
15
16
|
}
|
|
16
17
|
};
|
|
17
18
|
|
|
18
|
-
export class Cluster extends
|
|
19
|
+
export class Cluster extends Host {
|
|
19
20
|
#masters = new Set();
|
|
20
21
|
#backups = new Set();
|
|
21
22
|
|
|
@@ -49,44 +50,61 @@ export class Cluster extends Owner {
|
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
async *preparePackages(stagingDir) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
` interface ${ni.name}`,
|
|
60
|
-
" virtual_router_id 101",
|
|
61
|
-
" priority 255",
|
|
62
|
-
" advert_int 1",
|
|
63
|
-
" authentication {",
|
|
64
|
-
" auth_type PASS",
|
|
65
|
-
" auth_pass pass1234",
|
|
66
|
-
" }",
|
|
67
|
-
" virtual_ipaddress {",
|
|
68
|
-
` ${ni.rawAddress}`,
|
|
69
|
-
" }",
|
|
70
|
-
"}"
|
|
71
|
-
];
|
|
72
|
-
|
|
73
|
-
await writeLines(
|
|
74
|
-
join(packageStagingDir, "etc/keepalived"),
|
|
75
|
-
"keepalived.conf",
|
|
76
|
-
cfg
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
result.properties.name = name;
|
|
80
|
-
result.properties.dependencies = ["keepalived"];
|
|
81
|
-
|
|
82
|
-
result.sources.push(
|
|
83
|
-
new FileContentProvider(packageStagingDir + "/")[
|
|
84
|
-
Symbol.asyncIterator
|
|
85
|
-
]()
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
yield result;
|
|
53
|
+
|
|
54
|
+
const result = {
|
|
55
|
+
sources: [],
|
|
56
|
+
outputs: this.outputs,
|
|
57
|
+
properties: {
|
|
58
|
+
description: `${this.typeName} definitions for ${this.fullName}`,
|
|
59
|
+
access: "private"
|
|
89
60
|
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
let interfaces = new Set();
|
|
64
|
+
|
|
65
|
+
for(const cluster of this.owner.clusters()) {
|
|
66
|
+
interfaces = interfaces.union(cluster.masters.union(cluster.backups));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
for (const ni of interfaces) {
|
|
70
|
+
const name = `keepalived-${ni.host.name}`;
|
|
71
|
+
const packageStagingDir = join(stagingDir, name);
|
|
72
|
+
|
|
73
|
+
const cfg = [];
|
|
74
|
+
|
|
75
|
+
for(const cluster of this.owner.clusters()) {
|
|
76
|
+
cfg.push(`vrrp_instance ${cluster.name} {`);
|
|
77
|
+
cfg.push(` state ${cluster.masters.has(ni) ? "MASTER" : "BACKUP"}`);
|
|
78
|
+
cfg.push(` interface ${ni.name}`,);
|
|
79
|
+
cfg.push(" virtual_ipaddress {");
|
|
80
|
+
cfg.push(` ${cluster.rawAddress}`);
|
|
81
|
+
cfg.push(" }");
|
|
82
|
+
cfg.push(" virtual_router_id 101");
|
|
83
|
+
cfg.push(" priority 255");
|
|
84
|
+
cfg.push(" advert_int 1");
|
|
85
|
+
cfg.push(" authentication {");
|
|
86
|
+
cfg.push(" auth_type PASS");
|
|
87
|
+
cfg.push(" auth_pass pass1234");
|
|
88
|
+
cfg.push(" }");
|
|
89
|
+
cfg.push("}");
|
|
90
|
+
cfg.push("");
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
await writeLines(
|
|
94
|
+
join(packageStagingDir, "etc/keepalived"),
|
|
95
|
+
"keepalived.conf",
|
|
96
|
+
cfg
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
result.properties.name = name;
|
|
100
|
+
result.properties.dependencies = ["keepalived"];
|
|
101
|
+
result.properties.replaces = [`${this.typeName}-${this.owner.name}-${this.name}-${ni.host.name}`];
|
|
102
|
+
|
|
103
|
+
result.sources.push(
|
|
104
|
+
new FileContentProvider(packageStagingDir + "/")[Symbol.asyncIterator]()
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
yield result;
|
|
90
108
|
}
|
|
91
109
|
}
|
|
92
110
|
}
|
package/src/owner.mjs
CHANGED
|
@@ -146,8 +146,9 @@ export class Owner extends Base {
|
|
|
146
146
|
return this.typeNamed("host", name);
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
hosts() {
|
|
150
|
-
|
|
149
|
+
* hosts() {
|
|
150
|
+
yield * this.typeList("host");
|
|
151
|
+
yield * this.typeList("cluster");
|
|
151
152
|
}
|
|
152
153
|
|
|
153
154
|
networkNamed(name) {
|
package/types/cluster.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export class Cluster extends
|
|
1
|
+
export class Cluster extends Host {
|
|
2
2
|
static get typeDefinition(): {
|
|
3
3
|
name: string;
|
|
4
4
|
owners: (string | {
|
|
@@ -377,4 +377,4 @@ export class Cluster extends Owner {
|
|
|
377
377
|
get backups(): Set<any>;
|
|
378
378
|
#private;
|
|
379
379
|
}
|
|
380
|
-
import {
|
|
380
|
+
import { Host } from "./host.mjs";
|
package/types/owner.d.mts
CHANGED
|
@@ -188,7 +188,7 @@ export class Owner extends Base {
|
|
|
188
188
|
locationNamed(name: any): any;
|
|
189
189
|
locations(): any;
|
|
190
190
|
hostNamed(name: any): any;
|
|
191
|
-
hosts(): any
|
|
191
|
+
hosts(): Generator<any, void, any>;
|
|
192
192
|
networkNamed(name: any): any;
|
|
193
193
|
networks(): any;
|
|
194
194
|
subnetNamed(name: any): any;
|