关于neutron router-update在server端执行流程

输入neutron router-update 参数执行后,neutron-server收到neutronclient发来的http请求后,根据路由映射选择相应的controller下的函数。

1.neutron/api/v2/base.py(493)update():所有的关于update操作都将在这处理

  def update(self, request, id, body=None, **kwargs):        
        """Updates the specified entity's attributes."""
           parent_id = kwargs.get(self._parent_id_name)
           try:
                payload = body.copy()#body是请求部分,在这里body里包含了传过来的路由信息
           except AttributeError:
                msg = _("Invalid format: %s") % request.body
                raise exceptions.BadRequest(resource='body', msg=msg)
           payload['id'] = id#id是路由器的id
           self._notifier.info(request.context,
           self._resource + '.update.start', payload)
           body = Controller.prepare_request_body(request.context, body, False,
                                                self._resource, self._attr_info,
                                                allow_bulk=self._allow_bulk)#路由信息
           action = self._plugin_handlers[self.UPDATE]
           # Load object to check authz
           # but pass only attributes in the original body and required
           # by the policy engine to the policy 'brain'
           field_list = [name for (name, value) in self._attr_info.iteritems()
                       if (value.get('required_by_policy') or
                           value.get('primary_key') or
                           'default' not in value)] #field_list是orig_obj

     policy.init()
            orig_obj = self._item(request, id, field_list=field_list,
                                  parent_id=parent_id)
            orig_object_copy = copy.copy(orig_obj)
            orig_obj.update(body[self._resource])
           # Ensure policy engine is initialized
           policy.init()orig_obj[const.ATTRIBUTES_TO_UPDATE] = body[self._resource].k

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值