neutron安全组分析(三)

4.2.   安全组更新


1、 Neutron-client发送updatesecuritygroup消息给neutron-server,neutron-server调用securitygroupplugin中的update_security_group方法处理消息;

2、 在update_security_group方法中直接更新安全组表项。

3、 securitygroup plugin会回应updatesecuritygroup result给neutron-client。更新成功则返回更新的安全组信息;失败则返回失败原因。

代码如下:

neutron.db.securitygroups_db.py

classSecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase)

def update_security_group(self, context, id, security_group):

        s = security_group['security_group']

 

        kwargs = {

            'context': context,

            'security_group_id': id,

            'security_group': s,

        }

        # NOTE(armax): a callback exceptionhere will prevent the request

        # from being processed. This is a hookpoint for backend's validation;

        # we raise to propagate the reason forthe failure.

        try:

            registry.notify(

                resources.SECURITY_GROUP,events.BEFORE_UPDATE, self,

                **kwargs)

        except exceptions.CallbackFailure as e:

            raiseext_sg.SecurityGroupConflict(reason=e)

 

        withcontext.session.begin(subtransactions=True):

            sg = self._get_security_group(context,id)

            if sg['name'] == 'default' and'name' in s:

                raiseext_sg.SecurityGroupCannotUpdateDefault()

            sg.update(s)   #更新安全组表项

        sg_dict =self._make_security_group_dict(sg)

 

        kwargs['security_group'] = sg_dict

       registry.notify(resources.SECURITY_GROUP, events.AFTER_UPDATE, self,

                        **kwargs)

        return sg_dict

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
neutron 的插件部分负责实现具体的网络功能,如虚拟网络、路由、安全等。在 neutron 中,插件是通过扩展 neutron 的核心服务来实现的。因此,插件的代码位于 `neutron/services` 目录下。 插件的实现一般需要继承 neutron 的核心服务类,例如 L3 插件需要继承 `neutron.services.l3_router.l3_router_plugin.L3RouterPlugin` 类。插件需要实现一些特定的方法来提供网络功能,例如 L3 插件需要实现 `create_router`、`update_router`、`delete_router` 等方法来管理 L3 路由器。 在插件的实现中,还需要与 neutron 的其他服务进行协同工作,如与网络代理服务通信来实现 DHCP、L3 路由等功能。为了实现这些功能,插件需要通过调用 neutron 的 API 接口、代理接口等来完成。 除了实现特定的网络功能外,插件还需要处理一些通用的网络操作,如网络异常处理、配置文件解析等。这些通用的操作一般放在插件的 `neutron/services/common` 目录下。 在插件的实现过程中,需要注意以下几个方面: 1. 实现特定的网络功能:插件需要实现特定的方法来提供网络功能,例如虚拟网络、路由、安全等。 2. 与其他服务的协同工作:插件需要与 neutron 的其他服务进行协同工作,如与网络代理服务通信来实现 DHCP、L3 路由等功能。 3. 处理通用的网络操作:插件还需要处理一些通用的网络操作,如网络异常处理、配置文件解析等。 4. 调试和测试:在插件的实现过程中,需要进行调试和测试,以确保插件能够正确地提供网络功能。 总之,neutron 插件的源码分析需要深入了解网络技术和 OpenStack 的架构设计,同时需要具备良好的编程能力和调试能力。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值