pmcf 6.46.1 → 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.1",
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,8 +219,8 @@ export class core {
219
219
  mapFromDirections(directions, property) {
220
220
  return new AggregatedMap(
221
221
  [...this.walkDirections(directions)]
222
+ .filter(node => node?.[property])
222
223
  .map(node => node[property])
223
- .filter(node => node !== undefined)
224
224
  );
225
225
  }
226
226
 
@@ -235,9 +235,6 @@ export class core {
235
235
  for (const node of this.walkDirections(directions)) {
236
236
  const value = node[property];
237
237
  if (value !== undefined) {
238
- if (!(value instanceof Set)) {
239
- console.log("NO SET", value, node.fullName, property);
240
- }
241
238
  collected = collected.union(value);
242
239
  }
243
240
  }
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";
@@ -1,12 +1,7 @@
1
1
  import { join } from "node:path";
2
2
  import { FileContentProvider } from "npm-pkgbuild";
3
3
  import { default_collection_attribute_writable } from "pacc";
4
- import {
5
- addType,
6
- FAMILY_UNIX,
7
- FAMILY_IPV4_IPV6,
8
- CoreService
9
- } from "pmcf";
4
+ import { addType, FAMILY_UNIX, FAMILY_IPV4_IPV6, CoreService } from "pmcf";
10
5
  import { writeLines } from "../utils.mjs";
11
6
 
12
7
  export class chrony extends CoreService {
@@ -83,11 +78,12 @@ export class chrony extends CoreService {
83
78
 
84
79
  return values.join(" ");
85
80
  }
81
+
86
82
  const lines = [
87
83
  this.servers.flat().map(chronyServer),
88
84
  this.peers
89
85
  .flat()
90
- .filter(endpoint => endpoint.host !== host)
86
+ .filter(endpoint => !endpoint.service.host.isMember(host))
91
87
  .map(chronyServer),
92
88
  `mailonchange ${this.administratorEmail} 0.5`,
93
89
  "local stratum 10 orphan",