diff --git a/src/Kathara/cli/ui/utils.py b/src/Kathara/cli/ui/utils.py index c0373b02..56e0f9cb 100644 --- a/src/Kathara/cli/ui/utils.py +++ b/src/Kathara/cli/ui/utils.py @@ -92,6 +92,12 @@ def create_topology_table(lab: Lab) -> Optional[RenderableType]: table = Table(title=ts_header, show_lines=True, box=box.SQUARE_DOUBLE_HEAD) + if not lab.links: + return Group( + Text(ts_header, style="italic", justify="center"), + create_panel("No Collision Domains Found", style="red bold", justify="center", box=box.DOUBLE) + ) + for link in sorted(lab.links.values(), key=lambda x: x.name): row_data = { 'LINK NAME': link.name, diff --git a/src/Kathara/manager/docker/DockerManager.py b/src/Kathara/manager/docker/DockerManager.py index e27bbae0..819893d5 100644 --- a/src/Kathara/manager/docker/DockerManager.py +++ b/src/Kathara/manager/docker/DockerManager.py @@ -707,7 +707,6 @@ def get_lab_from_api(self, lab_hash: Optional[str] = None, lab_name: Optional[st device.meta["sysctls"] = container.attrs["HostConfig"]["Sysctls"] if "none" not in container.attrs["NetworkSettings"]["Networks"]: - if "bridge" in container.attrs["NetworkSettings"]["Networks"].keys(): device.add_meta("bridged", True) container.attrs["NetworkSettings"]["Networks"].pop("bridge") @@ -763,6 +762,9 @@ def update_lab_from_api(self, lab: Lab) -> None: if "bridge" in container.attrs["NetworkSettings"]["Networks"].keys(): container.attrs["NetworkSettings"]["Networks"].pop("bridge") + if "none" in container.attrs["NetworkSettings"]["Networks"].keys(): + container.attrs["NetworkSettings"]["Networks"].pop("none") + current_ifaces = [ (lab.get_or_new_link(deployed_networks[name].attrs["Labels"]["name"]), options) for name, options in sorted(container.attrs["NetworkSettings"]["Networks"].items(), diff --git a/src/Kathara/manager/docker/stats/DockerMachineStats.py b/src/Kathara/manager/docker/stats/DockerMachineStats.py index 9d8b9a03..914504dc 100644 --- a/src/Kathara/manager/docker/stats/DockerMachineStats.py +++ b/src/Kathara/manager/docker/stats/DockerMachineStats.py @@ -37,12 +37,10 @@ def __init__(self, machine_api_object: Container): self.container_name: str = machine_api_object.name self.user: Optional[str] = machine_api_object.labels['user'] self.image: str = machine_api_object.image.tags[0] - self.interfaces: str = ",".join(sorted( - [f"{v['DriverOpts']['kathara.iface']}:{v['DriverOpts']['kathara.link']}" for n, v in - machine_api_object.attrs['NetworkSettings']['Networks'].items()])) # Dynamic Information self.status: Optional[str] = None self.pids: Optional[int] = None + self.interfaces: str = "-" self.cpu_usage: str = "-" self.mem_usage: str = "- / -" self.mem_percent: str = "-" @@ -65,6 +63,21 @@ def update(self) -> None: self.status = self.machine_api_object.status self.pids = updated_stats['pids_stats']['current'] if 'current' in updated_stats['pids_stats'] else 0 + + if self.name == "pc2": + print(self.machine_api_object.attrs['NetworkSettings']) + + networks = self.machine_api_object.attrs['NetworkSettings']['Networks'] + if 'none' in networks: + networks.pop('none') + if 'bridge' in networks: + networks.pop('bridge') + if networks: + self.interfaces = ", ".join(sorted( + [f"{v['DriverOpts']['kathara.iface']}:{v['DriverOpts']['kathara.link']}" for n, v in networks.items()])) + else: + self.interfaces = "-" + if "system_cpu_usage" in updated_stats["cpu_stats"]: cpu_usage = updated_stats["cpu_stats"]["cpu_usage"]["total_usage"] / \ updated_stats["cpu_stats"]["system_cpu_usage"]