aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlice Ferrazzi <alicef@gentoo.org>2017-07-15 23:29:34 +0900
committerAlice Ferrazzi <alicef@gentoo.org>2017-07-15 23:29:34 +0900
commit2322079f7346955da9a5aa10abde12e605ae5907 (patch)
treebcbbf333d4eee4d2a25e43a2cfb3c1d94b01a5c6 /elivepatch_client
parentmoving uuid functions to the client as RFC 4122 (diff)
downloadelivepatch-2322079f7346955da9a5aa10abde12e605ae5907.tar.gz
elivepatch-2322079f7346955da9a5aa10abde12e605ae5907.tar.bz2
elivepatch-2322079f7346955da9a5aa10abde12e605ae5907.zip
setting uuid from the client
Diffstat (limited to 'elivepatch_client')
-rw-r--r--elivepatch_client/client/checkers.py36
-rw-r--r--elivepatch_client/client/restful.py4
2 files changed, 6 insertions, 34 deletions
diff --git a/elivepatch_client/client/checkers.py b/elivepatch_client/client/checkers.py
index d437aa6..318e174 100644
--- a/elivepatch_client/client/checkers.py
+++ b/elivepatch_client/client/checkers.py
@@ -5,7 +5,6 @@
# Distributed under the terms of the GNU General Public License v2 or later
import gzip
-import shelve
import uuid
import os
@@ -31,8 +30,9 @@ class Kernel(object):
self.patch = ''
self.restserver_url = restserver_url
self.kernel_version = None
- self.rest_manager = restful.ManaGer(self.restserver_url, self.kernel_version)
- self.uuid = id_generate_uuid()
+ self.session_uuid = id_generate_uuid()
+ print('This session uuid: ' + str(self.session_uuid))
+ self.rest_manager = restful.ManaGer(self.restserver_url, self.kernel_version, self.session_uuid)
def set_config(self, config_path):
self.config = config_path
@@ -53,41 +53,13 @@ class Kernel(object):
# Get kernel version from the configuration file header
self.kernel_version = f_action.config_kernel_version(self.config)
self.rest_manager.set_kernel_version(self.kernel_version)
- print('debug: kernel version =' + self.rest_manager.get_kernel_version())
+ print('debug: kernel version = ' + self.rest_manager.get_kernel_version())
path, patch_file = (os.path.split(self.patch))
-
- # check uuid
- data_store = shelve.open('uuid')
-
- # get old uuid if present
- try:
- old_uuid = data_store['UUID']
- except:
- old_uuid = None
- print('no UUID')
-
# send uncompressed config and patch files
replay = self.rest_manager.send_file(self.config, self.patch, file, patch_file, '/elivepatch/api/v1.0/get_files')
- # get uuid returned from the server
- try:
- uuid = replay['get_config']['UUID']
- except:
- uuid = None
- self.rest_manager.set_uuid(uuid)
-
- # check if the uuid is new
- if uuid:
- try:
- if uuid != old_uuid or not old_uuid:
- print('new uuid: ' + str(uuid))
- data_store['UUID'] = uuid
- data_store.close()
- except:
- pass
-
def build_livepatch(self):
self.rest_manager.build_livepatch()
diff --git a/elivepatch_client/client/restful.py b/elivepatch_client/client/restful.py
index 938fa5f..d8a55a0 100644
--- a/elivepatch_client/client/restful.py
+++ b/elivepatch_client/client/restful.py
@@ -14,11 +14,11 @@ class ManaGer(object):
RESTful client functions
"""
- def __init__(self, server_url, kernel_version):
+ def __init__(self, server_url, kernel_version, uuid):
self.server_url = server_url
self.kernel_version = kernel_version
# universally unique identifier for multi-threading
- self.uuid = None
+ self.uuid = uuid
def set_uuid(self, uuid):
self.uuid = uuid