-import plc
-import auth
-api = plc.PLC(auth.auth, auth.plc)
-
-from config import config
-from optparse import OptionParser
-
-import soltesz
-fb = soltesz.dbLoad("findbad")
-
-def get_current_state(fbnode):
- state = fbnode['state']
- l = state.lower()
- if l == "debug": return 'dbg'
- return l
-
-parser = OptionParser()
-parser.set_defaults(nodegroup="Alpha",
- node=None,
- nodelist=None,
- list=False,
- add=False,
- delete=False,
- )
-parser.add_option("", "--nodegroup", dest="nodegroup", metavar="NodegroupName",
- help="Specify a nodegroup to perform actions on")
-parser.add_option("", "--list", dest="list", action="store_true",
- help="List all nodes in the given nodegroup")
-parser.add_option("", "--add", dest="add", action="store_true",
- help="Add nodes to the given nodegroup")
-parser.add_option("", "--delete", dest="delete", action="store_true",
- help="Delete nodes from the given nodegroup")
-parser.add_option("", "--node", dest="node", metavar="nodename.edu",
- help="A single node name to add to the nodegroup")
-parser.add_option("", "--nodelist", dest="nodelist", metavar="list.txt",
- help="Use all nodes in the given file for operation.")
-config = config(parser)
-config.parse_args()
-
-# COLLECT nodegroups, nodes and node lists
-ng = api.GetNodeGroups({'name' : config.nodegroup})
-nodelist = api.GetNodes(ng[0]['node_ids'])
-hostnames = [ n['hostname'] for n in nodelist ]
-
-if config.node or config.nodelist:
- if config.node: hostnames = [ config.node ]
- else: hostnames = config.getListFromFile(config.nodelist)
-
-# commands:
-if config.list:
- print " ---- Nodes in the %s Node Group ----" % config.nodegroup
- i = 0
- for node in nodelist:
- print "%-2d" % i,
- if node['hostname'] in fb['nodes']:
- node['current'] = get_current_state(fb['nodes'][node['hostname']]['values'])
+from monitor import database
+from monitor.database.info.model import FindbadNodeRecord
+from monitor import util
+from monitor.wrapper import plc
+from monitor import parser as parsermodule
+
+api = plc.getAuthAPI()
+
+from nodequery import verify,query_to_dict,node_select
+from monitor.common import *
+from sets import Set
+
+def main():
+
+ parser = parsermodule.getParser(['nodesets'])
+ parser.set_defaults( list=True,
+ add=False,
+ nocolor=False,
+ notng=False,
+ delete=False,)
+
+ parser.add_option("", "--not", dest="notng", action="store_true",
+ help="All nodes NOT in nodegroup.")
+ parser.add_option("", "--nocolor", dest="nocolor", action="store_true",
+ help="Enable color")
+ parser.add_option("", "--list", dest="list", action="store_true",
+ help="List all nodes in the given nodegroup")
+ parser.add_option("", "--add", dest="add", action="store_true",
+ help="Add nodes to the given nodegroup")
+ parser.add_option("", "--delete", dest="delete", action="store_true",
+ help="Delete nodes from the given nodegroup")
+
+ parser = parsermodule.getParser(['defaults'], parser)
+ config = parsermodule.parse_args(parser)
+
+ # COLLECT nodegroups, nodes and node lists
+ if config.node or config.nodelist:
+ if config.node:
+ hostlist = [ config.node ]
+ else:
+ hostlist = util.file.getListFromFile(config.nodelist)
+
+ # NOTE: preserve order given in file. Otherwise, return values are not in order
+ # given to GetNodes
+ nodelist = []
+ for h in hostlist:
+ nodelist.append( plccache.GetNodeByName(h) )
+
+ group_str = "Given"
+
+ elif config.site:
+ site = plccache.GetSitesByName([config.site])
+ if len (site) > 0:
+ site = site[0]
+ nodelist = plccache.GetNodesByIds(site['node_ids'])