Merge lp:~majduk/charms/trusty/neutron-contrail/trunk into lp:~sdn-charmers/charms/trusty/neutron-contrail/trunk

Proposed by Michał Ajduk
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
Reviewer Review Type Date Requested Status
Ante Karamatić Approve
Robert Ayres Pending
Review via email: mp+340373@code.launchpad.net

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

To post a comment you must log in.
Revision history for this message
Ante Karamatić (ivoks) wrote :

See comments in line.

review: Needs Fixing
Revision history for this message
Ante Karamatić (ivoks) :
Revision history for this message
Michał Ajduk (majduk) wrote :

Replies inline.

Revision history for this message
Michał Ajduk (majduk) :
Revision history for this message
Ante Karamatić (ivoks) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'config.yaml'
--- config.yaml 2017-09-20 19:59:00 +0000
+++ config.yaml 2018-07-05 12:51:18 +0000
@@ -83,6 +83,16 @@
83 Value can be specified as either a hexidecimal bitmask e.g. 0xFFFFFFFF or83 Value can be specified as either a hexidecimal bitmask e.g. 0xFFFFFFFF or
84 as a numbered list separated by commas e.g. 0,1 (ranges are also supported84 as a numbered list separated by commas e.g. 0,1 (ranges are also supported
85 using '-' e.g. 0-2).85 using '-' e.g. 0-2).
86 dpdk-mempool-size:
87 type: int
88 default: 65536
89 description: vrouter packet pool size
90 dpdk-txd-size:
91 type: int
92 description: vrouter TX packet descriptor pool size
93 dpdk-rxd-size:
94 type: int
95 description: vrouter RX packet descriptor pool size
86 virtual-gateways:96 virtual-gateways:
87 type: string97 type: string
88 description: |98 description: |
8999
=== modified file 'files/40contrail'
--- files/40contrail 2017-07-17 05:03:53 +0000
+++ files/40contrail 2018-07-05 12:51:18 +0000
@@ -1,3 +1,13 @@
1Explanation: Use contrail versions of libvirt packages
2Package: libvirt*
3Pin: version /contrail/
4Pin-Priority: 1001
5
6Explanation: Use contrail versions of qemu packages
7Package: qemu-*
8Pin: version /contrail/
9Pin-Priority: 1001
10
1Explanation: Use contrail versions of nova packages11Explanation: Use contrail versions of nova packages
2Package: nova-*12Package: nova-*
3Pin: version /contrail/13Pin: version /contrail/
414
=== modified file 'hooks/neutron_contrail_hooks.py'
--- hooks/neutron_contrail_hooks.py 2018-03-21 19:34:17 +0000
+++ hooks/neutron_contrail_hooks.py 2018-07-05 12:51:18 +0000
@@ -40,6 +40,7 @@
40 leader_get,40 leader_get,
41 leader_set,41 leader_set,
42 log,42 log,
43 status_set,
43 relation_get,44 relation_get,
44 relation_ids,45 relation_ids,
45 relation_set46 relation_set
@@ -49,7 +50,8 @@
49 get_total_ram,50 get_total_ram,
50 restart_on_change,51 restart_on_change,
51 service_restart,52 service_restart,
52 service_start53 service_start,
54 service_stop
53)55)
5456
55import charmhelpers.core.sysctl as sysctl57import charmhelpers.core.sysctl as sysctl
@@ -84,6 +86,9 @@
84 provision_vrouter,86 provision_vrouter,
85 reboot,87 reboot,
86 set_dpdk_coremask,88 set_dpdk_coremask,
89 set_dpdk_mempool_size,
90 set_dpdk_txd_size,
91 set_dpdk_rxd_size,
87 set_huge_pages_parameters,92 set_huge_pages_parameters,
88 units,93 units,
89 unprovision_local_metadata,94 unprovision_local_metadata,
@@ -93,7 +98,11 @@
93 write_nodemgr_config,98 write_nodemgr_config,
94 write_vnc_api_config,99 write_vnc_api_config,
95 write_vrouter_config,100 write_vrouter_config,
96 write_vrouter_vgw_interfaces101 write_vrouter_vgw_interfaces,
102 is_vrouter_running,
103 vhost_gateway,
104 vhost_ip,
105 apply_configuration
97)106)
98107
99PACKAGES = [ "contrail-utils", "python-jinja2", "python-netifaces",108PACKAGES = [ "contrail-utils", "python-jinja2", "python-netifaces",
@@ -103,8 +112,6 @@
103 "contrail-vrouter-dpdk-init", "contrail-vrouter-agent",112 "contrail-vrouter-dpdk-init", "contrail-vrouter-agent",
104 "contrail-vrouter-common" ]113 "contrail-vrouter-common" ]
105114
106PACKAGES_DPDK_DEPS = [ "dpdk-depends-packages" ]
107
108PACKAGES_LBAAS = [ "python-barbicanclient", "haproxy" ]115PACKAGES_LBAAS = [ "python-barbicanclient", "haproxy" ]
109116
110PACKAGES_VROUTER = [ "contrail-vrouter-dkms", "contrail-vrouter-agent",117PACKAGES_VROUTER = [ "contrail-vrouter-dkms", "contrail-vrouter-agent",
@@ -114,6 +121,13 @@
114 "contrail-nova-vif", "contrail-vrouter-init",121 "contrail-nova-vif", "contrail-vrouter-init",
115 "contrail-vrouter-common" ]122 "contrail-vrouter-common" ]
116123
124PACKAGES_LIBVIRT = [ "libvirt-bin", "libvirt0" ]
125
126PACKAGES_QEMU = [ "qemu-block-extra","qemu-system","qemu-system-arm",
127 "qemu-system-common","qemu-system-mips","qemu-system-misc",
128 "qemu-system-ppc","qemu-system-sparc","qemu-system-x86",
129 "qemu-utils" ]
130
117hooks = Hooks()131hooks = Hooks()
118config = config()132config = config()
119133
@@ -150,6 +164,13 @@
150 unprovision_vrouter()164 unprovision_vrouter()
151 config["vrouter-provisioned"] = False165 config["vrouter-provisioned"] = False
152166
167@hooks.hook('update-status')
168def update_status():
169 if is_vrouter_running():
170 status_set('active',"vrouter is running")
171 else:
172 status_set('blocked',"vrouter is not running")
173
153@hooks.hook("config-changed")174@hooks.hook("config-changed")
154def config_changed():175def config_changed():
155 configure_huge_pages()176 configure_huge_pages()
@@ -282,8 +303,11 @@
282 check_local_metadata()303 check_local_metadata()
283 contrail_discovery_relation()304 contrail_discovery_relation()
284305
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"],
286 "/etc/contrail/contrail-vrouter-nodemgr.conf": ["contrail-vrouter-nodemgr"]})307 "/etc/contrail/contrail-vrouter-nodemgr.conf": ["supervisor-vrouter"]},
308 False,
309 {"supervisor-vrouter": apply_configuration}
310 )
287def contrail_discovery_relation():311def contrail_discovery_relation():
288 write_vrouter_config()312 write_vrouter_config()
289 write_nodemgr_config()313 write_nodemgr_config()
@@ -306,7 +330,11 @@
306 check_vrouter()330 check_vrouter()
307 check_local_metadata()331 check_local_metadata()
308332
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"],
334 "/etc/contrail/contrail-vrouter-nodemgr.conf": ["supervisor-vrouter"]},
335 False,
336 {"supervisor-vrouter": apply_configuration}
337 )
310def control_node_relation():338def control_node_relation():
311 write_vrouter_config()339 write_vrouter_config()
312340
@@ -346,7 +374,7 @@
346@hooks.hook()374@hooks.hook()
347def install():375def install():
348 configure_sources(True, "install-sources", "install-keys")376 configure_sources(True, "install-sources", "install-keys")
349 apt_upgrade(fatal=True, dist=True)377 apt_upgrade(options=["--yes", "--force-yes"], fatal=True, dist=True)
350 fix_vrouter_scripts() # bug in 2.0+20141015.1 packages378 fix_vrouter_scripts() # bug in 2.0+20141015.1 packages
351 apt_install(PACKAGES, fatal=True)379 apt_install(PACKAGES, fatal=True)
352 utils.CONTRAIL_VERSION = dpkg_version("contrail-utils")380 utils.CONTRAIL_VERSION = dpkg_version("contrail-utils")
@@ -361,19 +389,24 @@
361 # install lbaas packages389 # install lbaas packages
362 apt_install(PACKAGES_LBAAS, fatal=True)390 apt_install(PACKAGES_LBAAS, fatal=True)
363391
392 apply_configuration("supervisor-vrouter")
364 service_restart("nova-compute")393 service_restart("nova-compute")
365394
366def install_dpdk_vrouter():395def install_dpdk_vrouter():
367 apt_install(PACKAGES_DPDK_DEPS, fatal=True)
368 check_call(["/opt/contrail/contrail_packages_dpdk/setup.sh"])
369 with open("/etc/init/supervisor-vrouter.override", "w") as conf:396 with open("/etc/init/supervisor-vrouter.override", "w") as conf:
370 conf.write("manual\n")397 conf.write("manual\n")
371 apt_install(PACKAGES_DPDK, options=["--allow-unauthenticated"], fatal=True)398
372399
373 if not os.path.exists("/etc/apt/preferences.d/40contrail"):400 if not os.path.exists("/etc/apt/preferences.d/40contrail"):
401 # contrail libvirt and qemu packages
402 shutil.copy("files/40contrail", "/etc/apt/preferences.d")
403 apt_install(PACKAGES_LIBVIRT, options=["--reinstall", "--force-yes"],
404 fatal=True)
405 apt_install(PACKAGES_QEMU, options=["--reinstall", "--force-yes"],
406 fatal=True)
407 apt_install(PACKAGES_DPDK, options=["--allow-unauthenticated"], fatal=True)
374 # contrail nova packages contain vrouter vhostuser vif408 # contrail nova packages contain vrouter vhostuser vif
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\""],
376 apt_install("nova-compute", options=["--reinstall", "--force-yes"],
377 fatal=True)410 fatal=True)
378411
379 fix_kexec_tools()412 fix_kexec_tools()
@@ -385,16 +418,14 @@
385 service_restart("libvirt-bin")418 service_restart("libvirt-bin")
386 configure_vrouter()419 configure_vrouter()
387420
388 set_dpdk_coremask(config.get("dpdk-coremask"))421 write_dpdk_config()
422
389 write_agent_param_config()423 write_agent_param_config()
390 iface = config["vhost-phy"]424 iface = config["vhost-phy"]
391 config["dpdk-pci"] = pci_address(iface)425 config["dpdk-pci"] = pci_address(iface)
392 config["dpdk-mac"] = netifaces.ifaddresses(iface)[netifaces.AF_LINK][0]["addr"]426 config["dpdk-mac"] = netifaces.ifaddresses(iface)[netifaces.AF_LINK][0]["addr"]
393 write_vrouter_config()427 write_vrouter_config()
394 os.remove("/etc/init/supervisor-vrouter.override")428 os.remove("/etc/init/supervisor-vrouter.override")
395 service_start("supervisor-vrouter")
396 write_vrouter_config()
397 service_restart("contrail-vrouter-agent")
398429
399 fix_libvirt()430 fix_libvirt()
400431
@@ -424,7 +455,11 @@
424455
425@hooks.hook("neutron-metadata-relation-departed")456@hooks.hook("neutron-metadata-relation-departed")
426@hooks.hook("neutron-metadata-relation-broken")457@hooks.hook("neutron-metadata-relation-broken")
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"],
459 "/etc/contrail/contrail-vrouter-nodemgr.conf": ["supervisor-vrouter"]},
460 False,
461 {"supervisor-vrouter": apply_configuration}
462 )
428def neutron_metadata_relation():463def neutron_metadata_relation():
429 write_vrouter_config()464 write_vrouter_config()
430465
@@ -462,22 +497,46 @@
462 except UnregisteredHookError as e:497 except UnregisteredHookError as e:
463 log("Unknown hook {} - skipping.".format(e))498 log("Unknown hook {} - skipping.".format(e))
464499
500def fill_vhost_phy_opts():
501 iface = config.get("vhost-interface")
502 #save physical iface setting
503 if iface:
504 config["vhost-phy"] = iface
505 config["vhost-phy-gw"] = vhost_gateway()
506 config["vhost-phy-ip"] = vhost_ip(iface)
507 if not config["vhost-phy-ip"]:
508 config["vhost-phy-ip"] = vhost_ip("vhost0")
509
465@hooks.hook("upgrade-charm")510@hooks.hook("upgrade-charm")
466def upgrade_charm():511def upgrade_charm():
467 if "vhost-phy" not in config:512 if "vhost-phy" not in config:
468 config["vhost-phy"] = \513 fill_vhost_phy_opts()
469 check_output(["awk", "/^physical_interface =/ { print $3 }", "/etc/contrail/contrail-vrouter-agent.conf"]).rstrip()
470 write_vrouter_config()514 write_vrouter_config()
471 write_vnc_api_config()515 write_vnc_api_config()
472 write_nodemgr_config()516 write_nodemgr_config()
473 service_restart("supervisor-vrouter")517 if config["dpdk"]:
474518 write_dpdk_config()
475@restart_on_change({"/etc/contrail/contrail-vrouter-agent.conf": ["contrail-vrouter-agent"],519 apply_configuration("supervisor-vrouter")
476 "/etc/contrail/contrail-vrouter-nodemgr.conf": ["contrail-vrouter-nodemgr"]})520
521def write_dpdk_config():
522 log("Writing file /etc/contrail/supervisord_vrouter_files/contrail-vrouter-dpdk.ini")
523 set_dpdk_coremask(config.get("dpdk-coremask"))
524 set_dpdk_mempool_size(config.get("dpdk-mempool-size"))
525 set_dpdk_txd_size(config.get("dpdk-txd-size"))
526 set_dpdk_rxd_size(config.get("dpdk-rxd-size"))
527
528@restart_on_change({"/etc/contrail/contrail-vrouter-agent.conf": ["supervisor-vrouter"],
529 "/etc/contrail/contrail-vrouter-nodemgr.conf": ["supervisor-vrouter"],
530 "/etc/contrail/supervisord_vrouter_files/contrail-vrouter-dpdk.ini": ["supervisor-vrouter"]},
531 False,
532 {"supervisor-vrouter": apply_configuration }
533 )
477def write_config():534def write_config():
478 write_vrouter_config()535 write_vrouter_config()
479 write_vnc_api_config()536 write_vnc_api_config()
480 write_nodemgr_config()537 write_nodemgr_config()
538 if config["dpdk"]:
539 write_dpdk_config()
481540
482if __name__ == "__main__":541if __name__ == "__main__":
483 main()542 main()
484543
=== modified file 'hooks/neutron_contrail_utils.py'
--- hooks/neutron_contrail_utils.py 2018-03-21 19:34:17 +0000
+++ hooks/neutron_contrail_utils.py 2018-07-05 12:51:18 +0000
@@ -51,7 +51,8 @@
51 fstab_mount,51 fstab_mount,
52 mkdir,52 mkdir,
53 service_restart,53 service_restart,
54 service_start54 service_start,
55 service_stop
55)56)
5657
57from charmhelpers.core.templating import render58from charmhelpers.core.templating import render
@@ -122,8 +123,11 @@
122 if config["dpdk"]:123 if config["dpdk"]:
123 args.append("-d")124 args.append("-d")
124 iface = config.get("vhost-interface")125 iface = config.get("vhost-interface")
126 #save physical iface setting
125 if iface:127 if iface:
126 args.append(iface)128 args.append(iface)
129 config["vhost-phy-ip"] = vhost_ip(iface)
130 config["vhost-phy-gw"] = vhost_gateway()
127 config["vhost-phy"] = check_output(args, cwd="scripts").rstrip()131 config["vhost-phy"] = check_output(args, cwd="scripts").rstrip()
128132
129def contrail_api_ctx():133def contrail_api_ctx():
@@ -343,7 +347,7 @@
343 iface = config.get("control-interface")347 iface = config.get("control-interface")
344 addr = netifaces.ifaddresses(iface)[netifaces.AF_INET][0]["addr"]348 addr = netifaces.ifaddresses(iface)[netifaces.AF_INET][0]["addr"]
345 except (ValueError, KeyError):349 except (ValueError, KeyError):
346 addr = None350 addr = config["vhost-phy-ip"]["ip"]
347 return { "control_network_ip": addr }351 return { "control_network_ip": addr }
348352
349def neutron_metadata_ctx():353def neutron_metadata_ctx():
@@ -389,7 +393,7 @@
389393
390def provision_vrouter():394def provision_vrouter():
391 hostname = gethostname()395 hostname = gethostname()
392 ip = netifaces.ifaddresses("vhost0")[netifaces.AF_INET][0]["addr"]396 ip = config["vhost-phy-ip"]["ip"]
393 api_port = None397 api_port = None
394 api_ip = config.get("contrail-api-ip")398 api_ip = config.get("contrail-api-ip")
395 if api_ip:399 if api_ip:
@@ -422,6 +426,34 @@
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),
423 "/etc/contrail/supervisord_vrouter_files/contrail-vrouter-dpdk.ini"])427 "/etc/contrail/supervisord_vrouter_files/contrail-vrouter-dpdk.ini"])
424428
429def set_dpdk_command_param(param,value):
430 command=check_output(["sed","-n", "-e",
431 "/^command/p",
432 "/etc/contrail/supervisord_vrouter_files/contrail-vrouter-dpdk.ini"]).split()
433 try:
434 idx = command.index(param)
435 if value and value > 0:
436 command[idx+1]=str(value)
437 else:
438 command[idx]=""
439 command[idx+1]=""
440 except ValueError:
441 if value and value > 0:
442 command.append(param)
443 command.append(str(value))
444 check_output(["sed","-i", "-e",
445 "s!^command.*$!{}!".format( " ".join( command) ),
446 "/etc/contrail/supervisord_vrouter_files/contrail-vrouter-dpdk.ini"])
447
448def set_dpdk_mempool_size(size):
449 set_dpdk_command_param("--vr_mempool_sz",size)
450
451def set_dpdk_txd_size(size):
452 set_dpdk_command_param("--dpdk_txd_sz",size)
453
454def set_dpdk_rxd_size(size):
455 set_dpdk_command_param("--dpdk_rxd_sz",size)
456
425def set_huge_pages_parameters(size, pages):457def set_huge_pages_parameters(size, pages):
426 with open("/proc/cmdline", "r") as f:458 with open("/proc/cmdline", "r") as f:
427 line = f.read()459 line = f.read()
@@ -523,9 +555,10 @@
523 # determine vhost gateway555 # determine vhost gateway
524 gateway = config.get("vhost-gateway")556 gateway = config.get("vhost-gateway")
525 if gateway == "auto":557 if gateway == "auto":
558 iface = config.get("vhost-interface")
526 for line in check_output(["route", "-n"]).splitlines()[2:]:559 for line in check_output(["route", "-n"]).splitlines()[2:]:
527 l = line.split()560 l = line.split()
528 if "G" in l[3] and l[7] == "vhost0":561 if "G" in l[3] and ( l[7] == "vhost0" or l[7] == iface ):
529 return l[1]562 return l[1]
530 gateway = None563 gateway = None
531 return gateway564 return gateway
@@ -536,15 +569,16 @@
536 addr = netifaces.ifaddresses(iface)[netifaces.AF_INET][0]569 addr = netifaces.ifaddresses(iface)[netifaces.AF_INET][0]
537 ip = addr["addr"]570 ip = addr["addr"]
538 cidr = netaddr.IPNetwork(ip + "/" + addr["netmask"]).prefixlen571 cidr = netaddr.IPNetwork(ip + "/" + addr["netmask"]).prefixlen
539 return ip + "/" + str(cidr)572 return { "ip":ip, "prefixlen": str(cidr) }
540 except (ValueError, KeyError):573 except (ValueError, KeyError):
541 return None574 return None
542575
543def vrouter_ctx():576def vrouter_ctx():
544 return { "vhost_ip": vhost_ip("vhost0"),577 return { "vhost_ip": "%s/%s" % ( config["vhost-phy-ip"]["ip"], config["vhost-phy-ip"]["prefixlen"] ),
545 "vhost_gateway": vhost_gateway(),578 "vhost_gateway": config["vhost-phy-gw"],
546 "vhost_physical": config["vhost-phy"] }579 "vhost_physical": config["vhost-phy"] }
547580
581
548def vrouter_vgw_ctx():582def vrouter_vgw_ctx():
549 ctx = {}583 ctx = {}
550 vgws = config.get("virtual-gateways")584 vgws = config.get("virtual-gateways")
@@ -575,6 +609,45 @@
575 ctx.update(identity_admin_ctx())609 ctx.update(identity_admin_ctx())
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)
577611
612def is_ctx_complete(ctx,dpdk=False):
613 log("vrouter config ctx: %s" % str(ctx) )
614 try:
615 if ctx["control_nodes"] == "":
616 log("control_nodes missing")
617 return False
618 if ctx["discovery_server"] == "":
619 log("discovery_server missing")
620 return False
621 if ctx["metadata_secret"] == "":
622 log("metadata_secret missing")
623 return False
624 if ctx["control_network_ip"] == "":
625 log("control_network_ip missing")
626 return False
627 if ctx["vhost_ip"] is None or ctx["vhost_ip"] == "":
628 log("vhost_ip missing")
629 return False
630 if ctx["vhost_gateway"] is None or ctx["vhost_gateway"] == "":
631 log("vhost_gateway missing")
632 return False
633 if ctx["vhost_physical"] == "":
634 log("vhost_physical missing")
635 return False
636 if dpdk:
637 if ctx["phy_address"] == "":
638 log("dpdk phy_address missing")
639 return False
640 if ctx["phy_mac"] == "":
641 log("dpdk phy_mac missing")
642 return False
643 if ctx["phy_driver"] == "":
644 log("dpdk phy_driver missing")
645 return False
646 return True
647 except KeyError as e:
648 log("Error %s missing" % str(e) )
649 return False
650
578def write_vrouter_config():651def write_vrouter_config():
579 ctx = {}652 ctx = {}
580 ctx.update(control_node_ctx())653 ctx.update(control_node_ctx())
@@ -586,9 +659,35 @@
586 if config["dpdk"]:659 if config["dpdk"]:
587 ctx["dpdk"] = True660 ctx["dpdk"] = True
588 ctx.update(dpdk_ctx())661 ctx.update(dpdk_ctx())
589 render("contrail-vrouter-agent.conf",662 if is_ctx_complete(ctx):
590 "/etc/contrail/contrail-vrouter-agent.conf", ctx, perms=0440)663 render("contrail-vrouter-agent.conf",
664 "/etc/contrail/contrail-vrouter-agent.conf", ctx, perms=0440)
665 else:
666 log("Configuration incomplete: contrail-vrouter-agent.conf")
667
591668
592def write_vrouter_vgw_interfaces():669def write_vrouter_vgw_interfaces():
593 ctx = vrouter_vgw_ctx()670 ctx = vrouter_vgw_ctx()
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)
672
673def is_vrouter_running():
674 try:
675 for line in check_output(["contrail-status","-d"]).splitlines():
676 state = line.strip().split()
677 if len(state) > 0 and state[0] != '==':
678 if state[1] != 'active':
679 return False
680 return True
681 except CalledProcessError:
682 return False
683
684def configure_scaling_governor():
685 check_call(["./set-scaling-governor.sh"], cwd="scripts")
686
687def apply_configuration(service):
688 #service is provided by @restart_on_change hook
689 log("Configuration changed for %s, restarting vrouter" % service)
690 service_stop("supervisor-vrouter")
691 if config["dpdk"]:
692 configure_scaling_governor()
693 service_start("supervisor-vrouter")
595694
=== added symlink 'hooks/update-status'
=== target is u'neutron_contrail_hooks.py'
=== modified file 'scripts/create-vrouter.sh'
--- scripts/create-vrouter.sh 2018-03-21 19:34:17 +0000
+++ scripts/create-vrouter.sh 2018-07-05 12:51:18 +0000
@@ -29,6 +29,11 @@
2929
30configVRouter()30configVRouter()
31{31{
32 if [ $6 -gt 0 ];
33 mtu_param="mtu $6"
34 else
35 mtu_param=""
36 fi
32 cat juju-header37 cat juju-header
33 if [ -s "$3" ]; then38 if [ -s "$3" ]; then
34 printf "\n%s\n" "auto $2"39 printf "\n%s\n" "auto $2"
@@ -43,14 +48,15 @@
43 echo "iface vhost0 inet dhcp"48 echo "iface vhost0 inet dhcp"
44 fi49 fi
45 if [ -n "$1" ]; then50 if [ -n "$1" ]; then
46 cat <<-EOF51 cat <<-EOF
52 $mtu_param
47 post-up ip link set vhost0 address $553 post-up ip link set vhost0 address $5
48 post-up [ -e /etc/network/routes ] \\54 post-up [ -e /etc/network/routes ] \\
49 && { service networking-routes stop; service networking-routes start; }55 && { service networking-routes stop; service networking-routes start; }
50 EOF56 EOF
51 else57 else
52 cat <<-EOF58 cat <<-EOF
53 pre-up ip link add address \$(cat /sys/class/net/$2/address) type vhost59 pre-up ip link add address \$(cat /sys/class/net/$2/address) type vhost
54 pre-up vif --add $2 --mac \$(cat /sys/class/net/$2/address) --vrf 0 --vhost-phys --type physical60 pre-up vif --add $2 --mac \$(cat /sys/class/net/$2/address) --vrf 0 --vhost-phys --type physical
55 pre-up vif --add vhost0 --mac \$(cat /sys/class/net/$2/address) --vrf 0 --type vhost --xconnect $261 pre-up vif --add vhost0 --mac \$(cat /sys/class/net/$2/address) --vrf 0 --type vhost --xconnect $2
56 post-down vif --list | awk '/^vif.*OS: vhost0/ {split(\$1, arr, "\\/"); print arr[2];}' | xargs vif --delete62 post-down vif --list | awk '/^vif.*OS: vhost0/ {split(\$1, arr, "\\/"); print arr[2];}' | xargs vif --delete
@@ -117,12 +123,13 @@
117 iface_cfg=/dev/null123 iface_cfg=/dev/null
118 fi124 fi
119 if [ -n "$1" ]; then125 if [ -n "$1" ]; then
120 mac=$(cat /sys/class/net/$2/address)126 mac=$(cat /sys/class/net/$2/address )
127 mtu=$(cat /sys/class/net/$2/mtu )
121 fi128 fi
122 ifacedown $iface_down vhost0 >&2; sleep 5129 ifacedown $iface_down vhost0 >&2; sleep 5
123 configureInterfacesDir130 configureInterfacesDir
124 configureInterfaces $iface_delete131 configureInterfaces $iface_delete
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} \
126 > /etc/network/interfaces.d/vrouter.cfg133 > /etc/network/interfaces.d/vrouter.cfg
127 ifaceup $iface_up >&2134 ifaceup $iface_up >&2
128 if [ -z "$1" ]; then135 if [ -z "$1" ]; then
129136
=== added file 'scripts/set-scaling-governor.sh'
--- scripts/set-scaling-governor.sh 1970-01-01 00:00:00 +0000
+++ scripts/set-scaling-governor.sh 2018-07-05 12:51:18 +0000
@@ -0,0 +1,8 @@
1#!/bin/sh -e
2#
3# Script used to set scaling_governor to performance
4
5for f in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor ; do
6 echo performance > $f ;
7done
8

Subscribers

People subscribed via source and target branches