pmcf 2.3.2 → 2.4.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": "2.3.2",
3
+ "version": "2.4.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/base.mjs CHANGED
@@ -121,6 +121,16 @@ export class Base {
121
121
  break;
122
122
  }
123
123
  } else {
124
+ if (property.values) {
125
+ if (property.values.indexOf(value) < 0) {
126
+ this.error(
127
+ property.name,
128
+ "unknown value",
129
+ value,
130
+ property.values
131
+ );
132
+ }
133
+ }
124
134
  this[property.name] = value;
125
135
  }
126
136
  }
package/src/host.mjs CHANGED
@@ -40,15 +40,30 @@ const HostTypeDefinition = {
40
40
  },
41
41
  services: { type: "service", collection: true, writeable: true },
42
42
  aliases: { type: "string", collection: true, writeable: true },
43
- os: { type: "string", collection: false, writeable: true },
43
+ os: {
44
+ type: "string",
45
+ collection: false,
46
+ writeable: true,
47
+ values: ["osx", "windows", "linux"]
48
+ },
44
49
  "machine-id": { type: "string", collection: false, writeable: true },
45
50
  distribution: { type: "string", collection: false, writeable: true },
46
- deployment: { type: "string", collection: false, writeable: true },
51
+ deployment: {
52
+ type: "string",
53
+ collection: false,
54
+ writeable: true,
55
+ values: ["production", "development"]
56
+ },
47
57
  weight: { type: "number", collection: false, writeable: true },
48
58
  serial: { type: "string", collection: false, writeable: true },
49
59
  vendor: { type: "string", collection: false, writeable: true },
50
60
  chassis: { type: "string", collection: false, writeable: true },
51
- architecture: { type: "string", collection: false, writeable: true },
61
+ architecture: {
62
+ type: "string",
63
+ collection: false,
64
+ writeable: true,
65
+ values: ["x86", "aarch64", "armv7"]
66
+ },
52
67
  replaces: { type: "string", collection: true, writeable: true },
53
68
  depends: { type: "string", collection: true, writeable: true },
54
69
  provides: { type: "string", collection: true, writeable: true },
