Ejemplo n.º 1
0
 def modify_state(_):
     _config = config[0]
     d = group.modify_state(
         partial(controller.obey_config_change, self.log,
                 transaction_id(request), _config,
                 launch_config=None))
     return d
Ejemplo n.º 2
0
 def _do_obey_config_change(result):
     group_id = result['id']
     config = result['groupConfiguration']
     group = self.store.get_scaling_group(self.log, self.tenant_id, group_id)
     d = group.modify_state(partial(controller.obey_config_change, self.log,
                                    transaction_id(request), config))
     return d.addCallback(lambda _: result)
Ejemplo n.º 3
0
 def pause_scaling_group(self, request):
     """
     Pause a scaling group.  This means that no scaling policies will get
     executed (execution will be rejected).  This is an idempotent operation -
     pausing an already paused group does nothing.
     """
     group = self.store.get_scaling_group(self.log, self.tenant_id, self.group_id)
     return controller.pause_scaling_group(self.log, transaction_id(request), group)
Ejemplo n.º 4
0
 def resume_scaling_group(self, request):
     """
     Resume a scaling group.  This means that scaling policies will now get
     executed as usual.  This is an idempotent operation - resuming an already
     running group does nothing.
     """
     group = self.store.get_scaling_group(self.log, self.tenant_id, self.group_id)
     return controller.resume_scaling_group(self.log, transaction_id(request), group)
Ejemplo n.º 5
0
 def _get_launch_and_obey_config_change(scaling_group, state):
     d = scaling_group.view_launch_config()
     d.addCallback(partial(
         controller.obey_config_change,
         self.log,
         transaction_id(request),
         data, scaling_group, state))
     return d
Ejemplo n.º 6
0
 def execute_policy((tenant_id, group_id, policy_id)):
     bound_log = self.log.bind(tenant_id=tenant_id,
                               scaling_group_id=group_id,
                               policy_id=policy_id)
     logl[0] = bound_log
     group = self.store.get_scaling_group(bound_log, tenant_id, group_id)
     return group.modify_state(partial(controller.maybe_execute_scaling_policy,
                                       bound_log, transaction_id(request),
                                       policy_id=policy_id))
Ejemplo n.º 7
0
 def delete_server(self, request, server_id):
     """
     Delete a server from the group.
     """
     group = self.store.get_scaling_group(self.log, self.tenant_id, self.scaling_group_id)
     d = group.modify_state(
         partial(remove_server_from_group, self.log.bind(server_id=server_id),
                 transaction_id(request), server_id,
                 extract_bool_arg(request, 'replace', True)))
     return d
Ejemplo n.º 8
0
 def delete_scaling_group(self, request):
     """
     Delete a scaling group if there are no entities belonging to the
     scaling group.  If successful, no response body will be returned.
     """
     group = self.store.get_scaling_group(self.log, self.tenant_id,
                                          self.group_id)
     force = extract_bool_arg(request, 'force', False)
     return controller.delete_group(
         self.dispatcher, log, transaction_id(request), group, force)
Ejemplo n.º 9
0
 def resume_scaling_group(self, request):
     """
     Resume a scaling group.  This means that scaling policies will now get
     executed as usual.  This is an idempotent operation - resuming an
     already running group does nothing.
     """
     group = self.store.get_scaling_group(
         self.log, self.tenant_id, self.group_id)
     return controller.resume_scaling_group(
         self.log, transaction_id(request), group, self.dispatcher)
Ejemplo n.º 10
0
 def pause_scaling_group(self, request):
     """
     Pause a scaling group.  This means that no scaling policies will get
     executed (execution will be rejected).  This is an idempotent
     operation - pausing an already paused group does nothing.
     """
     group = self.store.get_scaling_group(
         self.log, self.tenant_id, self.group_id)
     return controller.pause_scaling_group(
         self.log, transaction_id(request), group, self.dispatcher)
Ejemplo n.º 11
0
 def delete_scaling_group(self, request):
     """
     Delete a scaling group if there are no entities belonging to the
     scaling group.  If successful, no response body will be returned.
     """
     group = self.store.get_scaling_group(self.log, self.tenant_id,
                                          self.group_id)
     force = extract_bool_arg(request, 'force', False)
     return controller.delete_group(
         self.dispatcher, log, transaction_id(request), group, force)
Ejemplo n.º 12
0
 def execute_policy((tenant_id, group_id, policy_id)):
     bound_log = self.log.bind(tenant_id=tenant_id,
                               scaling_group_id=group_id,
                               policy_id=policy_id)
     logl[0] = bound_log
     group = self.store.get_scaling_group(bound_log, tenant_id,
                                          group_id)
     return controller.modify_and_trigger(
         self.dispatcher,
         group,
         bound_log_kwargs(bound_log),
         partial(controller.maybe_execute_scaling_policy,
                 bound_log, transaction_id(request),
                 policy_id=policy_id),
         modify_state_reason='execute_webhook')
