Ejemplo n.º 1
0
    def test_get_account_skey(self):
        config = {'account': {'skey': 'PASSWORD'}}

        Config.set_config(config)
        skey = Config.get_account_skey()

        self.assertEqual(skey, 'PASSWORD')
Ejemplo n.º 2
0
def create_tasks(server_to_writer):
    """
    Create a pair of Producer-Consumer objects for each endpoint enabled within
    the account defined in config, or retrieve child accounts and do the same
    if the account is MSP. Return a list containing the asyncio tasks for
    running those objects.

    @param writer   Dictionary mapping server ids to writer objects

    @return list of asyncio tasks for running the Producer and Consumer objects
    """
    tasks = []

    # Object with functions needed to utilize log API calls
    admin = create_admin(
        Config.get_account_ikey(), Config.get_account_skey(),
        Config.get_account_hostname())

    # This is where functionality would be added to check if an account is MSP
    # (Config.account_is_msp), and then retrieve child accounts (ignoring those
    # in a blocklist) if the account is indeed MSP

    for mapping in Config.get_account_endpoint_server_mappings():
        # Get the writer to be used for this set of endpoints
        writer = server_to_writer[mapping.get('server')]

        for endpoint in mapping.get('endpoints'):
            new_tasks = create_consumer_producer_pair(endpoint, writer, admin)
            tasks.extend(new_tasks)

    return tasks