# remove-cloud-reg.py
# Removal of fin cloud registration key
#

import json
import subprocess
import argparse

if __name__ == "__main__":
    parser = argparse.ArgumentParser(
        description="Removal of cloud registration key"
    )
    parser.add_argument("--conffile", required=True, type=str)
    args = parser.parse_args()

    print("Parsing configuration file : " + args.conffile)

    # Open and read the JSON file
    with open(args.conffile, 'r') as file:
        data = json.load(file)

    container = data['container']['name']

    subprocess.call(f'docker exec {container} rm -r var/etc/finEdge2Cloud/cloud.ks', shell=True)
    subprocess.call(f'docker restart {container}', shell=True)
