From f2f1746fd8e769c03319bed4c22687b5d1e72e3c Mon Sep 17 00:00:00 2001 From: Andy Bavier Date: Wed, 27 May 2009 17:19:43 +0000 Subject: [PATCH] Generate egre-keys.txt file from slice tags --- NodeManager-topo.spec | 2 +- topo.py | 30 ++++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/NodeManager-topo.spec b/NodeManager-topo.spec index c8590ef..a04871e 100644 --- a/NodeManager-topo.spec +++ b/NodeManager-topo.spec @@ -2,7 +2,7 @@ Name: NodeManager-topo Version: 0.5 -Release: 2 +Release: 3 Summary: Plugin supporting creating a default virtual topology. Group: System Environment/Daemons diff --git a/topo.py b/topo.py index 5cdc7c1..a86ea81 100755 --- a/topo.py +++ b/topo.py @@ -351,7 +351,28 @@ def update_hosts(slicename, hosts): f.close() return +""" +Write /etc/vini/egre-keys.txt, used by vsys topo scripts +""" +def write_egre_keys(slicekeys): + vini_dir = "/etc/vini" + if not os.path.exists(vini_dir): + try: + os.mkdir(vini_dir) + except os.error: + logger.log("topo: could not create %s\n" % vini_dir) + return + keys_file = "%s/egre-keys.txt" % vini_dir + f = open(keys_file, 'w') + for slice in slicekeys: + f.write("%s %s\n" % (slice, slicekeys[slice])) + f.close() + return + +""" +Executed on NM startup +""" def start(options, config): run ("echo 1 > /proc/sys/net/ipv4/ip_forward") pass @@ -368,10 +389,14 @@ def GetSlivers(data): global ifaces, old_ifaces ifaces = old_ifaces = sioc.gifconf() + slicekeys = {} for sliver in data['slivers']: attrs = {} - for attribute in sliver['attributes']: - attrs[attribute['tagname']] = attribute['value'] + for tag in sliver['attributes']: + attrs[tag['tagname']] = tag['value'] + if tag['tagname'] == 'egre_key': + slicekeys[sliver['name']] = tag['value'] + if 'netns' in attrs: netns = int(attrs['netns']) @@ -395,6 +420,7 @@ def GetSlivers(data): sliver['name']) clean_up_old_virtual_links() + write_egre_keys(slicekeys) return -- 2.43.0