!11 升级至migration-tools-1.0.1版本
From: @f16lx Reviewed-by: @xingwei-liu Signed-off-by: @xingwei-liu
This commit is contained in:
commit
68fa06d5c7
@ -1,72 +0,0 @@
|
||||
From 854c1d018b9a5f1079f387101c62f86009c3baac Mon Sep 17 00:00:00 2001
|
||||
From: Super User <root@localhost.localdomain>
|
||||
Date: Mon, 21 Aug 2023 16:19:47 +0800
|
||||
Subject: [PATCH] fix export error and no migration details issue
|
||||
|
||||
---
|
||||
ut-Migration-tools/index.py | 4 ++--
|
||||
ut-Migration-tools/templates/MT_migration.html | 3 ++-
|
||||
ut-Migration-tools/views/migration.py | 6 +++++-
|
||||
3 files changed, 9 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/ut-Migration-tools/index.py b/ut-Migration-tools/index.py
|
||||
index 59e6830..635c5ac 100644
|
||||
--- a/ut-Migration-tools/index.py
|
||||
+++ b/ut-Migration-tools/index.py
|
||||
@@ -218,7 +218,7 @@ def MT_export_migration_reports():
|
||||
:return:
|
||||
"""
|
||||
mod = check_methods()
|
||||
- f = open("/usr/lib/migration-tools-agent/.passwd.txt","r")
|
||||
+ f = open("/usr/lib/migration-tools-server/.passwd.txt","r")
|
||||
password = f.read()
|
||||
f.close()
|
||||
if mod:
|
||||
@@ -234,7 +234,7 @@ def MT_export_migration_reports():
|
||||
print("export report mkdir error:%s" % mkdir_log_pwd)
|
||||
|
||||
info = mod.split(',')
|
||||
- scp_log = "sshpass -p %s" % password + " scp -r %s" % json_data.get('info').split("|")[0] + "@%s" % info[1] \
|
||||
+ scp_log = "sshpass -p '%s'" % password + " scp -r %s" % json_data.get('info').split("|")[0] + "@%s" % info[1] \
|
||||
+ ":/var/tmp/uos-migration/UOS*.tar.gz /var/uos-migration/"
|
||||
try:
|
||||
os.system(scp_log)
|
||||
diff --git a/ut-Migration-tools/templates/MT_migration.html b/ut-Migration-tools/templates/MT_migration.html
|
||||
index 39bed0b..77bf56a 100644
|
||||
--- a/ut-Migration-tools/templates/MT_migration.html
|
||||
+++ b/ut-Migration-tools/templates/MT_migration.html
|
||||
@@ -65,7 +65,8 @@
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
- progress = setInterval("check_progress()",2000);
|
||||
+ progress = setInterval("check_progress()",2000);
|
||||
+ log_info = setInterval("migration_details()",2000);
|
||||
setInterval("system_migration()",36000);
|
||||
});
|
||||
|
||||
diff --git a/ut-Migration-tools/views/migration.py b/ut-Migration-tools/views/migration.py
|
||||
index 33c4b19..2e9c0c5 100644
|
||||
--- a/ut-Migration-tools/views/migration.py
|
||||
+++ b/ut-Migration-tools/views/migration.py
|
||||
@@ -38,6 +38,10 @@ def close_tool(data):
|
||||
def check_user(data):
|
||||
services = check_services(data, '/check_user')
|
||||
if services:
|
||||
+ json_data = json.loads(data)
|
||||
+ with open('/usr/lib/migration-tools-server/.passwd.txt','w',encoding='utf-8') as f:
|
||||
+ text = json_data['passwd']
|
||||
+ f.write(text)
|
||||
return services
|
||||
|
||||
def check_repo(data):
|
||||
@@ -85,4 +89,4 @@ def system_migration(data):
|
||||
def migration_details(data):
|
||||
services = check_services(data, '/migration_details')
|
||||
if services:
|
||||
- return services
|
||||
\ No newline at end of file
|
||||
+ return services
|
||||
--
|
||||
2.41.0
|
||||
|
||||
@ -1,32 +0,0 @@
|
||||
From b7df99566ea6988c5411468b2b9d7e02f25bc85a Mon Sep 17 00:00:00 2001
|
||||
From: Super User <root@localhost.localdomain>
|
||||
Date: Wed, 6 Sep 2023 17:14:29 +0800
|
||||
Subject: [PATCH] allow uefi boot
|
||||
|
||||
---
|
||||
.../centos7/openeuler/centos72openeuler.py | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/ut-Migration-tools/ut-Migration-tools-0.1/centos7/openeuler/centos72openeuler.py b/ut-Migration-tools/ut-Migration-tools-0.1/centos7/openeuler/centos72openeuler.py
|
||||
index 1cedebf..f24d765 100644
|
||||
--- a/ut-Migration-tools/ut-Migration-tools-0.1/centos7/openeuler/centos72openeuler.py
|
||||
+++ b/ut-Migration-tools/ut-Migration-tools-0.1/centos7/openeuler/centos72openeuler.py
|
||||
@@ -195,7 +195,6 @@ def main():
|
||||
|
||||
if system_sync():
|
||||
subprocess.run('dnf -y groupinstall Minimal Install', shell=True)
|
||||
- conf_grub()
|
||||
else:
|
||||
print("Removing confilct package yum...")
|
||||
os.system("rpm -e --nodeps yum")
|
||||
@@ -216,6 +215,7 @@ def main():
|
||||
if os.path.exists(yum_conflict_dir):
|
||||
shutil.rmtree(yum_conflict_dir)
|
||||
print("Installing yum...")
|
||||
+ conf_grub()
|
||||
run_subprocess('dnf install -y yum'.split())
|
||||
|
||||
print("System migration completed, rebooting system")
|
||||
--
|
||||
2.41.0
|
||||
|
||||
@ -1,72 +0,0 @@
|
||||
From 76920b1ab0b7204c2feaf7dc2fa04b6d72730b5a Mon Sep 17 00:00:00 2001
|
||||
From: lixin <lixinb@uniontech.com>
|
||||
Date: Wed, 6 Sep 2023 17:23:29 +0800
|
||||
Subject: [PATCH] modify grub rules to match NIC name
|
||||
|
||||
---
|
||||
.../centos7/openeuler/centos72openeuler.py | 41 ++++++++++++++++++-
|
||||
1 file changed, 40 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/ut-Migration-tools/ut-Migration-tools-0.1/centos7/openeuler/centos72openeuler.py b/ut-Migration-tools/ut-Migration-tools-0.1/centos7/openeuler/centos72openeuler.py
|
||||
index f24d765..2be7b6b 100644
|
||||
--- a/ut-Migration-tools/ut-Migration-tools-0.1/centos7/openeuler/centos72openeuler.py
|
||||
+++ b/ut-Migration-tools/ut-Migration-tools-0.1/centos7/openeuler/centos72openeuler.py
|
||||
@@ -83,6 +83,43 @@ def add_boot_option():
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
+
|
||||
+def set_grub_biosdev_rules():
|
||||
+ """
|
||||
+ Set grub bisodev rule which can be don`t modify network configuration names.
|
||||
+ When the leapp has been made initrd, the function will set net.ifnames in /etc/default/grub.
|
||||
+ Returns:
|
||||
+ """
|
||||
+ default_grub_path = "/etc/default/grub"
|
||||
+ set_content = "net.ifnames=0 biosdevname=0"
|
||||
+ if not os.path.exists(default_grub_path):
|
||||
+ return
|
||||
+ with open(default_grub_path, 'r') as gf:
|
||||
+ gret = gf.readlines()
|
||||
+ gf.close()
|
||||
+ grub_content = ''
|
||||
+ for i in range(len(gret)):
|
||||
+ if "GRUB_CMDLINE_LINUX" in gret[i]:
|
||||
+ cmdline_tmp = gret[i].split('"', -1)[1]
|
||||
+ grub_content += 'GRUB_CMDLINE_LINUX="' + cmdline_tmp + ' ' + set_content + '"\n'
|
||||
+ continue
|
||||
+ grub_content += gret[i]
|
||||
+ try:
|
||||
+ if not os.path.exists(default_grub_path + '.disable'):
|
||||
+ shutil.copyfile(default_grub_path, default_grub_path + '.disable')
|
||||
+ os.remove(default_grub_path)
|
||||
+ else:
|
||||
+ print("grub file has been modified")
|
||||
+ return
|
||||
+ except Exception as e:
|
||||
+ print(e)
|
||||
+ return
|
||||
+ with open(default_grub_path, 'w+') as wgf:
|
||||
+ wgf.write(grub_content)
|
||||
+ wgf.close()
|
||||
+ return True
|
||||
+
|
||||
+
|
||||
def swap_release(release):
|
||||
tmp_dir = '/var/tmp'
|
||||
rpme_release = 'rpm -qf /etc/os-release | xargs -i rpm -e --nodeps {}'
|
||||
@@ -214,8 +251,10 @@ def main():
|
||||
yum_conflict_dir = '/etc/yum/'
|
||||
if os.path.exists(yum_conflict_dir):
|
||||
shutil.rmtree(yum_conflict_dir)
|
||||
- print("Installing yum...")
|
||||
+ print("Configuring grub...")
|
||||
+ set_grub_biosdev_rules()
|
||||
conf_grub()
|
||||
+ print("Installing yum...")
|
||||
run_subprocess('dnf install -y yum'.split())
|
||||
|
||||
print("System migration completed, rebooting system")
|
||||
--
|
||||
2.41.0
|
||||
|
||||
@ -1,19 +1,39 @@
|
||||
Name: migration-tools
|
||||
Version: 1.0.0
|
||||
Release: 4
|
||||
Summary: A tool to help users migrate the Centos system to the UOS system and openEuler system
|
||||
Version: 1.0.1
|
||||
Release: 1
|
||||
License: MulanPSL-2.0
|
||||
Source0: ut-Migration-tools.tar.gz
|
||||
Patch0: 0001-fix-export-error-and-no-migration-details-issue.patch
|
||||
Patch1: 0002-fix-uefi-boot-failed.patch
|
||||
Patch2: 0003-modify-grub-rules-to-match-NIC-name.patch
|
||||
Summary: A tool to help users migrate the Centos system to the UOS system and openEuler system
|
||||
|
||||
Source0: migration-tools.tar.gz
|
||||
Source1: requires.tar.gz
|
||||
Source2: xlwt-1.3.0-py2.py3-none-any.whl
|
||||
BuildArch: noarch
|
||||
%description
|
||||
UOS Migration Software
|
||||
|
||||
%if 0%{?rhel} >= 7
|
||||
%package -n migration-tools-agent
|
||||
Summary: migration-tools-agent
|
||||
License: MulanPSL-2.0
|
||||
Requires: dnf
|
||||
Requires: libabigail
|
||||
Requires: python3
|
||||
Requires: python3-flask
|
||||
Requires: python3-paramiko
|
||||
Requires: python3-requests
|
||||
Requires: python3-xlrd
|
||||
Requires: python3-xlwt
|
||||
Requires: openssl
|
||||
Requires: rsync
|
||||
Requires: yum-utils
|
||||
|
||||
%description -n migration-tools-agent
|
||||
Migration software agent side
|
||||
%endif
|
||||
|
||||
%package -n migration-tools-server
|
||||
Summary: migration-tools-server
|
||||
License: MulanPSL-2.0
|
||||
License: MulanPSL-2.0
|
||||
Requires: python3
|
||||
Requires: python3-pip
|
||||
Requires: sshpass
|
||||
@ -27,23 +47,31 @@ Migration software server side
|
||||
|
||||
%prep
|
||||
%setup -c
|
||||
%patch 0 -p1
|
||||
%patch 1 -p1
|
||||
%patch 2 -p1
|
||||
|
||||
%if 0%{?openEuler}
|
||||
cp -f %SOURCE1 agent-requires/
|
||||
cp -f %SOURCE2 agent-requires/
|
||||
%endif
|
||||
|
||||
%install
|
||||
rm -rf %{buildroot}
|
||||
mkdir -p $RPM_BUILD_ROOT/usr/lib/migration-tools-server
|
||||
mkdir -p $RPM_BUILD_ROOT/var/tmp/uos-migration
|
||||
%{__mkdir_p} $RPM_BUILD_ROOT/etc/migration-tools
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/migration-tools
|
||||
|
||||
cp -r ut-Migration-tools/* $RPM_BUILD_ROOT/usr/lib/migration-tools-server/
|
||||
cp -r * $RPM_BUILD_ROOT/usr/lib/migration-tools-server/
|
||||
|
||||
%if 0%{?rhel} >= 7
|
||||
mkdir -p $RPM_BUILD_ROOT/usr/lib/migration-tools-agent
|
||||
cp -r * $RPM_BUILD_ROOT/usr/lib/migration-tools-agent/
|
||||
%endif
|
||||
|
||||
# Install server config
|
||||
%{__cp} -r $RPM_BUILD_ROOT/usr/lib/migration-tools-server/server/migration-tools.conf $RPM_BUILD_ROOT/etc/migration-tools
|
||||
|
||||
|
||||
%post -n migration-tools-server
|
||||
pip3 install /usr/lib/migration-tools-server/agent-requires/xlwt-1.3.0-py2.py3-none-any.whl --no-cache-dir
|
||||
mkdir -p /etc/migration-tools
|
||||
mkdir -p /var/tmp/uos-migration
|
||||
cp -r /usr/lib/migration-tools-server/server/migration-tools-server.service /usr/lib/systemd/system/
|
||||
@ -53,18 +81,40 @@ systemctl daemon-reload
|
||||
systemctl restart migration-tools-server.service
|
||||
systemctl enable migration-tools-server.service
|
||||
|
||||
%if 0%{?rhel} >= 7
|
||||
%post -n migration-tools-agent
|
||||
mkdir -p /etc/migration-tools
|
||||
mkdir -p /var/tmp/uos-migration
|
||||
cp -r /usr/lib/migration-tools-agent/server/migration-tools-agent.service /usr/lib/systemd/system/
|
||||
systemctl daemon-reload
|
||||
%endif
|
||||
|
||||
%postun -n migration-tools-server
|
||||
systemctl disable migration-tools-server.service
|
||||
rm -rf /usr/lib/migration-tools-server/
|
||||
rm -rf /usr/lib/migration-tools
|
||||
rm -rf /usr/bin/migration-tools
|
||||
rm -rf /usr/lib/systemd/system/migration-tools-server.service
|
||||
|
||||
%if 0%{?rhel} >= 7
|
||||
%postun -n migration-tools-agent
|
||||
rm -rf /usr/lib/migration-tools-agent/
|
||||
rm -rf /usr/lib/migration-tools
|
||||
rm -rf /usr/bin/migration-tools
|
||||
%endif
|
||||
|
||||
%files -n migration-tools-server
|
||||
/etc/migration-tools
|
||||
/usr/lib/migration-tools-server
|
||||
|
||||
%if 0%{?rhel} >= 7
|
||||
%files -n migration-tools-agent
|
||||
/usr/lib/migration-tools-agent
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Tue Mar 05 2024 lixin <lixinb@uniontech.com> - 1.0.1-1
|
||||
- Supports migrations to OpenEuler system using the web-based interface.
|
||||
|
||||
* Wed Sep 06 2023 lixin <lixinb@uniontech.com> - 1.0.0-4
|
||||
- fix: fix uefi boot failed
|
||||
- fix: modify grub rules to match NIC name after migration
|
||||
|
||||
BIN
migration-tools.tar.gz
Normal file
BIN
migration-tools.tar.gz
Normal file
Binary file not shown.
BIN
requires.tar.gz
Normal file
BIN
requires.tar.gz
Normal file
Binary file not shown.
Binary file not shown.
BIN
xlwt-1.3.0-py2.py3-none-any.whl
Normal file
BIN
xlwt-1.3.0-py2.py3-none-any.whl
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user