Beispiel #1
0
    def _generate_status(self):
        ret = {
            "author": get_user(),
            "generated": get_time_str(),
            "gofed_version": VERSION,
            "hostname": get_hostname(),
            "topology": []
        }
        system = System(self.get_config(), self.get_system_json_path())

        for service_name in system.get_services_list():
            try:
                registry_response = system.get_service_location(service_name)
            except Exception as e:
                log.warning("Encountered error while querying for service '%s', skipping this service ('%s')"
                            % (service_name, str(e)))
            for response in registry_response:
                ret['topology'].append({
                    'service': service_name,
                    'host': response[0],
                    'port': response[1],
                    'type': 'computational' if system.is_computational(service_name) else 'storage'
                })

        ret['topology'].append({
            'type': 'registry',
            'host': system.get_registry_host(),
            'port': system.get_registry_port()
        })

        print dict2json(ret)
Beispiel #2
0
    def _make_header(self, services):
        ret = {}

        ret['gofed_version'] = VERSION
        ret['author'] = get_user()
        ret['hostname'] = get_hostname()
        ret['generated'] = get_time_str()
        ret['services'] = {}
        ret['services']['computational'] = services['computational']
        ret['services']['storages'] = services['storages']
        ret['git_head'] = get_githead()

        return ret
Beispiel #3
0
    def main(self):
        try:
            self.conf
        except Exception:
            log.error("config option is mandatory, see '--help'")
            sys.exit(1)

        self.conf = config2dict(self.conf)

        cls = ServiceEnvelope.SERVICE_CLASS
        logfile = self.logfile if self.logfile != '-' else None
        verbose = not self.quiet
        name = cls.get_service_name()
        version = cls.get_service_version()

        log.init(logfile, verbose, name)
        log.critical("Service starting at %s, version is %s" %
                     (get_time_str(), version))

        service_cls = ServiceEnvelope.SERVICE_CLASS
        service_cls.on_startup(self.conf, self.system_json)

        ServiceEnvelope.worker_pid = os.fork()

        if ServiceEnvelope.worker_pid == 0:
            self.run_worker_process()
        else:
            signal.signal(signal.SIGINT, ServiceEnvelope.signal_handler)
            signal.signal(signal.SIGTERM, ServiceEnvelope.signal_handler)

            try:
                while os.waitpid(ServiceEnvelope.worker_pid, 0):
                    pass
            except Exception:
                pass

            # finish logging and ensure that all messages are flushed
            log.critical("Service terminated at %s" % get_time_str())
            log.close()
Beispiel #4
0
    def _make_header(self, services):
        ret = {}

        ret['gofed_version'] = VERSION
        ret['author'] = get_user()
        ret['hostname'] = get_hostname()
        ret['generated'] = get_time_str()
        ret['services'] = {}
        ret['services']['computational'] = services['computational']
        ret['services']['storages'] = services['storages']
        ret['git_head'] = get_githead()

        return ret
Beispiel #5
0
    def _generate_status(self):
        ret = {
            "author": get_user(),
            "generated": get_time_str(),
            "gofed_version": VERSION,
            "hostname": get_hostname(),
            "topology": []
        }
        system = System(self.get_config(), self.get_system_json_path())

        for service_name in system.get_services_list():
            try:
                registry_response = system.get_service_location(service_name)
            except Exception as e:
                log.warning(
                    "Encountered error while querying for service '%s', skipping this service ('%s')"
                    % (service_name, str(e)))
            for response in registry_response:
                ret['topology'].append({
                    'service':
                    service_name,
                    'host':
                    response[0],
                    'port':
                    response[1],
                    'type':
                    'computational'
                    if system.is_computational(service_name) else 'storage'
                })

        ret['topology'].append({
            'type': 'registry',
            'host': system.get_registry_host(),
            'port': system.get_registry_port()
        })

        print dict2json(ret)
 def log_processed_time(self):
     self._stats['finished'] = get_time_str()
 def log_process_time(self):
     self._stats['started'] = get_time_str()
 def log_connect_time(self):
     self._stats['connected'] = get_time_str()