Example #1
0
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)
Example #2
0
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 releaseScannerLock(Framework):
    logger.debug('Finally, Starting Unlock Scanner Node')
    if not LockUtils.releaseScannerLock(Framework):
        Framework.setStepExecutionStatus(WorkflowStepStatus.FAILURE)
    else:
        logger.debug('Unlock Scanner Node finished')
        Framework.setProperty(LockUtils.ScannerNodeUnSetLock, LockUtils.ScannerNodeUnSetLock)
        Framework.setStepExecutionStatus(WorkflowStepStatus.SUCCESS)
    logger.debug('Releasing connection after unlock scan node')
    InventoryUtils.releaseConnection(Framework)
Example #4
0
def releaseResources(Framework):
	logger.debug('Releasing resources')
	# we try to remove lock if lock was acquired and not unlocked yet
	logger.debug('Releasing scanner node lock if not unlocked yet')
	logger.debug('LockUtils.ScannerNodeSetLock in Framework: ', Framework.getProperty(LockUtils.ScannerNodeSetLock))
	logger.debug('LockUtils.ScannerNodeUnSetLock in Framework: ', Framework.getProperty(LockUtils.ScannerNodeUnSetLock))
	if Framework.getProperty(LockUtils.ScannerNodeSetLock) and not Framework.getProperty(LockUtils.ScannerNodeUnSetLock):
		if InventoryUtils.ensureConnection(Framework):
			LockUtils.releaseScannerLock(Framework)
		else:
			logger.debug('Failed to remove lock as failed to connect to host')
	else:
		logger.debug('Not removing lock as lock was not acquired or already unlocked')
	if Framework.getProperty(InventoryUtils.STATE_PROPERTY_CLEAN_UP_STATE_FINALLY):
		logger.debug('Clear up state saved in DB')
		Framework.clearState()
		Framework.setProperty(InventoryUtils.STATE_PROPERTY_CLEAN_UP_STATE_FINALLY, '')
	logger.debug('Releasing shell connection to the remote node if not released yet')
	InventoryUtils.releaseConnection(Framework)
def releaseScannerLock(Framework):
    logger.debug('Finally, Starting Unlock Scanner Node')
    if not LockUtils.releaseScannerLock(Framework):
        Framework.setStepExecutionStatus(WorkflowStepStatus.FAILURE)
    else:
        logger.debug('Unlock Scanner Node finished')
        Framework.setProperty(LockUtils.ScannerNodeUnSetLock,
                              LockUtils.ScannerNodeUnSetLock)
        Framework.setStepExecutionStatus(WorkflowStepStatus.SUCCESS)
    logger.debug('Releasing connection after unlock scan node')
    InventoryUtils.releaseConnection(Framework)
Example #6
0
def releaseScannerLock(Framework):
    logger.debug('Starting Unlock Scanner Node step')
    logger.debug("Start checking ud_unique_id...")
    client = Framework.getConnectedClient()
    if client:
        uduid = InventoryUtils.getUduid(
            client,
            InventoryUtils.isStampEnabled(Framework, client.getIpAddress()))
        Framework.setProperty(InventoryUtils.ATTR_UD_UNIQUE_ID, uduid)
    if not LockUtils.releaseScannerLock(Framework):
        Framework.setStepExecutionStatus(WorkflowStepStatus.FAILURE)
    else:
        logger.debug('Unlock Scanner Node step finished')
        Framework.setProperty(LockUtils.ScannerNodeUnSetLock,
                              LockUtils.ScannerNodeUnSetLock)
        Framework.setStepExecutionStatus(WorkflowStepStatus.SUCCESS)
    logger.debug('Releasing connection after unlock scan node')
    InventoryUtils.releaseConnection(Framework)