Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependencies linux #332

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lnst/Common/NetUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import re
import socket
import subprocess
from pyroute2 import IPRoute


def normalize_hwaddr(hwaddr):
Expand All @@ -24,6 +23,7 @@ def normalize_hwaddr(hwaddr):


def scan_netdevs():
from pyroute2 import IPRoute
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i grepped this in the repo and we don't actually use this function anywhere... i think we should just remove it completely...

originally i wanted to know if this was in any way used on the controller, because this seems like an agent only function anyway.

scan = []

with IPRoute() as ipr:
Expand Down
21 changes: 14 additions & 7 deletions lnst/Devices/Device.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@
"""

import re
import ethtool
import pyroute2
import logging
import pprint
import time
from abc import ABCMeta
from pyroute2.netlink.rtnl import ifinfmsg
from lnst.Common.Logs import log_exc_traceback
from lnst.Common.ExecCmd import exec_cmd, ExecCmdFail
from lnst.Common.DeviceError import DeviceError, DeviceDeleted, DeviceDisabled
Expand All @@ -28,10 +25,6 @@
from lnst.Common.HWAddress import hwaddress
from lnst.Common.Utils import wait_for_condition

from pyroute2.netlink.rtnl import RTM_NEWLINK
from pyroute2.netlink.rtnl import RTM_NEWADDR
from pyroute2.netlink.rtnl import RTM_DELADDR

TOGGLE_STATE_TIMEOUT = 15 + 3 # as a reserve

class DeviceMeta(ABCMeta):
Expand All @@ -55,6 +48,20 @@ class Device(object, metaclass=DeviceMeta):
"""

def __init__(self, if_manager):
import ethtool
import pyroute2
global ethtool
global pyroute2

from pyroute2.netlink.rtnl import ifinfmsg
from pyroute2.netlink.rtnl import RTM_NEWLINK
from pyroute2.netlink.rtnl import RTM_NEWADDR
from pyroute2.netlink.rtnl import RTM_DELADDR
global ifinfmsg
global RTM_NEWLINK
global RTM_NEWADDR
global RTM_DELADDR

self.ifindex = None
self._nl_msg = None
self._devlink = None
Expand Down
7 changes: 5 additions & 2 deletions lnst/Devices/L2TPSessionDevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
[email protected] (Jan Tluka)
"""

from pyroute2.netlink import NetlinkError
from pyroute2.netlink.generic.l2tp import L2tp
from lnst.Common.DeviceError import DeviceError, DeviceConfigError
from lnst.Devices.Device import Device

Expand Down Expand Up @@ -55,6 +53,11 @@ def test(self):
_mandatory_opts = ["tunnel_id", "session_id", "peer_session_id"]

def __init__(self, ifmanager, *args, **kwargs):
from pyroute2.netlink import NetlinkError
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we should have a generic Device._import_agent_dependencies method which is then extended in the derived class here to separate it a bit logically from normal instance initialization.

from pyroute2.netlink.generic.l2tp import L2tp
global NetlinkError
global L2tp

self._name = None
for i in self._mandatory_opts:
if i not in kwargs:
Expand Down
4 changes: 2 additions & 2 deletions lnst/RecipeCommon/L2TPManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
"""

import logging
from pyroute2.netlink import NetlinkError
from pyroute2.netlink.generic.l2tp import L2tp
from lnst.Common.LnstError import LnstError


Expand Down Expand Up @@ -84,6 +82,8 @@ def _test(self):
)
"""
def __init__(self):
from pyroute2.netlink import NetlinkError
from pyroute2.netlink.generic.l2tp import L2tp
self._tunnels = []

try:
Expand Down
3 changes: 2 additions & 1 deletion lnst/RecipeCommon/MPTCPManager.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from enum import IntFlag
from typing import Dict, List

from pyroute2 import MPTCP
from socket import AF_INET, AF_INET6
from lnst.Common.IpAddress import ipaddress, BaseIpAddress

Expand Down Expand Up @@ -78,6 +77,8 @@ def is_backup(self):

class MPTCPManager:
def __init__(self):
from pyroute2 import MPTCP

self._mptcp = MPTCP()
self._endpoints = {}

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ include = ["schema-am.rng", "install/*", "lnst-ctl.conf"]
[tool.poetry.dependencies]
python = "^3.9"
lxml = "*"
ethtool = "*"
pyroute2 = "*"
ethtool = {version = "*", platform = 'linux'}
pyroute2 = {version = "*", platform = 'linux'}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think if possible i'd also like this to be split in a way that these only install on the Agent installations... and a pure controller installation doesn't need these.

simply for situations when i want to install a pure controller on linux, this will still want to install these dependencies.


libvirt-python = {version = "*", optional = true }
podman = {version = "*", optional = true }
Expand Down
Loading