Exemplo n.º 1
0
    def valor_create_pool(self, number_of_valors):

        aws = AWS()

        return self.valor_manager.create_valor_pool(number_of_valors,
                                                    aws.get_subnet_id(),
                                                    aws.get_sec_group().id)
Exemplo n.º 2
0
    def get_empty_valor(self, migration_source_valor_id=None):
        """ Get and return an available valor node.
        If less than the standby number of valors exist then
        create more standby valors
        """

        empty_valors = self.get_available_valors(migration_source_valor_id)

        # Check if there are no empty valors
        # If there are none then create a valor node
        if not empty_valors:
            aws = AWS()
            valor_id = self.create_and_launch_valor(aws.get_subnet_id(),
                                                    aws.get_sec_group().id)

            # Check the valor state and verify that it is 'RUNNING'
            self.verify_valor_running(valor_id)

            empty_valor = self.rethinkdb_manager.get_valor(valor_id)
        else:
            # Select a random index for the array of empty_valors
            # This essentially selects a random valor from the list of valors
            random_index = random.randint(0, len(empty_valors) - 1)

            # Check the valor state and verify that it is 'RUNNING'
            self.verify_valor_running(empty_valors[random_index]['valor_id'])

            empty_valor = empty_valors[random_index]

        return empty_valor
Exemplo n.º 3
0
    def create_standby_valors(self):

        empty_valors = self.get_available_valors()

        # Check if the number of empty valors is less than NUM_STANDBY_VALORS
        # If so then create additional valors
        if len(empty_valors) <= NUM_STANDBY_VALORS:

            NUM_VALORS_TO_CREATE = NUM_STANDBY_VALORS - len(empty_valors)

            aws = AWS()

            for i in range(NUM_VALORS_TO_CREATE):
                create_standby_valors_thread = threading.Thread(
                    target=self.create_and_launch_valor,
                    args=(
                        aws.get_subnet_id(),
                        aws.get_sec_group().id,
                    ))
                create_standby_valors_thread.start()

        elif len(empty_valors) > NUM_STANDBY_VALORS:
            # Number of empty valors is more than the required number of
            # standby valors so do nothing
            pass
Exemplo n.º 4
0
    def valor_create(self):

        aws = AWS()

        return self.valor_manager.create_valor(aws.get_subnet_id(),
                                               aws.get_sec_group().id)