diff options
author | Roberto Hueso Gómez <rhueso@soleta.eu> | 2020-09-15 13:42:28 +0200 |
---|---|---|
committer | Roberto Hueso Gómez <rhueso@soleta.eu> | 2020-09-15 13:42:28 +0200 |
commit | ea5b22c35e170deff7321abaca5d81cb289c69f7 (patch) | |
tree | 9a2a701e7274b26ee00ff7f64e7b9adea3490d77 /ogcp/views.py | |
parent | 1ce9c8a95b7677f3131160df62d9a3ce73f4706a (diff) |
Add delete partition view
This view deletes and formats a partition from the selected machine.
Diffstat (limited to 'ogcp/views.py')
-rw-r--r-- | ogcp/views.py | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/ogcp/views.py b/ogcp/views.py index 13ad3b6..8c14675 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -153,7 +153,38 @@ def action_setup_modify(): @app.route('/action/setup/delete', methods=['POST']) def action_setup_delete(): - return make_response("200 OK", 200) + form = PartitionForm(request.form) + if form.validate(): + ips = form.ips.data.split(' ') + db_partitions = get_client_setup(ips) + + payload = {'clients': ips, + 'disk': str(form.disk.data), + 'cache': str(0), + 'cache_size': str(0), + 'partition_setup': []} + + for db_part in db_partitions: + if db_part['partition'] == 0: + # Skip if this is disk setup. + continue + partition_setup = {'partition': str(db_part['partition']), + 'code': db_part['code'], + 'filesystem': db_part['filesystem'], + 'size': str(db_part['size']), + 'format': str(int(False))} + payload['partition_setup'].append(partition_setup) + + modified_part = payload['partition_setup'][int(form.partition.data) - 1] + modified_part['filesystem'] = FS_CODES[1] + modified_part['code'] = PART_TYPE_CODES[0] + modified_part['size'] = str(0) + modified_part['format'] = str(int(True)) + + r = g.server.post('/setup', payload=payload) + if r.status_code == requests.codes.ok: + return make_response("200 OK", 200) + return make_response("400 Bad Request", 400) @app.route('/action/reboot', methods=['POST']) def action_reboot(): |