add url processing function

This commit is contained in:
xuezhixin 2024-11-05 15:55:39 +08:00
parent 4c57ab5040
commit 3aaae0d2ef
2 changed files with 54 additions and 1 deletions

View File

@ -0,0 +1,48 @@
From b627e1aecff4edd096c4ce6cc04486adc04fe89e Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Fri, 10 Nov 2023 10:44:12 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0url=E5=A4=84=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
interaction.py | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
create mode 100644 interaction.py
diff --git a/interaction.py b/interaction.py
new file mode 100644
index 0000000..e4016ab
--- /dev/null
+++ b/interaction.py
@@ -0,0 +1,25 @@
+import requests
+import json
+from sysmig_agent.share import getSysMigConf
+
+headers = {'content-type': 'application/json'}
+
+class Interaction:
+ def __init__(self, url, data):
+ self.url = url
+ self.data = data
+
+ def send_post_requests(self):
+ try:
+ r = requests.post(url=self.url, data=self.data, headers=headers, timeout=10)
+ except:
+ r = None
+ return r
+
+
+def splice_url(data, url, ip):
+ uos_sysmig_conf = json.loads(getSysMigConf(ip))
+ port = json.loads(uos_sysmig_conf).get('agentport').strip()[1:-1]
+ post_url = "http://" + ip + ":" + port + url
+ data = Interaction(post_url, data)
+ return data.send_post_requests()
\ No newline at end of file
--
2.20.1

View File

@ -1,6 +1,6 @@
Name: migration-tools
Version: 1.0.2
Release: 23
Release: 24
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
@ -30,6 +30,8 @@ Patch20: 0020-get-task-process-and-migration-stage-information.patch
Patch21: 0021-get-agent-ip-interface.patch
Patch22: 0022-udpate-agent-host-status-online.patch
Patch23: 0023-update-the-status-of-the-migration-phase.patch
Patch24: 0024-add-url-processing-function.patch
BuildArch: noarch
BuildRequires: systemd
@ -128,6 +130,9 @@ rm -rf /usr/bin/migration-tools
%endif
%changelog
* Tue Nov 5 2024 xuezhixin <xuezhixin@uniontech.com> - 1.0.2-24
- 0024-add-url-processing-function.patch
* Mon Nov 4 2024 xuezhixin <xuezhixin@uniontech.com> - 1.0.2-23
- 0023-update-the-status-of-the-migration-phase.patch