pmcf 2.4.1 → 2.5.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.4.1",
3
+ "version": "2.5.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/host.mjs CHANGED
@@ -385,6 +385,24 @@ export class Host extends Base {
385
385
  }
386
386
  }
387
387
 
388
+ get network() {
389
+ for (const ni of this.networkInterfaces.values()) {
390
+ if (ni._kind !== "loopback" && ni._network) {
391
+ return ni._network;
392
+ }
393
+ }
394
+
395
+ return super.network;
396
+ }
397
+
398
+ get networks() {
399
+ return new Set(
400
+ [...this.networkInterfaces.values()]
401
+ .filter(ni => ni._network)
402
+ .map(ni => ni._network)
403
+ );
404
+ }
405
+
388
406
  get networkInterfaces() {
389
407
  return this._networkInterfaces;
390
408
  }
package/src/owner.mjs CHANGED
@@ -137,28 +137,20 @@ export class Owner extends Base {
137
137
  return this.typeNamed("host", name) || this.typeNamed("cluster", name);
138
138
  }
139
139
 
140
- *hosts() {
141
- const hosts = new Set();
140
+ hosts() {
141
+ let hosts = new Set();
142
142
 
143
143
  for (const type of ["host", "cluster"]) {
144
- for (const host of this.typeList(type)) {
145
- if (!hosts.has(host)) {
146
- hosts.add(host);
147
- yield host;
148
- }
149
- }
144
+ hosts = hosts.union(new Set(Array.from(this.typeList(type))));
150
145
  }
151
146
 
152
147
  for (const type of types.host.owners) {
153
148
  for (const object of this.typeList(type)) {
154
- for (const host of object.hosts()) {
155
- if (!hosts.has(host)) {
156
- hosts.add(host);
157
- yield host;
158
- }
159
- }
149
+ hosts = hosts.union(object.hosts());
160
150
  }
161
151
  }
152
+
153
+ return hosts;
162
154
  }
163
155
 
164
156
  networkNamed(name) {
@@ -179,7 +171,7 @@ export class Owner extends Base {
179
171
  }
180
172
  yield* this.typeList("subnet");
181
173
 
182
- /* for (const network of this.networks()) {
174
+ /* for (const network of this.networks()) {
183
175
  yield* network.subnets();
184
176
  }*/
185
177
  }
@@ -39,6 +39,9 @@ export class DHCPService extends Service {
39
39
  const network = this.network;
40
40
  const host = this.server;
41
41
  const name = host.name;
42
+
43
+ console.log("kea", host.name, network.name);
44
+
42
45
  const packageData = {
43
46
  dir,
44
47
  sources: [new FileContentProvider(dir + "/")[Symbol.asyncIterator]()],
@@ -54,7 +57,9 @@ export class DHCPService extends Service {
54
57
 
55
58
  const commonConfig = {
56
59
  "interfaces-config": {
57
- interfaces: [...host.networkInterfaces.values()].filter(ni=>ni.kind !== 'loopback').map(ni => ni.name)
60
+ interfaces: [...host.networkInterfaces.values()]
61
+ .filter(ni => ni.kind !== "loopback")
62
+ .map(ni => ni.name)
58
63
  },
59
64
  "lease-database": {
60
65
  type: "memfile",
@@ -164,7 +169,7 @@ export class DHCPService extends Service {
164
169
  "option-data": [
165
170
  {
166
171
  name: "domain-name-servers",
167
- data: serviceAddresses(this, {
172
+ data: serviceAddresses(network, {
168
173
  type: "dns",
169
174
  priority: "<10"
170
175
  }).join(",")
package/types/host.d.mts CHANGED
@@ -227,6 +227,7 @@ export class Host extends Base {
227
227
  domainNamesIn(domain: any): Generator<any, void, unknown>;
228
228
  get host(): this;
229
229
  named(name: any): any;
230
+ get networks(): Set<any>;
230
231
  set networkInterfaces(networkInterface: Map<any, any>);
231
232
  get networkInterfaces(): Map<any, any>;
232
233
  networkAddresses(): Generator<{
package/types/owner.d.mts CHANGED
@@ -142,7 +142,7 @@ export class Owner extends Base {
142
142
  locationNamed(name: any): any;
143
143
  locations(): any;
144
144
  hostNamed(name: any): any;
145
- hosts(): Generator<any, void, unknown>;
145
+ hosts(): Set<any>;
146
146
  networkNamed(name: any): any;
147
147
  networks(): any;
148
148
  subnetNamed(name: any): any;