コード例 #1
0
ファイル: utilsTests.py プロジェクト: kripper/vdsm
 def testMissing(self):
     NAME = 'nonsense'
     try:
         utils.CommandPath(NAME, 'utter nonsense').cmd
     except OSError as e:
         self.assertEquals(e.errno, errno.ENOENT)
         self.assertIn(NAME, e.strerror)
コード例 #2
0
ファイル: utilsTests.py プロジェクト: rexhsu/vdsm-ubuntu
 def testMissing(self):
     NAME = 'nonsense'
     try:
         utils.CommandPath(NAME, 'utter nonsense').cmd
     except OSError as e:
         self.assertEquals(e.errno, errno.ENOENT)
         self.assertTrue(NAME in e.strerror,
                         msg='%s not in %s' % (NAME, e.strerror))
コード例 #3
0
ファイル: storagedev.py プロジェクト: igoihman/vdsm
import blivet.size
from blivet.devices import LVMLogicalVolumeDevice
from blivet.devices import LVMThinLogicalVolumeDevice
from blivet import udev

from vdsm import commands
from vdsm import utils
from vdsm.gluster import exception as ge

from . import fstab
from . import gluster_mgmt_api

log = logging.getLogger("Gluster")
_pvCreateCommandPath = utils.CommandPath(
    "pvcreate",
    "/sbin/pvcreate",
    "/usr/sbin/pvcreate",
)
_vgCreateCommandPath = utils.CommandPath(
    "vgcreate",
    "/sbin/vgcreate",
    "/usr/sbin/vgcreate",
)
_lvconvertCommandPath = utils.CommandPath(
    "lvconvert",
    "/sbin/lvconvert",
    "/usr/sbin/lvconvert",
)
_lvchangeCommandPath = utils.CommandPath(
    "lvchange",
    "/sbin/lvchange",
コード例 #4
0
ファイル: numa.py プロジェクト: rexhsu/vdsm
import os.path
import xml.etree.cElementTree as ET

from vdsm import cmdutils
from vdsm import commands
from vdsm import libvirtconnection
from vdsm import supervdsm
from vdsm import utils

# xml file name -> (last mtime, cached value)
_libvirt_vcpu_pids_cache = {}

NumaTopology = namedtuple('NumaTopology', 'topology, distances, cpu_topology')
CpuTopology = namedtuple('CpuTopology', 'sockets, cores, threads, online_cpus')

_SYSCTL = utils.CommandPath("sysctl", "/sbin/sysctl", "/usr/sbin/sysctl")

AUTONUMA_STATUS_DISABLE = 0
AUTONUMA_STATUS_ENABLE = 1
AUTONUMA_STATUS_UNKNOWN = 2


def topology(capabilities=None):
    '''
    Get what we call 'numa topology' of the host from libvirt. This topology
    contains mapping numa cell -> (cpu ids, total memory).

    Example:
        {'0': {'cpus': [0, 1, 2, 3, 4, 10, 11, 12, 13, 14],
               'totalMemory': '32657'},
         '1': {'cpus': [5, 6, 7, 8, 9, 15, 16, 17, 18, 19],
コード例 #5
0
ファイル: api.py プロジェクト: igoihman/vdsm
import logging

_SUCCESS = {'status': doneCode}
GEOREP_PUB_KEY_PATH = "/var/lib/glusterd/geo-replication/common_secret.pem.pub"
MOUNT_BROKER_ROOT = "/var/mountbroker-root"
META_VOLUME = "gluster_shared_storage"
META_VOL_MOUNT_POINT = "/var/run/gluster/shared_storage"
LOCK_FILE_DIR = META_VOL_MOUNT_POINT + "/snaps/lock_files"
LOCK_FILE = LOCK_FILE_DIR + "/lock_file"
SNAP_SCHEDULER_FLAG_FILE = META_VOL_MOUNT_POINT + "/snaps/current_scheduler"
FS_TYPE = "glusterfs"
SNAP_SCHEDULER_ALREADY_DISABLED_RC = 7


_snapSchedulerPath = utils.CommandPath(
    "snap_scheduler.py",
    "/usr/sbin/snap_scheduler.py",
)

_stopAllProcessesPath = utils.CommandPath(
    "stop-all-gluster-processes.sh",
    "/usr/share/glusterfs/scripts/stop-all-gluster-processes.sh",
)


GLUSTER_RPM_PACKAGES = (
    ('glusterfs', ('glusterfs',)),
    ('glusterfs-fuse', ('glusterfs-fuse',)),
    ('glusterfs-geo-replication', ('glusterfs-geo-replication',)),
    ('glusterfs-rdma', ('glusterfs-rdma',)),
    ('glusterfs-server', ('glusterfs-server',)),
    ('gluster-swift', ('gluster-swift',)),
コード例 #6
0
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# 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
import os
from functools import wraps
from nose.plugins.skip import SkipTest

from vdsm import utils

modprobe = utils.CommandPath("modprobe",
                             "/usr/sbin/modprobe",  # Fedora, EL7
                             )


def RequireDummyMod(f):
    """
    Assumes root privileges to be used after
    ValidateRunningAsRoot decoration.
    """
    return _require_mod(f, 'dummy')


def RequireBondingMod(f):
    """
    Assumes root privileges to be used after
    ValidateRunningAsRoot decoration.
コード例 #7
0
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# 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 vdsm import utils

_hostNameCommandPath = utils.CommandPath(
    "hostname",
    "/bin/hostname",
)


class HostNameException(Exception):
    def __init__(self, rc):
        self.rc = rc
        self.message = 'hostname execution failed with error code %s' % self.rc

    def __str__(self):
        return self.message


def getHostNameFqdn():
    rc, out, err = utils.execCmd([_hostNameCommandPath.cmd, '--fqdn'])
    if rc:
コード例 #8
0
#
# Refer to the README and COPYING files for full details of the license
#
"""
System commands facade
"""

from __future__ import absolute_import

from vdsm import commands
from vdsm import supervdsm
from vdsm import utils

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


class Failed(Exception):
    pass


def systemd_run(unit_name, cgroup_slice, *args):
    return _result(supervdsm.getProxy().systemd_run(unit_name, cgroup_slice,
                                                    *args))


def systemctl_stop(name):
    return _result(supervdsm.getProxy().systemctl_stop(name))
コード例 #9
0
# 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 __future__ import absolute_import

from vdsm import cmdutils
from vdsm import commands
from vdsm import utils

from . import expose

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

_MACHINECTL = utils.CommandPath(
    "machinectl",
    "/bin/machinectl",
    "/usr/bin/machinectl",
)

_ACCOUNTING = (
    cmdutils.Accounting.CPU,
    cmdutils.Accounting.Memory,
    cmdutils.Accounting.BlockIO,
)
コード例 #10
0
ファイル: curlImgWrap.py プロジェクト: rexhsu/vdsm-debian
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# 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
#

import signal

from vdsm import utils, constants

_curl = utils.CommandPath(
    "curl",
    "/usr/bin/curl",
)  # Fedora, EL6

CURL_OPTIONS = ["-q", "--silent", "--fail", "--show-error"]


class CurlError(Exception):
    def __init__(self, ecode, stdout, stderr, message=None):
        self.ecode = ecode
        self.stdout = stdout
        self.stderr = stderr
        self.message = message

    def __str__(self):
        return "ecode=%s, stdout=%s, stderr=%s, message=%s" % (
            self.ecode, self.stdout, self.stderr, self.message)
コード例 #11
0
ファイル: cli.py プロジェクト: eprasad/vdsm
# 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
#

import xml.etree.cElementTree as etree

from vdsm import utils
from vdsm import netinfo
import exception as ge
from hostname import getHostNameFqdn, HostNameException
from . import makePublic

_glusterCommandPath = utils.CommandPath(
    "gluster",
    "/usr/sbin/gluster",
)

if hasattr(etree, 'ParseError'):
    _etreeExceptions = (etree.ParseError, AttributeError, ValueError)
else:
    _etreeExceptions = (SyntaxError, AttributeError, ValueError)


def _getGlusterVolCmd():
    return [_glusterCommandPath.cmd, "--mode=script", "volume"]


def _getGlusterPeerCmd():
    return [_glusterCommandPath.cmd, "--mode=script", "peer"]
コード例 #12
0
import collections
import json
import logging
import uuid

from vdsm.config import config
from vdsm import utils

from . import command
from . import runner
from . import xmlfile

_DOCKER = utils.CommandPath(
    "docker",
    "/bin/docker",
    "/usr/bin/docker",
)

# TODO: networking
_RunConfig = collections.namedtuple('_RunConfig', [
    'image_path', 'volume_paths', 'volume_mapping', 'memory_size_mib',
    'network'
])


class RunConfig(_RunConfig):
    @classmethod
    def from_domain(cls, dom):
        mem = dom.memory()
        path, volumes = dom.drives()
コード例 #13
0
import random
import time
import threading

from nose.plugins.skip import SkipTest

from vdsm import netinfo
from vdsm import vdscli
from vdsm import utils

SUCCESS = 0
Qos = namedtuple('Qos', 'inbound outbound')

ip = utils.CommandPath(
    'ip',
    '/sbin/ip',  # EL6
    '/usr/sbin/ip',  # Fedora
)

service = utils.CommandPath(
    "service",
    "/sbin/service",  # EL6
    "/usr/sbin/service",  # Fedora
)


def createDummy():
    """
    Creates a dummy interface, in a fixed number of attempts (100).
    The dummy interface created has a pseudo-random name (e.g. dummy_85
    in the format dummy_Number). Assumes root privileges.
コード例 #14
0
ファイル: passwd.py プロジェクト: rexhsu/vdsm
# 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 __future__ import absolute_import
from vdsm import constants
from vdsm import commands
from vdsm import utils


from . import YES, NO


_SASLDBLISTUSERS2 = utils.CommandPath("sasldblistusers2",
                                      "/usr/sbin/sasldblistusers2",
                                      )
_LIBVIRT_SASLDB = "/etc/libvirt/passwd.db"
_SASLPASSWD2 = utils.CommandPath("saslpasswd2",
                                 "/usr/sbin/saslpasswd2",
                                 )
SASL_USERNAME = "******"
LIBVIRT_PASSWORD_PATH = constants.P_VDSM_KEYS + 'libvirt_password'


def isconfigured():
    script = (str(_SASLDBLISTUSERS2), '-f', _LIBVIRT_SASLDB)
    _, out, _ = commands.execCmd(script)
    for user in out:
        if SASL_USERNAME in user:
            return YES
コード例 #15
0
ファイル: utilsTests.py プロジェクト: kripper/vdsm
 def testExisting(self):
     cp = utils.CommandPath('sh', 'utter nonsense', '/bin/sh')
     self.assertEquals(cp.cmd, '/bin/sh')
コード例 #16
0
from blivet.devices import LVMVolumeGroupDevice
from blivet.devices import LVMThinPoolDevice
from blivet.devices import LVMLogicalVolumeDevice
from blivet.devices import LVMThinLogicalVolumeDevice

import storage.lvm as lvm
from vdsm import utils

import fstab
import exception as ge
from . import makePublic

log = logging.getLogger("Gluster")
_lvconvertCommandPath = utils.CommandPath(
    "lvconvert",
    "/sbin/lvconvert",
    "/usr/sbin/lvconvert",
)
_lvchangeCommandPath = utils.CommandPath(
    "lvchange",
    "/sbin/lvchange",
    "/usr/sbin/lvchange",
)

# All size are in MiB unless otherwise specified
DEFAULT_CHUNK_SIZE_KB = 256
DEFAULT_METADATA_SIZE_KB = 16777216
MIN_VG_SIZE = 1048576
MIN_METADATA_PERCENT = 0.005
DEFAULT_FS_TYPE = "xfs"
DEFAULT_MOUNT_OPTIONS = "inode64,noatime"
コード例 #17
0
ファイル: utilsTests.py プロジェクト: kripper/vdsm
 def testExistingNotInPaths(self):
     """Tests if CommandPath can find the executable like the 'which' unix
     tool"""
     cp = utils.CommandPath('sh', 'utter nonsense')
     _, stdout, _ = utils.execCmd(['which', 'sh'])
     self.assertIn(cp.cmd, stdout)
コード例 #18
0
ファイル: multipath.py プロジェクト: vinzenz/vdsm
    "    getuid_callout          \"%(scsi_id_path)s --whitelisted "
    "--replace-whitespace --device=/dev/%%n\"\n"
    "}\n"
    "device {\n"
    "    vendor                  \"COMPELNT\"\n"
    "    product                 \"Compellent Vol\"\n"
    "    no_path_retry           fail\n"
    "}\n"
    "}")
MPATH_CONF_TEMPLATE = MPATH_CONF_TAG + STRG_MPATH_CONF

log = logging.getLogger("Storage.Multipath")

_scsi_id = utils.CommandPath(
    "scsi_id",
    "/sbin/scsi_id",  # EL6
    "/usr/lib/udev/scsi_id",  # Fedora
    "/lib/udev/scsi_id",  # Ubuntu
)


def rescan():
    """
    Forces multipath daemon to rescan the list of available devices and
    refresh the mapping table. New devices can be found under /dev/mapper

    Should only be called from hsm._rescanDevices()
    """

    # First ask iSCSI to rescan all its sessions
    iscsi.rescan()
コード例 #19
0
from vdsm.storage import misc

import iscsi

DEV_ISCSI = "iSCSI"
DEV_FCP = "FCP"
DEV_MIXED = "MIXED"
SYS_BLOCK = "/sys/block"
QUEUE = "queue"

TOXIC_CHARS = '()*+?|^$.\\'

log = logging.getLogger("Storage.Multipath")

_SCSI_ID = utils.CommandPath("scsi_id",
                             "/usr/lib/udev/scsi_id",    # Fedora, EL7
                             "/lib/udev/scsi_id")        # Ubuntu

_MULTIPATHD = utils.CommandPath("multipathd",
                                "/usr/sbin/multipathd",  # Fedora, EL7
                                "/sbin/multipathd")      # Ubuntu


class Error(Exception):
    """ multipath operation failed """


def rescan():
    """
    Forces multipath daemon to rescan the list of available devices and
    refresh the mapping table. New devices can be found under /dev/mapper
コード例 #20
0
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# 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 __future__ import absolute_import

from vdsm import cmdutils
from vdsm import commands
from vdsm import utils

_blkdiscard = utils.CommandPath("blkdiscard", "/sbin/blkdiscard")


def blkdiscard(device):
    cmd = [_blkdiscard.cmd]
    cmd.append(device)

    rc, out, err = commands.execCmd(cmd)

    if rc != 0:
        raise cmdutils.Error(cmd, rc, out, err)
コード例 #21
0
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# 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
#

import logging
from vdsm import utils

_UDEVADM = utils.CommandPath("udevadm", "/sbin/udevadm", "/usr/sbin/udevadm")


class Error(Exception):
    def __init__(self, rc, out, err):
        self.rc = rc
        self.out = out
        self.err = err

    def __str__(self):
        return "Process failed with rc=%d out=%r err=%r" % (self.rc, self.out,
                                                            self.err)


def settle(timeout, exit_if_exists=None):
    """
コード例 #22
0
ファイル: conttestlib.py プロジェクト: bronhaim/vdsm
 def __init__(self):
     self._docker = utils.CommandPath('docker', *self.paths('docker'))
     self._systemctl = utils.CommandPath('systemctl',
                                         *self.paths('systemctl'))
     self._systemd_run = utils.CommandPath('systemd-run',
                                           *self.paths('systemd-run'))