Merge lp:~majduk/charms/trusty/neutron-contrail/trunk into lp:~sdn-charmers/charms/trusty/neutron-contrail/trunk
- Trusty Tahr (14.04)
- trunk
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Michał Sawicz |
Approved revision: | 89 |
Merged at revision: | 75 |
Proposed branch: | lp:~majduk/charms/trusty/neutron-contrail/trunk |
Merge into: | lp:~sdn-charmers/charms/trusty/neutron-contrail/trunk |
Diff against target: |
531 lines (+230/-37) 6 files modified
config.yaml (+10/-0) files/40contrail (+10/-0) hooks/neutron_contrail_hooks.py (+83/-24) hooks/neutron_contrail_utils.py (+108/-9) scripts/create-vrouter.sh (+11/-4) scripts/set-scaling-governor.sh (+8/-0) |
To merge this branch: | bzr merge lp:~majduk/charms/trusty/neutron-contrail/trunk |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ante Karamatić | Approve | ||
Robert Ayres | Pending | ||
Review via email: mp+340373@code.launchpad.net |
Commit message
Description of the change
Changelog:
Allow changing dpdk_coremask, dpdk_mempool_size, dpdk_txd_size, dpdk_rxd_size using config-changed. Always restart supervisor-vrouter service as per Juniper recommen
dation.
Set kernel CPU frequency scaling_governor to performance. This is required on DPDK enabled nodes.
Add custom restart function for vrouter. DPDK vRouter does require i40e driver to be reloaded as it is not correctly reassigned to the interfaces after vRouter stop.
Render vrouter agent configuration (and in effect restart vrouter) only when configuration is complete. Incomplete configuration causes vrouter to deconfigure interf
aces and fail to start.
Store vhost0 interface IP, prefix length and gateway in config. This prevents issue where IP or Gateway is lost when config-changed is ran during vrouter restart or before vrouter was first started after the install
Update vhost-phy, vhost-phy-ip and vhost-phy-gw on charm upgrade
Add parameters for vrouter: dpdk-mempool-size, dpdk-txd-size, dpdk-rxd-size.
Allow reconfiguration of dpdk-coremask in config-changed
Use Contrail provided version of nova-*, libvirt-* and qemu-*
Present vrouter status in juju to simplify debugging and quicker service status overview
Setup jumboframe support
Ante Karamatić (ivoks) : | # |
Michał Ajduk (majduk) wrote : | # |
Replies inline.
Michał Ajduk (majduk) : | # |
Preview Diff
1 | === modified file 'config.yaml' | |||
2 | --- config.yaml 2017-09-20 19:59:00 +0000 | |||
3 | +++ config.yaml 2018-07-05 12:51:18 +0000 | |||
4 | @@ -83,6 +83,16 @@ | |||
5 | 83 | Value can be specified as either a hexidecimal bitmask e.g. 0xFFFFFFFF or | 83 | Value can be specified as either a hexidecimal bitmask e.g. 0xFFFFFFFF or |
6 | 84 | as a numbered list separated by commas e.g. 0,1 (ranges are also supported | 84 | as a numbered list separated by commas e.g. 0,1 (ranges are also supported |
7 | 85 | using '-' e.g. 0-2). | 85 | using '-' e.g. 0-2). |
8 | 86 | dpdk-mempool-size: | ||
9 | 87 | type: int | ||
10 | 88 | default: 65536 | ||
11 | 89 | description: vrouter packet pool size | ||
12 | 90 | dpdk-txd-size: | ||
13 | 91 | type: int | ||
14 | 92 | description: vrouter TX packet descriptor pool size | ||
15 | 93 | dpdk-rxd-size: | ||
16 | 94 | type: int | ||
17 | 95 | description: vrouter RX packet descriptor pool size | ||
18 | 86 | virtual-gateways: | 96 | virtual-gateways: |
19 | 87 | type: string | 97 | type: string |
20 | 88 | description: | | 98 | description: | |
21 | 89 | 99 | ||
22 | === modified file 'files/40contrail' | |||
23 | --- files/40contrail 2017-07-17 05:03:53 +0000 | |||
24 | +++ files/40contrail 2018-07-05 12:51:18 +0000 | |||
25 | @@ -1,3 +1,13 @@ | |||
26 | 1 | Explanation: Use contrail versions of libvirt packages | ||
27 | 2 | Package: libvirt* | ||
28 | 3 | Pin: version /contrail/ | ||
29 | 4 | Pin-Priority: 1001 | ||
30 | 5 | |||
31 | 6 | Explanation: Use contrail versions of qemu packages | ||
32 | 7 | Package: qemu-* | ||
33 | 8 | Pin: version /contrail/ | ||
34 | 9 | Pin-Priority: 1001 | ||
35 | 10 | |||
36 | 1 | Explanation: Use contrail versions of nova packages | 11 | Explanation: Use contrail versions of nova packages |
37 | 2 | Package: nova-* | 12 | Package: nova-* |
38 | 3 | Pin: version /contrail/ | 13 | Pin: version /contrail/ |
39 | 4 | 14 | ||
40 | === modified file 'hooks/neutron_contrail_hooks.py' | |||
41 | --- hooks/neutron_contrail_hooks.py 2018-03-21 19:34:17 +0000 | |||
42 | +++ hooks/neutron_contrail_hooks.py 2018-07-05 12:51:18 +0000 | |||
43 | @@ -40,6 +40,7 @@ | |||
44 | 40 | leader_get, | 40 | leader_get, |
45 | 41 | leader_set, | 41 | leader_set, |
46 | 42 | log, | 42 | log, |
47 | 43 | status_set, | ||
48 | 43 | relation_get, | 44 | relation_get, |
49 | 44 | relation_ids, | 45 | relation_ids, |
50 | 45 | relation_set | 46 | relation_set |
51 | @@ -49,7 +50,8 @@ | |||
52 | 49 | get_total_ram, | 50 | get_total_ram, |
53 | 50 | restart_on_change, | 51 | restart_on_change, |
54 | 51 | service_restart, | 52 | service_restart, |
56 | 52 | service_start | 53 | service_start, |
57 | 54 | service_stop | ||
58 | 53 | ) | 55 | ) |
59 | 54 | 56 | ||
60 | 55 | import charmhelpers.core.sysctl as sysctl | 57 | import charmhelpers.core.sysctl as sysctl |
61 | @@ -84,6 +86,9 @@ | |||
62 | 84 | provision_vrouter, | 86 | provision_vrouter, |
63 | 85 | reboot, | 87 | reboot, |
64 | 86 | set_dpdk_coremask, | 88 | set_dpdk_coremask, |
65 | 89 | set_dpdk_mempool_size, | ||
66 | 90 | set_dpdk_txd_size, | ||
67 | 91 | set_dpdk_rxd_size, | ||
68 | 87 | set_huge_pages_parameters, | 92 | set_huge_pages_parameters, |
69 | 88 | units, | 93 | units, |
70 | 89 | unprovision_local_metadata, | 94 | unprovision_local_metadata, |
71 | @@ -93,7 +98,11 @@ | |||
72 | 93 | write_nodemgr_config, | 98 | write_nodemgr_config, |
73 | 94 | write_vnc_api_config, | 99 | write_vnc_api_config, |
74 | 95 | write_vrouter_config, | 100 | write_vrouter_config, |
76 | 96 | write_vrouter_vgw_interfaces | 101 | write_vrouter_vgw_interfaces, |
77 | 102 | is_vrouter_running, | ||
78 | 103 | vhost_gateway, | ||
79 | 104 | vhost_ip, | ||
80 | 105 | apply_configuration | ||
81 | 97 | ) | 106 | ) |
82 | 98 | 107 | ||
83 | 99 | PACKAGES = [ "contrail-utils", "python-jinja2", "python-netifaces", | 108 | PACKAGES = [ "contrail-utils", "python-jinja2", "python-netifaces", |
84 | @@ -103,8 +112,6 @@ | |||
85 | 103 | "contrail-vrouter-dpdk-init", "contrail-vrouter-agent", | 112 | "contrail-vrouter-dpdk-init", "contrail-vrouter-agent", |
86 | 104 | "contrail-vrouter-common" ] | 113 | "contrail-vrouter-common" ] |
87 | 105 | 114 | ||
88 | 106 | PACKAGES_DPDK_DEPS = [ "dpdk-depends-packages" ] | ||
89 | 107 | |||
90 | 108 | PACKAGES_LBAAS = [ "python-barbicanclient", "haproxy" ] | 115 | PACKAGES_LBAAS = [ "python-barbicanclient", "haproxy" ] |
91 | 109 | 116 | ||
92 | 110 | PACKAGES_VROUTER = [ "contrail-vrouter-dkms", "contrail-vrouter-agent", | 117 | PACKAGES_VROUTER = [ "contrail-vrouter-dkms", "contrail-vrouter-agent", |
93 | @@ -114,6 +121,13 @@ | |||
94 | 114 | "contrail-nova-vif", "contrail-vrouter-init", | 121 | "contrail-nova-vif", "contrail-vrouter-init", |
95 | 115 | "contrail-vrouter-common" ] | 122 | "contrail-vrouter-common" ] |
96 | 116 | 123 | ||
97 | 124 | PACKAGES_LIBVIRT = [ "libvirt-bin", "libvirt0" ] | ||
98 | 125 | |||
99 | 126 | PACKAGES_QEMU = [ "qemu-block-extra","qemu-system","qemu-system-arm", | ||
100 | 127 | "qemu-system-common","qemu-system-mips","qemu-system-misc", | ||
101 | 128 | "qemu-system-ppc","qemu-system-sparc","qemu-system-x86", | ||
102 | 129 | "qemu-utils" ] | ||
103 | 130 | |||
104 | 117 | hooks = Hooks() | 131 | hooks = Hooks() |
105 | 118 | config = config() | 132 | config = config() |
106 | 119 | 133 | ||
107 | @@ -150,6 +164,13 @@ | |||
108 | 150 | unprovision_vrouter() | 164 | unprovision_vrouter() |
109 | 151 | config["vrouter-provisioned"] = False | 165 | config["vrouter-provisioned"] = False |
110 | 152 | 166 | ||
111 | 167 | @hooks.hook('update-status') | ||
112 | 168 | def update_status(): | ||
113 | 169 | if is_vrouter_running(): | ||
114 | 170 | status_set('active',"vrouter is running") | ||
115 | 171 | else: | ||
116 | 172 | status_set('blocked',"vrouter is not running") | ||
117 | 173 | |||
118 | 153 | @hooks.hook("config-changed") | 174 | @hooks.hook("config-changed") |
119 | 154 | def config_changed(): | 175 | def config_changed(): |
120 | 155 | configure_huge_pages() | 176 | configure_huge_pages() |
121 | @@ -282,8 +303,11 @@ | |||
122 | 282 | check_local_metadata() | 303 | check_local_metadata() |
123 | 283 | contrail_discovery_relation() | 304 | contrail_discovery_relation() |
124 | 284 | 305 | ||
127 | 285 | @restart_on_change({"/etc/contrail/contrail-vrouter-agent.conf": ["contrail-vrouter-agent"], | 306 | @restart_on_change({"/etc/contrail/contrail-vrouter-agent.conf": ["supervisor-vrouter"], |
128 | 286 | "/etc/contrail/contrail-vrouter-nodemgr.conf": ["contrail-vrouter-nodemgr"]}) | 307 | "/etc/contrail/contrail-vrouter-nodemgr.conf": ["supervisor-vrouter"]}, |
129 | 308 | False, | ||
130 | 309 | {"supervisor-vrouter": apply_configuration} | ||
131 | 310 | ) | ||
132 | 287 | def contrail_discovery_relation(): | 311 | def contrail_discovery_relation(): |
133 | 288 | write_vrouter_config() | 312 | write_vrouter_config() |
134 | 289 | write_nodemgr_config() | 313 | write_nodemgr_config() |
135 | @@ -306,7 +330,11 @@ | |||
136 | 306 | check_vrouter() | 330 | check_vrouter() |
137 | 307 | check_local_metadata() | 331 | check_local_metadata() |
138 | 308 | 332 | ||
140 | 309 | @restart_on_change({"/etc/contrail/contrail-vrouter-agent.conf": ["contrail-vrouter-agent"]}) | 333 | @restart_on_change({"/etc/contrail/contrail-vrouter-agent.conf": ["supervisor-vrouter"], |
141 | 334 | "/etc/contrail/contrail-vrouter-nodemgr.conf": ["supervisor-vrouter"]}, | ||
142 | 335 | False, | ||
143 | 336 | {"supervisor-vrouter": apply_configuration} | ||
144 | 337 | ) | ||
145 | 310 | def control_node_relation(): | 338 | def control_node_relation(): |
146 | 311 | write_vrouter_config() | 339 | write_vrouter_config() |
147 | 312 | 340 | ||
148 | @@ -346,7 +374,7 @@ | |||
149 | 346 | @hooks.hook() | 374 | @hooks.hook() |
150 | 347 | def install(): | 375 | def install(): |
151 | 348 | configure_sources(True, "install-sources", "install-keys") | 376 | configure_sources(True, "install-sources", "install-keys") |
153 | 349 | apt_upgrade(fatal=True, dist=True) | 377 | apt_upgrade(options=["--yes", "--force-yes"], fatal=True, dist=True) |
154 | 350 | fix_vrouter_scripts() # bug in 2.0+20141015.1 packages | 378 | fix_vrouter_scripts() # bug in 2.0+20141015.1 packages |
155 | 351 | apt_install(PACKAGES, fatal=True) | 379 | apt_install(PACKAGES, fatal=True) |
156 | 352 | utils.CONTRAIL_VERSION = dpkg_version("contrail-utils") | 380 | utils.CONTRAIL_VERSION = dpkg_version("contrail-utils") |
157 | @@ -361,19 +389,24 @@ | |||
158 | 361 | # install lbaas packages | 389 | # install lbaas packages |
159 | 362 | apt_install(PACKAGES_LBAAS, fatal=True) | 390 | apt_install(PACKAGES_LBAAS, fatal=True) |
160 | 363 | 391 | ||
161 | 392 | apply_configuration("supervisor-vrouter") | ||
162 | 364 | service_restart("nova-compute") | 393 | service_restart("nova-compute") |
163 | 365 | 394 | ||
164 | 366 | def install_dpdk_vrouter(): | 395 | def install_dpdk_vrouter(): |
165 | 367 | apt_install(PACKAGES_DPDK_DEPS, fatal=True) | ||
166 | 368 | check_call(["/opt/contrail/contrail_packages_dpdk/setup.sh"]) | ||
167 | 369 | with open("/etc/init/supervisor-vrouter.override", "w") as conf: | 396 | with open("/etc/init/supervisor-vrouter.override", "w") as conf: |
168 | 370 | conf.write("manual\n") | 397 | conf.write("manual\n") |
170 | 371 | apt_install(PACKAGES_DPDK, options=["--allow-unauthenticated"], fatal=True) | 398 | |
171 | 372 | 399 | ||
172 | 373 | if not os.path.exists("/etc/apt/preferences.d/40contrail"): | 400 | if not os.path.exists("/etc/apt/preferences.d/40contrail"): |
173 | 401 | # contrail libvirt and qemu packages | ||
174 | 402 | shutil.copy("files/40contrail", "/etc/apt/preferences.d") | ||
175 | 403 | apt_install(PACKAGES_LIBVIRT, options=["--reinstall", "--force-yes"], | ||
176 | 404 | fatal=True) | ||
177 | 405 | apt_install(PACKAGES_QEMU, options=["--reinstall", "--force-yes"], | ||
178 | 406 | fatal=True) | ||
179 | 407 | apt_install(PACKAGES_DPDK, options=["--allow-unauthenticated"], fatal=True) | ||
180 | 374 | # contrail nova packages contain vrouter vhostuser vif | 408 | # contrail nova packages contain vrouter vhostuser vif |
183 | 375 | shutil.copy("files/40contrail", "/etc/apt/preferences.d") | 409 | apt_install("nova-compute", options=["--reinstall", "--force-yes", "-o Dpkg::Options::=\"--force-confold\"", "-o Dpkg::Options::=\"--force-confdef\""], |
182 | 376 | apt_install("nova-compute", options=["--reinstall", "--force-yes"], | ||
184 | 377 | fatal=True) | 410 | fatal=True) |
185 | 378 | 411 | ||
186 | 379 | fix_kexec_tools() | 412 | fix_kexec_tools() |
187 | @@ -385,16 +418,14 @@ | |||
188 | 385 | service_restart("libvirt-bin") | 418 | service_restart("libvirt-bin") |
189 | 386 | configure_vrouter() | 419 | configure_vrouter() |
190 | 387 | 420 | ||
192 | 388 | set_dpdk_coremask(config.get("dpdk-coremask")) | 421 | write_dpdk_config() |
193 | 422 | |||
194 | 389 | write_agent_param_config() | 423 | write_agent_param_config() |
195 | 390 | iface = config["vhost-phy"] | 424 | iface = config["vhost-phy"] |
196 | 391 | config["dpdk-pci"] = pci_address(iface) | 425 | config["dpdk-pci"] = pci_address(iface) |
197 | 392 | config["dpdk-mac"] = netifaces.ifaddresses(iface)[netifaces.AF_LINK][0]["addr"] | 426 | config["dpdk-mac"] = netifaces.ifaddresses(iface)[netifaces.AF_LINK][0]["addr"] |
198 | 393 | write_vrouter_config() | 427 | write_vrouter_config() |
199 | 394 | os.remove("/etc/init/supervisor-vrouter.override") | 428 | os.remove("/etc/init/supervisor-vrouter.override") |
200 | 395 | service_start("supervisor-vrouter") | ||
201 | 396 | write_vrouter_config() | ||
202 | 397 | service_restart("contrail-vrouter-agent") | ||
203 | 398 | 429 | ||
204 | 399 | fix_libvirt() | 430 | fix_libvirt() |
205 | 400 | 431 | ||
206 | @@ -424,7 +455,11 @@ | |||
207 | 424 | 455 | ||
208 | 425 | @hooks.hook("neutron-metadata-relation-departed") | 456 | @hooks.hook("neutron-metadata-relation-departed") |
209 | 426 | @hooks.hook("neutron-metadata-relation-broken") | 457 | @hooks.hook("neutron-metadata-relation-broken") |
211 | 427 | @restart_on_change({"/etc/contrail/contrail-vrouter-agent.conf": ["contrail-vrouter-agent"]}) | 458 | @restart_on_change({"/etc/contrail/contrail-vrouter-agent.conf": ["supervisor-vrouter"], |
212 | 459 | "/etc/contrail/contrail-vrouter-nodemgr.conf": ["supervisor-vrouter"]}, | ||
213 | 460 | False, | ||
214 | 461 | {"supervisor-vrouter": apply_configuration} | ||
215 | 462 | ) | ||
216 | 428 | def neutron_metadata_relation(): | 463 | def neutron_metadata_relation(): |
217 | 429 | write_vrouter_config() | 464 | write_vrouter_config() |
218 | 430 | 465 | ||
219 | @@ -462,22 +497,46 @@ | |||
220 | 462 | except UnregisteredHookError as e: | 497 | except UnregisteredHookError as e: |
221 | 463 | log("Unknown hook {} - skipping.".format(e)) | 498 | log("Unknown hook {} - skipping.".format(e)) |
222 | 464 | 499 | ||
223 | 500 | def fill_vhost_phy_opts(): | ||
224 | 501 | iface = config.get("vhost-interface") | ||
225 | 502 | #save physical iface setting | ||
226 | 503 | if iface: | ||
227 | 504 | config["vhost-phy"] = iface | ||
228 | 505 | config["vhost-phy-gw"] = vhost_gateway() | ||
229 | 506 | config["vhost-phy-ip"] = vhost_ip(iface) | ||
230 | 507 | if not config["vhost-phy-ip"]: | ||
231 | 508 | config["vhost-phy-ip"] = vhost_ip("vhost0") | ||
232 | 509 | |||
233 | 465 | @hooks.hook("upgrade-charm") | 510 | @hooks.hook("upgrade-charm") |
234 | 466 | def upgrade_charm(): | 511 | def upgrade_charm(): |
235 | 467 | if "vhost-phy" not in config: | 512 | if "vhost-phy" not in config: |
238 | 468 | config["vhost-phy"] = \ | 513 | fill_vhost_phy_opts() |
237 | 469 | check_output(["awk", "/^physical_interface =/ { print $3 }", "/etc/contrail/contrail-vrouter-agent.conf"]).rstrip() | ||
239 | 470 | write_vrouter_config() | 514 | write_vrouter_config() |
240 | 471 | write_vnc_api_config() | 515 | write_vnc_api_config() |
241 | 472 | write_nodemgr_config() | 516 | write_nodemgr_config() |
246 | 473 | service_restart("supervisor-vrouter") | 517 | if config["dpdk"]: |
247 | 474 | 518 | write_dpdk_config() | |
248 | 475 | @restart_on_change({"/etc/contrail/contrail-vrouter-agent.conf": ["contrail-vrouter-agent"], | 519 | apply_configuration("supervisor-vrouter") |
249 | 476 | "/etc/contrail/contrail-vrouter-nodemgr.conf": ["contrail-vrouter-nodemgr"]}) | 520 | |
250 | 521 | def write_dpdk_config(): | ||
251 | 522 | log("Writing file /etc/contrail/supervisord_vrouter_files/contrail-vrouter-dpdk.ini") | ||
252 | 523 | set_dpdk_coremask(config.get("dpdk-coremask")) | ||
253 | 524 | set_dpdk_mempool_size(config.get("dpdk-mempool-size")) | ||
254 | 525 | set_dpdk_txd_size(config.get("dpdk-txd-size")) | ||
255 | 526 | set_dpdk_rxd_size(config.get("dpdk-rxd-size")) | ||
256 | 527 | |||
257 | 528 | @restart_on_change({"/etc/contrail/contrail-vrouter-agent.conf": ["supervisor-vrouter"], | ||
258 | 529 | "/etc/contrail/contrail-vrouter-nodemgr.conf": ["supervisor-vrouter"], | ||
259 | 530 | "/etc/contrail/supervisord_vrouter_files/contrail-vrouter-dpdk.ini": ["supervisor-vrouter"]}, | ||
260 | 531 | False, | ||
261 | 532 | {"supervisor-vrouter": apply_configuration } | ||
262 | 533 | ) | ||
263 | 477 | def write_config(): | 534 | def write_config(): |
264 | 478 | write_vrouter_config() | 535 | write_vrouter_config() |
265 | 479 | write_vnc_api_config() | 536 | write_vnc_api_config() |
266 | 480 | write_nodemgr_config() | 537 | write_nodemgr_config() |
267 | 538 | if config["dpdk"]: | ||
268 | 539 | write_dpdk_config() | ||
269 | 481 | 540 | ||
270 | 482 | if __name__ == "__main__": | 541 | if __name__ == "__main__": |
271 | 483 | main() | 542 | main() |
272 | 484 | 543 | ||
273 | === modified file 'hooks/neutron_contrail_utils.py' | |||
274 | --- hooks/neutron_contrail_utils.py 2018-03-21 19:34:17 +0000 | |||
275 | +++ hooks/neutron_contrail_utils.py 2018-07-05 12:51:18 +0000 | |||
276 | @@ -51,7 +51,8 @@ | |||
277 | 51 | fstab_mount, | 51 | fstab_mount, |
278 | 52 | mkdir, | 52 | mkdir, |
279 | 53 | service_restart, | 53 | service_restart, |
281 | 54 | service_start | 54 | service_start, |
282 | 55 | service_stop | ||
283 | 55 | ) | 56 | ) |
284 | 56 | 57 | ||
285 | 57 | from charmhelpers.core.templating import render | 58 | from charmhelpers.core.templating import render |
286 | @@ -122,8 +123,11 @@ | |||
287 | 122 | if config["dpdk"]: | 123 | if config["dpdk"]: |
288 | 123 | args.append("-d") | 124 | args.append("-d") |
289 | 124 | iface = config.get("vhost-interface") | 125 | iface = config.get("vhost-interface") |
290 | 126 | #save physical iface setting | ||
291 | 125 | if iface: | 127 | if iface: |
292 | 126 | args.append(iface) | 128 | args.append(iface) |
293 | 129 | config["vhost-phy-ip"] = vhost_ip(iface) | ||
294 | 130 | config["vhost-phy-gw"] = vhost_gateway() | ||
295 | 127 | config["vhost-phy"] = check_output(args, cwd="scripts").rstrip() | 131 | config["vhost-phy"] = check_output(args, cwd="scripts").rstrip() |
296 | 128 | 132 | ||
297 | 129 | def contrail_api_ctx(): | 133 | def contrail_api_ctx(): |
298 | @@ -343,7 +347,7 @@ | |||
299 | 343 | iface = config.get("control-interface") | 347 | iface = config.get("control-interface") |
300 | 344 | addr = netifaces.ifaddresses(iface)[netifaces.AF_INET][0]["addr"] | 348 | addr = netifaces.ifaddresses(iface)[netifaces.AF_INET][0]["addr"] |
301 | 345 | except (ValueError, KeyError): | 349 | except (ValueError, KeyError): |
303 | 346 | addr = None | 350 | addr = config["vhost-phy-ip"]["ip"] |
304 | 347 | return { "control_network_ip": addr } | 351 | return { "control_network_ip": addr } |
305 | 348 | 352 | ||
306 | 349 | def neutron_metadata_ctx(): | 353 | def neutron_metadata_ctx(): |
307 | @@ -389,7 +393,7 @@ | |||
308 | 389 | 393 | ||
309 | 390 | def provision_vrouter(): | 394 | def provision_vrouter(): |
310 | 391 | hostname = gethostname() | 395 | hostname = gethostname() |
312 | 392 | ip = netifaces.ifaddresses("vhost0")[netifaces.AF_INET][0]["addr"] | 396 | ip = config["vhost-phy-ip"]["ip"] |
313 | 393 | api_port = None | 397 | api_port = None |
314 | 394 | api_ip = config.get("contrail-api-ip") | 398 | api_ip = config.get("contrail-api-ip") |
315 | 395 | if api_ip: | 399 | if api_ip: |
316 | @@ -422,6 +426,34 @@ | |||
317 | 422 | "s!^command=.*/usr/bin/contrail-vrouter-dpdk!command=taskset {} /usr/bin/contrail-vrouter-dpdk!".format(args), | 426 | "s!^command=.*/usr/bin/contrail-vrouter-dpdk!command=taskset {} /usr/bin/contrail-vrouter-dpdk!".format(args), |
318 | 423 | "/etc/contrail/supervisord_vrouter_files/contrail-vrouter-dpdk.ini"]) | 427 | "/etc/contrail/supervisord_vrouter_files/contrail-vrouter-dpdk.ini"]) |
319 | 424 | 428 | ||
320 | 429 | def set_dpdk_command_param(param,value): | ||
321 | 430 | command=check_output(["sed","-n", "-e", | ||
322 | 431 | "/^command/p", | ||
323 | 432 | "/etc/contrail/supervisord_vrouter_files/contrail-vrouter-dpdk.ini"]).split() | ||
324 | 433 | try: | ||
325 | 434 | idx = command.index(param) | ||
326 | 435 | if value and value > 0: | ||
327 | 436 | command[idx+1]=str(value) | ||
328 | 437 | else: | ||
329 | 438 | command[idx]="" | ||
330 | 439 | command[idx+1]="" | ||
331 | 440 | except ValueError: | ||
332 | 441 | if value and value > 0: | ||
333 | 442 | command.append(param) | ||
334 | 443 | command.append(str(value)) | ||
335 | 444 | check_output(["sed","-i", "-e", | ||
336 | 445 | "s!^command.*$!{}!".format( " ".join( command) ), | ||
337 | 446 | "/etc/contrail/supervisord_vrouter_files/contrail-vrouter-dpdk.ini"]) | ||
338 | 447 | |||
339 | 448 | def set_dpdk_mempool_size(size): | ||
340 | 449 | set_dpdk_command_param("--vr_mempool_sz",size) | ||
341 | 450 | |||
342 | 451 | def set_dpdk_txd_size(size): | ||
343 | 452 | set_dpdk_command_param("--dpdk_txd_sz",size) | ||
344 | 453 | |||
345 | 454 | def set_dpdk_rxd_size(size): | ||
346 | 455 | set_dpdk_command_param("--dpdk_rxd_sz",size) | ||
347 | 456 | |||
348 | 425 | def set_huge_pages_parameters(size, pages): | 457 | def set_huge_pages_parameters(size, pages): |
349 | 426 | with open("/proc/cmdline", "r") as f: | 458 | with open("/proc/cmdline", "r") as f: |
350 | 427 | line = f.read() | 459 | line = f.read() |
351 | @@ -523,9 +555,10 @@ | |||
352 | 523 | # determine vhost gateway | 555 | # determine vhost gateway |
353 | 524 | gateway = config.get("vhost-gateway") | 556 | gateway = config.get("vhost-gateway") |
354 | 525 | if gateway == "auto": | 557 | if gateway == "auto": |
355 | 558 | iface = config.get("vhost-interface") | ||
356 | 526 | for line in check_output(["route", "-n"]).splitlines()[2:]: | 559 | for line in check_output(["route", "-n"]).splitlines()[2:]: |
357 | 527 | l = line.split() | 560 | l = line.split() |
359 | 528 | if "G" in l[3] and l[7] == "vhost0": | 561 | if "G" in l[3] and ( l[7] == "vhost0" or l[7] == iface ): |
360 | 529 | return l[1] | 562 | return l[1] |
361 | 530 | gateway = None | 563 | gateway = None |
362 | 531 | return gateway | 564 | return gateway |
363 | @@ -536,15 +569,16 @@ | |||
364 | 536 | addr = netifaces.ifaddresses(iface)[netifaces.AF_INET][0] | 569 | addr = netifaces.ifaddresses(iface)[netifaces.AF_INET][0] |
365 | 537 | ip = addr["addr"] | 570 | ip = addr["addr"] |
366 | 538 | cidr = netaddr.IPNetwork(ip + "/" + addr["netmask"]).prefixlen | 571 | cidr = netaddr.IPNetwork(ip + "/" + addr["netmask"]).prefixlen |
368 | 539 | return ip + "/" + str(cidr) | 572 | return { "ip":ip, "prefixlen": str(cidr) } |
369 | 540 | except (ValueError, KeyError): | 573 | except (ValueError, KeyError): |
370 | 541 | return None | 574 | return None |
371 | 542 | 575 | ||
372 | 543 | def vrouter_ctx(): | 576 | def vrouter_ctx(): |
375 | 544 | return { "vhost_ip": vhost_ip("vhost0"), | 577 | return { "vhost_ip": "%s/%s" % ( config["vhost-phy-ip"]["ip"], config["vhost-phy-ip"]["prefixlen"] ), |
376 | 545 | "vhost_gateway": vhost_gateway(), | 578 | "vhost_gateway": config["vhost-phy-gw"], |
377 | 546 | "vhost_physical": config["vhost-phy"] } | 579 | "vhost_physical": config["vhost-phy"] } |
378 | 547 | 580 | ||
379 | 581 | |||
380 | 548 | def vrouter_vgw_ctx(): | 582 | def vrouter_vgw_ctx(): |
381 | 549 | ctx = {} | 583 | ctx = {} |
382 | 550 | vgws = config.get("virtual-gateways") | 584 | vgws = config.get("virtual-gateways") |
383 | @@ -575,6 +609,45 @@ | |||
384 | 575 | ctx.update(identity_admin_ctx()) | 609 | ctx.update(identity_admin_ctx()) |
385 | 576 | render("vnc_api_lib.ini", "/etc/contrail/vnc_api_lib.ini", ctx) | 610 | render("vnc_api_lib.ini", "/etc/contrail/vnc_api_lib.ini", ctx) |
386 | 577 | 611 | ||
387 | 612 | def is_ctx_complete(ctx,dpdk=False): | ||
388 | 613 | log("vrouter config ctx: %s" % str(ctx) ) | ||
389 | 614 | try: | ||
390 | 615 | if ctx["control_nodes"] == "": | ||
391 | 616 | log("control_nodes missing") | ||
392 | 617 | return False | ||
393 | 618 | if ctx["discovery_server"] == "": | ||
394 | 619 | log("discovery_server missing") | ||
395 | 620 | return False | ||
396 | 621 | if ctx["metadata_secret"] == "": | ||
397 | 622 | log("metadata_secret missing") | ||
398 | 623 | return False | ||
399 | 624 | if ctx["control_network_ip"] == "": | ||
400 | 625 | log("control_network_ip missing") | ||
401 | 626 | return False | ||
402 | 627 | if ctx["vhost_ip"] is None or ctx["vhost_ip"] == "": | ||
403 | 628 | log("vhost_ip missing") | ||
404 | 629 | return False | ||
405 | 630 | if ctx["vhost_gateway"] is None or ctx["vhost_gateway"] == "": | ||
406 | 631 | log("vhost_gateway missing") | ||
407 | 632 | return False | ||
408 | 633 | if ctx["vhost_physical"] == "": | ||
409 | 634 | log("vhost_physical missing") | ||
410 | 635 | return False | ||
411 | 636 | if dpdk: | ||
412 | 637 | if ctx["phy_address"] == "": | ||
413 | 638 | log("dpdk phy_address missing") | ||
414 | 639 | return False | ||
415 | 640 | if ctx["phy_mac"] == "": | ||
416 | 641 | log("dpdk phy_mac missing") | ||
417 | 642 | return False | ||
418 | 643 | if ctx["phy_driver"] == "": | ||
419 | 644 | log("dpdk phy_driver missing") | ||
420 | 645 | return False | ||
421 | 646 | return True | ||
422 | 647 | except KeyError as e: | ||
423 | 648 | log("Error %s missing" % str(e) ) | ||
424 | 649 | return False | ||
425 | 650 | |||
426 | 578 | def write_vrouter_config(): | 651 | def write_vrouter_config(): |
427 | 579 | ctx = {} | 652 | ctx = {} |
428 | 580 | ctx.update(control_node_ctx()) | 653 | ctx.update(control_node_ctx()) |
429 | @@ -586,9 +659,35 @@ | |||
430 | 586 | if config["dpdk"]: | 659 | if config["dpdk"]: |
431 | 587 | ctx["dpdk"] = True | 660 | ctx["dpdk"] = True |
432 | 588 | ctx.update(dpdk_ctx()) | 661 | ctx.update(dpdk_ctx()) |
435 | 589 | render("contrail-vrouter-agent.conf", | 662 | if is_ctx_complete(ctx): |
436 | 590 | "/etc/contrail/contrail-vrouter-agent.conf", ctx, perms=0440) | 663 | render("contrail-vrouter-agent.conf", |
437 | 664 | "/etc/contrail/contrail-vrouter-agent.conf", ctx, perms=0440) | ||
438 | 665 | else: | ||
439 | 666 | log("Configuration incomplete: contrail-vrouter-agent.conf") | ||
440 | 667 | |||
441 | 591 | 668 | ||
442 | 592 | def write_vrouter_vgw_interfaces(): | 669 | def write_vrouter_vgw_interfaces(): |
443 | 593 | ctx = vrouter_vgw_ctx() | 670 | ctx = vrouter_vgw_ctx() |
444 | 594 | render("vrouter-vgw.cfg", "/etc/network/interfaces.d/vrouter-vgw.cfg", ctx) | 671 | render("vrouter-vgw.cfg", "/etc/network/interfaces.d/vrouter-vgw.cfg", ctx) |
445 | 672 | |||
446 | 673 | def is_vrouter_running(): | ||
447 | 674 | try: | ||
448 | 675 | for line in check_output(["contrail-status","-d"]).splitlines(): | ||
449 | 676 | state = line.strip().split() | ||
450 | 677 | if len(state) > 0 and state[0] != '==': | ||
451 | 678 | if state[1] != 'active': | ||
452 | 679 | return False | ||
453 | 680 | return True | ||
454 | 681 | except CalledProcessError: | ||
455 | 682 | return False | ||
456 | 683 | |||
457 | 684 | def configure_scaling_governor(): | ||
458 | 685 | check_call(["./set-scaling-governor.sh"], cwd="scripts") | ||
459 | 686 | |||
460 | 687 | def apply_configuration(service): | ||
461 | 688 | #service is provided by @restart_on_change hook | ||
462 | 689 | log("Configuration changed for %s, restarting vrouter" % service) | ||
463 | 690 | service_stop("supervisor-vrouter") | ||
464 | 691 | if config["dpdk"]: | ||
465 | 692 | configure_scaling_governor() | ||
466 | 693 | service_start("supervisor-vrouter") | ||
467 | 595 | 694 | ||
468 | === added symlink 'hooks/update-status' | |||
469 | === target is u'neutron_contrail_hooks.py' | |||
470 | === modified file 'scripts/create-vrouter.sh' | |||
471 | --- scripts/create-vrouter.sh 2018-03-21 19:34:17 +0000 | |||
472 | +++ scripts/create-vrouter.sh 2018-07-05 12:51:18 +0000 | |||
473 | @@ -29,6 +29,11 @@ | |||
474 | 29 | 29 | ||
475 | 30 | configVRouter() | 30 | configVRouter() |
476 | 31 | { | 31 | { |
477 | 32 | if [ $6 -gt 0 ]; | ||
478 | 33 | mtu_param="mtu $6" | ||
479 | 34 | else | ||
480 | 35 | mtu_param="" | ||
481 | 36 | fi | ||
482 | 32 | cat juju-header | 37 | cat juju-header |
483 | 33 | if [ -s "$3" ]; then | 38 | if [ -s "$3" ]; then |
484 | 34 | printf "\n%s\n" "auto $2" | 39 | printf "\n%s\n" "auto $2" |
485 | @@ -43,14 +48,15 @@ | |||
486 | 43 | echo "iface vhost0 inet dhcp" | 48 | echo "iface vhost0 inet dhcp" |
487 | 44 | fi | 49 | fi |
488 | 45 | if [ -n "$1" ]; then | 50 | if [ -n "$1" ]; then |
490 | 46 | cat <<-EOF | 51 | cat <<-EOF |
491 | 52 | $mtu_param | ||
492 | 47 | post-up ip link set vhost0 address $5 | 53 | post-up ip link set vhost0 address $5 |
493 | 48 | post-up [ -e /etc/network/routes ] \\ | 54 | post-up [ -e /etc/network/routes ] \\ |
494 | 49 | && { service networking-routes stop; service networking-routes start; } | 55 | && { service networking-routes stop; service networking-routes start; } |
495 | 50 | EOF | 56 | EOF |
496 | 51 | else | 57 | else |
497 | 52 | cat <<-EOF | 58 | cat <<-EOF |
499 | 53 | pre-up ip link add address \$(cat /sys/class/net/$2/address) type vhost | 59 | pre-up ip link add address \$(cat /sys/class/net/$2/address) type vhost |
500 | 54 | pre-up vif --add $2 --mac \$(cat /sys/class/net/$2/address) --vrf 0 --vhost-phys --type physical | 60 | pre-up vif --add $2 --mac \$(cat /sys/class/net/$2/address) --vrf 0 --vhost-phys --type physical |
501 | 55 | pre-up vif --add vhost0 --mac \$(cat /sys/class/net/$2/address) --vrf 0 --type vhost --xconnect $2 | 61 | pre-up vif --add vhost0 --mac \$(cat /sys/class/net/$2/address) --vrf 0 --type vhost --xconnect $2 |
502 | 56 | post-down vif --list | awk '/^vif.*OS: vhost0/ {split(\$1, arr, "\\/"); print arr[2];}' | xargs vif --delete | 62 | post-down vif --list | awk '/^vif.*OS: vhost0/ {split(\$1, arr, "\\/"); print arr[2];}' | xargs vif --delete |
503 | @@ -117,12 +123,13 @@ | |||
504 | 117 | iface_cfg=/dev/null | 123 | iface_cfg=/dev/null |
505 | 118 | fi | 124 | fi |
506 | 119 | if [ -n "$1" ]; then | 125 | if [ -n "$1" ]; then |
508 | 120 | mac=$(cat /sys/class/net/$2/address) | 126 | mac=$(cat /sys/class/net/$2/address ) |
509 | 127 | mtu=$(cat /sys/class/net/$2/mtu ) | ||
510 | 121 | fi | 128 | fi |
511 | 122 | ifacedown $iface_down vhost0 >&2; sleep 5 | 129 | ifacedown $iface_down vhost0 >&2; sleep 5 |
512 | 123 | configureInterfacesDir | 130 | configureInterfacesDir |
513 | 124 | configureInterfaces $iface_delete | 131 | configureInterfaces $iface_delete |
515 | 125 | configVRouter "$1" $iface_up $iface_cfg $TMP/vrouter.cfg $mac \ | 132 | configVRouter "$1" $iface_up $iface_cfg $TMP/vrouter.cfg ${mac:-0} ${mtu:-0} \ |
516 | 126 | > /etc/network/interfaces.d/vrouter.cfg | 133 | > /etc/network/interfaces.d/vrouter.cfg |
517 | 127 | ifaceup $iface_up >&2 | 134 | ifaceup $iface_up >&2 |
518 | 128 | if [ -z "$1" ]; then | 135 | if [ -z "$1" ]; then |
519 | 129 | 136 | ||
520 | === added file 'scripts/set-scaling-governor.sh' | |||
521 | --- scripts/set-scaling-governor.sh 1970-01-01 00:00:00 +0000 | |||
522 | +++ scripts/set-scaling-governor.sh 2018-07-05 12:51:18 +0000 | |||
523 | @@ -0,0 +1,8 @@ | |||
524 | 1 | #!/bin/sh -e | ||
525 | 2 | # | ||
526 | 3 | # Script used to set scaling_governor to performance | ||
527 | 4 | |||
528 | 5 | for f in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor ; do | ||
529 | 6 | echo performance > $f ; | ||
530 | 7 | done | ||
531 | 8 |
See comments in line.