aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlice Ferrazzi <alicef@gentoo.org>2017-06-28 03:39:00 +0900
committerAlice Ferrazzi <alicef@gentoo.org>2017-06-28 03:39:00 +0900
commit6eca2eec3572cad0181b3ce61f521ff40fa85ec1 (patch)
tree45f687cfc45f0fb9516fb8a69c352a5403162578 /elivepatch_client
parentRemoved basic auth (diff)
downloadelivepatch-6eca2eec3572cad0181b3ce61f521ff40fa85ec1.tar.gz
elivepatch-6eca2eec3572cad0181b3ce61f521ff40fa85ec1.tar.bz2
elivepatch-6eca2eec3572cad0181b3ce61f521ff40fa85ec1.zip
Added working get function for download the live patch generated
Diffstat (limited to 'elivepatch_client')
-rw-r--r--elivepatch_client/client/cli.py1
-rw-r--r--elivepatch_client/client/restful.py17
2 files changed, 14 insertions, 4 deletions
diff --git a/elivepatch_client/client/cli.py b/elivepatch_client/client/cli.py
index 23cd577..3694845 100644
--- a/elivepatch_client/client/cli.py
+++ b/elivepatch_client/client/cli.py
@@ -49,6 +49,7 @@ class Main(object):
current_kernel.send_config(config.url)
current_kernel.send_patch(config.url)
current_kernel.build_livepatch(config.url)
+ current_kernel.get_livepatch(config.url)
elif config.version:
print('elivepatch version: '+str(VERSION))
else:
diff --git a/elivepatch_client/client/restful.py b/elivepatch_client/client/restful.py
index 1e5fea2..f6ee7f2 100644
--- a/elivepatch_client/client/restful.py
+++ b/elivepatch_client/client/restful.py
@@ -3,7 +3,7 @@
import json, base64
import requests
from requests.auth import HTTPBasicAuth
-
+import time
class ManaGer(object):
def __init__(self, server_url):
@@ -30,10 +30,19 @@ class ManaGer(object):
print(r.json())
def get_livepatch(self):
+ from io import BytesIO
url = self.server_url+'/elivepatch/api/v1.0/get_livepatch'
payload = {
'KernelVersion': '4.10.16'
}
- r = requests.post(url, json=payload)
- print(r.text)
- print(r.json()) \ No newline at end of file
+ r = requests.get(url)
+ if r.status_code == requests.codes.ok: # livepatch returned ok
+ b= BytesIO(r.content)
+ with open('myfile.ko', 'wb') as out:
+ out.write(r.content)
+ r.close()
+ print(b)
+ else:
+ r.close()
+ time.sleep(5)
+ return self.get_livepatch() # try to get the livepatch again