--- a/components/openstack/neutron/files/neutron-l3-agent Thu Apr 16 01:36:32 2015 -0700
+++ b/components/openstack/neutron/files/neutron-l3-agent Mon Apr 20 12:35:51 2015 -0700
@@ -1,6 +1,6 @@
#!/usr/bin/python2.6
-# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
@@ -24,6 +24,26 @@
from subprocess import CalledProcessError, Popen, PIPE, check_call
+def set_hostmodel(value):
+ cmd = ["/usr/sbin/ipadm", "show-prop", "-p", "hostmodel",
+ "-co", "current", "ipv4"]
+ p = Popen(cmd, stdout=PIPE, stderr=PIPE)
+ output, error = p.communicate()
+ if p.returncode != 0:
+ print "failed to retrieve hostmodel ipadm property"
+ return False
+ if output.strip() == value:
+ return True
+ cmd = ["/usr/sbin/ipadm", "set-prop", "-t", "-p", "hostmodel=%s" % value,
+ "ipv4"]
+ p = Popen(cmd, stdout=PIPE, stderr=PIPE)
+ output, error = p.communicate()
+ if p.returncode != 0:
+ print "failed to set ipadm hostmodel property to %s" % value
+ return False
+ return True
+
+
def start():
# verify paths are valid
for f in sys.argv[2:4]:
@@ -56,6 +76,10 @@
"enabled before enabling neutron-l3-agent"
return smf_include.SMF_EXIT_ERR_CONFIG
+ # set the hostmodel property if necessary
+ if not set_hostmodel("src-priority"):
+ return smf_include.SMF_EXIT_ERR_FATAL
+
cmd = "/usr/lib/neutron/neutron-l3-agent --config-file %s " \
"--config-file %s" % tuple(sys.argv[2:4])
smf_include.smf_subprocess(cmd)
@@ -137,8 +161,9 @@
ipnat_rules = output.splitlines()
# L3 agent IP NAT rules are of the form
- # bimap l3e64ccc496_a_0 192.168.1.3/32 -> 172.16.10.3/32
- prog = re.compile('l3e[0-9A-Fa-f\_]{10}_0')
+ # bimap l3e64ccc496_a_0 .... OR
+ # rdr l3iedf345cc96_a_0 ....
+ prog = re.compile('l3[ie][0-9A-Fa-f\_]{10}_0')
for ipnat_rule in ipnat_rules:
if not prog.search(ipnat_rule):
continue
@@ -178,6 +203,9 @@
print "failed to remove datalinks used by L3 agent: %s" % (err)
return smf_include.SMF_EXIT_ERR_FATAL
+ # finally reset the hostmodel property
+ if not set_hostmodel("weak"):
+ return smf_include.SMF_EXIT_ERR_FATAL
return smf_include.SMF_EXIT_OK
if __name__ == "__main__":