neutron 相关agent 服务分析
1 | def init(args, **kwargs): |
##初始化manager 服务的详细分析
manager = neutron.agent.dhcp.agent.DhcpAgentWithStateReport 的详细分析
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45 class DhcpAgentWithStateReport(DhcpAgent):
def __init__(self, host=None, conf=None):
super(DhcpAgentWithStateReport, self).__init__(host=host, conf=conf)
self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)
#获取 rpc 服务器
self.agent_state = {
'binary': 'neutron-dhcp-agent',
'host': host,
'topic': topics.DHCP_AGENT,
'configurations': {
'dhcp_driver': self.conf.dhcp_driver,
'use_namespaces': self.conf.use_namespaces,
'dhcp_lease_duration': self.conf.dhcp_lease_duration,
'log_agent_heartbeats': self.conf.AGENT.log_agent_heartbeats},
'start_flag': True,
'agent_type': constants.AGENT_TYPE_DHCP}
#获取 rpc 更新的状态值 agent_state
report_interval = self.conf.AGENT.report_interval
self.use_call = True
#循环执行每隔 report_interval 秒
if report_interval:
self.heartbeat = loopingcall.FixedIntervalLoopingCall(
self._report_state)
self.heartbeat.start(interval=report_interval)
#状态更新
def _report_state(self):
try:
self.agent_state.get('configurations').update(
self.cache.get_state())
ctx = context.get_admin_context_without_session()
self.state_rpc.report_state(ctx, self.agent_state, self.use_call)
self.use_call = False
except AttributeError:
# This means the server does not support report_state
LOG.warn(_LW("Neutron server does not support state report."
" State report for this agent will be disabled."))
self.heartbeat.stop()
self.run()
return
except Exception:
LOG.exception(_LE("Failed reporting state!"))
return
if self.agent_state.pop('start_flag', None):
self.run()
##dhcp 服务所要执行的linux的shell 命令汇总
- kill -9 $pid 关闭dnsmasq 服务
- /var/lib/neutron/dhcp/827$uuid 删除dnsmasq 的配置文件
- u’ip netns exec qdhcp-827b355e-4348-41e8-96c7-c99e0ba08126 ip link set ns-b9f61118-2f up’ 启动网卡
- [‘sudo’, ‘ip’, ‘netns’, ‘exec’, ‘qdhcp-827b355e-4348-41e8-96c7-c99e0ba08126’, ‘ip’, ‘-o’, ‘link’, ‘show’, ‘ns-b9f61118-2f’]
- sudo ip netns exec qdhcp-827b355e-4348-41e8-96c7-c99e0ba08126 ip addr show ns-b9f61118-2f permanent
- sudo ip netns exec qdhcp-827b355e-4348-41e8-96c7-c99e0ba08126 ip route list dev ns-b9f61118-2f
- sudo ip netns exec qdhcp-827b355e-4348-41e8-96c7-c99e0ba08126 dnsmasq –no-hosts –no-resolv –strict-order –except-interface=lo –pid-file=/var/lib/neutron/dhcp/827b355e-4348-41e8-96c7-c99e0ba08126/pid –dhcp-hostsfile=/var/lib/neutron/dhcp/827b355e-4348-41e8-96c7-c99e0ba08126/host –addn-hosts=/var/lib/neutron/dhcp/827b355e-4348-41e8-96c7-c99e0ba08126/addn_hosts –dhcp-optsfile=/var/lib/neutron/dhcp/827b355e-4348-41e8-96c7-c99e0ba08126/opts –dhcp-leasefile=/var/
lib/neutron/dhcp/827b355e-4348-41e8-96c7-c99e0ba08126/leases –dhcp-match=set:ipxe,175 –bind-interfaces –interface=ns-b9f61118-2f –dhcp-range=set:tag0,192.168.222.0,static,86400s –dhcp-lease-max=256 –conf-file= –domain=openstacklocal 启动 dnsmasq 服务
总结 每一个namespace网络都会有相应的 dnsmasq 服务
##linux bridge 服务所要执行的linux的shell命令汇总
- ip link add vxlan-1 type vlan id 1 dev eth0 proxy
- bridge fdb append 00:00:00:00:00:00 dev vxlan-1 dst 1.1.1.1
- ip -o link show vxlan-1
- sudo ip link set vxlan-1 down
- sudo ip link delete vxlan-1