#!/usr/bin/python3 # -*- encoding: utf-8 -*- # # vim: tabstop=4 shiftwidth=4 softtabstop=4 # # Copyright (c) 2023-2024 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # """ software sync between duplex controllers to be called after prestaging """ import os import six.moves.configparser as configparser import software.constants as constants import sys import upgrade_utils KEYSTONE_CONFIG_SECTION = "keystone_authtoken" CONF = configparser.ConfigParser(interpolation=None) CONF.optionxform = str def main(): try: if not os.path.exists(constants.SOFTWARE_CONFIG_FILE_LOCAL): raise Exception("Software config file is not found!") CONF.read(constants.SOFTWARE_CONFIG_FILE_LOCAL) if not CONF.has_section(KEYSTONE_CONFIG_SECTION): raise Exception(f"ERROR: {KEYSTONE_CONFIG_SECTION} section does not exist!") config = dict(CONF.items(KEYSTONE_CONFIG_SECTION)) usm_token, usm_endpoint = \ upgrade_utils.get_token_endpoint(config, service_type="usm") api_cmd = usm_endpoint + "/deploy/software_sync" method = 'POST' output = upgrade_utils.call_api(usm_token, method, api_cmd) result = output.get("result") if not result: raise Exception(f"ERROR: Unable to sync subclouds controllers!") print(result) except Exception as ex: print(f"Exception: {str(ex)}") return -1 if __name__ == "__main__": sys.exit(main())