Exemplo n.º 1
0
def configure():
    # Remove a previous configuration (if present)
    confutils.remove_conf(FILES, CONF_VERSION)

    vdsmConfiguration = {
        'socket_activation': _libvirt_uses_socket_activation(),
        'ssl_enabled': config.getboolean('vars', 'ssl'),
        'sanlock_enabled': constants.SANLOCK_ENABLED,
        'libvirt_selinux': constants.LIBVIRT_SELINUX
    }

    # write configuration
    for cfile, content in FILES.items():
        content['configure'](content, CONF_VERSION, vdsmConfiguration)

    # enable and acivate dev-hugepages1G mounth path
    if not _is_hugetlbfs_1g_mounted():
        try:
            service.service_start('dev-hugepages1G.mount')
        except service.ServiceOperationError:
            status = service.service_status('dev-hugepages1G.mount', False)
            if status == 0:
                raise

    if _libvirt_uses_socket_activation():
        cfg = _read_libvirt_connection_config()

        if cfg.listen_tcp != 0:
            systemctl.enable(_LIBVIRT_TCP_SOCKET_UNIT)

        if cfg.listen_tls != 0:
            systemctl.enable(_LIBVIRT_TLS_SOCKET_UNIT)
Exemplo n.º 2
0
def configure():
    """
    Set up the multipath daemon configuration to the known and
    supported state. The original configuration, if any, is saved
    """

    if os.path.exists(_CONF_FILE):
        backup = _CONF_FILE + '.' + time.strftime("%Y%m%d%H%M")
        shutil.copyfile(_CONF_FILE, backup)
        sys.stdout.write("Backup previous multipath.conf to %r\n" % backup)

    with tempfile.NamedTemporaryFile(
            mode="wb",
            prefix=os.path.basename(_CONF_FILE) + ".tmp",
            dir=os.path.dirname(_CONF_FILE),
            delete=False) as f:
        try:
            f.write(_CONF_DATA)
            f.flush()
            selinux.restorecon(f.name)
            os.chmod(f.name, 0o644)
            os.rename(f.name, _CONF_FILE)
        except:
            os.unlink(f.name)
            raise

    # Flush all unused multipath device maps
    commands.execCmd([constants.EXT_MULTIPATH, "-F"])

    try:
        service.service_reload("multipathd")
    except service.ServiceOperationError:
        status = service.service_status("multipathd", False)
        if status == 0:
            raise
Exemplo n.º 3
0
    def test_service_down(self):
        service_stop('vdsmd')
        vdsm_version = commands.run(['rpm', '-q', 'vdsm'])
        downgrade_vdsm(el7_ovirt36_repo)
        upgrade_vdsm()

        assert commands.run(['rpm', '-q', 'vdsm']) == vdsm_version
        assert service_status('vdsmd') == 1
Exemplo n.º 4
0
    def test_service_down(self):
        service_stop('vdsmd')
        vdsm_version = commands.run(['rpm', '-q', 'vdsm'])
        downgrade_vdsm(el7_ovirt36_repo)
        upgrade_vdsm()

        assert commands.run(['rpm', '-q', 'vdsm']) == vdsm_version
        assert service_status('vdsmd') == 1
Exemplo n.º 5
0
    def service_down_test(self):
        service_stop('vdsmd')
        vdsm_version = run_command(['rpm', '-q', 'vdsm'])
        downgrade_vdsm(el7_ovirt36_repo)
        upgrade_vdsm()

        self.assertEqual(run_command(['rpm', '-q', 'vdsm']), vdsm_version)
        self.assertEqual(service_status('vdsmd'), 1)
Exemplo n.º 6
0
    def service_down_test(self):
        service_stop('vdsmd')
        vdsm_version = run_command(['rpm', '-q', 'vdsm'])
        downgrade_vdsm(el7_ovirt36_repo)
        upgrade_vdsm()

        self.assertEqual(run_command(['rpm', '-q', 'vdsm']), vdsm_version)
        self.assertEqual(service_status('vdsmd'), 1)
Exemplo n.º 7
0
def init_callback():
    restore_sigchld()

    # TODO: add ssl option
    log("Init: Check VDSM availability")
    if service.service_status("vdsmd"):
        log("vdsmd is not running.")
        return

    global client
    client = jsonrpcvdscli.connect('jms.topic.vdsm_requests')
    # TODO: add to jsonrpcvdscli even method registration
    client._client.registerEventCallback(event_recieved)
def init_callback():
    restore_sigchld()

    # TODO: add ssl option
    log("Init: Check VDSM availability")
    if service.service_status("vdsmd"):
        log("vdsmd is not running.")
        return

    global client
    client = jsonrpcvdscli.connect('jms.topic.vdsm_requests')
    # TODO: add to jsonrpcvdscli even method registration
    client._client.registerEventCallback(event_recieved)
Exemplo n.º 9
0
def _serviceStatus(serviceName):
    rc = service.service_status(serviceName)

    if rc == 0:
        return _formatStatus(serviceName, StatusTypes.RUNNING)

    # If rc is not zero, then service may not be available or stopped
    # Check if service is managed, if not managed return the status as
    # NOT_AVAILABLE else return STOPPED
    rc1 = service.service_is_managed(serviceName)
    if rc1 == 0:
        return _formatStatus(serviceName, StatusTypes.STOPPED)
    else:
        return _formatStatus(serviceName, StatusTypes.NOT_AVAILABLE)
Exemplo n.º 10
0
def _serviceStatus(serviceName):
    rc = service.service_status(serviceName)

    if rc == 0:
        return _formatStatus(serviceName, StatusTypes.RUNNING)

    # If rc is not zero, then service may not be available or stopped
    # Check if service is managed, if not managed return the status as
    # NOT_AVAILABLE else return STOPPED
    rc1 = service.service_is_managed(serviceName)
    if rc1 == 0:
        return _formatStatus(serviceName, StatusTypes.STOPPED)
    else:
        return _formatStatus(serviceName, StatusTypes.NOT_AVAILABLE)
