pmcf 6.46.2 → 6.46.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "6.46.2",
3
+ "version": "6.46.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/cluster.mjs CHANGED
@@ -10,8 +10,7 @@ import {
10
10
  } from "./common-attributes.mjs";
11
11
  import { writeLines } from "./utils.mjs";
12
12
 
13
- export class Cluster extends Host {
14
- static name = "cluster";
13
+ export class cluster extends Host {
15
14
  static priority = 1.5;
16
15
  static attributes = {
17
16
  masters: {
@@ -41,17 +40,24 @@ export class Cluster extends Host {
41
40
 
42
41
  masters = [];
43
42
  backups = [];
44
- routerId = 100;
45
43
  checkInterval = 60;
46
44
 
47
- get content() {
48
- return this.masters.map(m => m.host)[0]?.content;
49
- }
50
-
51
45
  get members() {
52
46
  return new Set(this.masters).union(new Set(this.backups));
53
47
  }
54
48
 
49
+ isMember(host) {
50
+ return super.isMember(host) || this.hosts.get(host.name) === host;
51
+ }
52
+
53
+ get hosts() {
54
+ return new Map([...this.members].map(m => [m.host.name, m.host]));
55
+ }
56
+
57
+ get content() {
58
+ return [...this.hosts.values()][0]?.content;
59
+ }
60
+
55
61
  async *preparePackages(stagingDir) {
56
62
  for (const ni of [...this.owner.clusters.values()].reduce(
57
63
  (all, cluster) => all.union(cluster.members),
package/src/core.mjs CHANGED
@@ -219,7 +219,7 @@ export class core {
219
219
  mapFromDirections(directions, property) {
220
220
  return new AggregatedMap(
221
221
  [...this.walkDirections(directions)]
222
- .filter(node => node !== undefined)
222
+ .filter(node => node?.[property])
223
223
  .map(node => node[property])
224
224
  );
225
225
  }
package/src/host.mjs CHANGED
@@ -178,6 +178,10 @@ export class Host extends ServiceOwner {
178
178
  return parts[parts.length - 1].toLowerCase();
179
179
  }
180
180
 
181
+ isMember(host) {
182
+ return this === host;
183
+ }
184
+
181
185
  get services() {
182
186
  return new AggregatedMap([
183
187
  this._services,
@@ -318,7 +322,7 @@ export class Host extends ServiceOwner {
318
322
  const packageData = await this.packageData;
319
323
 
320
324
  packageData.sources.push(
321
- ...await Array.fromAsync(this.templateContent()),
325
+ ...(await Array.fromAsync(this.templateContent())),
322
326
  new FileContentProvider({
323
327
  dir,
324
328
  pattern: ["**/*", "**/.ssh/*"],
@@ -0,0 +1,3 @@
1
+ import { cluster } from "./cluster.mjs";
2
+
3
+ export class keepalived extends cluster {}
package/src/module.mjs CHANGED
@@ -2,6 +2,8 @@ export * from "./type.mjs";
2
2
  export * from "./core.mjs";
3
3
  export * from "./base.mjs";
4
4
  export * from "./cluster.mjs";
5
+ export * from "./keepalived.mjs";
6
+
5
7
  export * from "./owner.mjs";
6
8
  export * from "./root.mjs";
7
9
  export * from "./subnet.mjs";
@@ -83,7 +83,7 @@ export class chrony extends CoreService {
83
83
  this.servers.flat().map(chronyServer),
84
84
  this.peers
85
85
  .flat()
86
- .filter(endpoint => endpoint.host !== host)
86
+ .filter(endpoint => !endpoint.service.host.isMember(host))
87
87
  .map(chronyServer),
88
88
  `mailonchange ${this.administratorEmail} 0.5`,
89
89
  "local stratum 10 orphan",