pmcf 6.0.0 → 6.1.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "6.0.0",
3
+ "version": "6.1.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -52,7 +52,7 @@
52
52
  "dependencies": {
53
53
  "aggregated-map": "^1.0.7",
54
54
  "content-entry-transform": "^1.6.9",
55
- "ip-utilties": "^3.1.3",
55
+ "ip-utilties": "^3.2.0",
56
56
  "npm-pkgbuild": "^20.7.12",
57
57
  "pacc": "^10.4.0",
58
58
  "package-directory": "^8.2.0"
package/src/cluster.mjs CHANGED
@@ -56,19 +56,15 @@ export class Cluster extends Host {
56
56
  )) {
57
57
  const host = ni.host;
58
58
  const packageStagingDir = join(stagingDir, host.name);
59
- const location = `${this.owner.name}-${host.name}`;
59
+ const name = `${this.owner.name}-${host.name}`;
60
60
 
61
61
  const packageData = host.packageData;
62
62
  packageData.sources.push(
63
63
  new FileContentProvider(packageStagingDir + "/")
64
64
  );
65
- packageData.properties.name = `keepalived-${location}`;
65
+ packageData.properties.name = `keepalived-${name}`;
66
66
  packageData.properties.description = `${this.typeName} definitions for ${this.fullName}`;
67
- packageData.properties.groups.push(
68
- "service-config",
69
- location,
70
- "keepalived"
71
- );
67
+ packageData.properties.groups.push("service-config", name, "keepalived");
72
68
 
73
69
  const extra = [];
74
70
 
@@ -91,6 +87,7 @@ export class Cluster extends Host {
91
87
  ""
92
88
  ];
93
89
 
90
+ const credentials = [];
94
91
  for (const cluster of [...this.owner.clusters].sort((a, b) =>
95
92
  a.name.localeCompare(b.name)
96
93
  )) {
@@ -123,12 +120,14 @@ export class Cluster extends Host {
123
120
  reducedPrio = cluster.backups.indexOf(ni) + 5;
124
121
  }
125
122
 
123
+ const credential = cluster.name.toUpperCase() + "_PASSWORD";
124
+ credentials.push(credential);
126
125
  cfg.push(` priority ${host.priority - reducedPrio}`);
127
126
  cfg.push(" smtp_alert");
128
127
  cfg.push(" advert_int 5");
129
128
  cfg.push(" authentication {");
130
129
  cfg.push(" auth_type PASS");
131
- cfg.push(" auth_pass pass1234");
130
+ cfg.push(" auth_pass ${" + credential + "}");
132
131
  cfg.push(" }");
133
132
 
134
133
  cfg.push(
@@ -218,6 +217,18 @@ export class Cluster extends Host {
218
217
  `Conflicts=${cluster.name}-master.target ${cluster.name}-backup.target`
219
218
  ]
220
219
  );
220
+
221
+ await writeLines(
222
+ join(packageStagingDir, "/usr/lib/systemd/system/keepalived.d"),
223
+ `use-credentials.conf`,
224
+ [
225
+ "[Service]",
226
+ ...credentials.map(
227
+ c =>
228
+ `LoadCredentialEncrypted=${c}:/etc/credstore.encrypted/keepalived.password`
229
+ )
230
+ ]
231
+ );
221
232
  }
222
233
 
223
234
  await writeLines(
@@ -64,7 +64,7 @@ export class wlan extends ethernet {
64
64
 
65
65
  await writeLines(
66
66
  join(dir, "usr/lib/systemd/system/iwd.service.d/"),
67
- "pmcf.conf",
67
+ "credentials.conf",
68
68
  [
69
69
  sectionLines("Service", {
70
70
  LoadCredentialEncrypted: `${secretName}:/etc/credstore.encrypted/${secretName}`
@@ -0,0 +1,62 @@
1
+ import {
2
+ default_attribute_writable,
3
+ string_collection_attribute_writable,
4
+ string_attribute_writable,
5
+ integer_attribute_writable,
6
+ hostname_attribute as hostname_attribute_base,
7
+ boolean_attribute_writable
8
+ } from "pacc";
9
+
10
+ export const networkAddressType = "network|host|network_interface";
11
+
12
+ export const networks_attribute = {
13
+ ...default_attribute_writable,
14
+ name: "networks",
15
+ type: "network",
16
+ collection: true
17
+ };
18
+
19
+ export const psk_attribute = { ...string_attribute_writable, name: "psk" };
20
+ export const ssid_attribute = { ...string_attribute_writable, name: "ssid" };
21
+ export const hostname_attribute = {
22
+ ...hostname_attribute_base,
23
+ name: "hostName",
24
+ writable: true
25
+ };
26
+
27
+ export const networkAttributes = {
28
+ scope: {
29
+ ...string_attribute_writable,
30
+ name: "scope",
31
+ values: ["global", "site", "link", "host"]
32
+ // default: "global"
33
+ },
34
+ class: {
35
+ ...string_attribute_writable,
36
+ name: "class",
37
+ values: ["10GBASE-T", "1000BASE-T", "100BASE-T", "10BASE-T"]
38
+ },
39
+ kind: {
40
+ ...string_attribute_writable,
41
+ name: "kind",
42
+ values: ["loopback", "ethernet", "wlan", "wireguard", "fiber", "dsl"]
43
+ },
44
+ ssid: ssid_attribute,
45
+ psk: psk_attribute,
46
+ secretName: { ...string_attribute_writable, name: "secretName" },
47
+ metric: { ...integer_attribute_writable, name: "metric" /*default: 1004*/ },
48
+ mtu: { ...integer_attribute_writable, name: "mtu", default: 1500 },
49
+ gateway: { ...default_attribute_writable, name: "gateway", type: "host" },
50
+ multicastDNS: { ...boolean_attribute_writable, name: "multicastDNS" }
51
+ };
52
+
53
+ export const networkAddressAttributes = {
54
+ hostName: hostname_attribute,
55
+ cidrAddresses: {
56
+ ...string_collection_attribute_writable,
57
+ name: "cidrAddresses"
58
+ },
59
+ cidrAddress: { ...string_attribute_writable, name: "cidrAddress" },
60
+ addresses: { ...string_collection_attribute_writable, name: "addresses" },
61
+ address: { ...string_attribute_writable, name: "address" }
62
+ };
package/src/network.mjs CHANGED
@@ -1,11 +1,7 @@
1
1
  import { AggregatedMap } from "aggregated-map";
2
- import { addType, assign } from "pmcf";
2
+ import { addType } from "pmcf";
3
3
  import { Owner } from "./owner.mjs";
4
- import {
5
- networkAttributes,
6
- bridges_attribute,
7
- subnets_attribute
8
- } from "./common-attributes.mjs";
4
+ import { networkAttributes, bridges_attribute } from "./common-attributes.mjs";
9
5
  import { Subnet } from "./subnet.mjs";
10
6
 
11
7
  export class Network extends Owner {
@@ -58,7 +54,7 @@ export class Network extends Owner {
58
54
  get subnets() {
59
55
  if (!this._subnets.get("fe80::/64")) {
60
56
  const linkLocal = new Subnet("fe80::/64");
61
- this._subnets.set(linkLocal.address,linkLocal);
57
+ this._subnets.set(linkLocal.address, linkLocal);
62
58
  //assign(subnets_attribute, this, linkLocal);
63
59
  }
64
60
 
@@ -69,6 +65,13 @@ export class Network extends Owner {
69
65
  : super.subnets;
70
66
  }
71
67
 
68
+ /**
69
+ * @return {Set<string>}
70
+ */
71
+ get families() {
72
+ return new Set([...this.subnets.values()].map(subnet => subnet.family));
73
+ }
74
+
72
75
  set secretName(value) {
73
76
  this._secretName = value;
74
77
  }
package/src/subnet.mjs CHANGED
@@ -51,11 +51,6 @@ export class Subnet {
51
51
  }
52
52
  }
53
53
 
54
- get children()
55
- {
56
- return [];
57
- }
58
-
59
54
  *_walkDirections(directions, seen) {
60
55
  }
61
56