def unInstallAgent(Framework): protocolName = Framework.getProperty( InventoryUtils.STATE_PROPERTY_CONNECTED_SHELL_PROTOCOL_NAME) logger.debug('Protocal name: ', protocolName) client = Framework.getConnectedClient() uduid = InventoryUtils.getUduid(client) logger.debug('UD_UNIQUE_ID: ', uduid) Framework.setProperty(InventoryUtils.ATTR_UD_UNIQUE_ID, uduid) if protocolName == ClientsConsts.DDM_AGENT_PROTOCOL_NAME: # Should release lock first if there will be no connected credential after agent uninstallation. logger.debug( 'The connected credential is UDA. Try to release lock first.') LockUtils.releaseScannerLock(Framework) if AgentUtils.isAgentInstalled(Framework): logger.debug('There is an agent in remote machine.') # Run uninstall command. shouldStop = AgentUtils.agentUnInstallRoutine(Framework) if shouldStop != 0: Framework.setStepExecutionStatus(WorkflowStepStatus.FATAL_FAILURE) logger.debug('Failed to uninstall agent.') else: logger.debug( 'There is no agent in remote machine. The job will be done.') reason = 'There is no agent in remote machine' Framework.setProperty( InventoryUtils.generateSkipStep('Check Agent UnInstalled'), reason) Framework.setStepExecutionStatus(WorkflowStepStatus.SUCCESS)
def unInstallAgent(Framework): protocolName = Framework.getProperty(InventoryUtils.STATE_PROPERTY_CONNECTED_SHELL_PROTOCOL_NAME) logger.debug('Protocal name: ', protocolName) client = Framework.getConnectedClient() uduid = InventoryUtils.getUduid(client) logger.debug('UD_UNIQUE_ID: ', uduid) Framework.setProperty(InventoryUtils.ATTR_UD_UNIQUE_ID, uduid) if protocolName == ClientsConsts.DDM_AGENT_PROTOCOL_NAME: # Should release lock first if there will be no connected credential after agent uninstallation. logger.debug('The connected credential is UDA. Try to release lock first.') LockUtils.releaseScannerLock(Framework) if AgentUtils.isAgentInstalled(Framework): logger.debug('There is an agent in remote machine.') # Run uninstall command. shouldStop = AgentUtils.agentUnInstallRoutine(Framework) if shouldStop != 0: Framework.setStepExecutionStatus(WorkflowStepStatus.FATAL_FAILURE) logger.debug('Failed to uninstall agent.') else: logger.debug('There is no agent in remote machine. The job will be done.') reason = 'There is no agent in remote machine' Framework.setProperty(InventoryUtils.generateSkipStep('Check Agent UnInstalled'), reason) Framework.setStepExecutionStatus(WorkflowStepStatus.SUCCESS)
def CheckAgentInstalledBeforeInstallation(Framework): try: logger.debug('Check if the UDA has already been installed...') agentInstalled = AgentUtils.isAgentInstalled(Framework) logger.debug('Agent installed result:%s' % agentInstalled) # Framework.setProperty('isAgentInstalled', agentInstalled) if agentInstalled: logger.debug('Check if the UDA can be connected...') agentConnected = isAgentConnected(Framework) logger.debug('Agent connecting result:%s' % agentConnected) # Framework.setProperty('isAgentConnected', agentConnected) if agentConnected: reason = 'The UDA has been already installed and can be connected successfully.' Framework.setProperty(InventoryUtils.generateSkipStep('Install Agent'), reason) Framework.setProperty(InventoryUtils.generateSkipStep('Check Agent Install Error Code'), reason) Framework.setProperty(InventoryUtils.generateSkipStep('Check Agent Installed'), reason) else: logger.debug('Agent installed but can not connect, reinstall it.') Framework.setProperty(InventoryUtils.STATE_PROPERTY_IS_UPGRADE, 'true') except: Framework.setStepExecutionStatus(WorkflowStepStatus.FATAL_FAILURE) Framework.setStepExecutionStatus(WorkflowStepStatus.SUCCESS)