Ejemplo n.º 1
0
class DhcpClient(object):
    PID_FILE = '/var/run/dhclient%s-%s.pid'
    DHCLIENT = CommandPath('dhclient', '/sbin/dhclient')

    def __init__(self,
                 iface,
                 family=4,
                 default_route=False,
                 duid_source=None,
                 cgroup=DHCLIENT_CGROUP):
        self.iface = iface
        self.family = family
        self.default_route = default_route
        self.duid_source_file = None if duid_source is None else (
            LEASE_FILE.format('' if family == 4 else '6', duid_source))
        self.pidFile = self.PID_FILE % (family, self.iface)
        if not os.path.exists(LEASE_DIR):
            os.mkdir(LEASE_DIR)
        self.leaseFile = LEASE_FILE.format('' if family == 4 else '6',
                                           self.iface)
        self._cgroup = cgroup

    def _dhclient(self):
        # Ask dhclient to stop any dhclient running for the device
        if os.path.exists(os.path.join(netinfo.NET_PATH, self.iface)):
            kill_dhclient(self.iface, self.family)
        cmd = [
            self.DHCLIENT.cmd,
            '-%s' % self.family, '-1', '-pf', self.pidFile, '-lf',
            self.leaseFile, self.iface
        ]
        if not self.default_route:
            # Instruct Fedora/EL's dhclient-script not to set gateway on iface
            cmd += ['-e', 'DEFROUTE=no']
        if self.duid_source_file:
            cmd += ['-df', self.duid_source_file]
        cmd = cmdutils.systemd_run(cmd, scope=True, slice=self._cgroup)
        return execCmd(cmd)

    def start(self, blocking):
        if blocking:
            return self._dhclient()
        else:
            t = threading.Thread(target=self._dhclient,
                                 name='vdsm-dhclient-%s' % self.iface)
            t.daemon = True
            t.start()

    def shutdown(self):
        try:
            pid = int(open(self.pidFile).readline().strip())
        except IOError as e:
            if e.errno == os.errno.ENOENT:
                pass
            else:
                raise
        else:
            _kill_and_rm_pid(pid, self.pidFile)
Ejemplo n.º 2
0
class DhcpClient(object):
    PID_FILE = '/var/run/dhclient-%s.pid'
    LEASE_DIR = '/var/lib/dhclient/'
    LEASE_FILE = LEASE_DIR + 'dhclient-%s.lease'
    DHCLIENT = CommandPath('dhclient', '/sbin/dhclient')

    def __init__(self, iface):
        self.iface = iface
        self.pidFile = self.PID_FILE % self.iface
        if not os.path.exists(self.LEASE_DIR):
            os.mkdir(self.LEASE_DIR)
        self.leaseFile = (self.LEASE_FILE % self.iface)

    def _dhclient(self):
        # Ask dhclient to stop any dhclient running for the device
        if os.path.exists(os.path.join(netinfo.NET_PATH, self.iface)):
            kill_dhclient(self.iface)
        rc, out, err = execCmd([
            self.DHCLIENT.cmd, '-1', '-pf', self.pidFile, '-lf',
            self.leaseFile, self.iface
        ])
        return rc, out, err

    def start(self, async):
        if async:
            t = threading.Thread(target=self._dhclient,
                                 name='vdsm-dhclient-%s' % self.iface)
            t.daemon = True
            t.start()
        else:
            rc, out, err = self._dhclient()
            return rc

    def shutdown(self):
        try:
            pid = int(open(self.pidFile).readline().strip())
        except IOError as e:
            if e.errno == os.errno.ENOENT:
                pass
            else:
                raise
        else:
            try:
                os.kill(pid, signal.SIGTERM)
            except OSError as e:
                if e.errno == os.errno.ESRCH:
                    pass
                else:
                    raise
            rmFile(self.pidFile)
Ejemplo n.º 3
0
import fcntl
import os
import socket
import struct

from netaddr.core import AddrFormatError
from netaddr import IPAddress
from netaddr import IPNetwork

from vdsm.commands import execCmd
from vdsm.config import config
from vdsm.network.netlink import link
from vdsm.utils import anyFnmatch
from vdsm.utils import CommandPath

_IP_BINARY = CommandPath('ip', '/sbin/ip')