Exemplo n.º 11
0
def configure():
    """
    Set up the multipath daemon configuration to the known and
    supported state. The original configuration, if any, is saved
    """

    if os.path.exists(_CONF_FILE):
        backup = _CONF_FILE + '.' + time.strftime("%Y%m%d%H%M")
        shutil.copyfile(_CONF_FILE, backup)
        sys.stdout.write("Backup previous multipath.conf to %r\n" % backup)
        utils.persist(backup)

    with tempfile.NamedTemporaryFile(
            mode="wb",
            prefix=os.path.basename(_CONF_FILE) + ".tmp",
            dir=os.path.dirname(_CONF_FILE),
            delete=False) as f:
        try:
            f.write(_CONF_DATA)
            f.flush()
            if selinux.is_selinux_enabled():
                selinux.restorecon(f.name)
            os.chmod(f.name, 0o644)
            # On ovirt node multipath.conf is a bind mount and rename will fail
            # if we do not unpersist first, making this non-atomic.
            utils.unpersist(_CONF_FILE)
            os.rename(f.name, _CONF_FILE)
        except:
            os.unlink(f.name)
            raise

    utils.persist(_CONF_FILE)

    # Flush all unused multipath device maps
    commands.execCmd([constants.EXT_MULTIPATH, "-F"])

    try:
        service.service_reload("multipathd")
    except service.ServiceOperationError:
        status = service.service_status("multipathd", False)
        if status == 0:
            raise
Exemplo n.º 12
0
def configure():
    """
    Set up the multipath daemon configuration to the known and
    supported state. The original configuration, if any, is saved
    """

    if os.path.exists(_CONF_FILE):
        backup = _CONF_FILE + '.' + time.strftime("%Y%m%d%H%M")
        shutil.copyfile(_CONF_FILE, backup)
        sys.stdout.write("Backup previous multipath.conf to %r\n" % backup)

    with tempfile.NamedTemporaryFile(
            mode="wb",
            prefix=os.path.basename(_CONF_FILE) + ".tmp",
            dir=os.path.dirname(_CONF_FILE),
            delete=False) as f:
        try:
            f.write(_CONF_DATA)
            f.flush()
            selinux.restorecon(f.name)
            os.chmod(f.name, 0o644)
            os.rename(f.name, _CONF_FILE)
        except:
            os.unlink(f.name)
            raise

    # Flush all unused multipath device maps. 'multipath'
    # returns 1 if any of the devices is in use and unable to flush.
    try:
        commands.run([constants.EXT_MULTIPATH, "-F"])
    except cmdutils.Error:
        pass

    try:
        service.service_reload("multipathd")
    except service.ServiceOperationError:
        status = service.service_status("multipathd", False)
        if status == 0:
            raise
Exemplo n.º 13
0
Arquivo: libvirt.py Projeto: nirs/vdsm
def configure():
    # Remove a previous configuration (if present)
    confutils.remove_conf(FILES, CONF_VERSION)

    vdsmConfiguration = {
        'ssl_enabled': config.getboolean('vars', 'ssl'),
        'sanlock_enabled': constants.SANLOCK_ENABLED,
        'libvirt_selinux': constants.LIBVIRT_SELINUX
    }

    # write configuration
    for cfile, content in FILES.items():
        content['configure'](content, CONF_VERSION, vdsmConfiguration)

    # enable and acivate dev-hugepages1G mounth path
    if not _is_hugetlbfs_1g_mounted():
        try:
            service.service_start('dev-hugepages1G.mount')
        except service.ServiceOperationError:
            status = service.service_status('dev-hugepages1G.mount', False)
            if status == 0:
                raise
Exemplo n.º 14
0
def configure():
    # Remove a previous configuration (if present)
    confutils.remove_conf(FILES, CONF_VERSION)

    vdsmConfiguration = {
        'ssl_enabled': config.getboolean('vars', 'ssl'),
        'sanlock_enabled': constants.SANLOCK_ENABLED,
        'libvirt_selinux': constants.LIBVIRT_SELINUX
    }

    # write configuration
    for cfile, content in FILES.items():
        content['configure'](content, CONF_VERSION, vdsmConfiguration)

    # enable and acivate dev-hugepages1G mounth path
    if not _is_hugetlbfs_1g_mounted():
        try:
            service.service_start('dev-hugepages1G.mount')
        except service.ServiceOperationError:
            status = service.service_status('dev-hugepages1G.mount', False)
            if status == 0:
                raise
Exemplo n.º 15
0
def configure():
    removeConf()

    vdsmConfiguration = {
        'ssl_enabled': _ssl(),
        'sanlock_enabled': constants.SANLOCK_ENABLED,
        'libvirt_selinux': constants.LIBVIRT_SELINUX
    }

    # write configuration
    for cfile, content in FILES.items():
        content['configure'](content, CONF_VERSION, vdsmConfiguration)

    # enable and acivate dev-hugepages1G mounth path
    if not _is_hugetlbfs_1g_mounted():
        try:
            service.service_start('dev-hugepages1G.mount')
        except service.ServiceOperationError:
            status = service.service_status('dev-hugepages1G.mount', False)
            if status == 0:
                raise

    _inject_unit_requirement(_LIBVIRT_SERVICE_UNIT, _socket_unit())
Exemplo n.º 16
0
def _is_ovs_service_running():
    return service_status('openvswitch', verbose=False) == 0
Exemplo n.º 17
0
def _is_ovs_service_running():
    return service_status('openvswitch', verbose=False) == 0