Beispiel #1
0
    def run(self, check_interval=1):
        """ Run the daemon

        :type check_interval: int
        :param check_interval: Delay in seconds between checks
        """
        while True:
            used_keys = set()
            table_names = set()
            configured_tables = configuration['tables'].keys()

            # Add regexp table names
            for table_name in dynamodb.list_tables():
                for key_name in configured_tables:
                    if re.match(key_name, table_name):
                        logger.debug(
                            "Table {0} match with config key {1}".format(
                                table_name, key_name))
                        table_names.add((table_name, key_name))
                        used_keys.add(key_name)

            # Remove used tables
            for table_name in used_keys:
                configured_tables.remove(table_name)

            # Add regular tables
            for table_name in configured_tables:
                table_names.add((table_name, table_name))

            # Ensure provisioning
            for table_name, key_name in sorted(table_names):
                core.ensure_provisioning(table_name, key_name)

            # Sleep between the checks
            time.sleep(check_interval)
    def run(self, check_interval=1):
        """ Run the daemon

        :type check_interval: int
        :param check_interval: Delay in seconds between checks
        """
        while True:
            used_keys = set()
            table_names = set()
            configured_tables = configuration['tables'].keys()

            # Add regexp table names
            for table_name in dynamodb.list_tables():
                for key_name in configured_tables:
                    if re.match(key_name, table_name):
                        logger.debug("Table {0} match with config key {1}".format(
                            table_name, key_name))
                        table_names.add((table_name, key_name))
                        used_keys.add(key_name)

            # Remove used tables
            for table_name in used_keys:
                configured_tables.remove(table_name)

            # Add regular tables
            for table_name in configured_tables:
                table_names.add((table_name, table_name))

            # Ensure provisioning
            for table_name, key_name in sorted(table_names):
                core.ensure_provisioning(table_name, key_name)

            # Sleep between the checks
            time.sleep(check_interval)
    def run(self, check_interval=1):
        """ Run the daemon

        :type check_interval: int
        :param check_interval: Delay in seconds between checks
        """
        while True:
            for table_name in configuration['tables'].keys():
                core.ensure_provisioning(table_name)
            time.sleep(check_interval)
Beispiel #4
0
def main():
    """ Main function called from dynamic-dynamodb """
    if configuration['global']['daemon']:
        pid_file = '/tmp/dynamic-dynamodb.{0}.pid'.format(
            configuration['global']['instance'])
        daemon = DynamicDynamoDBDaemon(pid_file)

        if configuration['global']['daemon'] == 'start':
            daemon.start(
                check_interval=configuration['global']['check_interval'])

        elif configuration['global']['daemon'] == 'stop':
            daemon.stop()

        elif configuration['global']['daemon'] == 'restart':
            daemon.restart()

        else:
            print 'Valid options for --daemon are start, stop and restart'
            sys.exit(1)
    else:
        table_names = set()
        used_keys = set()
        configured_tables = configuration['tables'].keys()

        # Add regexp table names
        for table_name in dynamodb.list_tables():
            for key_name in configured_tables:
                if re.match(key_name, table_name):
                    logger.debug("Table {0} match with config key {1}".format(
                        table_name, key_name))
                    table_names.add((table_name, key_name))
                    used_keys.add(key_name)

        # Remove used tables
        for table_name in used_keys:
            configured_tables.remove(table_name)

        # Add regular tables
        for table_name in configured_tables:
            table_names.add((table_name, table_name))

        # Ensure provisioning
        for table_name, key_name in sorted(table_names):
            core.ensure_provisioning(table_name, key_name)
def main():
    """ Main function called from dynamic-dynamodb """
    if configuration['global']['daemon']:
        pid_file = '/tmp/dynamic-dynamodb.{0}.pid'.format(
            configuration['global']['instance'])
        daemon = DynamicDynamoDBDaemon(pid_file)

        if configuration['global']['daemon'] == 'start':
            daemon.start(
                check_interval=configuration['global']['check_interval'])

        elif configuration['global']['daemon'] == 'stop':
            daemon.stop()

        elif configuration['global']['daemon'] == 'restart':
            daemon.restart()

        else:
            print 'Valid options for --daemon are start, stop and restart'
            sys.exit(1)
    else:
        table_names = set()
        used_keys = set()
        configured_tables = configuration['tables'].keys()

        # Add regexp table names
        for table_name in dynamodb.list_tables():
            for key_name in configured_tables:
                if re.match(key_name, table_name):
                    logger.debug("Table {0} match with config key {1}".format(
                        table_name, key_name))
                    table_names.add((table_name, key_name))
                    used_keys.add(key_name)

        # Remove used tables
        for table_name in used_keys:
            configured_tables.remove(table_name)

        # Add regular tables
        for table_name in configured_tables:
            table_names.add((table_name, table_name))

        # Ensure provisioning
        for table_name, key_name in sorted(table_names):
            core.ensure_provisioning(table_name, key_name)
def main():
    """ Main function called from dynamic-dynamodb """
    if configuration['global']['daemon']:
        pid_file = '/tmp/dynamic-dynamodb.{0}.pid'.format(
            configuration['global']['instance'])
        daemon = DynamicDynamoDBDaemon(pid_file)

        if configuration['global']['daemon'] == 'start':
            daemon.start(
                check_interval=configuration['global']['check_interval'])

        elif configuration['global']['daemon'] == 'stop':
            daemon.stop()

        elif configuration['global']['daemon'] == 'restart':
            daemon.restart()

        else:
            print 'Valid options for --daemon are start, stop and restart'
            sys.exit(1)
    else:
        for table_name in configuration['tables'].keys():
            core.ensure_provisioning(table_name)