NET_SYSFS = '/sys/class/net'
DUMMY_BRIDGE = ';vdsmdummy;'
_ROUTE_FLAGS = frozenset((
    # copied from iproute2's rtnl_rtntype_n2a()
    'unicast',
    'local',
    'broadcast',
    'anycast',
    'multicast',
    'blackhole',
    'unreachable',
    'prohibit',
    'throw',
    'nat',
Ejemplo n.º 4
0
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
# Refer to the README and COPYING files for full details of the license
#

from collections import namedtuple
from vdsm.utils import CommandPath
from vdsm.storage.misc import execCmd

ScanOutput = namedtuple('ScanOutput', [
    'partitionName', 'partitionStartBytes', 'partitionAlignment',
    'alignmentScanResult', 'alignmentScanExplanation'
])

_virtAlignmentScan = CommandPath(
    "virt-alignment-scan",
    "/usr/bin/virt-alignment-scan",  # Fedora, EL6
)


class VirtAlignError(Exception):
    pass


def runScanArgs(*args):
    cmd = [_virtAlignmentScan.cmd]
    cmd.extend(args)
    # TODO: remove the environment variable when the issue in
    # virt-alignment-scan/libvirt is resolved
    # http://bugzilla.redhat.com/1151838
    return execCmd(cmd, env={'LIBGUESTFS_BACKEND': 'direct'})
Ejemplo n.º 5
0
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
# Refer to the README and COPYING files for full details of the license
#

from errno import ENOENT, ESRCH
import logging
import os
from signal import SIGKILL, SIGTERM
from time import sleep, time

from vdsm.utils import CommandPath, execCmd

_DNSMASQ_BINARY = CommandPath('dnsmasq', '/usr/sbin/dnsmasq')
_DHCLIENT_BINARY = CommandPath('dhclient', '/usr/sbin/dhclient',
                               '/sbin/dhclient')
_START_CHECK_TIMEOUT = 0.5
_DHCLIENT_TIMEOUT = 10
_WAIT_FOR_STOP_TIMEOUT = 2
_DHCLIENT_LEASE = '/var/lib/dhclient/dhclient{0}--{1}.lease'
_DHCLIENT_LEASE_LEGACY = '/var/lib/dhclient/dhclient{0}-{1}.leases'


class DhcpError(Exception):
    pass


class Dnsmasq():
    def __init__(self):
Ejemplo n.º 6
0
import storage.storage_exception as se
import storage.volume
from storage.misc import execCmd
from storage.mount import Mount

from vdsm.config import config
from vdsm.constants import VDSM_USER, VDSM_GROUP
from vdsm.utils import CommandPath, RollbackContext
from vdsm import vdscli

from virt import vmstatus

if not config.getboolean('vars', 'xmlrpc_enable'):
    raise SkipTest("XML-RPC Bindings are disabled")

_exportfs = CommandPath("exportfs", "/usr/sbin/exportfs")

DEFAULT_TYPES = ('localfs', 'iscsi', 'glusterfs', 'nfs')
TYPES = tuple(os.environ.get('VDSM_TEST_STORAGE_TYPES', '').split()) \
    or DEFAULT_TYPES

DEFAULT_VERSIONS = (0, 3)
VERSIONS = tuple(os.environ.get('VDSM_TEST_STORAGE_VERSIONS', '').split()) \
    or DEFAULT_VERSIONS


@expandPermutations
class StorageTest(TestCaseBase):
    UPSTATES = frozenset((vmstatus.UP, vmstatus.POWERING_UP))

    def runTest(self):
Ejemplo n.º 7
0
from vdsm.constants import EXT_BRCTL
from vdsm.network.netconfpersistence import RunningConfig
from vdsm import sysctl
from vdsm.utils import CommandPath
from vdsm.commands import execCmd

from . import Configurator, runDhclient, getEthtoolOpts, wait_for_device
from .dhclient import DhcpClient
from ..errors import ConfigNetworkError, ERR_FAILED_IFUP, ERR_FAILED_IFDOWN
from ..models import Nic
from ..sourceroute import DynamicSourceRoute
from ..utils import remove_custom_bond_option

_ETHTOOL_BINARY = CommandPath(
    'ethtool',
    '/usr/sbin/ethtool',  # F19+
    '/sbin/ethtool',  # EL6, ubuntu and Debian
    '/usr/bin/ethtool',  # Arch
)
_BRCTL_DEV_EXISTS = ("device %s already exists; can't create bridge with the "
                     "same name")


def is_available():
    return True


class Iproute2(Configurator):
    def __init__(self, inRollback=False):
        self.unifiedPersistence = True
        super(Iproute2, self).__init__(ConfigApplier(), inRollback)
        self.runningConfig = RunningConfig()
Ejemplo n.º 8
0
from testlib import VdsmTestCase as TestCaseBase
from testlib import permutations, expandPermutations
from testlib import temporaryPath

import verify

from vdsm import cpuarch
from vdsm.utils import CommandPath
from vdsm.virt import vmstatus
from vdsm.storage.misc import execCmd

from utils import getProxy, SUCCESS


_mkinitrd = CommandPath("mkinitrd",
                        "/usr/bin/mkinitrd",  # Fedora
                        "/sbin/mkinitrd")  # RHEL 6.x, Centos 6.x
_kernelVer = os.uname()[2]
_kernelPath = "/boot/vmlinuz-" + _kernelVer
_initramfsPath = None
_initramfsPaths = ["/boot/initramfs-%s.img" % _kernelVer,  # Fedora, RHEL
                   "/boot/initrd.img-" + _kernelVer,  # Ubuntu
                   ]
_tmpinitramfs = False

VM_MINIMAL_UPTIME = 30

_GRAPHICS_FOR_ARCH = {cpuarch.PPC64LE: 'vnc',
                      cpuarch.X86_64: 'qxl'}

Ejemplo n.º 9
0
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
# Refer to the README and COPYING files for full details of the license
#
from contextlib import contextmanager

import six

from hooking import execCmd
import hooking

from vdsm.utils import CommandPath

EXT_IP = CommandPath('ip', '/sbin/ip').cmd
EXT_OVS_VSCTL = CommandPath('ovs-vsctl',
                            '/usr/sbin/ovs-vsctl',
                            '/usr/bin/ovs-vsctl').cmd
EXT_OVS_APPCTL = CommandPath('ovs-appctl',
                             '/usr/sbin/ovs-appctl',
                             '/usr/bin/ovs-appctl').cmd
BRIDGE_NAME = 'ovsbr0'

INIT_CONFIG_FILE = '/tmp/ovs_init_config'  # TODO: VDSM tmp folder


def rget(dict, keys, default=None):
    """ Recursive dictionary.get()
    >>> rget({'a': {'b': 'hello'}}, ('a', 'b'))
    'hello'
Ejemplo n.º 10
0
from vdsm.constants import P_VDSM_LOG, P_VDSM_RUN, EXT_KVM_2_OVIRT
from vdsm import cmdutils, concurrent, libvirtconnection
from vdsm.utils import monotonic_time, traceback, CommandPath, \
    NICENESS, IOCLASS

try:
    import ovirt_imageio_common
except ImportError:
    ovirt_imageio_common = None

_lock = threading.Lock()
_jobs = {}

_V2V_DIR = os.path.join(P_VDSM_RUN, 'v2v')
_LOG_DIR = os.path.join(P_VDSM_LOG, 'import')
_VIRT_V2V = CommandPath('virt-v2v', '/usr/bin/virt-v2v')
_SSH_AGENT = CommandPath('ssh-agent', '/usr/bin/ssh-agent')
_SSH_ADD = CommandPath('ssh-add', '/usr/bin/ssh-add')
_XEN_SSH_PROTOCOL = 'xen+ssh'
_VMWARE_PROTOCOL = 'vpx'
_KVM_PROTOCOL = 'qemu'
_SSH_AUTH_RE = '(SSH_AUTH_SOCK)=([^;]+).*;\nSSH_AGENT_PID=(\d+)'
_OVF_RESOURCE_CPU = 3
_OVF_RESOURCE_MEMORY = 4
_OVF_RESOURCE_NETWORK = 10

# OVF Specification:
# https://www.iso.org/obp/ui/#iso:std:iso-iec:17203:ed-1:v1:en
_OVF_NS = 'http://schemas.dmtf.org/ovf/envelope/1'
_RASD_NS = 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/' \
           'CIM_ResourceAllocationSettingData'
Ejemplo n.º 11
0
from __future__ import absolute_import

import collections
import json
import logging
import uuid

from vdsm.commands import execCmd
from vdsm.network import errors as ne
from vdsm.network.errors import ConfigNetworkError
from vdsm.utils import CommandPath

from . import (API as DriverAPI, Transaction as DriverTransaction, Command as
               DriverCommand)

_EXT_OVS_VSCTL = CommandPath('ovs-vsctl', '/usr/sbin/ovs-vsctl',
                             '/usr/bin/ovs-vsctl').cmd

# TODO: add a test which checks if following lists are mutual exclusive
# if there is just one item in a list, it is reported as single item
_DB_ENTRIES_WHICH_SHOULD_BE_LIST = {'ports', 'interfaces'}
# if a single item entry is not defined, it is reported as empty list
_DB_ENTRIES_WHICH_SHOULD_NOT_BE_LIST = {
    'tag', 'bond_active_slave', 'bond_mode', 'lacp', 'mac_in_use'
}


class Transaction(DriverTransaction):
    def __init__(self):
        self.commands = []

    def commit(self):
Ejemplo n.º 12
0
Archivo: v2v.py Proyecto: fancyKai/vdsm
import libvirt

from vdsm.constants import P_VDSM_RUN
from vdsm.define import errCode, doneCode
from vdsm import libvirtconnection, response, concurrent
from vdsm.infra import zombiereaper
from vdsm.utils import traceback, CommandPath, execCmd, NICENESS, IOCLASS

import caps

_lock = threading.Lock()
_jobs = {}

_V2V_DIR = os.path.join(P_VDSM_RUN, 'v2v')
_VIRT_V2V = CommandPath('virt-v2v', '/usr/bin/virt-v2v')
_OVF_RESOURCE_CPU = 3
_OVF_RESOURCE_MEMORY = 4
_OVF_RESOURCE_NETWORK = 10

# OVF Specification:
# https://www.iso.org/obp/ui/#iso:std:iso-iec:17203:ed-1:v1:en
_OVF_NS = 'http://schemas.dmtf.org/ovf/envelope/1'
_RASD_NS = 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/' \
           'CIM_ResourceAllocationSettingData'

ImportProgress = namedtuple('ImportProgress',
                            ['current_disk', 'disk_count', 'description'])
DiskProgress = namedtuple('DiskProgress', ['progress'])

Ejemplo n.º 13
0
Archivo: vsctl.py Proyecto: rexhsu/vdsm
def _ovs_vsctl_cmd():
    return CommandPath('ovs-vsctl', '/usr/sbin/ovs-vsctl',
                       '/usr/bin/ovs-vsctl').cmd
Ejemplo n.º 14
0
import re
import sys
from collections import defaultdict

from vdsm.tool import expose
from vdsm.utils import CommandPath
from vdsm.utils import execCmd as _execCmd


def execCmd(argv, raw=True, *args, **kwargs):
    return _execCmd(argv, raw=raw, *args, **kwargs)


_SYSTEMCTL = CommandPath(
    "systemctl",
    "/bin/systemctl",
    "/usr/bin/systemctl",
)

_INITCTL = CommandPath(
    "initctl",
    "/sbin/initctl",
)

_SERVICE = CommandPath(
    "service",
    "/sbin/service",
    "/usr/sbin/service",
)

_CHKCONFIG = CommandPath(
Ejemplo n.º 15
0
from nose.plugins.skip import SkipTest

from testrunner import VdsmTestCase as TestCaseBase
from testrunner import permutations, expandPermutations
from testrunner import temporaryPath

from vdsm.utils import CommandPath, RollbackContext
import storageTests as storage
from storage.misc import execCmd

from utils import VdsProxy, SUCCESS

from virt import vmstatus

_mkinitrd = CommandPath(
    "mkinitrd",
    "/usr/bin/mkinitrd",  # Fedora
    "/sbin/mkinitrd")  # RHEL 6.x, Centos 6.x
_modprobe = CommandPath(
    "modprobe",
    "/usr/sbin/modprobe",  # Fedora, Ubuntu
    "/sbin/modprobe")  # RHEL6
_kernelVer = os.uname()[2]
_kernelPath = "/boot/vmlinuz-" + _kernelVer
_initramfsPath = None
_initramfsPaths = [
    "/boot/initramfs-%s.img" % _kernelVer,  # Fedora, RHEL
    "/boot/initrd.img-" + _kernelVer,  # Ubuntu
]
_tmpinitramfs = False

VM_MINIMAL_UPTIME = 30
Ejemplo n.º 16
0
import signal
import struct
import time
from contextlib import contextmanager
from multiprocessing import Process

from nose.plugins.skip import SkipTest

from vdsm.constants import EXT_BRCTL, EXT_TC
from vdsm.ipwrapper import (addrAdd, linkSet, linkAdd, linkDel, IPRoute2Error,
                            netns_add, netns_delete, netns_exec)
from vdsm.netlink import monitor
from vdsm.utils import CommandPath, execCmd, random_iface_name

EXT_IP = "/sbin/ip"
_IPERF3_BINARY = CommandPath('iperf3', '/usr/bin/iperf3')


class ExecError(RuntimeError):
    def __init__(self, msg, out, err):
        super(ExecError, self).__init__(msg)
        self.out = out
        self.err = err


def check_call(cmd):
    rc, out, err = execCmd(cmd, raw=True)
    if rc != 0:
        raise ExecError(
            'Command %s returned non-zero exit status %s.' % (cmd, rc), out,
            err)
Ejemplo n.º 17
0
from vdsm.constants import VDSM_USER, VDSM_GROUP, QEMU_PROCESS_USER, EXT_SUDO
import storage.sd
import storage.storage_exception as se
import storage.volume
from storage.misc import execCmd
from storage.misc import RollbackContext
from storage.mount import Mount
from vdsm.utils import CommandPath
from vdsm import vdscli

_VARTMP = '/var/tmp'

if not config.getboolean('vars', 'xmlrpc_enable'):
    raise SkipTest("XML-RPC Bindings are disabled")

_mkinitrd = CommandPath("mkinird", "/usr/bin/mkinitrd")
_modprobe = CommandPath(
    "modprobe",
    "/usr/sbin/modprobe",  # Fedora, Ubuntu
    "/sbin/modprobe",  # RHEL6
)
_exportfs = CommandPath("exportfs", "/usr/sbin/exportfs")


def readableBy(filePath, user):
    rc, out, err = execCmd([EXT_SUDO, '-u', user, 'head', '-c', '0', filePath])
    return rc == 0


@contextmanager
def kernelBootImages():
Ejemplo n.º 18
0
from testlib import namedTemporaryDir
import v2v
from vdsm import libvirtconnection
from vdsm.password import ProtectedPassword
from vdsm.utils import CommandPath, execCmd

from nose.plugins.skip import SkipTest
from testlib import VdsmTestCase as TestCaseBase, recorded
from monkeypatch import MonkeyPatch, MonkeyPatchScope

import vmfakelib as fake

VmSpec = namedtuple('VmSpec', ['name', 'vmid'])

FAKE_VIRT_V2V = CommandPath('fake-virt-v2v', os.path.abspath('fake-virt-v2v'))


def _mac_from_uuid(vmid):
    return "52:54:%s:%s:%s:%s" % (vmid[:2], vmid[2:4], vmid[4:6], vmid[6:8])


class VmMock(object):
    def __init__(self,
                 name="RHEL",
                 vmid="564d7cb4-8e3d-06ec-ce82-7b2b13c6a611"):
        self._name = name
        self._vmid = vmid
        self._mac_address = _mac_from_uuid(vmid)

    def name(self):
Ejemplo n.º 19
0
import errno
import logging
import os
import subprocess

from vdsm import cmdutils
from vdsm import concurrent
from vdsm.network import errors as ne
from vdsm.network.link import iface as linkiface
from vdsm.commands import execCmd
from vdsm.utils import CommandPath, memoized, pgrep, kill_and_rm_pid

from . import address

DHCLIENT_BINARY = CommandPath('dhclient', '/sbin/dhclient')
DHCLIENT_CGROUP = 'vdsm-dhclient'
LEASE_DIR = '/var/lib/dhclient'
LEASE_FILE = os.path.join(LEASE_DIR, 'dhclient{0}--{1}.lease')


class DhcpClient(object):
    PID_FILE = '/var/run/dhclient%s-%s.pid'

    def __init__(self, iface, family=4, default_route=False, duid_source=None,
                 cgroup=DHCLIENT_CGROUP):
        self.iface = iface
        self.family = family
        self.default_route = default_route
        self.duid_source_file = None if duid_source is None else (
            LEASE_FILE.format('' if family == 4 else '6', duid_source))
Ejemplo n.º 20
0
           has_snapshots=False),
    VmSpec("RHEL_2",
           str(uuid.uuid4()),
           id=2,
           active=False,
           has_snapshots=False),
    VmSpec("RHEL_3",
           str(uuid.uuid4()),
           id=3,
           active=False,
           has_snapshots=False),
    VmSpec("RHEL_4", str(uuid.uuid4()), id=4, active=False,
           has_snapshots=True),
)

FAKE_VIRT_V2V = CommandPath('fake-virt-v2v', os.path.abspath('fake-virt-v2v'))
FAKE_SSH_ADD = CommandPath('fake-ssh-add', os.path.abspath('fake-ssh-add'))
FAKE_SSH_AGENT = CommandPath('fake-ssh-agent',
                             os.path.abspath('fake-ssh-agent'))


def _mac_from_uuid(vm_uuid):
    return "52:54:%s:%s:%s:%s" % (vm_uuid[:2], vm_uuid[2:4], vm_uuid[4:6],
                                  vm_uuid[6:8])


class MockVirDomain(object):
    def __init__(self,
                 name="RHEL",
                 vm_uuid="564d7cb4-8e3d-06ec-ce82-7b2b13c6a611",
                 id=0,
Ejemplo n.º 21
0
from storage.misc import execCmd
from storage.mount import Mount

from vdsm.config import config
from vdsm.constants import VDSM_USER, VDSM_GROUP
from vdsm.utils import CommandPath, RollbackContext
from vdsm import vdscli

from virt import vmstatus

if not config.getboolean('vars', 'xmlrpc_enable'):
    raise SkipTest("XML-RPC Bindings are disabled")

_modprobe = CommandPath(
    "modprobe",
    "/usr/sbin/modprobe",  # Fedora, Ubuntu
    "/sbin/modprobe",  # RHEL6
)
_exportfs = CommandPath("exportfs", "/usr/sbin/exportfs")

DEFAULT_TYPES = ('localfs', 'iscsi', 'glusterfs', 'nfs')
TYPES = tuple(os.environ.get('VDSM_TEST_STORAGE_TYPES', '').split()) \
    or DEFAULT_TYPES

DEFAULT_VERSIONS = (0, 3)
VERSIONS = tuple(os.environ.get('VDSM_TEST_STORAGE_VERSIONS', '').split()) \
    or DEFAULT_VERSIONS


@expandPermutations
class StorageTest(TestCaseBase):
Ejemplo n.º 22
0
VM_ID_KEY = 'vmId'
PROVIDER_TYPE_KEY = 'provider_type'
OPENSTACK_NET_PROVIDER_TYPE = 'OPENSTACK_NETWORK'
VNIC_ID_KEY = 'vnic_id'
PLUGIN_TYPE_KEY = 'plugin_type'
SECURITY_GROUPS_KEY = 'security_groups'
PT_BRIDGE = 'LINUX_BRIDGE'
PT_OVS = 'OPEN_VSWITCH'

# Default integration bridge name to use for OVS
INTEGRATION_BRIDGE = 'br-int'

# The maximum device name length in Linux
DEV_MAX_LENGTH = 14

EXT_BRCTL = CommandPath('brctl', '/sbin/brctl', '/usr/sbin/brctl').cmd
EXT_IP = CommandPath('ip', '/sbin/ip').cmd
ovs_vsctl = CommandPath('ovs-vsctl', '/usr/sbin/ovs-vsctl',
                        '/usr/bin/ovs-vsctl')
MARK_FOR_UNPAUSE_FILE = 'marked_for_unpause'
MARK_FOR_UNPAUSE_PATH = os.path.join(
    constants.P_VDSM_RUN,
    '%s',
    MARK_FOR_UNPAUSE_FILE,
)

# Make pyflakes happy
DUMMY_BRIDGE


def executeOrExit(command):
Ejemplo n.º 23
0
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
#
# Refer to the README and COPYING files for full details of the license
#
from contextlib import contextmanager
import logging

from nose.plugins.skip import SkipTest

from vdsm.utils import CommandPath
from vdsm.utils import execCmd

_FIREWALLD_BINARY = CommandPath('firewall-cmd', '/bin/firewall-cmd')
_IPTABLES_BINARY = CommandPath('iptables', '/sbin/iptables')
_SERVICE_BINARY = CommandPath('service', '/sbin/service')


class FirewallError(Exception):
    pass


@contextmanager
def allow_dhcp(iface):
    """Temporarily allow DHCP traffic in firewall."""
    _allow_dhcp(iface)
    try:
        yield
    finally: