# # 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.common import cmdutils _SYSTEMCTL = cmdutils.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))
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 = cmdutils.CommandPath( "snap_scheduler.py", "/usr/sbin/snap_scheduler.py", ) _stopAllProcessesPath = cmdutils.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',)),
# from __future__ import absolute_import from __future__ import division import json from functools import partial from testlib import VdsmTestCase as TestCaseBase from monkeypatch import MonkeyPatch, MonkeyPatchScope from vdsm.common import commands from vdsm.common import cmdutils from vdsm.gluster import thinstorage _fake_vdoCommandPath = cmdutils.CommandPath( "true", "/bin/true", ) def fake_json_call(data, cmd, **kw): return 0, [json.dumps(data)], [] class GlusterStorageDevTest(TestCaseBase): def test_logical_volume_list(self): data = { "report": [{ "lv": [{ "lv_size": "52613349376", "data_percent": "0.06", "lv_name": "internal_pool",
import blivet.formats.fs import blivet.size from blivet.devices import LVMLogicalVolumeDevice from blivet.devices import LVMThinLogicalVolumeDevice from blivet import udev from vdsm.common import cmdutils from vdsm.common import commands from vdsm.gluster import exception as ge from vdsm.gluster import fstab from . import gluster_mgmt_api log = logging.getLogger("Gluster") _pvCreateCommandPath = cmdutils.CommandPath( "pvcreate", "/sbin/pvcreate", "/usr/sbin/pvcreate", ) _vgCreateCommandPath = cmdutils.CommandPath( "vgcreate", "/sbin/vgcreate", "/usr/sbin/vgcreate", ) _lvconvertCommandPath = cmdutils.CommandPath( "lvconvert", "/sbin/lvconvert", "/usr/sbin/lvconvert", ) _lvchangeCommandPath = cmdutils.CommandPath( "lvchange", "/sbin/lvchange",
from vdsm.common.units import MiB from vdsm.constants import P_VDSM_LOG, P_VDSM_RUN, EXT_KVM_2_OVIRT from vdsm.utils import 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 = cmdutils.CommandPath('virt-v2v', '/usr/bin/virt-v2v') _SSH_AGENT = cmdutils.CommandPath('ssh-agent', '/usr/bin/ssh-agent') _SSH_ADD = cmdutils.CommandPath('ssh-add', '/usr/bin/ssh-add') _XEN_SSH_PROTOCOL = 'xen+ssh' _VMWARE_PROTOCOL = 'vpx' _KVM_PROTOCOL = 'qemu' _SSH_AUTH_RE = br'(SSH_AUTH_SOCK)=([^;]+).*;\nSSH_AGENT_PID=(\d+)' _OVF_RESOURCE_CPU = 3 _OVF_RESOURCE_MEMORY = 4 _OVF_RESOURCE_NETWORK = 10 _QCOW2_COMPAT_SUPPORTED = ('0.10', '1.1') _OVF_ORIGIN_OVIRT = 3 # OVF Specification: # https://www.iso.org/obp/ui/#iso:std:iso-iec:17203:ed-1:v1:en
# 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 __future__ import division from vdsm.common import cmdutils from vdsm.common import commands from . import expose _DOCKER = cmdutils.CommandPath( "docker", "/bin/docker", "/usr/bin/docker", ) @expose def docker_net_inspect(network): return commands.execCmd([ _DOCKER.cmd, 'network', 'inspect', network, ], raw=True)
from vdsm.common import properties from vdsm.common import supervdsm from vdsm.common import systemctl from vdsm.common import systemd from vdsm.common import nbdutils from vdsm.common.time import monotonic_time from . import constants as sc from . import exception as se from . import fileUtils from . sdc import sdCache DEFAULT_SOCKET_MODE = 0o660 RUN_DIR = os.path.join(constants.P_VDSM_RUN, "nbd") QEMU_NBD = cmdutils.CommandPath( "qemu-nbd", "/usr/local/bin/qemu-nbd", "/usr/bin/qemu-nbd") log = logging.getLogger("storage.nbd") class Error(Exception): """ Base class for nbd errors """ class Timeout(Error): """ Timeout starting nbd server """ class InvalidPath(Error): """ Path is not a valid volume path """
def testExisting(self): cp = cmdutils.CommandPath('sh', 'utter nonsense', '/bin/sh') self.assertEqual(cp.cmd, '/bin/sh')
def fake_scsi_id(monkeypatch, fake_executeable): monkeypatch.setattr( multipath, "_SCSI_ID", cmdutils.CommandPath("fake-scsi_id", str(fake_executeable))) return fake_executeable
def fake_multipathd(monkeypatch, fake_executeable): monkeypatch.setattr( multipath, "_MULTIPATHD", cmdutils.CommandPath("fake-multipathd", str(fake_executeable))) return fake_executeable
# # 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 import os from vdsm.common import cmdutils from vdsm.common import commands from vdsm.common import supervdsm LSOF = cmdutils.CommandPath('lsof', '/usr/bin/lsof') log = logging.getLogger("storage.lsof") def run(path): if os.geteuid() != 0: return supervdsm.getProxy().lsof_run(path) cmd = [ LSOF.cmd, # Produce 4 lines per each process: # p<PID> # c<COMMAND> # L<USER> # f<FD>
def fake_scsi_id(monkeypatch, fake_executeable): fake_executeable.write(SCSI_ID_SCRIPT.format(FAKE_SCSI_ID_OUTPUT)) monkeypatch.setattr( multipath, "_SCSI_ID", cmdutils.CommandPath("fake-scsi_id", str(fake_executeable)))
# 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 import logging from vdsm.common import cmdutils from vdsm.common import commands _UDEVADM = cmdutils.CommandPath("udevadm", "/sbin/udevadm", "/usr/sbin/udevadm") def settle(timeout, exit_if_exists=None): """ Watches the udev event queue, and wait until all current events are handled. Arguments: timeout Maximum number of seconds to wait for the event queue to become empty. A value of 0 will check if the queue is empty and always return immediately. exit_if_exists Stop waiting if file exists. """
# 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 commands from vdsm.common import cmdutils from vdsm.gluster import exception as ge from . import gluster_mgmt_api _glusterEventsApi = cmdutils.CommandPath("gluster-eventsapi", "/sbin/gluster-eventsapi", "/usr/sbin/gluster-eventsapi",) @gluster_mgmt_api def webhookAdd(url, bearerToken=None): command = [_glusterEventsApi.cmd, "webhook-add", url] if bearerToken: command.append('--bearer_token=%s' % bearerToken) rc, out, err = commands.execCmd(command) if rc: raise ge.GlusterWebhookAddException(rc, out, err) else: return True
# 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 __future__ import division import os from functools import wraps from nose.plugins.skip import SkipTest from vdsm.common import cmdutils from vdsm.common import commands modprobe = cmdutils.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.
from vdsm.storage import hba from vdsm.storage import iscsi from vdsm.storage import misc DEV_ISCSI = "iSCSI" DEV_FCP = "FCP" DEV_MIXED = "MIXED" SYS_BLOCK = "/sys/block" QUEUE = "queue" TOXIC_CHARS = '()*+?|^$.\\' log = logging.getLogger("storage.Multipath") _SCSI_ID = cmdutils.CommandPath("scsi_id", "/usr/lib/udev/scsi_id", # Fedora, EL7 "/lib/udev/scsi_id") # Ubuntu _MULTIPATHD = cmdutils.CommandPath("multipathd", "/usr/sbin/multipathd", # Fedora, EL7 "/sbin/multipathd") # Ubuntu # List of multipath devices that should never be handled by vdsm. The # main use case is to filter out the multipath devices the host is # booting from when configuring hypervisor to boot from SAN. This device # must have a special rule to queue I/O when all paths have failed, and # accessing it in vdsm commands may hang vdsm. BLACKLIST = frozenset( d.strip() for d in config.get("multipath", "blacklist").split(",") if d)
# 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 import six from vdsm.common import cmdutils from vdsm.common import commands from vdsm import constants _curl = cmdutils.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.msg = message def __str__(self): return "ecode=%s, stdout=%s, stderr=%s, message=%s" % ( self.ecode, self.stdout, self.stderr, self.msg)
def testExistingNotInPaths(self): """Tests if CommandPath can find the executable like the 'which' unix tool""" cp = cmdutils.CommandPath('sh', 'utter nonsense') _, stdout, _ = commands.execCmd(['which', 'sh']) self.assertIn(cp.cmd.encode(), stdout)
import json import logging import yaml from six import iteritems from vdsm.common import cmdutils from vdsm.common import commands from vdsm.common.units import KiB from . import exception as ge from . import gluster_mgmt_api log = logging.getLogger("Gluster") _lvsCommandPath = cmdutils.CommandPath( "lvs", "/sbin/lvs", "/usr/sbin/lvs", ) _pvsCommandPath = cmdutils.CommandPath( "pvs", "/sbin/pvs", "/usr/sbin/pvs", ) _vdoCommandPath = cmdutils.CommandPath( "vdo", "/bin/vdo", "/usr/bin/vdo", ) @gluster_mgmt_api
# Refer to the README and COPYING files for full details of the license # from __future__ import absolute_import from __future__ import division import os import sys from vdsm.common import cmdutils from vdsm.common import commands from vdsm.storage import fileUtils from vdsm.tool import service from . import YES, NO _MULTIPATHD = cmdutils.CommandPath("multipathd", "/usr/sbin/multipathd") _CONF_FILE = "/etc/multipath.conf" # The first line of multipath.conf configured by vdsm must contain a # "VDSM REVISION X.Y" tag. Note that older version used "RHEV REVISION X.Y" # format. _CURRENT_TAG = "# VDSM REVISION 2.0" _OLD_TAGS = ( "# VDSM REVISION 1.9", "# VDSM REVISION 1.8", "# VDSM REVISION 1.7", "# VDSM REVISION 1.6", "# VDSM REVISION 1.5",
# Refer to the README and COPYING files for full details of the license # from __future__ import absolute_import import io from vdsm import constants from vdsm import commands from vdsm.common import cache from vdsm.common import cmdutils from . import YES, NO, MAYBE _SASLDBLISTUSERS2 = cmdutils.CommandPath( "sasldblistusers2", "/usr/sbin/sasldblistusers2", ) _LIBVIRT_SASLDB = "/etc/libvirt/passwd.db" _SASL2_CONF = "/etc/sasl2/libvirt.conf" _SASLPASSWD2 = cmdutils.CommandPath( "saslpasswd2", "/usr/sbin/saslpasswd2", ) SASL_USERNAME = "******" LIBVIRT_PASSWORD_PATH = constants.P_VDSM_KEYS + 'libvirt_password' def isconfigured(): ret = passwd_isconfigured() if ret == NO: return ret
# from __future__ import absolute_import import json import logging import os import re from vdsm.common import cmdutils from vdsm.common import commands from vdsm.common import exception from vdsm.common.cache import memoized from vdsm.config import config from vdsm.storage import operation _qemuimg = cmdutils.CommandPath("qemu-img", "/usr/bin/qemu-img") _log = logging.getLogger("QemuImg") class FORMAT: QCOW2 = "qcow2" QCOW = "qcow" QED = "qed" RAW = "raw" VMDK = "vmdk" _QCOW2_COMPAT_SUPPORTED = ("0.10", "1.1")
def __init__(self): self._docker = cmdutils.CommandPath('docker', *self.paths('docker')) self._systemctl = cmdutils.CommandPath('systemctl', *self.paths('systemctl')) self._systemd_run = cmdutils.CommandPath('systemd-run', *self.paths('systemd-run'))