rootwarp 添加系统命令 service openstack-nova-network restart 报错,解决办法

a)报错问题:

a)/usr/bin/nova-rootwrap:Unauthorized command: service openstack-nova-network restart (no filtermatched)

b)解决办法:

i.Vim nova/openstack/common/rootwrap/filters.py

1.cla***sNetFilter(CommandFilter):

2.

3.    def match(self, userargs):

4.        # Compute manager restart network s

5.        if userargs[0] == 'service':

6.            if userargs[1] =='openstack-nova-network':

7.                return (userargs[2] in('restart', 'start', 'stop'))

8.            else:

9.                return True


ii.Vim /usr/share/nova/rootwrap/compute.fileter

1.# nova/compute/manager.py

2.service: CommandFilter,service, root


iii.解决以上问题


iv.URL: https://wiki.openstack.org/wiki/Rootwrap


             注: 也可以这样操作

               1) 在 /etc/nova/创建一个目录 rootwrap.d,

               2) 在touch 文件compute.filters

                   [Filters]

                   # nova/compute/manager.py

                   service: CommandFilter, service, root

                   # 将来便于管理,可以添加多个 filter