Example #1
0
def register(rpc_backend_client, device_info, local_ip, local_ip6,
             capabilities):
    # There is still some confusion regarding how best to determine what ip
    # to publish. Current wisdom suggest that we find the default gateway,
    # determine the interface used for the default route, and take whatever
    # address is configured. This 'should' be the DHCP address right?
    # Relying solely on dhclient (in the initrd) might be an option and would
    # allow for parsing dhclient.leases.
    # Currently, the preboot environment uses udhcpc, so modifying the script
    # udhcpc calls on renew/bound to publish a cookie with vars set by the dhcp
    # server is an option as well

    # Either process should be configurable. ie,
    #  default_ip_source: simple # use default route
    #                     udhcpc # script in preconfig leaves cookie, parse the cookie
    #                     dhclient # parse /var/lib/dhclient.leases

    # And then there is ipv6, where we'd need to DHCP to get a route-able address
    # subnet, and then heuristically generate an ip address in the subnet, forgoing
    # the explicit need for publishing the address

    # UPDATE: Determine the route taken to find rpc_backend and use that interface

    agent_info = {
        'rpc_address': local_ip,
        'rpc_address6': local_ip6,
        'rpc_port': agent_configuration.get('rpc_port', 9003),
        'ping_port': agent_configuration.get('ping_port', 9004),
        'localtime': time.time(),
        'capabilities': _serialize_capabilities(capabilities)
    }

    return rpc_backend_client.register(device_info, agent_info)
Example #2
0
 def __init__(self):
     """ MegaRAID support for RAID abstraction.
     This class is using the mercury native storcli interface. The interface is very thin.
     As such, vendor_info may need a little more cleanup in comparison to SmartArray
     """
     super(MegaRAIDActions, self).__init__()
     self.storcli = Storcli(binary_path=agent_configuration.get(
         'hardware', {}).get(
         'raid', {}).get(
         'storcli_path') or 'storcli')
Example #3
0
def entry(press_configuration):
    set_environment(agent_configuration.get('press_environment', {}))

    log.info('Initializing plugins')
    init_plugins(press_configuration)

    return_data = {}

    p = None
    try:
        p = Press(press_configuration)
    except Exception:
        exec_dict = parse_exception()
        log.error('Error during initialization: {}'.format(
            fancy_traceback_short(exec_dict)))
        return_data = {
            'error': True,
            'message': 'Error during initialization',
            'exception': exec_dict
        }

    if p:
        try:
            p.run()
        except Exception:
            exec_dict = parse_exception()
            log.error('Error during deployment: {}'.format(
                fancy_traceback_short(exec_dict)))
            return_data = {
                'error': True,
                'message': 'Error during initialization',
                'exception': exec_dict
            }
        finally:
            if p.layout.committed:
                time.sleep(2)
                p.teardown()

            # Clear logging handlers!
            del logging.getLogger(
                'press').handlers[:]  # python2 doesn't have list.clear()

            # Clear hooks
            clear_hooks()

    return return_data
Example #4
0
    def __init__(self, configuration, logger):
        """

        :param configuration:
        """
        self.configuration = configuration
        self.local_config = self.configuration.get('agent', {})
        self.remote_config = self.configuration.get('remote', {})
        self.agent_bind_address = self.local_config.get(
            'service_bind_address', 'tcp://0.0.0.0:9003')
        self.pong_bind_address = self.local_config.get('pong_bind_address',
                                                       'tcp://0.0.0.0:9004')

        self.rpc_backend_url = agent_configuration.get('remote',
                                                       {}).get('rpc_service')
        self.log_handler = logger

        if not self.rpc_backend_url:
            raise MercuryCritical('Missing rpc backend in local configuration')

        self.backend = BackEndClient(self.rpc_backend_url)
Example #5
0
def setup_logging():
    log_level = logging.getLevelName(agent_configuration['agent']['log_level'])
    logging.basicConfig(level=log_level)
    fh = logging.FileHandler(agent_configuration['agent']['log_file'])

    fh.setLevel(log_level)
    formatter = logging.Formatter(agent_configuration['agent']['log_format'])
    fh.setFormatter(formatter)

    mercury_logger = logging.getLogger('mercury')
    mercury_logger.addHandler(fh)
    mercury_logger.info('Starting Agent')

    # Quiet these down
    logging.getLogger('mercury.agent.pong').setLevel(logging.ERROR)
    logging.getLogger('hpssa._cli').setLevel(logging.ERROR)

    # Configure the remote logging handler
    mh = MercuryLogHandler(
        agent_configuration.get('remote', {}).get('log_service'))
    mercury_logger.addHandler(mh)

    # Return this so that we can inject the mercury_id once we have it
    return mh
Example #6
0
 def __init__(self):
     super(SmartArrayActions, self).__init__()
     self.hpssa = HPSSA(hpssa_path=agent_configuration.get(
         'hardware', {}).get('raid', {}).get('hpssacli_path') or 'hpssacli')