def gen_status(path, lg = None): try : lck, err = lock.get_lock('generate_status') if err: raise Exception(err) if not lck: raise Exception('Generate Status : Could not acquire lock.') fullmanifestpath = os.path.normpath("%s/master.manifest"%path) ret, err = manifest_status.generate_status_info(fullmanifestpath) if not ret : if err: raise Exception(err) else: raise Exception('No status info obtained') fullpath = os.path.normpath("%s/master.status"%path) fulltmppath = "/tmp/master.status.tmp" #Generate into a tmp file with open(fulltmppath, 'w') as fd: json.dump(ret, fd, indent=2) #Now move the tmp to the actual manifest file name #print 'fullpath is ', fullpath shutil.move(fulltmppath, fullpath) except Exception, e: logger.log_or_print('Error generating status : %s'%e, lg, level='critical') lock.release_lock('generate_status') return -1, 'Error generating status : %s'%e
def gen_manifest(path): try: lck, err = lock.get_lock('generate_manifest') if err: raise Exception(err) if not lck: raise Exception('Could not acquire lock.') ret, err = manifest_status.generate_manifest_info() if not ret: if err: raise Exception(err) else: raise Exception('No manifest info obtained') else: fullpath = os.path.normpath("%s/master.manifest" % path) fulltmppath = "/tmp/master.manifest.tmp" fullcopypath = os.path.normpath( "%s/master.manifest.%s" % (path, datetime.datetime.now().strftime("%B_%d_%Y_%H_%M_%S"))) #Generate into a tmp file with open(fulltmppath, 'w') as fd: json.dump(ret, fd, indent=2) #Copy original to a backup if os.path.isfile(fullpath): shutil.copyfile(fullpath, fullcopypath) #Now move the tmp to the actual manifest file name shutil.move(fulltmppath, fullpath) except Exception, e: lock.release_lock('generate_manifest') return -1, 'Error generating manifest : %s' % str(e)
def main(): try: lck, err = lock.get_lock('unicell_poll_for_alerts') if err: raise Exception(err) if not lck: raise Exception('Could not acquire lock. Exiting.') alert_list = [] now = int(time.time()) db_path, err = common.get_db_path() if err: raise Exception(err) tasks_query = "select * from tasks where last_run_time > '%d' and (status = 'error-retrying' or status = 'failed');" % ( now - 110) #print "\ntasks_query: ", tasks_query rows, err = db.read_multiple_rows(db_path, tasks_query) #print "\nrows: ", rows if err: raise Exception(err) if rows: for row in rows: msg = "%s: %s." % (row['status'], row['description']) alert_list.append(msg) #print "\nalert_list: ", alert_list if alert_list: alerts.raise_alert(alert_list) lock.release_lock('unicell_poll_for_alerts') except Exception, e: print "Error generating alerts : %s ! Exiting." % str(e) sys.exit(-1)
fullcopypath = os.path.normpath( "%s/master.manifest.%s" % (path, datetime.datetime.now().strftime("%B_%d_%Y_%H_%M_%S"))) try: # Generate into a tmp file with open(fulltmppath, 'w') as fd: json.dump(ret, fd, indent=2) # Copy original to a backup if os.path.isfile(fullpath): shutil.copyfile(fullpath, fullcopypath) # Now move the tmp to the actual manifest file name shutil.move(fulltmppath, fullpath) except Exception, e: print "Error generating the manifest file : %s" % str(e) ret_code = -1 lock.release_lock('generate_manifest') return ret_code import atexit atexit.register(lock.release_lock, 'generate_manifest') def main(): try: num_args = len(sys.argv) if num_args > 1: path = sys.argv[1] else: path, err = common.get_system_status_path()
rc, ret = _gen_status_info(fullmanifestpath) if rc != 0: ret_code = rc else: fullpath = os.path.normpath("%s/master.status" % path) fulltmppath = os.path.normpath("%s/master.status.tmp" % path) try: # Generate into a tmp file with open(fulltmppath, 'w') as fd: json.dump(ret, fd, indent=2) # Now move the tmp to the actual manifest file name shutil.move(fulltmppath, fullpath) except Exception, e: print "Error generating the status file : %s" % str(e) ret_code = -1 lock.release_lock('generate_status') return ret_code import atexit atexit.register(lock.release_lock, 'generate_status') def main(): try: num_args = len(sys.argv) if num_args > 1: path = sys.argv[1] else: path, err = common.get_system_status_path()
def main(): try: platform, err = common.get_platform() if err: raise Exception(err) lck, err = lock.get_lock('poll_for_alerts') if err: raise Exception(err) if not lck: raise Exception('Could not acquire lock. Exiting.') if platform == 'gridcell': from integralstor_gridcell import system_info gluster_lck, err = lock.get_lock('gluster_commands') else: from integralstor_unicell import system_info si, err = system_info.load_system_config() if platform == 'gridcell': lock.release_lock('gluster_commands') if err: raise Exception(err) if not si: raise Exception('Could not load system information') alert_list = [] for node_name, node in si.items(): if 'errors' in node and node['errors']: if platform == 'gridcell': msg = 'GRIDCell : %s. ' % node_name else: msg = '' msg += '. '.join(node['errors']) alert_list.append(msg) hw_platform, err = common.get_hardware_platform() if hw_platform: if hw_platform == 'dell': from integralstor_common.platforms import dell alerts_dict, err = dell.get_alert_logs() if alerts_dict: current_time = int(time.time()) for time_stamp, alerts_list in alerts_dict.items(): for alert_dict in alerts_list: if alert_dict['Severity'] == 'Critical': if (current_time - time_stamp) < (60 * 60): alert_list.append( alert_dict['description']) #print time_stamp, alert_dict #print "======================" #print alert_list #print "======================" if alert_list: alerts.raise_alert(alert_list) lock.release_lock('poll_for_alerts') except Exception, e: print "Error generating alerts : %s ! Exiting." % str(e) sys.exit(-1)
fullpath = os.path.normpath("%s/master.manifest"%path) fulltmppath = os.path.normpath("%s/master.manifest.tmp"%path) fullcopypath = os.path.normpath("%s/master.manifest.%s"%(path, datetime.datetime.now().strftime("%B_%d_%Y_%H_%M_%S"))) try: #Generate into a tmp file with open(fulltmppath, 'w') as fd: json.dump(ret, fd, indent=2) #Copy original to a backup if os.path.isfile(fullpath): shutil.copyfile(fullpath, fullcopypath) #Now move the tmp to the actual manifest file name shutil.move(fulltmppath, fullpath) except Exception, e: print "Error generating the manifest file : %s"%str(e) ret_code = -1 lock.release_lock('generate_manifest') return ret_code import atexit atexit.register(lock.release_lock, 'generate_manifest') def main(): try : num_args = len(sys.argv) if num_args > 1: path = sys.argv[1] else: path = common.get_system_status_path() if not path: path = '/tmp'