pmcf 2.28.0 → 2.29.1

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/bin/pmcf-diagram CHANGED
@@ -13,14 +13,16 @@ function q(str) {
13
13
  console.log("graph G {");
14
14
  console.log(" node [shape=record];");
15
15
  for await (const host of location.hosts()) {
16
- console.log(
17
- ` ${q(host.name)} [label="${host.name}|{${[
18
- ...host.networkInterfaces.values()
19
- ]
20
- .filter(ni => !ni.isTemplate && ni.kind !== "loopback")
21
- .map(ni => `<${q(ni.name)}> ${ni.name}`)
22
- .join("|")}}"];`
23
- );
16
+ if (host.clusters.size === 0) {
17
+ console.log(
18
+ ` ${q(host.name)} [label="${host.name}|{${[
19
+ ...host.networkInterfaces.values()
20
+ ]
21
+ .filter(ni => !ni.isTemplate && ni.kind !== "loopback")
22
+ .map(ni => `<${q(ni.name)}> ${ni.name}`)
23
+ .join("|")}}"];`
24
+ );
25
+ }
24
26
  }
25
27
 
26
28
  for await (const network of location.networks()) {
@@ -45,7 +47,29 @@ for await (const network of location.networks()) {
45
47
  }
46
48
 
47
49
  for await (const cluster of location.clusters()) {
48
- console.log(` ${[...cluster.members].map(b => `${q(b.host.name)}:${b.name}`).join(" -- ")};`);
50
+ console.log(` subgraph cluster_${cluster.name} {`);
51
+
52
+ for (const ni of cluster.members) {
53
+ const host = ni.host;
54
+ console.log(
55
+ ` ${q(host.name)} [label="${host.name}|{${[
56
+ ...host.networkInterfaces.values()
57
+ ]
58
+ .filter(ni => !ni.isTemplate && ni.kind !== "loopback")
59
+ .map(ni => `<${q(ni.name)}> ${ni.name}`)
60
+ .join("|")}}"];`
61
+ );
62
+ }
63
+
64
+ /*
65
+ console.log(
66
+ ` ${[...cluster.members]
67
+ .map(b => `${q(b.host.name)}:${b.name}`)
68
+ .join(" -- ")};`
69
+
70
+ );*/
71
+
72
+ console.log(` } [label="${cluster.name}"];`);
49
73
  }
50
74
 
51
75
  for (const bridge of location.bridges) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "2.28.0",
3
+ "version": "2.29.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/cluster.mjs CHANGED
@@ -40,6 +40,7 @@ export class Cluster extends Host {
40
40
 
41
41
  set masters(value) {
42
42
  this._masters.add(value);
43
+ value.cluster = this;
43
44
  }
44
45
 
45
46
  get masters() {
@@ -48,6 +49,8 @@ export class Cluster extends Host {
48
49
 
49
50
  set backups(value) {
50
51
  this._backups.add(value);
52
+
53
+ value.cluster = this;
51
54
  }
52
55
 
53
56
  get backups() {
@@ -26,6 +26,8 @@ export async function generateNetworkDefs(host, packageData) {
26
26
  const networkDir = join(packageData.dir, "etc/systemd/network");
27
27
 
28
28
  for (const ni of host.networkInterfaces.values()) {
29
+ await ni.systemdDefinitions(packageData);
30
+
29
31
  switch (ni.kind) {
30
32
  case "loopback":
31
33
  continue;
@@ -101,11 +103,7 @@ export async function generateNetworkDefs(host, packageData) {
101
103
 
102
104
  await writeLines(networkDir, `${ni.name}.network`, networkSections);
103
105
 
104
- switch (ni?.kind) {
105
- case "wireguard":
106
- {
107
- }
108
- break;
106
+ switch (ni.kind) {
109
107
  case "wifi": {
110
108
  const d = join(packageData.dir, "etc/wpa_supplicant");
111
109
  await mkdir(d, { recursive: true });
package/src/host.mjs CHANGED
@@ -324,6 +324,18 @@ export class Host extends Base {
324
324
  }
325
325
  }
326
326
 
327
+ get clusters() {
328
+ const clusters = new Set();
329
+
330
+ for (const ni of this.networkInterfaces.values()) {
331
+ if (ni.cluster) {
332
+ clusters.add(ni.cluster);
333
+ }
334
+ }
335
+
336
+ return clusters;
337
+ }
338
+
327
339
  get host() {
328
340
  return this;
329
341
  }
@@ -89,6 +89,8 @@ class SkeletonNetworkInterface extends Base {
89
89
  get addresses() {
90
90
  return [...this.ipAddresses].map(([address]) => address);
91
91
  }
92
+
93
+ async systemdDefinitions(packageData) {}
92
94
  }
93
95
 
94
96
  export const NetworkInterfaceTypeDefinition = {
@@ -133,8 +135,6 @@ export class NetworkInterface extends SkeletonNetworkInterface {
133
135
  _ipAddresses = new Map();
134
136
  _scope;
135
137
  _metric;
136
- _ssid;
137
- _psk;
138
138
  _kind;
139
139
  _hostName;
140
140
  _hwaddr;
@@ -247,6 +247,40 @@ export class NetworkInterface extends SkeletonNetworkInterface {
247
247
  return this.extendedProperty("_class") ?? this.network?.class;
248
248
  }
249
249
 
250
+ set kind(value) {
251
+ this._kind = value;
252
+ }
253
+
254
+ get kind() {
255
+ return this.extendedProperty("_kind") ?? this.network?.kind;
256
+ }
257
+ }
258
+
259
+ const WLANNetworkInterfaceTypeDefinition = {
260
+ name: "wlan",
261
+ specializationOf: NetworkInterfaceTypeDefinition,
262
+ owners: NetworkInterfaceTypeDefinition.owners,
263
+ extends: NetworkInterfaceTypeDefinition,
264
+ priority: 0.1,
265
+ properties: {}
266
+ };
267
+
268
+ export class WLANNetworkInterface extends NetworkInterface {
269
+ _ssid;
270
+ _psk;
271
+
272
+ static {
273
+ addType(this);
274
+ }
275
+
276
+ static get typeDefinition() {
277
+ return WLANNetworkInterfaceTypeDefinition;
278
+ }
279
+
280
+ /*get kind() {
281
+ return WLANNetworkInterfaceTypeDefinition.name;
282
+ }*/
283
+
250
284
  set ssid(value) {
251
285
  this._ssid = value;
252
286
  }
@@ -262,14 +296,6 @@ export class NetworkInterface extends SkeletonNetworkInterface {
262
296
  get psk() {
263
297
  return this.extendedProperty("_psk") ?? this.network?.psk;
264
298
  }
265
-
266
- set kind(value) {
267
- this._kind = value;
268
- }
269
-
270
- get kind() {
271
- return this.extendedProperty("_kind") ?? this.network?.kind;
272
- }
273
299
  }
274
300
 
275
301
  const LoopbackNetworkInterfaceTypeDefinition = {
package/types/host.d.mts CHANGED
@@ -225,6 +225,7 @@ export class Host extends Base {
225
225
  get domainNames(): Set<any>;
226
226
  get domainName(): any;
227
227
  domainNamesIn(domain: any): Generator<any, void, unknown>;
228
+ get clusters(): Set<any>;
228
229
  get host(): this;
229
230
  named(name: any): any;
230
231
  get networks(): Set<any>;
@@ -319,8 +319,6 @@ export class NetworkInterface extends SkeletonNetworkInterface {
319
319
  _ipAddresses: Map<any, any>;
320
320
  _scope: any;
321
321
  _metric: any;
322
- _ssid: any;
323
- _psk: any;
324
322
  _kind: any;
325
323
  _hostName: any;
326
324
  _hwaddr: any;
@@ -346,12 +344,338 @@ export class NetworkInterface extends SkeletonNetworkInterface {
346
344
  _MTU: any;
347
345
  set class(value: any);
348
346
  get class(): any;
347
+ set kind(value: any);
348
+ get kind(): any;
349
+ }
350
+ export class WLANNetworkInterface extends NetworkInterface {
351
+ static get typeDefinition(): {
352
+ name: string;
353
+ specializationOf: {
354
+ name: string;
355
+ priority: number;
356
+ owners: string[];
357
+ extends: {
358
+ name: string;
359
+ owners: any[];
360
+ properties: {
361
+ owner: {
362
+ type: string;
363
+ collection: boolean;
364
+ writeable: boolean;
365
+ };
366
+ type: {
367
+ type: string;
368
+ collection: boolean;
369
+ writeable: boolean;
370
+ };
371
+ name: {
372
+ type: string;
373
+ collection: boolean;
374
+ identifier: boolean;
375
+ writeable: boolean;
376
+ };
377
+ description: {
378
+ type: string;
379
+ collection: boolean;
380
+ writeable: boolean;
381
+ };
382
+ priority: {
383
+ type: string;
384
+ collection: boolean;
385
+ writeable: boolean;
386
+ };
387
+ directory: {
388
+ type: string;
389
+ collection: boolean;
390
+ writeable: boolean;
391
+ };
392
+ packaging: {
393
+ type: string;
394
+ collection: boolean;
395
+ writeable: boolean;
396
+ };
397
+ tags: {
398
+ type: string;
399
+ collection: boolean;
400
+ writeable: boolean;
401
+ };
402
+ };
403
+ };
404
+ specializations: {};
405
+ factoryFor(value: any): any;
406
+ properties: {
407
+ hostName: {
408
+ type: string;
409
+ collection: boolean;
410
+ writeable: boolean;
411
+ };
412
+ ipAddresses: {
413
+ type: string;
414
+ collection: boolean;
415
+ writeable: boolean;
416
+ };
417
+ hwaddr: {
418
+ type: string;
419
+ collection: boolean;
420
+ writeable: boolean;
421
+ };
422
+ network: {
423
+ type: string;
424
+ collection: boolean;
425
+ writeable: boolean;
426
+ };
427
+ destination: {
428
+ type: string;
429
+ collection: boolean;
430
+ writeable: boolean;
431
+ };
432
+ arpbridge: {
433
+ type: string;
434
+ collection: boolean;
435
+ writeable: boolean;
436
+ };
437
+ cidrAddresses: {
438
+ type: string;
439
+ collection: boolean;
440
+ writeable: boolean;
441
+ };
442
+ cidrAddress: {
443
+ type: string;
444
+ collection: boolean;
445
+ writeable: boolean;
446
+ };
447
+ addresses: {
448
+ type: string;
449
+ collection: boolean;
450
+ writeable: boolean;
451
+ };
452
+ address: {
453
+ type: string;
454
+ collection: boolean;
455
+ writeable: boolean;
456
+ };
457
+ scope: {
458
+ type: string;
459
+ collection: boolean;
460
+ writeable: boolean;
461
+ values: string[];
462
+ default: string;
463
+ };
464
+ class: {
465
+ type: string;
466
+ collection: boolean;
467
+ writeable: boolean;
468
+ values: string[];
469
+ };
470
+ kind: {
471
+ type: string;
472
+ collection: boolean;
473
+ writeable: boolean;
474
+ values: string[];
475
+ };
476
+ ssid: {
477
+ type: string;
478
+ collection: boolean;
479
+ writeable: boolean;
480
+ };
481
+ psk: {
482
+ type: string;
483
+ collection: boolean;
484
+ writeable: boolean;
485
+ };
486
+ metric: {
487
+ type: string;
488
+ collection: boolean;
489
+ writeable: boolean;
490
+ default: number;
491
+ };
492
+ MTU: {
493
+ type: string;
494
+ collection: boolean;
495
+ writeable: boolean;
496
+ default: number;
497
+ };
498
+ gateway: {
499
+ type: string;
500
+ collection: boolean;
501
+ writeable: boolean;
502
+ };
503
+ multicastDNS: {
504
+ type: string;
505
+ collection: boolean;
506
+ writeable: boolean;
507
+ default: boolean;
508
+ };
509
+ };
510
+ };
511
+ owners: string[];
512
+ extends: {
513
+ name: string;
514
+ priority: number;
515
+ owners: string[];
516
+ extends: {
517
+ name: string;
518
+ owners: any[];
519
+ properties: {
520
+ owner: {
521
+ type: string;
522
+ collection: boolean;
523
+ writeable: boolean;
524
+ };
525
+ type: {
526
+ type: string;
527
+ collection: boolean;
528
+ writeable: boolean;
529
+ };
530
+ name: {
531
+ type: string;
532
+ collection: boolean;
533
+ identifier: boolean;
534
+ writeable: boolean;
535
+ };
536
+ description: {
537
+ type: string;
538
+ collection: boolean;
539
+ writeable: boolean;
540
+ };
541
+ priority: {
542
+ type: string;
543
+ collection: boolean;
544
+ writeable: boolean;
545
+ };
546
+ directory: {
547
+ type: string;
548
+ collection: boolean;
549
+ writeable: boolean;
550
+ };
551
+ packaging: {
552
+ type: string;
553
+ collection: boolean;
554
+ writeable: boolean;
555
+ };
556
+ tags: {
557
+ type: string;
558
+ collection: boolean;
559
+ writeable: boolean;
560
+ };
561
+ };
562
+ };
563
+ specializations: {};
564
+ factoryFor(value: any): any;
565
+ properties: {
566
+ hostName: {
567
+ type: string;
568
+ collection: boolean;
569
+ writeable: boolean;
570
+ };
571
+ ipAddresses: {
572
+ type: string;
573
+ collection: boolean;
574
+ writeable: boolean;
575
+ };
576
+ hwaddr: {
577
+ type: string;
578
+ collection: boolean;
579
+ writeable: boolean;
580
+ };
581
+ network: {
582
+ type: string;
583
+ collection: boolean;
584
+ writeable: boolean;
585
+ };
586
+ destination: {
587
+ type: string;
588
+ collection: boolean;
589
+ writeable: boolean;
590
+ };
591
+ arpbridge: {
592
+ type: string;
593
+ collection: boolean;
594
+ writeable: boolean;
595
+ };
596
+ cidrAddresses: {
597
+ type: string;
598
+ collection: boolean;
599
+ writeable: boolean;
600
+ };
601
+ cidrAddress: {
602
+ type: string;
603
+ collection: boolean;
604
+ writeable: boolean;
605
+ };
606
+ addresses: {
607
+ type: string;
608
+ collection: boolean;
609
+ writeable: boolean;
610
+ };
611
+ address: {
612
+ type: string;
613
+ collection: boolean;
614
+ writeable: boolean;
615
+ };
616
+ scope: {
617
+ type: string;
618
+ collection: boolean;
619
+ writeable: boolean;
620
+ values: string[];
621
+ default: string;
622
+ };
623
+ class: {
624
+ type: string;
625
+ collection: boolean;
626
+ writeable: boolean;
627
+ values: string[];
628
+ };
629
+ kind: {
630
+ type: string;
631
+ collection: boolean;
632
+ writeable: boolean;
633
+ values: string[];
634
+ };
635
+ ssid: {
636
+ type: string;
637
+ collection: boolean;
638
+ writeable: boolean;
639
+ };
640
+ psk: {
641
+ type: string;
642
+ collection: boolean;
643
+ writeable: boolean;
644
+ };
645
+ metric: {
646
+ type: string;
647
+ collection: boolean;
648
+ writeable: boolean;
649
+ default: number;
650
+ };
651
+ MTU: {
652
+ type: string;
653
+ collection: boolean;
654
+ writeable: boolean;
655
+ default: number;
656
+ };
657
+ gateway: {
658
+ type: string;
659
+ collection: boolean;
660
+ writeable: boolean;
661
+ };
662
+ multicastDNS: {
663
+ type: string;
664
+ collection: boolean;
665
+ writeable: boolean;
666
+ default: boolean;
667
+ };
668
+ };
669
+ };
670
+ priority: number;
671
+ properties: {};
672
+ };
673
+ _ssid: any;
674
+ _psk: any;
349
675
  set ssid(value: any);
350
676
  get ssid(): any;
351
677
  set psk(value: any);
352
678
  get psk(): any;
353
- set kind(value: any);
354
- get kind(): any;
355
679
  }
356
680
  export class LoopbackNetworkInterface extends SkeletonNetworkInterface {
357
681
  static get typeDefinition(): {
@@ -1026,6 +1350,7 @@ declare class SkeletonNetworkInterface extends Base {
1026
1350
  networkAddress(filter: any): NetworkAddress;
1027
1351
  get address(): any;
1028
1352
  get addresses(): any[];
1353
+ systemdDefinitions(packageData: any): Promise<void>;
1029
1354
  }
1030
1355
  import { Base } from "pmcf";
1031
1356
  import { NetworkAddress } from "pmcf";