[Erp5-report] r34849 luke - /erp5/trunk/utils/erp5.timmy/src/erp5/timmy/timmy.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Apr 29 11:49:00 CEST 2010
Author: luke
Date: Thu Apr 29 11:48:58 2010
New Revision: 34849
URL: http://svn.erp5.org?rev=34849&view=rev
Log:
- catch xml-rpc communication issues and emit log and re-raise
Modified:
erp5/trunk/utils/erp5.timmy/src/erp5/timmy/timmy.py
Modified: erp5/trunk/utils/erp5.timmy/src/erp5/timmy/timmy.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.timmy/src/erp5/timmy/timmy.py?rev=34849&r1=34848&r2=34849&view=diff
==============================================================================
--- erp5/trunk/utils/erp5.timmy/src/erp5/timmy/timmy.py [utf8] (original)
+++ erp5/trunk/utils/erp5.timmy/src/erp5/timmy/timmy.py [utf8] Thu Apr 29 11:48:58 2010
@@ -561,129 +561,133 @@
raise
try:
try:
- server = XMLRPCServer(options.server_url,
- getServerKey(options.key_file))
- partition_dict_list = server.call('getComputerConfigurationDictList')
- except socket.error, e:
- logging.error('Unable to connect to remote server, verify if the URL is'
- ' accessible.')
- sys.exit(1)
- except xmlrpclib.Fault, e:
- logging.error('Error found on server side, unable to continue, failed:'
- ' %s.' % e.faultString)
- sys.exit(1)
-
- computer_id = getServerKey(options.key_file)
- server.call('updatePartitionState', computer_id, 'reportStarted',
- 'timmy is running on computer')
- supervisor_id = computer_id
- supervisor_list = [q for q in partition_dict_list if q['TYPE'] == \
- 'Supervisor Server']
- if len(supervisor_list) > 0:
- supervisor_id = supervisor_list[0]['PARTITION_ID']
-
- # prepare - run supervisor
- try:
- supervisord_popen = subprocess.Popen([SUPERVISORD],
- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- (result_std, result_err) = supervisord_popen.communicate()
- except:
- server.call('updatePartitionState', supervisor_id, 'reportError',
- 'Unsupported issue while trying to start supervisord: %s:%s' % (
- str(sys.exc_info()[0]), str(sys.exc_info()[1])))
- raise
-
- if supervisord_popen.returncode == 0:
- log_message = 'Supervisord started with: stdout = %r stderr = %r' % (
- result_std, result_err)
- server.call('updatePartitionState', supervisor_id, 'reportStarted',
- log_message)
- logging.info(log_message)
- else:
- if "Another program is already listening" in result_err:
- # XXX-Luke: It might be better to try to connect
- log_message = 'Supervisord already running: stdout = %r stderr = %r' \
- % (result_std, result_err)
+ try:
+ server = XMLRPCServer(options.server_url,
+ getServerKey(options.key_file))
+ partition_dict_list = server.call('getComputerConfigurationDictList')
+ except socket.error, e:
+ logging.error('Unable to connect to remote server, verify if the URL is'
+ ' accessible.')
+ sys.exit(1)
+ except xmlrpclib.Fault, e:
+ logging.error('Error found on server side, unable to continue, failed:'
+ ' %s.' % e.faultString)
+ sys.exit(1)
+
+ computer_id = getServerKey(options.key_file)
+ server.call('updatePartitionState', computer_id, 'reportStarted',
+ 'timmy is running on computer')
+ supervisor_id = computer_id
+ supervisor_list = [q for q in partition_dict_list if q['TYPE'] == \
+ 'Supervisor Server']
+ if len(supervisor_list) > 0:
+ supervisor_id = supervisor_list[0]['PARTITION_ID']
+
+ # prepare - run supervisor
+ try:
+ supervisord_popen = subprocess.Popen([SUPERVISORD],
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ (result_std, result_err) = supervisord_popen.communicate()
+ except:
+ server.call('updatePartitionState', supervisor_id, 'reportError',
+ 'Unsupported issue while trying to start supervisord: %s:%s' % (
+ str(sys.exc_info()[0]), str(sys.exc_info()[1])))
+ raise
+
+ if supervisord_popen.returncode == 0:
+ log_message = 'Supervisord started with: stdout = %r stderr = %r' % (
+ result_std, result_err)
server.call('updatePartitionState', supervisor_id, 'reportStarted',
log_message)
logging.info(log_message)
else:
- log_message = 'Supervisord unknown problem: stdout = %r stderr = %r' \
- % (result_std, result_err)
+ if "Another program is already listening" in result_err:
+ # XXX-Luke: It might be better to try to connect
+ log_message = 'Supervisord already running: stdout = %r stderr = %r' \
+ % (result_std, result_err)
+ server.call('updatePartitionState', supervisor_id, 'reportStarted',
+ log_message)
+ logging.info(log_message)
+ else:
+ log_message = 'Supervisord unknown problem: stdout = %r stderr = %r' \
+ % (result_std, result_err)
+ server.call('updatePartitionState', supervisor_id, 'reportError',
+ log_message)
+ logging.info(log_message)
+
+ # 1a pass - instance profiles
+ try:
+ updateInstanceProfiles(options.template_directory,
+ options.instances_directory, partition_dict_list)
+ except:
+ server.call('updatePartitionState', computer_id, 'reportError',
+ 'Unexpected issue while updating instance profiles: %s:%s' % (
+ str(sys.exc_info()[0]), str(sys.exc_info()[1])))
+ raise
+ # 1b pass - main profile
+ try:
+ updateBaseProfile(options.template_directory, options.main_output,
+ options.base_profile, options.instances_directory,
+ partition_dict_list)
+ except:
+ server.call('updatePartitionState', computer_id, 'reportError',
+ 'Unexpected issue while updating base profile: %s:%s' % (
+ str(sys.exc_info()[0]), str(sys.exc_info()[1])))
+ raise
+ # 2 pass - run buildout
+ try:
+ return_code, result_std, result_err = runBuildout(
+ options.buildout_binary, options.main_output,
+ options.buildout_offline)
+ if return_code != 0:
+ server.call('updatePartitionState', computer_id, 'reportError',
+ 'Buildout finished with bad status code (%s). Stdout = "%s", stde'
+ 'rr = "%s"' % (return_code, result_std, result_err))
+ except:
+ server.call('updatePartitionState', computer_id, 'reportError',
+ 'Unexpected issue while running buildout: %s:%s' % (
+ str(sys.exc_info()[0]), str(sys.exc_info()[1])))
+ raise
+
+ # force supervisor to reload its configuration
+ supervisorctl_popen = subprocess.Popen([SUPERVISORCTL, 'update'],
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ (result_std, result_err) = supervisorctl_popen.communicate()
+ if supervisorctl_popen.returncode == 0:
+ log_message = 'Supervisorctl updated with: stdout = %r stderr = %r' % (
+ result_std, result_err)
+ server.call('updatePartitionState', supervisor_id, 'reportStarted',
+ log_message)
+ logging.info(log_message)
+ else:
+ log_message = 'Supervisorctl issue during update: stdout = %r stderr ='\
+ ' %r' % (result_std, result_err)
server.call('updatePartitionState', supervisor_id, 'reportError',
log_message)
- logging.info(log_message)
-
- # 1a pass - instance profiles
- try:
- updateInstanceProfiles(options.template_directory,
- options.instances_directory, partition_dict_list)
- except:
- server.call('updatePartitionState', computer_id, 'reportError',
- 'Unexpected issue while updating instance profiles: %s:%s' % (
- str(sys.exc_info()[0]), str(sys.exc_info()[1])))
+ logging.error(log_message)
+
+ # 3 pass - manage instances
+ # XXX-Luke: To be moved to proper recipe
+ updated_partition_list = []
+ helper = Helper()
+ for partition_dict in partition_dict_list:
+ # install
+ # stop
+ # switch to special management
+ # start
+ partition = Partition(partition_dict)
+ switcher_dict = dict(
+ start = 'manageStart',
+ stop = 'manageStop',
+ nothing = 'manageNothing',
+ install = 'manageInstall',
+ )
+ action = getattr(helper, switcher_dict[partition_dict['ACTION']])
+ action(partition, server)
+ except xmlrpclib.Fault, e:
+ logging.error('Unexpected error in xml-rpc communication, unable to co'
+ 'ntinue, failed: %s.' % e.faultString)
raise
- # 1b pass - main profile
- try:
- updateBaseProfile(options.template_directory, options.main_output,
- options.base_profile, options.instances_directory,
- partition_dict_list)
- except:
- server.call('updatePartitionState', computer_id, 'reportError',
- 'Unexpected issue while updating base profile: %s:%s' % (
- str(sys.exc_info()[0]), str(sys.exc_info()[1])))
- raise
- # 2 pass - run buildout
- try:
- return_code, result_std, result_err = runBuildout(
- options.buildout_binary, options.main_output,
- options.buildout_offline)
- if return_code != 0:
- server.call('updatePartitionState', computer_id, 'reportError',
- 'Buildout finished with bad status code (%s). Stdout = "%s", stde'
- 'rr = "%s"' % (return_code, result_std, result_err))
- except:
- server.call('updatePartitionState', computer_id, 'reportError',
- 'Unexpected issue while running buildout: %s:%s' % (
- str(sys.exc_info()[0]), str(sys.exc_info()[1])))
- raise
-
- # force supervisor to reload its configuration
- supervisorctl_popen = subprocess.Popen([SUPERVISORCTL, 'update'],
- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- (result_std, result_err) = supervisorctl_popen.communicate()
- if supervisorctl_popen.returncode == 0:
- log_message = 'Supervisorctl updated with: stdout = %r stderr = %r' % (
- result_std, result_err)
- server.call('updatePartitionState', supervisor_id, 'reportStarted',
- log_message)
- logging.info(log_message)
- else:
- log_message = 'Supervisorctl issue during update: stdout = %r stderr ='\
- ' %r' % (result_std, result_err)
- server.call('updatePartitionState', supervisor_id, 'reportError',
- log_message)
- logging.error(log_message)
-
- # 3 pass - manage instances
- # XXX-Luke: To be moved to proper recipe
- updated_partition_list = []
- helper = Helper()
- for partition_dict in partition_dict_list:
- # install
- # stop
- # switch to special management
- # start
- partition = Partition(partition_dict)
- switcher_dict = dict(
- start = 'manageStart',
- stop = 'manageStop',
- nothing = 'manageNothing',
- install = 'manageInstall',
- )
- action = getattr(helper, switcher_dict[partition_dict['ACTION']])
- action(partition, server)
-
finally:
setRunning(False, options.pid_file)
More information about the Erp5-report
mailing list