migration-tools/0030-system-information-import-info-the-database-after-migration.patch

58 lines
1.9 KiB
Diff

From 88d87089720784e3dd57b1f780e5ecc398ed03be Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 11:20:58 +0800
Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E5=90=8E=E7=B3=BB=E7=BB=9F?=
=?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=AF=BC=E5=85=A5=E6=95=B0=E6=8D=AE=E5=BA=93?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/share.py | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/sysmig_agent/share.py b/sysmig_agent/share.py
index 1a12a7e..6b8da14 100644
--- a/sysmig_agent/share.py
+++ b/sysmig_agent/share.py
@@ -368,3 +368,36 @@ def main_conf(osname):
logger.info("Switch complete.UniontechOS recommends rebooting this system.")
return 0
+
+
+def sql_os_newversion(localos):
+ sql = "UPDATE agent_info SET agent_migration_os = '{}' WHERE agent_ip = '{}';".format(localos, get_local_ip())
+ try:
+ ret = DBHelper().execute(sql)
+ except:
+ pass
+
+
+def get_new_osversion():
+ new_os = '统信服务器操作系统V20({})'
+ path = '/etc/os-version'
+ if os.path.exists(path):
+ with open(path,'r') as v:
+ ret = v.readlines()
+ localos=ostype=''
+ for i in range(len(ret)):
+ if not ret[i]:
+ continue
+ if 'MinorVersion' in ret[i]:
+ strminor = str(ret[i])
+ _, localos = strminor.split('=',1)
+ if 'EditionName[zh_CN]' in ret[i]:
+ strminor = str(ret[i])
+ _, ostype = strminor.split('=',1)
+ ostype = re.sub('[^a-zA-Z]+','',ostype)
+ localos = localos.strip().strip('\n') + ostype.strip().strip('\n')
+ localos = new_os.format(localos.strip().strip('\n'))
+ sql_os_newversion(localos)
+
+ else:
+ sql_os_newversion('NULL')
--
2.20.1