Skip to content

Commit

Permalink
Merge pull request #289 from KatharaFramework/develop
Browse files Browse the repository at this point in the history
Kathará v3.7.5
  • Loading branch information
tcaiazzi authored May 1, 2024
2 parents 362ba16 + ec61ce5 commit dcb48fa
Show file tree
Hide file tree
Showing 18 changed files with 58 additions and 191 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ body:
attributes:
label: Kathará Version
description: "Please provide the Kathará version you are using (`kathara -v`)."
placeholder: "3.7.4"
placeholder: "3.7.5"
validations:
required: true
- type: textarea
Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ We release patches for security vulnerabilities only for the last version:

| Version | Supported Versions |
|---------|--------------------|
| 3.7.4 | :white_check_mark: |
| 3.7.5 | :white_check_mark: |

## Reporting a Vulnerability

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "kathara"
version = "3.7.4"
version = "3.7.5"
description = "A lightweight container-based network emulation tool."
readme = "README.md"
requires-python = ">=3.9"
Expand Down
4 changes: 2 additions & 2 deletions scripts/Linux-Deb/Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/make -f

VERSION=3.7.4
VERSION=3.7.5
DEBIAN_PACKAGE_VERSION=1
LAUNCHPAD_NAME=user
NO_BINARY_PACKAGES=pyroute2|pyuv|deepdiff

.PHONY: allSigned docker-build-image prepare-deb-source unpack-deb-source clean-output-folder copy-debian-folder download-pip build-man build-deb-unsigned build-deb-signed ppa clean venv autocompletion

allSigned: clean prepare-deb-source docker-signed_focal docker-signed_jammy
allSigned: clean prepare-deb-source docker-signed_focal docker-signed_jammy docker-signed_noble

docker-unsigned_%: clean prepare-deb-source docker-build-image_%
docker run -ti --rm -v `pwd`/../../:/opt/kathara kathara/linux-build-deb:$* /bin/bash -c \
Expand Down
4 changes: 2 additions & 2 deletions scripts/Linux-Deb/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kathara (__VERSION__-__DEBIAN_PACKAGE_VERSION____UBUNTU_VERSION__) __UBUNTU_VERSION__; urgency=low

* (Docker) Fix "rp_filter" on "eth0" that was causing startup errors on some distributions
* (Megalos) Fix watch methods while starting/stopping devices that were causing "lstart"/"lclean" to hang indefinitely
* (Docker) Fix "rp_filter" issue on all platforms and Docker versions
* (Docker) Fix Docker API objects reloading
* Minor fixes

-- Kathara Team <contact@kathara.org> __DATE__
2 changes: 1 addition & 1 deletion scripts/Linux-Pkg/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/make -f

VERSION=3.7.4
VERSION=3.7.5
PACKAGE_VERSION=1
AUR_NAME=user
AUR_MAIL=contact@kathara.org
Expand Down
4 changes: 2 additions & 2 deletions scripts/Linux-Pkg/pkginfo/kathara.changelog
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__DATE__ Kathara Team <******@kathara.org>

* Release v__VERSION__
* (Docker) Fix "rp_filter" on "eth0" that was causing startup errors on some distributions
* (Megalos) Fix watch methods while starting/stopping devices that were causing "lstart"/"lclean" to hang indefinitely
* (Docker) Fix "rp_filter" issue on all platforms and Docker versions
* (Docker) Fix Docker API objects reloading
* Minor fixes
2 changes: 1 addition & 1 deletion scripts/Linux-Rpm/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/make -f

VERSION=3.7.4
VERSION=3.7.5
PACKAGE_VERSION=1

.PHONY: all clean docker-build-image prepare-source prepare-man-pages prepare-bash-completion pack-source build
Expand Down
4 changes: 2 additions & 2 deletions scripts/Linux-Rpm/rpm/kathara.spec
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ chmod g+s %{_libdir}/kathara/kathara

%changelog
* __DATE__ Kathara Team <******@kathara.org> - __VERSION__-__PACKAGE_VERSION__
- (Docker) Fix "rp_filter" on "eth0" that was causing startup errors on some distributions
- (Megalos) Fix watch methods while starting/stopping devices that were causing "lstart"/"lclean" to hang indefinitely
- (Docker) Fix "rp_filter" issue on all platforms and Docker versions
- (Docker) Fix Docker API objects reloading
- Minor fixes
2 changes: 1 addition & 1 deletion scripts/OSX/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/make -s

