Ejemplo n.º 1
0
    def put(self, id, l7policy):
        """Updates a l7policy."""
        l7policy_dict = validate.sanitize_l7policy_api_args(
            l7policy.to_dict(render_unsets=False))
        context = pecan.request.context.get('octavia_context')
        # Make sure any specified redirect_pool_id exists
        if l7policy_dict.get('redirect_pool_id'):
            self._get_db_pool(context.session,
                              l7policy_dict['redirect_pool_id'])
        db_l7policy = self._get_db_l7policy(context.session, id)
        self._test_lb_and_listener_statuses(context.session)

        try:
            LOG.info(_LI("Sending Update of L7Policy %s to handler"), id)
            self.handler.update(db_l7policy,
                                l7policy_types.L7PolicyPUT(**l7policy_dict))
        except Exception:
            with excutils.save_and_reraise_exception(reraise=False):
                self.repositories.listener.update(
                    context.session,
                    self.listener_id,
                    operating_status=constants.ERROR)
        db_l7policy = self._get_db_l7policy(context.session, id)
        return self._convert_db_to_type(db_l7policy,
                                        l7policy_types.L7PolicyResponse)
Ejemplo n.º 2
0
 def test_update_l7policy(self):
     p = producer.L7PolicyProducer()
     l7policy_model = data_models.L7Policy(id=10)
     l7policy_updates = l7policy.L7PolicyPUT(enabled=False)
     p.update(l7policy_model, l7policy_updates)
     kw = {'l7policy_id': l7policy_model.id,
           'l7policy_updates': l7policy_updates.to_dict(
               render_unsets=False)}
     self.mck_client.cast.assert_called_once_with(
         {}, 'update_l7policy', **kw)