# Path: os_vif/internal/ip/api.py
# LOG = logging.getLogger(__name__)
# 
# Path: vif_plug_linux_bridge/privsep.py



import os
from os_vif.internal.ip.api import ip as ip_lib
from oslo_concurrency import lockutils
from oslo_concurrency import processutils
from oslo_log import log as logging
from vif_plug_linux_bridge import privsep
    # NOTE(danms): We also need to copy routes to the bridge so as
    #              not to break existing connectivity on the interface
    old_routes = []
    out, _ = processutils.execute('ip', 'route', 'show', 'dev',
                                  interface)
    for line in out.split('\n'):
        fields = line.split()
        if fields and 'via' in fields:
            old_routes.append(fields)
            processutils.execute('ip', 'route', 'del', *fields)

    out, _ = processutils.execute('ip', 'addr', 'show', 'dev',
                                  interface, 'scope', 'global')
    for line in out.split('\n'):
        fields = line.split()
        if fields and fields[0] == 'inet':
            if fields[-2] in ('secondary', 'dynamic', ):
                params = fields[1:-2]
            else:
                params = fields[1:-1]
                processutils.execute(*_ip_bridge_cmd('del', params,
                                                     fields[-1]),
                                     check_exit_code=[0, 2, 254])
                processutils.execute(*_ip_bridge_cmd('add', params,
                                                     bridge),
                                     check_exit_code=[0, 2, 254])
    for fields in old_routes:
        processutils.execute('ip', 'route', 'add', *fields)



# Path: os_vif/internal/ip/api.py
# LOG = logging.getLogger(__name__)
# 
# Path: vif_plug_linux_bridge/privsep.py



# Path: vif_plug_linux_bridge/linux_net.py
import os
from os_vif.internal.ip.api import ip as ip_lib
from oslo_concurrency import lockutils
from oslo_concurrency import processutils
from oslo_log import log as logging
from vif_plug_linux_bridge import privsep

    # NOTE(danms): We also need to copy routes to the bridge so as
    #              not to break existing connectivity on the interface
    old_routes = []
    out, _ = processutils.execute('ip', 'route', 'show', 'dev',
                                  interface)
    for line in out.split('\n'):
        fields = line.split()
        if fields and 'via' in fields:
            old_routes.append(fields)
            processutils.execute('ip', 'route', 'del', *fields)

    out, _ = processutils.execute('ip', 'addr', 'show', 'dev',
                                  interface, 'scope', 'global')
    for line in out.split('\n'):
        fields = line.split()
        if fields and fields[0] == 'inet':
            if fields[-2] in ('secondary', 'dynamic', ):
                params = fields[1:-2]
            else:
                params = fields[1:-1]
                processutils.execute(*_ip_bridge_cmd('del', params,
                                                     fields[-1]),
                                     check_exit_code=[0, 2, 254])
                processutils.execute(*_ip_bridge_cmd('add', params,
                                                     bridge),
                                     check_exit_code=[0, 2, 254])
    for fields in old_routes:
        processutils.execute('ip', 'route', 'add', *fields)



@privsep.vif_plug.entrypoint