From: Faiyaz Ahmed Date: Thu, 29 Nov 2007 18:08:28 +0000 (+0000) Subject: Adds new nodes to Sirius slice. Initial commit. X-Git-Tag: myplc-4.0-15~30 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=d52f782334bacfd126e70544938aec4fef333fd2;p=myplc.git Adds new nodes to Sirius slice. Initial commit. --- diff --git a/siriusnodes.py b/siriusnodes.py new file mode 100644 index 0000000..162aa54 --- /dev/null +++ b/siriusnodes.py @@ -0,0 +1,43 @@ +#!/usr/bin/python +''' +Subscribes new nodes to princeton_sirius slice. + +$Id : XXXXXX $ +''' + +import sys +from sets import Set + +# Load shell with default configuration +sys.path.append('/usr/share/plc_api') +from PLC.Shell import Shell +plc = Shell(globals()) + + + +def main(argv = None): + debug = False + allnodes = [] + whitelist = [] + newnodes = [] + + # Get All Nodes + for node in GetNodes(None, ['node_id']): allnodes.append(node['node_id']) + + # Get WhiteListed nodes + for node in GetWhitelist(None, ['node_id']): whitelist.append(node['node_id']) + + # Nodes already running slice + siriusnodes = GetSlices("princeton_sirius")[0]['node_ids'] + + available = Set(allnodes) - Set(whitelist) + + nodestoadd = available - Set(siriusnodes) + + for node in nodestoadd: newnodes.append(node) + + # Add to Sirius slice + if debug: + print newnodes + else: + AddSliceToNodes("princeton_sirius", [newnodes])