def service_check(self, env): import params env.set_params(params) if params.security_enabled: Execute(format( "{kinit_path_local} -kt {smokeuser_keytab} {smokeuser_principal}" ), user=params.smoke_test_user) atlas_host_call_count = 0 for atlas_host in params.atlas_hosts: if params.security_enabled: smoke_cmd = format( 'curl -k --negotiate -u : -b ~/cookiejar.txt -c ~/cookiejar.txt -s -o /dev/null -w "%{{http_code}}" {metadata_protocol}://{atlas_host}:{metadata_port}/' ) else: smoke_cmd = format( 'curl -k -s -o /dev/null -w "%{{http_code}}" {metadata_protocol}://{atlas_host}:{metadata_port}/' ) try: Execute(smoke_cmd, user=params.smoke_test_user, tries=5, try_sleep=10) except Exception, err: atlas_host_call_count = atlas_host_call_count + 1 Logger.error( "ATLAS service check failed for host {0} with error {1}". format(atlas_host, err))
def producer_service(action='start'): import params process = params.program_name server = xmlrpclib.Server(params.producer_rpc) status = get_status(params.producer_rpc, process) res = False try: if action == 'start': if status != 'RUNNING': res = server.supervisor.startProcess(process) elif action == 'stop': if status == 'RUNNING': res = server.supervisor.stopProcess(process) elif action == 'restart': res = server.supervisor.restart() except xmlrpclib.Fault: Logger.error("supervisor: process %s not found" % process) except Exception as msg: Logger.error("supervisor: process %s: %s" % (process, str(msg))) if res: res = 'success' else: res = 'failed' Logger.info("Action '%s' completed: %s" % (action, res))
def get_status(rpc, name): server = xmlrpclib.Server(rpc) try: info = server.supervisor.getProcessInfo(name) except xmlrpclib.Fault: Logger.error("supervisor: process %s not found" % name) except Exception as msg: Logger.error("supervisor: process %s: %s" % (name, str(msg))) return info['statename']
def service_check(self, env): import params env.set_params(params) server = xmlrpclib.Server(params.producer_rpc) info = dict() try: info = server.supervisor.getProcessInfo(params.program_name) except xmlrpclib.Fault: Logger.error("supervisor: process %s not found" % params.program_name) except Exception as msg: Logger.error("supervisor: process %s: %s" % (params.program_name, str(msg))) status = info.get('statename', None) # if status != 'RUNNING': # raise Fail("supervisor: process %s in %s state" % (params.program_name, status)) Logger.info("Status of process %s is %s" % (params.program_name, status))