diff options
author | Alice Ferrazzi <alicef@gentoo.org> | 2017-06-25 03:57:06 +0900 |
---|---|---|
committer | Alice Ferrazzi <alicef@gentoo.org> | 2017-06-25 03:57:06 +0900 |
commit | d26611fb898223f2ea2dcf323078347ca928cbda (patch) | |
tree | 2308726a97dc7e40ac8865d5f21fc4432c817557 | |
parent | moved kernel dir variable to livepatch class (diff) | |
download | elivepatch-d26611fb898223f2ea2dcf323078347ca928cbda.tar.gz elivepatch-d26611fb898223f2ea2dcf323078347ca928cbda.tar.bz2 elivepatch-d26611fb898223f2ea2dcf323078347ca928cbda.zip |
Creating the live patch downloader
-rw-r--r-- | elivepatch_server/elivepatch | 6 | ||||
-rw-r--r-- | elivepatch_server/resources/dispatcher.py | 40 |
2 files changed, 43 insertions, 3 deletions
diff --git a/elivepatch_server/elivepatch b/elivepatch_server/elivepatch index 657fd98..7e3b999 100644 --- a/elivepatch_server/elivepatch +++ b/elivepatch_server/elivepatch @@ -30,8 +30,10 @@ def create_app(): api.add_resource(AgentInfo.AgentAPI, '/elivepatch/api/', endpoint='root') api.add_resource(AgentInfo.AgentAPI, '/elivepatch/api/v1.0/agent', endpoint='agent') - api.add_resource(dispatcher.getLivePatch, '/elivepatch/api/v1.0/livepatch', - endpoint='livepatch') + api.add_resource(dispatcher.buildLivePatch, '/elivepatch/api/v1.0/build_livepatch', + endpoint='build_livepatch') + api.add_resource(dispatcher.getLivePatch, '/elivepatch/api/v1.0/get_livepatch', + endpoint='get_livepatch') api.add_resource(dispatcher.getConfig, '/elivepatch/api/v1.0/config', endpoint='config') api.add_resource(dispatcher.getPatch, '/elivepatch/api/v1.0/patch', diff --git a/elivepatch_server/resources/dispatcher.py b/elivepatch_server/resources/dispatcher.py index 0570010..406f5e0 100644 --- a/elivepatch_server/resources/dispatcher.py +++ b/elivepatch_server/resources/dispatcher.py @@ -37,6 +37,38 @@ lpatch.set_kernel_dir('/usr/src/linux-4.10.14-gentoo/') kernel_dir = lpatch.get_kernel_dir() +class buildLivePatch(Resource): + + def __init__(self): + self.reqparse = reqparse.RequestParser() + self.reqparse.add_argument('KernelVersion', type=str, required=False, + help='No task title provided', + location='json') + self.reqparse.add_argument('LivepatchStatus', type=str, required=False, + help='No task title provided', + location='json') + super(buildLivePatch, self).__init__() + pass + + def get(self): + lpatch.build_livepatch(kernel_dir, kernel_dir + '/vmlinux') + return {'packs': [marshal(pack, pack_fields) for pack in packs]} + + def post(self): + args = self.reqparse.parse_args() + kernel_config = lpatch.get_config() + kernel_patch = lpatch.get_patch() + if kernel_config and kernel_patch: + lpatch.set_lp_status('working') + lpatch.build_livepatch(kernel_dir, kernel_dir + '/vmlinux') + pack = { + 'id': packs['id'] + 1, + 'KernelVersion': args['KernelVersion'], + 'LivepatchStatus': lpatch.livepatch_status, + } + return {'agent': marshal(pack, pack_fields)}, 201 + + class getLivePatch(Resource): def __init__(self): @@ -51,7 +83,12 @@ class getLivePatch(Resource): pass def get(self): - lpatch.build_livepatch(kernel_dir, kernel_dir + '/vmlinux') + # Getting livepatch build status + status = lpatch.get_lp_status() + if status == 'done': + response = make_response() + response.headers['content-type'] = 'application/octet-stream' + return response return {'packs': [marshal(pack, pack_fields) for pack in packs]} def post(self): @@ -90,6 +127,7 @@ class getConfig(Resource): audioFile.save(audioFile_name) lpatch.set_config(audioFile_name) + class getPatch(Resource): def __init__(self): |