Jelajahi Sumber

Merge pull request #263 from Dany9966/http-transfer-fixes

HTTPS backup writer transfer fixes
Daniel Vincze 2 tahun lalu
induk
melakukan
b8aadc51a8
2 mengubah file dengan 19 tambahan dan 4 penghapusan
  1. 8 3
      coriolis/providers/backup_writers.py
  2. 11 1
      coriolis/utils.py

+ 8 - 3
coriolis/providers/backup_writers.py

@@ -19,11 +19,13 @@ from oslo_log import log as logging
 import paramiko
 import requests
 from six import with_metaclass
+
 from coriolis import constants
 from coriolis import data_transfer
 from coriolis import exception
 from coriolis import utils
 
+
 CONF = cfg.CONF
 opts = [
     cfg.BoolOpt('compress_transfers',
@@ -99,9 +101,12 @@ def _disable_lvm_metad_udev_rule(ssh):
     migrations with multiple replications, these services need to be disabled,
     therefore we make it impossible for the minion OS to create them.
     """
-    rule_path = "/lib/udev/rules.d/69-lvm-metad.rules"
-    if utils.test_ssh_path(ssh, rule_path):
-        utils.exec_ssh_cmd(ssh, "sudo rm %s" % rule_path, get_pty=True)
+    rule_paths = [
+        "/lib/udev/rules.d/69-lvm-metad.rules",
+        "/lib/udev/rules.d/69-dm-lvm.rules"]
+    for path in rule_paths:
+        if utils.test_ssh_path(ssh, path):
+            utils.exec_ssh_cmd(ssh, "sudo rm %s" % path, get_pty=True)
 
 
 def _check_deserialize_key(key):

+ 11 - 1
coriolis/utils.py

@@ -25,7 +25,6 @@ import OpenSSL
 from oslo_config import cfg
 from oslo_log import log as logging
 from oslo_serialization import jsonutils
-
 import netifaces
 import paramiko
 # NOTE(gsamfira): I am aware that this is not ideal, but pip
@@ -41,6 +40,7 @@ from coriolis import constants
 from coriolis import exception
 from coriolis import secrets
 
+
 opts = [
     cfg.StrOpt('qemu_img_path',
                default='qemu-img',
@@ -709,6 +709,15 @@ def _write_systemd(ssh, cmdline, svcname, run_as=None, start=True):
                 ssh, "sudo systemctl start %s" % svcname,
                 get_pty=True)
 
+    def _correct_selinux_label():
+        cmd = "sudo /sbin/restorecon -v %s" % serviceFilePath
+        try:
+            exec_ssh_cmd(ssh, cmd, get_pty=True)
+        except exception.CoriolisException:
+            LOG.warn(
+                "Could not relabel service '%s'. SELinux might not be "
+                "installed. Error was: %s", svcname, get_exception_details())
+
     systemd_args = {
         "cmdline": cmdline,
         "username": "root",
@@ -726,6 +735,7 @@ def _write_systemd(ssh, cmdline, svcname, run_as=None, start=True):
         ssh,
         "sudo mv /tmp/%s.service %s" % (name, serviceFilePath),
         get_pty=True)
+    _correct_selinux_label()
     _reload_and_start(start=start)