PRODUCT=Kathara
VERSION=3.7.4
VERSION=3.7.5
TARGET_DIRECTORY=Output
APPLE_DEVELOPER_CERTIFICATE_ID=FakeID
ROFF_DIR=../../docs/Roff
Expand Down
2 changes: 1 addition & 1 deletion scripts/Windows/installer.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "Kathara"
#define MyAppVersion "3.7.4"
#define MyAppVersion "3.7.5"
#define MyAppPublisher "Kathara Team"
#define MyAppURL "https://www.kathara.org"
#define MyAppExeName "kathara.exe"
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = kathara
version = 3.7.4
version = 3.7.5
author = Kathara Framework
author_email = contact@kathara.org
description = A lightweight container-based network emulation tool.
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
package_dir={'': 'src'},
packages=find_packages('src'),
py_modules=['kathara'],
version='3.7.4',
version='3.7.5',
license='gpl-3.0',
description='A lightweight container-based network emulation tool.',
author='Kathara Framework',
author_email='contact@kathara.org',
url='https://www.kathara.org',
download_url='https://github.com/KatharaFramework/Kathara/archive/refs/tags/3.7.4.tar.gz',
download_url='https://github.com/KatharaFramework/Kathara/archive/refs/tags/3.7.5.tar.gz',
keywords=['NETWORK-EMULATION', 'CONTAINERS', 'NFV'],
install_requires=[
"binaryornot>=0.4.4",
Expand Down
20 changes: 7 additions & 13 deletions src/Kathara/manager/docker/DockerMachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import docker.models.containers
from docker import DockerClient
from docker.errors import APIError
from docker.utils import version_lt

from .DockerImage import DockerImage
from .stats.DockerMachineStats import DockerMachineStats
Expand Down Expand Up @@ -101,11 +102,11 @@

class DockerMachine(object):
"""The class responsible for deploying Kathara devices as Docker container and interact with them."""
__slots__ = ['client', 'docker_image']
__slots__ = ['client', '_engine_version', 'docker_image']

def __init__(self, client: DockerClient, docker_image: DockerImage) -> None:
self.client: DockerClient = client

self._engine_version: str = client.version()['Version']
self.docker_image: DockerImage = docker_image

def deploy_machines(self, lab: Lab, selected_machines: Set[str] = None) -> None:
Expand Down Expand Up @@ -242,15 +243,8 @@ def create(self, machine: Machine) -> None:

sysctl_first_interface = {}
if first_machine_iface:
def sysctl_linux():
if utils.is_wsl_platform():
return {RP_FILTER_NAMESPACE % "eth0": 0}
return {}

def sysctl_windows():
return {RP_FILTER_NAMESPACE % "eth0": 0}

sysctl_first_interface = utils.exec_by_platform(sysctl_linux, sysctl_windows, lambda: {})
if version_lt(self._engine_version, "26.0.0"):
sysctl_first_interface = {RP_FILTER_NAMESPACE % "eth0": 0}

if machine.is_ipv6_enabled():
sysctl_parameters["net.ipv6.conf.all.forwarding"] = 1
Expand Down Expand Up @@ -345,7 +339,6 @@ def connect_interface(machine: Machine, interface: Interface) -> None:
DockerPluginError: If Kathara has been left in an inconsistent state.
APIError: If the Docker APIs return an error.
"""
machine.api_object.reload()
attached_networks = machine.api_object.attrs["NetworkSettings"]["Networks"]

if interface.link.api_object.name not in attached_networks:
Expand Down Expand Up @@ -375,7 +368,6 @@ def disconnect_from_link(machine: Machine, link: Link) -> None:
Returns:
None
"""
machine.api_object.reload()
attached_networks = machine.api_object.attrs["NetworkSettings"]["Networks"]

if link.api_object.name in attached_networks:
Expand Down Expand Up @@ -472,6 +464,8 @@ def start(self, machine: Machine) -> None:
f"Please specify a valid shell for this device."
)

machine.api_object.reload()

def undeploy(self, lab_hash: str, selected_machines: Set[str] = None) -> None:
"""Undeploy the devices contained in the network scenario defined by the lab_hash.
Expand Down
20 changes: 16 additions & 4 deletions src/Kathara/manager/docker/DockerManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def deploy_lab(self, lab: Lab, selected_machines: Set[str] = None) -> None:

@privileged
def connect_machine_to_link(self, machine: Machine, link: Link, mac_address: Optional[str] = None) -> None:
"""Create a new interface and connect a Kathara device to a collision domain.
"""Create a new interface on a running Kathara device and connect it to a collision domain.
Args:
machine (Kathara.model.Machine): A Kathara machine object.
Expand All @@ -174,7 +174,11 @@ def connect_machine_to_link(self, machine: Machine, link: Link, mac_address: Opt
if not machine.lab:
raise LabNotFoundError("Device `%s` is not associated to a network scenario." % machine.name)

if not machine.api_object or machine.api_object.status != "running":
if not machine.api_object:
raise MachineNotRunningError(machine.name)

machine.api_object.reload()
if machine.api_object.status != "running":
raise MachineNotRunningError(machine.name)

if not link.lab:
Expand All @@ -192,23 +196,31 @@ def connect_machine_to_link(self, machine: Machine, link: Link, mac_address: Opt

@privileged
def disconnect_machine_from_link(self, machine: Machine, link: Link) -> None:
"""Disconnect a Kathara device from a collision domain.
"""Disconnect a running Kathara device from a collision domain.
Args:
machine (Kathara.model.Machine): A Kathara machine object.
link (Kathara.model.Link): The Kathara collision domain from which disconnect the device.
link (Kathara.model.Link): The Kathara collision domain from which disconnect the running device.
Returns:
None
Raises:
LabNotFoundError: If the device specified is not associated to any network scenario.
MachineNotRunningError: If the specified device is not running.
LabNotFoundError: If the collision domain is not associated to any network scenario.
MachineCollisionDomainConflictError: If the device is not connected to the collision domain.
"""
if not machine.lab:
raise LabNotFoundError(f"Device `{machine.name}` is not associated to a network scenario.")

if not machine.api_object:
raise MachineNotRunningError(machine.name)

machine.api_object.reload()
if machine.api_object.status != "running":
raise MachineNotRunningError(machine.name)

if not link.lab:
raise LabNotFoundError(f"Collision domain `{link.name}` is not associated to a network scenario.")

Expand Down
2 changes: 1 addition & 1 deletion src/Kathara/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Tuple

CURRENT_VERSION = "3.7.4"
CURRENT_VERSION = "3.7.5"


def parse(version: str) -> Tuple:
Expand Down
Loading

0 comments on commit dcb48fa

Please sign in to comment.