Exemplo n.º 1
0
def configure_logging():
    import logging
    from chroma_agent.log import console_log, daemon_log

    console_log.addHandler(logging.StreamHandler(sys.stderr))
    console_log.setLevel(logging.INFO)
    daemon_log.addHandler(logging.StreamHandler(sys.stderr))
    daemon_log.setLevel(logging.WARNING)
Exemplo n.º 2
0
def main():
    parser = argparse.ArgumentParser(description="Simulated benchmarks")
    parser.add_argument('--remote_simulator',
                        required=False,
                        help="Disable built-in simulator (run it separately)",
                        default=False)
    parser.add_argument('--debug',
                        required=False,
                        help="Enable DEBUG-level logs",
                        default=False)
    parser.add_argument('--url',
                        required=False,
                        help="Manager URL",
                        default="https://localhost:8000")
    parser.add_argument('--username',
                        required=False,
                        help="REST API username",
                        default='admin')
    parser.add_argument('--password',
                        required=False,
                        help="REST API password",
                        default='lustre')
    parser.add_argument('--servers', help="server count", default=8, type=int)
    subparsers = parser.add_subparsers()

    log_ingest_parser = subparsers.add_parser("reset")
    log_ingest_parser.set_defaults(
        func=lambda args, simulator: Benchmark(args, simulator).reset())

    log_ingest_parser = subparsers.add_parser("log_ingest_rate")
    log_ingest_parser.set_defaults(func=lambda args, simulator: LogIngestRate(
        args, simulator).run_benchmark())

    server_count_limit_parser = subparsers.add_parser("server_count_limit")
    server_count_limit_parser.set_defaults(
        func=lambda args, simulator: ServerCountLimit(args, simulator
                                                      ).run_benchmark())

    server_count_limit_parser = subparsers.add_parser(
        "concurrent_registration_limit")
    server_count_limit_parser.set_defaults(
        func=lambda args, simulator: ConcurrentRegistrationLimit(
            args, simulator).run_benchmark())

    server_count_limit_parser = subparsers.add_parser("filesystem_size_limit")
    server_count_limit_parser.set_defaults(
        func=lambda args, simulator: FilesystemSizeLimit(args, simulator
                                                         ).run_benchmark())

    args = parser.parse_args()

    if args.debug:
        log.setLevel(logging.DEBUG)

    if not args.remote_simulator:
        log.info("Starting simulator...")

        # Enable logging by agent code run within simulator
        from chroma_agent.log import daemon_log
        daemon_log.setLevel(logging.DEBUG)
        handler = logging.FileHandler("chroma-agent.log")
        handler.setFormatter(
            logging.Formatter('[%(asctime)s] %(message)s',
                              '%d/%b/%Y:%H:%M:%S'))
        daemon_log.addHandler(handler)
        daemon_log.info("Enabled agent logging within simulator")

        from cluster_sim.simulator import ClusterSimulator
        simulator = ClusterSimulator(folder=None, url=args.url + "/")
        simulator.power.setup(1)
        simulator.start_all()
        simulator.setup(0,
                        0,
                        0,
                        nid_count=1,
                        cluster_size=4,
                        pdu_count=1,
                        su_size=0)
    else:
        simulator = xmlrpclib.ServerProxy("http://localhost:%s" %
                                          SIMULATOR_PORT,
                                          allow_none=True)

    try:
        log.info("Starting benchmark...")
        args.func(args, simulator)
    except:
        # Because we do a hard exit at the end here, explicitly log terminating
        # exceptions or they would get lost.
        log.error(traceback.format_exc())
        raise
    finally:
        # Do a hard exit to avoid dealing with lingering threads (not the cleanest, but
        # this isn't production code).
        os._exit(-1)

    log.info("Complete.")
Exemplo n.º 3
0
from blockdevice import BlockDevice
from ..lib.shell import Shell

try:
    # FIXME: this should be avoided, implicit knowledge of something outside the package
    from chroma_agent.log import daemon_log as log
except ImportError:
    log = logging.getLogger(__name__)

    if not log.handlers:
        handler = logging.FileHandler('blockdevice_zfs.log')
        handler.setFormatter(
            logging.Formatter(
                "[%(asctime)s: %(levelname)s/%(name)s] %(message)s"))
        log.addHandler(handler)
        log.setLevel(logging.DEBUG)


class NotZpoolException(Exception):
    pass


class BlockDeviceZfs(BlockDevice):
    # From lustre_disk.h
    LDD_F_SV_TYPE_MDT = 0x0001
    LDD_F_SV_TYPE_OST = 0x0002
    LDD_F_SV_TYPE_MGS = 0x0004
    LDD_F_SV_TYPE_MGS_or_MDT = (LDD_F_SV_TYPE_MGS | LDD_F_SV_TYPE_MDT)

    _supported_device_types = ['zfs']
        else:
            if os.path.exists(args.pid_file + ".lock"):
                sys.stderr.write("Removing stale lock file\n")
                os.remove(args.pid_file + ".lock")

        signal.signal(signal.SIGHUP, signal.SIG_IGN)
        context = DaemonContext(pidfile=PIDLockFile(args.pid_file))
        context.open()

        daemon_log_setup()
        console_log_setup()
        daemon_log.info("Starting in the background")
    else:
        context = None
        daemon_log_setup()
        daemon_log.addHandler(logging.StreamHandler())

        console_log_setup()

    try:
        daemon_log.info("Entering main loop")
        try:
            conf = config.get('settings', 'server')
        except (KeyError, TypeError) as e:
            daemon_log.error(
                "No configuration found (must be registered before running the agent service), "
                "details: %s" % e)
            return

        if config.profile_managed is False:
            # This is kind of terrible. The design of DevicePluginManager is