Commit d0f1cec3 authored by David Johnson's avatar David Johnson

Add support to synch with and store plab nodegroups in our DB (plab uses

them to key many different control actions, and we can't ignore them
anymore).  The driving need in this case is to dist out rootballs based on
the nodegroup so we can test plab4.2... but other ways to use this will
likely arise.

Also expanded the notion of config attributes I added during the push to
support multiple PLCs.  Now, config attributes are just per-PLC or
per-slice; they are per-PLC, but also conditional across
slice,nodegroup,node tuples.  This gives a ton of flexibility for the
different actions we need to take based on what kind of node the node is
-- and plab typically seems to distinguish this based on nodegroups.
parent 81a10581
This diff is collapsed.
......@@ -70,10 +70,13 @@ class NM4agent:
def _open(self):
if not self._isopen:
print "connecting to NM over ssh with command '%s'" % \
(DEF_NM_SSHCMD % (self.delacct,self.delkey,self.IP),)
try:
self.__agentconn = popen2.Popen3(DEF_NM_SSHCMD % (self.delacct,
self.delkey,
self.IP))
self.IP),
capturestderr=True)
self._isopen = True
except:
raise
......@@ -349,6 +352,9 @@ class PLCagent:
def NodeInfo(self,infilter=None,outfilter=None):
return self.__server.GetNodes(self.auth,infilter,outfilter)
def NodeGroupInfo(self,infilter=None,outfilter=None):
return self.__server.GetNodeGroups(self.auth,infilter,outfilter)
def PersonInfo(self,infilter=None,outfilter=None):
return self.__server.GetPersons(self.auth,infilter,outfilter)
......@@ -663,6 +669,14 @@ class mod_PLC4:
agent = self.__getAgent(None)
return tryXmlrpcCmd(agent.NodeInfo,(infilter,outfilter))
def getNodeGroups(self,infilter=None,outfilter=None):
"""
Basically, wraps the GetNodeGroups method, but also lets the caller
optimize the call by filtering.
"""
agent = self.__getAgent(None)
return tryXmlrpcCmd(agent.NodeGroupInfo,(infilter,outfilter))
def getNodeNetworks(self,infilter=None,outfilter=None):
"""
Basically, wraps the GetNodeNetworks method, but also lets the caller
......
......@@ -12,7 +12,7 @@ import libplab
from libtestbed import *
def usage(me):
print "Usage: %s [ -vd ] [<plc>]" % me
print "Usage: %s [ -vd ] [ -n ] [ -g ] [<plc>] ... [<plc>]" % me
print " (where <plc> is the name or id of a plc in the db)"
sys.exit(1)
......@@ -20,20 +20,42 @@ def usage(me):
def main(args):
me = args[0]
parser = TBParser()
parser.add_option("-n", "--nodes",dest="nodes",default=False,
action="store_true",help="Only synch node entries.")
parser.add_option("-g", "--nodegroups",dest="nodegroups",default=False,
action="store_true",help="Only synch node group entries.")
(options,cargs) = parser.parse_args()
both = True
if options.nodes and options.nodegroups:
both = True
elif options.nodes or options.nodegroups:
both = False
plab = libplab.Plab()
plcids = []
if len(cargs) > 0:
print "Updating node entries at %s." % cargs[0]
plab.updateNodeEntries(cargs[0])
# Only do the args...
plcids = cargs
else:
# Grab all the PLCs we know about and do for all...
plcs = plab.getPLCs()
for (name,idx) in plcs:
print "Updating node entries at %s." % name
plab.updateNodeEntries(name)
plcids.append(name)
pass
pass
for plc in plcids:
if options.nodes or both:
print "Updating node entries at %s." % plc
plab.updateNodeEntries(plc)
if options.nodegroups or both:
print "Updating node group entries at %s." % plc
plab.updateNodeGroupEntries(plc)
pass
return
if __name__ == "__main__":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment