#!/usr/bin/env python
# Copyright (c) 2020 Klustron inc. All rights reserved.
# This source code is licensed under Apache 2.0 License,
# combined with Common Clause Condition 1.0, as detailed in the NOTICE file.

import sys
import json
import getpass
import argparse
import platform
import os

# This is the driver process for handing clustermgr configuration differences between versions
def upgrade_clustermgr_config(verfrom, verto, scriptf):
    scriptf.write("confpath=\"$1\"\n\n")
    maps = {"1.2.2_to_1.3.1": upgrade_clustermgr_from_122_to_131}
    prokey = "%s_to_%s" % (verfrom, verto)
    if prokey in maps:
        upd_proc = maps.get(prokey)
        upd_proc(scriptf)

def upgrade_clustermgr_from_122_to_131(scriptf):
    cmdpat = "bash change_config.sh \"$confpath\" \"%s\" \"%s\"\n"
    scriptf.write(cmdpat % ("skip_license_check", "on"))

# This is the driver process for handing nodemgr configuration differences between versions
def upgrade_nodemgr_config(verfrom, verto, scriptf):
    scriptf.write("confpath=\"$1\"\n\n")
    maps = {"1.2.2_to_1.3.1": upgrade_nodemgr_from_122_to_131}
    prokey = "%s_to_%s" % (verfrom, verto)
    if prokey in maps:
        upd_proc = maps.get(prokey)
        upd_proc(scriptf)

def upgrade_nodemgr_from_122_to_131(scriptf):
    cmdpat = "bash change_config.sh \"$confpath\" \"%s\" \"%s\"\n"
    scriptf.write(cmdpat % ("skip_license_check", "on"))

