!69 get local ip on the agent

From: @xuezhizone 
Reviewed-by: @xingwei-liu 
Signed-off-by: @xingwei-liu
This commit is contained in:
openeuler-ci-bot 2024-11-04 07:52:38 +00:00 committed by Gitee
commit c3f243389e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 46 additions and 1 deletions

View File

@ -0,0 +1,41 @@
From 36a4d4629cef2cf5df278fd2ca503b6b84a89751 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 10:01:24 +0800
Subject: [PATCH] =?UTF-8?q?agent=E8=8E=B7=E5=8F=96=E6=9C=AC=E5=9C=B0IP?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/share.py | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/sysmig_agent/share.py b/sysmig_agent/share.py
index ec9265b..ea3d63a 100644
--- a/sysmig_agent/share.py
+++ b/sysmig_agent/share.py
@@ -7,9 +7,20 @@ import platform
import re
import shutil
import subprocess
-
+import socket
from sysmig_agent.utils import list_to_json
+
+def get_local_ip():
+ try:
+ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+ s.connect(('8.8.8.8', 80))
+ ip = s.getsockname()[0]
+ return ip
+ finally:
+ s.close()
+
+
def getSysMigConf():
confpath = '/etc/migration-tools/migration-tools.conf'
if not os.path.exists(confpath):
--
2.20.1

View File

@ -1,6 +1,6 @@
Name: migration-tools
Version: 1.0.2
Release: 15
Release: 16
License: MulanPSL-2.0
Summary: A tool to help users migrate the Centos system to the UOS system and openEuler system
Source0: %{name}-%{version}.tar.gz
@ -22,6 +22,7 @@ Patch12: 0012-add-agent_task-in-database.patch
Patch13: 0013-display-agent-host-information.patch
Patch14: 0014-modify-task-stream-interface.patch
Patch15: 0015-delete-host-information-interface.patch
Patch16: 0016-get-local-ip-on-the-agent.patch
BuildArch: noarch
BuildRequires: systemd
@ -120,6 +121,9 @@ rm -rf /usr/bin/migration-tools
%endif
%changelog
* Mon Nov 4 2024 xuezhixin <xuezhixin@uniontech.com> - 1.0.2-16
- 0016-get-local-ip-on-the-agent.patch
* Mon Nov 4 2024 xuezhixin <xuezhixin@uniontech.com> - 1.0.2-15
- 0015-delete-host-information-interface.patch