コード例 #1
0
ファイル: groups.py プロジェクト: dwcramer/otter
 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
コード例 #2
0
ファイル: groups.py プロジェクト: dian4554/otter
 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)
コード例 #3
0
ファイル: groups.py プロジェクト: dian4554/otter
 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)
コード例 #4
0
ファイル: groups.py プロジェクト: dian4554/otter
 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)
コード例 #5
0
ファイル: configs.py プロジェクト: stephamon/otter
 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
コード例 #6
0
ファイル: webhooks.py プロジェクト: RackerWilliams/otter
 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))
コード例 #7
0
ファイル: groups.py プロジェクト: dwcramer/otter
 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
コード例 #8
0
ファイル: groups.py プロジェクト: pratikmallya/otter
 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)
コード例 #9
0
ファイル: groups.py プロジェクト: manishtomar/otter
 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)
コード例 #10
0
ファイル: groups.py プロジェクト: manishtomar/otter
 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)
コード例 #11
0
ファイル: groups.py プロジェクト: manishtomar/otter
 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)
コード例 #12
0
ファイル: webhooks.py プロジェクト: rackerlabs/otter
 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')
コード例 #13
0
ファイル: groups.py プロジェクト: manishtomar/otter
 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)
コード例 #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')
コード例 #15
0
ファイル: policies.py プロジェクト: MariaAbrahms/otter
    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
コード例 #16
0
ファイル: groups.py プロジェクト: pratikmallya/otter
 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)
コード例 #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
コード例 #18
0
ファイル: groups.py プロジェクト: pratikmallya/otter
 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
コード例 #19
0
ファイル: policies.py プロジェクト: rackerlabs/otter
    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
コード例 #20
0
ファイル: policies.py プロジェクト: stephamon/otter
    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
コード例 #21
0
 def foo(self, request):
     transaction_ids.append(transaction_id(request))
     return 'ok'
コード例 #22
0
ファイル: configs.py プロジェクト: RackerWilliams/otter
 def _do_obey_config_change(_, group):
     return group.modify_state(
         partial(controller.obey_config_change, self.log, transaction_id(request),
                 data))
コード例 #23
0
 def foo(self, request, log):
     transaction_ids.append(transaction_id(request))
     return 'ok'