mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-26 07:02:22 +03:00
plugin installation process was managed about possible exceptions
This commit is contained in:
parent
7d22232c1c
commit
7d829bef7d
1 changed files with 28 additions and 13 deletions
|
@ -10,6 +10,7 @@ import stat
|
||||||
import subprocess
|
import subprocess
|
||||||
import uuid
|
import uuid
|
||||||
import urllib.request
|
import urllib.request
|
||||||
|
import errno
|
||||||
|
|
||||||
from base.Scope import Scope
|
from base.Scope import Scope
|
||||||
from base.messaging.ssh_file_transfer import FileTransfer
|
from base.messaging.ssh_file_transfer import FileTransfer
|
||||||
|
@ -57,6 +58,7 @@ class ExecutionManager(object):
|
||||||
temp_file = self.config_manager.get('CONNECTION', 'receivefileparam') + str(uuid.uuid4()) + '.deb'
|
temp_file = self.config_manager.get('CONNECTION', 'receivefileparam') + str(uuid.uuid4()) + '.deb'
|
||||||
|
|
||||||
if str(plugin['protocol']).lower() == 'ssh':
|
if str(plugin['protocol']).lower() == 'ssh':
|
||||||
|
try:
|
||||||
self.logger.debug('[ExecutionManager] Distribution protocol is {}'.format(str(plugin['protocol']).lower()))
|
self.logger.debug('[ExecutionManager] Distribution protocol is {}'.format(str(plugin['protocol']).lower()))
|
||||||
host = parameter_map['host']
|
host = parameter_map['host']
|
||||||
username = parameter_map['username']
|
username = parameter_map['username']
|
||||||
|
@ -67,6 +69,10 @@ class ExecutionManager(object):
|
||||||
transfer = FileTransfer(host, port, username, password)
|
transfer = FileTransfer(host, port, username, password)
|
||||||
transfer.connect()
|
transfer.connect()
|
||||||
transfer.get_file(temp_file, path)
|
transfer.get_file(temp_file, path)
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.error('[ExecutionManager] Plugin package could not fetch. Error Message: {}.'.format(str(e)))
|
||||||
|
self.logger.error('[ExecutionManager] Plugin Installation is cancelling')
|
||||||
|
return
|
||||||
|
|
||||||
elif plugin['protocol'].lower() == 'http':
|
elif plugin['protocol'].lower() == 'http':
|
||||||
self.logger.debug('[ExecutionManager] Distribution protocol is {}.'.format(str(plugin['protocol']).lower()))
|
self.logger.debug('[ExecutionManager] Distribution protocol is {}.'.format(str(plugin['protocol']).lower()))
|
||||||
|
@ -75,10 +81,19 @@ class ExecutionManager(object):
|
||||||
self.logger.debug('[ExecutionManager] Unsupported protocol is {}.'.format(str(plugin['protocol']).lower()))
|
self.logger.debug('[ExecutionManager] Unsupported protocol is {}.'.format(str(plugin['protocol']).lower()))
|
||||||
|
|
||||||
self.logger.debug('[ExecutionManager] Plugin package downloaded via {}.'.format(str(plugin['protocol']).lower()))
|
self.logger.debug('[ExecutionManager] Plugin package downloaded via {}.'.format(str(plugin['protocol']).lower()))
|
||||||
|
try:
|
||||||
self.install_deb(temp_file)
|
self.install_deb(temp_file)
|
||||||
self.logger.debug('[ExecutionManager] Plugin installed.')
|
self.logger.debug('[ExecutionManager] Plugin installed.')
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.error('[ExecutionManager] Could not install plugin. Error Message: {}'.format(str(e)))
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
self.remove_file(temp_file)
|
self.remove_file(temp_file)
|
||||||
self.logger.debug('[ExecutionManager] Temp files were removed.')
|
self.logger.debug('[ExecutionManager] Temp files were removed.')
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.error('[ExecutionManager] Could not remove temp file. Error Message: {}'.format(str(e)))
|
||||||
|
|
||||||
self.plugin_manager.loadSinglePlugin(plugin_name)
|
self.plugin_manager.loadSinglePlugin(plugin_name)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
Loading…
Reference in a new issue