Ejemplo n.º 13
0
 def _do_obey_config_change(result):
     group_id = result['id']
     config = result['groupConfiguration']
     launch = result['launchConfiguration']
     group = self.store.get_scaling_group(
         self.log, self.tenant_id, group_id)
     log = self.log.bind(scaling_group_id=group_id)
     d = controller.modify_and_trigger(
         self.dispatcher,
         group,
         bound_log_kwargs(log),
         partial(
             controller.obey_config_change, log,
             transaction_id(request), config, launch_config=launch),
         modify_state_reason='create_new_scaling_group')
     return d.addCallback(lambda _: result)
Ejemplo n.º 14
0
 def execute_policy((tenant_id, group_id, policy_id)):
     bound_log = self.log.bind(tenant_id=tenant_id,
                               scaling_group_id=group_id,
                               policy_id=policy_id)
     logl[0] = bound_log
     group = self.store.get_scaling_group(bound_log, tenant_id,
                                          group_id)
     return controller.modify_and_trigger(
         self.dispatcher,
         group,
         bound_log_kwargs(bound_log),
         partial(controller.maybe_execute_scaling_policy,
                 bound_log,
                 transaction_id(request),
                 policy_id=policy_id),
         modify_state_reason='execute_webhook')
Ejemplo n.º 15
0
    def execute_policy(self, request):
        """
        Execute this scaling policy.

        TBD: Response body.

        Example response::

            {}
        """
        group = self.store.get_scaling_group(self.log, self.tenant_id, self.scaling_group_id)
        d = group.modify_state(partial(controller.maybe_execute_scaling_policy,
                                       self.log, transaction_id(request),
                                       policy_id=self.policy_id))
        d.addCallback(lambda _: "{}")  # Return value TBD
        return d
Ejemplo n.º 16
0
 def _do_obey_config_change(result):
     group_id = result['id']
     config = result['groupConfiguration']
     launch = result['launchConfiguration']
     group = self.store.get_scaling_group(
         self.log, self.tenant_id, group_id)
     log = self.log.bind(scaling_group_id=group_id)
     d = controller.modify_and_trigger(
         self.dispatcher,
         group,
         bound_log_kwargs(log),
         partial(
             controller.obey_config_change, log,
             transaction_id(request), config, launch_config=launch),
         modify_state_reason='create_new_scaling_group')
     return d.addCallback(lambda _: result)
Ejemplo n.º 17
0
 def delete_server(self, request, server_id):
     """
     Delete a server from the group.
     """
     group = self.store.get_scaling_group(self.log, self.tenant_id,
                                          self.scaling_group_id)
     log = self.log.bind(server_id=server_id)
     d = controller.modify_and_trigger(
         self.dispatcher,
         group,
         bound_log_kwargs(log),
         partial(controller.remove_server_from_group, self.dispatcher, log,
                 transaction_id(request), server_id,
                 extract_bool_arg(request, 'replace', True),
                 extract_bool_arg(request, 'purge', True)),
         modify_state_reason='delete_server')
     return d
Ejemplo n.º 18
0
 def delete_server(self, request, server_id):
     """
     Delete a server from the group.
     """
     group = self.store.get_scaling_group(
         self.log, self.tenant_id, self.scaling_group_id)
     log = self.log.bind(server_id=server_id)
     d = controller.modify_and_trigger(
         self.dispatcher,
         group,
         bound_log_kwargs(log),
         partial(controller.remove_server_from_group,
                 self.dispatcher,
                 log,
                 transaction_id(request), server_id,
                 extract_bool_arg(request, 'replace', True),
                 extract_bool_arg(request, 'purge', True)),
         modify_state_reason='delete_server')
     return d
Ejemplo n.º 19
0
    def execute_policy(self, request):
        """
        Execute this scaling policy.

        TBD: Response body.

        Example response::

            {}
        """
        group = self.store.get_scaling_group(self.log, self.tenant_id,
                                             self.scaling_group_id)
        d = controller.modify_and_trigger(
            self.dispatcher,
            group,
            bound_log_kwargs(self.log),
            partial(controller.maybe_execute_scaling_policy,
                    self.log, transaction_id(request),
                    policy_id=self.policy_id),
            modify_state_reason='execute_policy')
        d.addCallback(lambda _: "{}")  # Return value TBD
        return d
Ejemplo n.º 20
0
    def execute_policy(self, request):
        """
        Execute this scaling policy.

        TBD: Response body.

        Example response::

            {}
        """
        group = self.store.get_scaling_group(self.log, self.tenant_id,
                                             self.scaling_group_id)
        d = controller.modify_and_trigger(
            self.dispatcher,
            group,
            bound_log_kwargs(self.log),
            partial(controller.maybe_execute_scaling_policy,
                    self.log,
                    transaction_id(request),
                    policy_id=self.policy_id),
            modify_state_reason='execute_policy')
        d.addCallback(lambda _: "{}")  # Return value TBD
        return d
Ejemplo n.º 21
0
 def foo(self, request):
     transaction_ids.append(transaction_id(request))
     return 'ok'
Ejemplo n.º 22
0
 def _do_obey_config_change(_, group):
     return group.modify_state(
         partial(controller.obey_config_change, self.log, transaction_id(request),
                 data))
Ejemplo n.º 23
0
 def foo(self, request, log):
     transaction_ids.append(transaction_id(request))
     return 'ok'