在neutron数据库增加一个列

起因是对agent有这样的需求:
-对特定的dhcp-agent,有特定标识后,只能手动调度过去,不能自动调度过去
所以考虑增加一列用于这样的标识

[sql]
1
alter table agents add column auto_schedule tinyint(1) default 0 not null;

添加完了之后,执行neutron agent-update并不生效,会提示属性不存在,这里还需要修改2个文件

[neutron/extensions/agent.py]
1
2
3
4
5
6
53         'description': {'allow_post': False, 'allow_put': True,
54 'is_visible': True,
55 'validate': {'type:string': None}},
56 'auto_schedule': {'allow_post': False, 'allow_put': True,
57 'convert_to': attr.convert_to_boolean,
58 'is_visible': True},
[neutron/db/agents_db.py]
1
2
3
67     # configurations: a json dict string, I think 4095 is enough
68 configurations = sa.Column(sa.String(4095), nullable=False)
69 auto_schedule = sa.Column(sa.Boolean, nullable=False, default=False)

然后就可以通过neutron agent-updage来更新这个列了

[CLI]
1
2
3
[test@mypc services]$ neutron agent-update --request-format json f7952a27-cf66-4b07-beb8-536f5d44fc42 --auto_schedule=True
Updated agent: f7952a27-cf66-4b07-beb8-536f5d44fc42