@@ -106,8 +121,7 @@ export class Host extends Base {
106
121
 
107
122
  for (const [name, ni] of host.networkInterfaces) {
108
123
  if (ni.isTemplate) {
109
- }
110
- else {
124
+ } else {
111
125
  let present = this._networkInterfaces.get(name);
112
126
  if (!present) {
113
127
  present = ni.forOwner(this);
@@ -499,8 +513,8 @@ export class NetworkInterface extends Base {
499
513
  }
500
514
 
501
515
  matches(other) {
502
- if(this.isTemplate) {
503
- const name = this.name.replace('*','');
516
+ if (this.isTemplate) {
517
+ const name = this.name.replace("*", "");
504
518
  return name.length === 0 || other.name.indexOf(name) >= 0;
505
519
  }
506
520
 
@@ -1,6 +1,16 @@
1
1
  export const networkProperties = {
2
- scope: { type: "string", collection: false, writeable: true },
3
- kind: { type: "string", collection: false, writeable: true },
2
+ scope: {
3
+ type: "string",
4
+ collection: false,
5
+ writeable: true,
6
+ values: ["global", "site", "link", "local"]
7
+ },
8
+ kind: {
9
+ type: "string",
10
+ collection: false,
11
+ writeable: true,
12
+ values: ["loopback", "ethernet", "wlan", "wireguard", "fiber", "dsl"]
13
+ },
4
14
  ssid: { type: "string", collection: false, writeable: true },
5
15
  psk: { type: "string", collection: false, writeable: true },
6
16
  metric: { type: "number", collection: false, writeable: true },
package/src/service.mjs CHANGED
@@ -87,7 +87,12 @@ export const ServiceTypeDefinition = {
87
87
  ...networkAddressProperties,
88
88
  ipAddresses: { type: "string", collection: true, writeable: true },
89
89
  port: { type: "number", collection: false, writeable: true },
90
- protocol: { type: "string", collection: false, writeable: true },
90
+ protocol: {
91
+ type: "string",
92
+ collection: false,
93
+ writeable: true,
94
+ values: ["tcp", "udp"]
95
+ },
91
96
  alias: { type: "string", collection: false, writeable: true },
92
97
  type: { type: "string", collection: false, writeable: true },
93
98
  weight: { type: "number", collection: false, writeable: true },
@@ -36,23 +36,24 @@ export class DHCPService extends Service {
36
36
 
37
37
  async *preparePackages(dir) {
38
38
  const network = this.network;
39
- const name = this.owner.owner.name;
39
+ const host = this.server;
40
+ const name = host.name;
40
41
  const packageData = {
41
42
  dir,
42
43
  sources: [new FileContentProvider(dir + "/")[Symbol.asyncIterator]()],
43
44
  outputs: this.outputs,
44
45
  properties: {
45
46
  name: `kea-${name}`,
46
- description: `kea definitions for ${this.fullName}`,
47
+ description: `kea definitions for ${this.fullName}@${name}`,
47
48
  access: "private",
48
49
  dependencies: ["kea"],
49
- replaces: ["kea-sw"] // TODO remove
50
+ replaces: ["kea-SW"] // TODO remove
50
51
  }
51
52
  };
52
53
 
53
54
  const commonConfig = {
54
55
  "interfaces-config": {
55
- interfaces: ["end0"]
56
+ interfaces: [...host.networkInterfaces.values()].filter(ni=>ni.kind !== 'loopback').map(ni => ni.name)
56
57
  },
57
58
  "lease-database": {
58
59
  type: "memfile",
@@ -205,6 +205,7 @@ export class Cluster extends Host {
205
205
  type: string;
206
206
  collection: boolean;
207
207
  writeable: boolean;
208
+ values: string[];
208
209
  };
209
210
  "machine-id": {
210
211
  type: string;
@@ -220,6 +221,7 @@ export class Cluster extends Host {
220
221
  type: string;
221
222
  collection: boolean;
222
223
  writeable: boolean;
224
+ values: string[];
223
225
  };
224
226
  weight: {
225
227
  type: string;
@@ -245,6 +247,7 @@ export class Cluster extends Host {
245
247
  type: string;
246
248
  collection: boolean;
247
249
  writeable: boolean;
250
+ values: string[];
248
251
  };
249
252
  replaces: {
250
253
  type: string;
@@ -82,6 +82,7 @@ export class ExtraSourceService extends Service {
82
82
  type: string;
83
83
  collection: boolean;
84
84
  writeable: boolean;
85
+ values: string[];
85
86
  };
86
87
  alias: {
87
88
  type: string;
package/types/host.d.mts CHANGED
@@ -70,6 +70,7 @@ export class Host extends Base {
70
70
  type: string;
71
71
  collection: boolean;
72
72
  writeable: boolean;
73
+ values: string[];
73
74
  };
74
75
  "machine-id": {
75
76
  type: string;
@@ -85,6 +86,7 @@ export class Host extends Base {
85
86
  type: string;
86
87
  collection: boolean;
87
88
  writeable: boolean;
89
+ values: string[];
88
90
  };
89
91
  weight: {
90
92
  type: string;
@@ -110,6 +112,7 @@ export class Host extends Base {
110
112
  type: string;
111
113
  collection: boolean;
112
114
  writeable: boolean;
115
+ values: string[];
113
116
  };
114
117
  replaces: {
115
118
  type: string;
@@ -360,11 +363,13 @@ export class NetworkInterface extends Base {
360
363
  type: string;
361
364
  collection: boolean;
362
365
  writeable: boolean;
366
+ values: string[];
363
367
  };
364
368
  kind: {
365
369
  type: string;
366
370
  collection: boolean;
367
371
  writeable: boolean;
372
+ values: string[];
368
373
  };
369
374
  ssid: {
370
375
  type: string;
@@ -3,6 +3,7 @@ export namespace networkProperties {
3
3
  let type: string;
4
4
  let collection: boolean;
5
5
  let writeable: boolean;
6
+ let values: string[];
6
7
  }
7
8
  namespace kind {
8
9
  let type_1: string;
@@ -11,6 +12,8 @@ export namespace networkProperties {
11
12
  export { collection_1 as collection };
12
13
  let writeable_1: boolean;
13
14
  export { writeable_1 as writeable };
15
+ let values_1: string[];
16
+ export { values_1 as values };
14
17
  }
15
18
  namespace ssid {
16
19
  let type_2: string;
@@ -150,11 +150,13 @@ export class Network extends Owner {
150
150
  type: string;
151
151
  collection: boolean;
152
152
  writeable: boolean;
153
+ values: string[];
153
154
  };
154
155
  kind: {
155
156
  type: string;
156
157
  collection: boolean;
157
158
  writeable: boolean;
159
+ values: string[];
158
160
  };
159
161
  ssid: {
160
162
  type: string;
@@ -67,6 +67,7 @@ export namespace ServiceTypeDefinition {
67
67
  type: string;
68
68
  collection: boolean;
69
69
  writeable: boolean;
70
+ values: string[];
70
71
  };
71
72
  alias: {
72
73
  type: string;
@@ -188,6 +189,7 @@ export class Service extends Base {
188
189
  type: string;
189
190
  collection: boolean;
190
191
  writeable: boolean;
192
+ values: string[];
191
193
  };
192
194
  alias: {
193
195
  type: string;
@@ -69,6 +69,7 @@ export class DHCPService extends Service {
69
69
  type: string;
70
70
  collection: boolean;
71
71
  writeable: boolean;
72
+ values: string[];
72
73
  };
73
74
  alias: {
74
75
  type: string;
@@ -74,6 +74,7 @@ export class DNSService extends ExtraSourceService {
74
74
  type: string;
75
75
  collection: boolean;
76
76
  writeable: boolean;
77
+ values: string[];
77
78
  };
78
79
  alias: {
79
80
  type: string;
@@ -72,6 +72,7 @@ export class NTPService extends ExtraSourceService {
72
72
  type: string;
73
73
  collection: boolean;
74
74
  writeable: boolean;
75
+ values: string[];
75
76
  };
76
77
  alias: {
77
78
  type: string;