diff options
author | 2017-08-07 15:27:06 +0900 | |
---|---|---|
committer | 2017-08-07 15:27:06 +0900 | |
commit | e8247e08d2ac1a83edd9baeffb633481ae586f32 (patch) | |
tree | c8c172f72152378eb13b965163a21e9aba6094bd | |
parent | renamed command function as internal function (diff) | |
download | elivepatch-e8247e08d2ac1a83edd9baeffb633481ae586f32.tar.gz elivepatch-e8247e08d2ac1a83edd9baeffb633481ae586f32.tar.bz2 elivepatch-e8247e08d2ac1a83edd9baeffb633481ae586f32.zip |
sending incremental patches and main patches
-rw-r--r-- | elivepatch_client/client/checkers.py | 5 | ||||
-rw-r--r-- | elivepatch_client/client/cli.py | 6 | ||||
-rw-r--r-- | elivepatch_client/client/restful.py | 20 |
3 files changed, 17 insertions, 14 deletions
diff --git a/elivepatch_client/client/checkers.py b/elivepatch_client/client/checkers.py index b27a231..8242150 100644 --- a/elivepatch_client/client/checkers.py +++ b/elivepatch_client/client/checkers.py @@ -43,7 +43,7 @@ class Kernel(object): def set_main_patch(self, main_patch_fullpath): self.main_patch_fullpath = main_patch_fullpath - def send_files(self): + def send_files(self, applied_patches_list): """ Send config and patch files @@ -70,10 +70,9 @@ class Kernel(object): print('debug: kernel version = ' + self.rest_manager.get_kernel_version()) send_api = '/elivepatch/api/v1.0/get_files' - incremental_patches= None # send uncompressed config and patch files fullpath - self.rest_manager.send_files(temporary_config, self.main_patch_fullpath, incremental_patches, send_api) + self.rest_manager.send_files(temporary_config, self.main_patch_fullpath, applied_patches_list, send_api) def build_livepatch(self): self.rest_manager.build_livepatch() diff --git a/elivepatch_client/client/cli.py b/elivepatch_client/client/cli.py index c6742d2..1596009 100644 --- a/elivepatch_client/client/cli.py +++ b/elivepatch_client/client/cli.py @@ -33,12 +33,12 @@ class Main(object): print('Kernel security CVE check is not implemented yet') elif config.patch: patch_manager = patch.ManaGer() - patch_manager.list(config.kernel_version) - print(config.kernel_version) + applied_patches_list = patch_manager.list(config.kernel_version) + print(applied_patches_list) current_kernel = Kernel(config.url, config.kernel_version) current_kernel.set_config(config.config) current_kernel.set_main_patch(config.patch) - current_kernel.send_files() + current_kernel.send_files(applied_patches_list) current_kernel.build_livepatch() current_kernel.get_livepatch() elif config.version: diff --git a/elivepatch_client/client/restful.py b/elivepatch_client/client/restful.py index af12f92..957aba9 100644 --- a/elivepatch_client/client/restful.py +++ b/elivepatch_client/client/restful.py @@ -51,11 +51,15 @@ class ManaGer(object): 'UUID': self.uuid } # Static patch and config filename - patch_01 = open(new_patch_fullpath, 'rb') - files = [('patch', ('01.patch', patch_01, 'multipart/form-data', {'Expires': '0'})), - ('patch', ('02.patch', patch_01, 'multipart/form-data', {'Expires': '0'})), - ('patch', ('03.patch', patch_01, 'multipart/form-data', {'Expires': '0'})), - ('config', ('config', open(temporary_config.name, 'rb'), 'multipart/form-data', {'Expires': '0'}))] + files=[] + counter = 0 + for incremental_patch_fullpath in incremental_patches: + read_incremental_patch = open(incremental_patch_fullpath, 'rb') + files.append(('patch', (str(counter) + '.patch', read_incremental_patch, 'multipart/form-data', {'Expires': '0'}))) + read_incremental_patch.close() + counter += 1 + files.append(('main_patch', ('main_patch', open(new_patch_fullpath, 'rb'), 'multipart/form-data', {'Expires': '0'}))) + files.append(('config', ('config', open(temporary_config.name, 'rb'), 'multipart/form-data', {'Expires': '0'}))) print(str(files)) temporary_config.close() try: @@ -79,7 +83,7 @@ class ManaGer(object): response = requests.post(url, json=payload) print(response.json()) except: - self.catching_exceptions_exit(self.build_livepatch) + self._catching_exceptions_exit(self.build_livepatch) def get_livepatch(self, patch_folder): from io import BytesIO @@ -102,7 +106,7 @@ class ManaGer(object): print('livepatch not found') r.close() except: - self.catching_exceptions_exit(self.get_livepatch) + self._catching_exceptions_exit(self.get_livepatch) elivepatch_uuid_dir = os.path.join('..', 'elivepatch-'+ self.uuid) livepatch_fulldir = os.path.join(elivepatch_uuid_dir, 'livepatch.ko') @@ -115,7 +119,7 @@ class ManaGer(object): else: print('livepatch not received') - def catching_exceptions_exit(self, current_function): + def _catching_exceptions_exit(self, current_function): e = sys.exc_info() print( "Error %s: %s" % (current_function.__name__, str(e)) ) sys.exit(1)
\ No newline at end of file |