本文整理汇总了Python中InventoryUtils.copyLocalFileToRemote方法的典型用法代码示例。如果您正苦于以下问题:Python InventoryUtils.copyLocalFileToRemote方法的具体用法?Python InventoryUtils.copyLocalFileToRemote怎么用?Python InventoryUtils.copyLocalFileToRemote使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InventoryUtils
的用法示例。
在下文中一共展示了InventoryUtils.copyLocalFileToRemote方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: upgradeConfigFile
# 需要导入模块: import InventoryUtils [as 别名]
# 或者: from InventoryUtils import copyLocalFileToRemote [as 别名]
def upgradeConfigFile(scannerPlatformConfig, Framework):
logger.debug('Installing configuration file')
#copying local scanner executable and config file to the remove machine
BASEDIR = Framework.getProperty(InventoryUtils.STATE_PROPERTY_RESOLVED_BASEDIR)
#scanner config local file
scannerConfigPerPlatformSettings = Framework.getParameter('ScannerConfigurationFile')
scannerConfig = ScannerConfigurationUtil.getInstance().loadScannerConfigurationPerPlatformWrapper(scannerConfigPerPlatformSettings)
platform = Framework.getProperty(InventoryUtils.STATE_PROPERTY_PLATFORM)
architecture = Framework.getProperty(InventoryUtils.STATE_PROPERTY_ARCHITECTURE)
scannerConfigFile = scannerConfig.getScannerNameForPlatform(platform, architecture)
logger.debug('Config file to be used:', scannerConfigFile)
#scanner config remote file
scannerRemoteConfigFile = scannerPlatformConfig.getScannerRemoteConfigFileName()
scannerConfigLocalpath = CollectorsParameters.PROBE_MGR_SCANNER_CONFIG_DIR + scannerConfigFile
logger.debug('Scanner config file local path:', scannerConfigLocalpath)
if not checkResourceExists(Framework, scannerConfigLocalpath):
return 0
scannerConfigRemotePath = BASEDIR + scannerRemoteConfigFile
if not InventoryUtils.copyLocalFileToRemote(Framework, scannerConfigLocalpath, scannerConfigRemotePath):
Framework.setStepExecutionStatus(WorkflowStepStatus.FAILURE)
return 0
Framework.setProperty(InventoryUtils.SCANNER_CONFIG_REMOTE_PATH, scannerConfigRemotePath)
return 1
示例2: upgradeScannerExecutable
# 需要导入模块: import InventoryUtils [as 别名]
# 或者: from InventoryUtils import copyLocalFileToRemote [as 别名]
def upgradeScannerExecutable(scannerPlatformConfig, Framework, shell):
logger.debug('Installing scanner')
#copying local scanner executable and config file to the remove machine
BASEDIR = Framework.getProperty(InventoryUtils.STATE_PROPERTY_RESOLVED_BASEDIR)
#scanner local executable file
scannerExecutable = scannerPlatformConfig.getScannerExecutable()
logger.debug('Scanner executable to be used:', scannerExecutable)
#scanner remote executable file
scannerRemoteExecutable = scannerPlatformConfig.getScannerRemoteExecutableName()
#local location of scanner and config file
scannerExecutableLocalPath = CollectorsParameters.PROBE_MGR_RESOURCES_DIR + 'ud_scanners' + str(File.separator) + scannerExecutable
logger.debug('Scanner executable local path:', scannerExecutableLocalPath)
if not checkResourceExists(Framework, scannerExecutableLocalPath):
return 0
scannerExecutableRemotePath = BASEDIR + scannerRemoteExecutable
if not InventoryUtils.copyLocalFileToRemote(Framework, scannerExecutableLocalPath, scannerExecutableRemotePath):
Framework.setStepExecutionStatus(WorkflowStepStatus.FAILURE)
# Try to terminate scanner, if scanner process is stopping the upload
logger.debug('Upload cannot proceed due to scanner process, terminate it.')
terminateScanner(Framework, shell, scannerRemoteExecutable)
return 0
# OK, now scanner file has already upgrade successful
Framework.setProperty(InventoryUtils.SCANNER_UPGRADE_DATE, Date())
Framework.setProperty(InventoryUtils.SCANNER_UPGRADE_STATE, '1')
Framework.setProperty(InventoryUtils.SCANNER_EXECUTABLE_REMOTE_PATH, scannerExecutableRemotePath)
return 1
示例3: upgradePrePostScript
# 需要导入模块: import InventoryUtils [as 别名]
# 或者: from InventoryUtils import copyLocalFileToRemote [as 别名]
def upgradePrePostScript(scannersConfigFile, scannerPlatformConfig, Framework):
logger.debug('Installing pre/post script')
BASEDIR = Framework.getProperty(InventoryUtils.STATE_PROPERTY_RESOLVED_BASEDIR)
platform = Framework.getProperty(InventoryUtils.STATE_PROPERTY_PLATFORM)
unixConfig = scannersConfigFile.getPlatformConfiguration('unix', "")
#whether run or not pre-scan and post-scan scripts
isPrePostScriptAllowed = Boolean.parseBoolean(Framework.getParameter('IsPrePostScriptAllowed'))
logger.debug("isPrePostScriptAllowed:", isPrePostScriptAllowed)
if not isPrePostScriptAllowed:
return
isAllUnix = False
preScanScriptLocalPath = getPrePostScriptLocalPath(scannerPlatformConfig.getScannerPreScanScriptLocalFile())
logger.debug('preScanScriptLocalPath:', preScanScriptLocalPath)
if InventoryUtils.isUnix(platform) and not os.path.exists(preScanScriptLocalPath):
logger.debug("No specific platform for the device, use all-unix.")
isAllUnix = True
preScanScriptLocalPath = getPrePostScriptLocalPath(unixConfig.getScannerPreScanScriptLocalFile())
logger.debug("preScanScriptLocalPath:", preScanScriptLocalPath)
postScanScriptLocalPath = getPrePostScriptLocalPath(scannerPlatformConfig.getScannerPostScanScriptLocalFile())
logger.debug('postScanScriptLocalPath:', postScanScriptLocalPath)
if InventoryUtils.isUnix(platform) and not os.path.exists(postScanScriptLocalPath):
logger.debug("No specific platform for the device, use all-unix.")
isAllUnix = True
postScanScriptLocalPath = getPrePostScriptLocalPath(unixConfig.getScannerPostScanScriptLocalFile())
logger.debug('postScanScriptLocalPath:', postScanScriptLocalPath)
preScanScriptRemotePath = BASEDIR + scannerPlatformConfig.getScannerPreScanScriptRemoteFile()
logger.debug('preScanScriptRemotePath:', preScanScriptRemotePath)
postScanScriptRemotePath = BASEDIR + scannerPlatformConfig.getScannerPostScanScriptRemoteFile()
logger.debug('postScanScriptRemotePath:', postScanScriptRemotePath)
if os.path.exists(preScanScriptLocalPath):
InventoryUtils.copyLocalFileToRemote(Framework, preScanScriptLocalPath, preScanScriptRemotePath)
if os.path.exists(postScanScriptLocalPath):
InventoryUtils.copyLocalFileToRemote(Framework, postScanScriptLocalPath, postScanScriptRemotePath)
# upgrade resource files for PrePostScript
upgradePrePostScriptResource(isAllUnix, Framework)
Framework.setProperty(InventoryUtils.SCANNER_PRE_SCAN_SCRIPT_REMOTE_PATH, preScanScriptRemotePath)
Framework.setProperty(InventoryUtils.SCANNER_POST_SCAN_SCRIPT_REMOTE_PATH, postScanScriptRemotePath)
示例4: restoreSWUtilizationConfiguration
# 需要导入模块: import InventoryUtils [as 别名]
# 或者: from InventoryUtils import copyLocalFileToRemote [as 别名]
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)
示例5: upgradePrePostScriptResource
# 需要导入模块: import InventoryUtils [as 别名]
# 或者: from InventoryUtils import copyLocalFileToRemote [as 别名]
def upgradePrePostScriptResource(isAllUnix, Framework):
logger.debug('Installing resource files for pre/post script')
BASEDIR = Framework.getProperty(InventoryUtils.STATE_PROPERTY_RESOLVED_BASEDIR)
platform = Framework.getProperty(InventoryUtils.STATE_PROPERTY_PLATFORM)
architecture = Framework.getProperty(InventoryUtils.STATE_PROPERTY_ARCHITECTURE)
if isAllUnix:
logger.debug("No specific platform for the device, use all-unix.")
platform = 'unix'
architecture = ''
elif platform in ['aix', 'windows']:
# since in PrePostScriptEditor, the aix and windows platforms have no architecture definitions,
# so just ignore the architecture value for aix and windows
architecture = ''
#get all local file path from resource folder and generate remote file path
prepostScanScriptResourcePathArray = getPrePostScriptResourcePathArray(BASEDIR, platform, architecture)
if prepostScanScriptResourcePathArray is not None:
# copy local resource files to remote
for (resourceLocalPath, resourceRemotePath) in prepostScanScriptResourcePathArray:
if os.path.exists(resourceLocalPath):
InventoryUtils.copyLocalFileToRemote(Framework, resourceLocalPath, resourceRemotePath)