Пример #1
0
def create_bridge(name):
    cmd = [
        "ip",
        "link",
        "add",
        name,
        "type",
        "bridge",
        "stp_state",
        "1"  # enable stp by default 1 == on 0 == off
    ]
    run(cmd)
    interface.Interface(name).up()
Пример #2
0
def create_vlan(name, parent, tag):
    try:
        run([
            "ip", "link", "add", "link", parent, "name", name, "type", "vlan",
            "id",
            str(tag)
        ])
    except subprocess.CalledProcessError as e:
        if e.stderr.startswith("Cannot find device "):
            raise FileNotFoundError(e.stderr)

        raise

    interface.Interface(name).up()
Пример #3
0
 def add_port(self, name):
     interface.Interface(name).down()
     run(["ip", "link", "set", name, "master", self.name])
Пример #4
0
def create_lagg(name):
    run(["ip", "link", "add", name, "type", "bond"])
    interface.Interface(name).up()
Пример #5
0
def create_bridge(name):
    run(["ip", "link", "add", name, "type", "bridge"])
    interface.Interface(name).up()