def backupSWUtilizationConfig(Framework):
    # keep remote ini files
    BASEDIR = AgentPlatformParameters.getAgentConfigurationPath(Framework)

    localDiscusgeFile = File.createTempFile(
        "discusge" + str(System.currentTimeMillis()) +
        Framework.getTriggerCIData('id'), ".ini")
    remoteDiscusgeFile = BASEDIR + "discusge.ini"

    if InventoryUtils.copyRemoteFileToLocal(
            Framework, remoteDiscusgeFile,
            localDiscusgeFile.getCanonicalPath(), 0, 1):
        Framework.setProperty("local_discusge_temp_file",
                              localDiscusgeFile.getCanonicalPath())
    else:
        Framework.reportWarning(
            "backup discusge.ini file in remote server failed, upgrade agent will use default configuration."
        )

    localPluginFile = File.createTempFile(
        "plugin" + str(System.currentTimeMillis()) +
        Framework.getTriggerCIData('id'), ".ini")
    remotePluginFile = BASEDIR + "plugin.ini"

    if InventoryUtils.copyRemoteFileToLocal(Framework, remotePluginFile,
                                            localPluginFile.getCanonicalPath(),
                                            0, 1):
        Framework.setProperty("local_plugin_temp_file",
                              localPluginFile.getCanonicalPath())
    else:
        Framework.reportWarning(
            "backup discusge.ini file in remote server failed, upgrade agent will use default configuration."
        )

    Framework.setStepExecutionStatus(WorkflowStepStatus.SUCCESS)
def restoreSWUtilizationConfiguration(Framework):
    InventoryUtils.releaseConnection(Framework)
    # Framework.setConnectedClient(None)
    InventoryUtils.acquireConnection(Framework)

    # try to restore ini files if existed
    BASEDIR = AgentPlatformParameters.getAgentConfigurationPath(Framework)

    pluginIniFile = Framework.getProperty("local_plugin_temp_file")
    discusgeIniFile = Framework.getProperty("local_discusge_temp_file")

    pluginIniFileSuccess = 1
    if pluginIniFile and not InventoryUtils.copyLocalFileToRemote(
            Framework, pluginIniFile, BASEDIR + "plugin.tni", 0):
        pluginIniFileSuccess = 0
        Framework.reportWarning(
            "restore plugin.ini file failed, will use default configuration")

    discusgeIniFileSuccess = 1
    if discusgeIniFile and not InventoryUtils.copyLocalFileToRemote(
            Framework, discusgeIniFile, BASEDIR + "discusge.tni", 0):
        discusgeIniFileSuccess = 0
        Framework.reportWarning(
            "restore discusge.ini file failed, will use default configuration")

    client = Framework.getConnectedClient()
    shell = shellutils.ShellUtils(client, skip_set_session_locale=True)
    if pluginIniFileSuccess:
        renameCMD = AgentPlatformParameters.getRenameCMD(
            Framework, BASEDIR, "plugin.tni", "plugin.ini")
        logger.debug(renameCMD)
        shell.execCmd(renameCMD)
    if discusgeIniFileSuccess:
        renameCMD = AgentPlatformParameters.getRenameCMD(
            Framework, BASEDIR, "discusge.tni", "discusge.ini")
        logger.debug(renameCMD)
        shell.execCmd(renameCMD)

    File(pluginIniFile).delete()
    File(discusgeIniFile).delete()

    Framework.setStepExecutionStatus(WorkflowStepStatus.SUCCESS)
def restoreSWUtilizationConfiguration(Framework):
	InventoryUtils.releaseConnection(Framework)
	# Framework.setConnectedClient(None)
	InventoryUtils.acquireConnection(Framework)

	# try to restore ini files if existed
	BASEDIR = AgentPlatformParameters.getAgentConfigurationPath(Framework)

	pluginIniFile = Framework.getProperty("local_plugin_temp_file")
	discusgeIniFile = Framework.getProperty("local_discusge_temp_file")

	pluginIniFileSuccess = 1
	if pluginIniFile and not InventoryUtils.copyLocalFileToRemote(Framework, pluginIniFile, BASEDIR + "plugin.tni", 0):
		pluginIniFileSuccess = 0
		Framework.reportWarning("restore plugin.ini file failed, will use default configuration")

	discusgeIniFileSuccess = 1
	if discusgeIniFile and not InventoryUtils.copyLocalFileToRemote(Framework, discusgeIniFile, BASEDIR + "discusge.tni", 0):
		discusgeIniFileSuccess = 0
		Framework.reportWarning("restore discusge.ini file failed, will use default configuration")

	client = Framework.getConnectedClient()
	shell = shellutils.ShellUtils(client, skip_set_session_locale=True)
	if pluginIniFileSuccess:
		renameCMD = AgentPlatformParameters.getRenameCMD(Framework, BASEDIR, "plugin.tni", "plugin.ini")
		logger.debug(renameCMD)
		shell.execCmd(renameCMD)
	if discusgeIniFileSuccess:
		renameCMD = AgentPlatformParameters.getRenameCMD(Framework, BASEDIR, "discusge.tni", "discusge.ini")
		logger.debug(renameCMD)
		shell.execCmd(renameCMD)

	File(pluginIniFile).delete()
	File(discusgeIniFile).delete()

	Framework.setStepExecutionStatus(WorkflowStepStatus.SUCCESS)
def backupSWUtilizationConfig(Framework):
	# keep remote ini files
	BASEDIR = AgentPlatformParameters.getAgentConfigurationPath(Framework)

	localDiscusgeFile = File.createTempFile("discusge" + str(System.currentTimeMillis()) + Framework.getTriggerCIData('id'), ".ini")
	remoteDiscusgeFile = BASEDIR + "discusge.ini"

	if InventoryUtils.copyRemoteFileToLocal(Framework, remoteDiscusgeFile, localDiscusgeFile.getCanonicalPath(), 0, 1):
		Framework.setProperty("local_discusge_temp_file", localDiscusgeFile.getCanonicalPath())
	else :
		Framework.reportWarning("backup discusge.ini file in remote server failed, upgrade agent will use default configuration.")

	localPluginFile = File.createTempFile("plugin" + str(System.currentTimeMillis()) + Framework.getTriggerCIData('id'), ".ini")
	remotePluginFile = BASEDIR + "plugin.ini"

	if InventoryUtils.copyRemoteFileToLocal(Framework, remotePluginFile, localPluginFile.getCanonicalPath(), 0, 1):
		Framework.setProperty("local_plugin_temp_file", localPluginFile.getCanonicalPath())
	else :
		Framework.reportWarning("backup discusge.ini file in remote server failed, upgrade agent will use default configuration.")

	Framework.setStepExecutionStatus(WorkflowStepStatus.SUCCESS)