Skip to content

Commit 0c2275f

Browse files
committed
ipv4: update from cluster
1 parent cf7c11b commit 0c2275f

File tree

6 files changed

+17
-7
lines changed

6 files changed

+17
-7
lines changed

src/warnet/backend/kubernetes_backend.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,8 @@ def create_pod_object(
567567
),
568568
)
569569

570-
def get_ipv4(self, pod_name: str, service_type: ServiceType) -> str | None:
570+
def get_ipv4(self, index: int, service_type: ServiceType) -> str | None:
571+
pod_name = self.get_pod_name(index, service_type)
571572
pod = self.get_pod(pod_name)
572573
if pod:
573574
return pod.status.pod_ip

src/warnet/cln.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def __init__(self, warnet, tank, backend: KubernetesBackend, options):
3030
self.image = options["ln_image"]
3131
self.cb = options["cb_image"]
3232
self.ln_config = options["ln_config"]
33+
self.ipv4 = None
3334
self.rpc_port = 10009
3435
self.impl = "cln"
3536

src/warnet/lnd.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def __init__(self, warnet, tank, backend: KubernetesBackend, options):
3232
self.image = options["ln_image"]
3333
self.cb = options["cb_image"]
3434
self.ln_config = options["ln_config"]
35+
self.ipv4 = None
3536
self.rpc_port = 10009
3637
self.impl = "lnd"
3738

src/warnet/server.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,13 @@ def scenario_log(self, proc):
170170
for line in proc.stdout:
171171
self.scenario_logger.info(line.decode().rstrip())
172172

173-
def get_warnet(self, network: str) -> Warnet:
173+
def get_warnet(self, network: str, refresh=False) -> Warnet:
174174
"""
175175
Will get a warnet from the cache if it exists.
176176
Otherwise it will create the network using from_network() and save it
177177
to the cache before returning it.
178178
"""
179-
if network in self.warnets:
179+
if network in self.warnets and not refresh:
180180
return self.warnets[network]
181181
wn = Warnet.from_network(network)
182182
if isinstance(wn, Warnet):
@@ -515,7 +515,7 @@ def network_info(self, network: str = "warnet") -> dict:
515515
"""
516516
Get info about a warnet network named <network>
517517
"""
518-
wn = self.get_warnet(network)
518+
wn = self.get_warnet(network, refresh=True)
519519
return wn._warnet_dict_representation()
520520

521521
def network_status(self, network: str = "warnet") -> list[dict]:

src/warnet/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import functools
2-
import ipaddress
32
import json
43
import logging
54
import os

src/warnet/warnet.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,20 @@ def _warnet_dict_representation(self) -> dict:
5454
tank_headers = [
5555
"Index",
5656
"Version",
57+
"IPv4",
5758
"bitcoin conf",
5859
"tc_netem",
5960
"LN",
6061
"LN Image",
62+
"LN IPv4",
6163
]
6264
has_ln = any(tank.lnnode and tank.lnnode.impl for tank in self.tanks)
6365
tanks = []
6466
for tank in self.tanks:
6567
tank_data = [
6668
tank.index,
6769
tank.version if tank.version else tank.image,
70+
tank.ipv4,
6871
tank.bitcoin_config,
6972
tank.netem,
7073
]
@@ -73,11 +76,13 @@ def _warnet_dict_representation(self) -> dict:
7376
[
7477
tank.lnnode.impl if tank.lnnode else "",
7578
tank.lnnode.image if tank.lnnode else "",
79+
tank.lnnode.ipv4 if tank.lnnode else "",
7680
]
7781
)
7882
tanks.append(tank_data)
7983
if not has_ln:
8084
tank_headers.remove("LN")
85+
tank_headers.remove("LN IPv4")
8186

8287
repr["tank_headers"] = tank_headers
8388
repr["tanks"] = tanks
@@ -133,8 +138,11 @@ def from_network(cls, network_name):
133138
if "services" in self.graph.graph:
134139
self.services = self.graph.graph["services"].split()
135140
for tank in self.tanks:
136-
pod_name = self.container_interface.get_pod_name(tank.index, ServiceType.BITCOIN)
137-
tank.ipv4 = self.container_interface.get_ipv4(pod_name, ServiceType.BITCOIN)
141+
tank.ipv4 = self.container_interface.get_ipv4(tank.index, ServiceType.BITCOIN)
142+
if tank.lnnode:
143+
tank.lnnode.ipv4 = self.container_interface.get_ipv4(
144+
tank.index, ServiceType.LIGHTNING
145+
)
138146
return self
139147

140148
def tanks_from_graph(self):

0 commit comments

Comments
 (0)