Commit 0efe7f2f authored by David Johnson's avatar David Johnson

Cleanup debug code so it makes sense in large exps.

parent 5819d940
......@@ -669,7 +669,7 @@ class Plab:
pass
except herror:
nodeent['HNAME'] = nodeent['IP']
print "WARNING: Failed to get hostname for %s" % nodeent['IP']
print "Warning: Failed to get hostname for %s" % nodeent['IP']
pass
pass
......@@ -698,7 +698,7 @@ class Plab:
nodeent['LINKTYPE'] = "pcplabinet"
return
else:
print "WARNING: Unknown gateway for host %s" % nodeent['IP']
print "Warning: Unknown gateway for host %s" % nodeent['IP']
# We don't know - must manually classify.
nodeent['LINKTYPE'] = "*Unknown*"
......@@ -1128,7 +1128,7 @@ class Plab:
failstr += "%s/%s: (expires: %s UTC)\n" % \
(n[:2] + (time.asctime(time.gmtime(n[2])),))
pass
SENDMAIL(TBOPS, "WARNING: PLAB leases have expired, or will soon",
SENDMAIL(TBOPS, "Warning: PLAB leases have expired, or will soon",
"The following plab leases have expired, or will soon:\n"
+ failstr + "\n\nPlease look into it!", TBOPS)
pass
......@@ -1195,7 +1195,7 @@ class Slice:
try:
self.plab.compat_agent.createSlice(self)
except:
print "WARNING: compat agent failed in createSlice; " \
print "Warning: compat agent failed in createSlice; " \
"\n watch for inconsistent DB state!"
pass
pass
......@@ -1239,7 +1239,7 @@ class Slice:
try:
self.plab.compat_agent.deleteSlice(self)
except:
print "WARNING: compat agent failed in deleteSlice; " \
print "Warning: compat agent failed in deleteSlice; " \
"\n watch for inconsistent DB state!"
pass
pass
......@@ -1331,7 +1331,7 @@ class Slice:
try:
self.plab.compat_agent.renewSlice(self)
except:
print "WARNING: compat agent failed in renewSlice; " \
print "Warning: compat agent failed in renewSlice; " \
"\n watch for inconsistent DB state!"
pass
pass
......@@ -1423,7 +1423,7 @@ class Slice:
try:
self.plab.compat_agent.deleteSlice(self)
except:
print "WARNING: compat agent failed in deleteSlice; " \
print "Warning: compat agent failed in deleteSlice; " \
"\n watch for inconsistent DB state!"
pass
pass
......@@ -1526,9 +1526,6 @@ class Node:
def __init__(self, slice, nodeid, pollNode = False):
self.slice = slice
self.nodeid = nodeid
#self.IP = self.__findIP()
#self.hostname = self.__findHostname()
#self.phys_nodeid = self.__findPhysNodeID()
(self.IP,self.hostname,self.phys_nodeid) = self.__findHostInfo()
self.leaseend = 0
self.nodemeta = None
......@@ -1548,7 +1545,7 @@ class Node:
component,operation,status,str(msg)))
except:
# do nothing
print "WARNING: could not log (%s,%s,%s,%s) into plab_nodehist!" % \
print "Warning: could not log (%s,%s,%s,%s) into plab_nodehist!" % \
(component,operation,status,msg)
pass
pass
......@@ -1737,15 +1734,14 @@ class Node:
# found a valid prefix for the rootball; update the name
rrootballname = rootball_triggers[tpc][tnc] + rootballname
if debug:
print "Updated rootball name from %s to %s" % (rootballname,
rrootballname)
print "Updated rootball name from %s to %s" \
% (rootballname,rrootballname)
pass
pass
else:
if debug:
print "rbtriggers: %s; looking for %s/%s" % (str(rootball_triggers),
str(tpc),
str(tnc))
print "rbtriggers: %s; looking for %s/%s" \
% (str(rootball_triggers),str(tpc),str(tnc))
pass
pass
pass
......@@ -1756,7 +1752,7 @@ class Node:
pass
pass
except:
print "WARNING: exception while trying to update rootball name"
print "Warning: exception while trying to update rootball name"
traceback.print_exc()
pass
......@@ -1836,8 +1832,8 @@ class Node:
if rtries == 0:
raise
else:
print "WARNING: perform %s on %s failed, try %d" \
% (command,self.nodeid,tries-rtries)
print "Warning: perform %s on %s failed, try %d of %d" \
% (command,self.nodeid,tries-rtries,tries)
try:
time.sleep(interval)
except:
......@@ -1869,8 +1865,9 @@ class Node:
if rtries == 0:
raise
else:
print "WARNING: copy %s to %s on %s failed, try %d" \
% (localfile,remotefile,self.nodeid,tries-rtries)
print "Warning: copy %s to %s on %s failed, try %d of %d" \
% (localfile,remotefile,self.nodeid,
tries-rtries,tries)
try:
time.sleep(interval)
except:
......
......@@ -87,13 +87,15 @@ class NM3agent:
def create_sliver(self, ticket):
res = self.__server.create_sliver(xmlrpclib.Binary(ticket))
if debug:
print "NM3: create_sliver: res = %s" % str(res)
print "NM3: create_sliver(%s/%s): res = %s" % (self.nodeid,self.IP,
str(res))
return res
def delete_sliver(self, rcap):
res = self.__server.delete_sliver(rcap)
if debug:
print "NM3: delete_sliver: res = %s" % str(res)
print "NM3: delete_sliver(%s/%s): res = %s" % (self.nodeid,self.IP,
str(res))
return res
def version(self):
......@@ -160,21 +162,19 @@ class NM4agent:
self._open()
try:
if debug:
print "NM4agent: sending xmlrpc request (%s,%s)" % (cmd,
str(args))
print "NM4: xmlrpc send(%s/%s): %s" % (self.nodeid,self.IP,cmd)
pass
print >>self.__agentconn.tochild, xmlrpclib.dumps(args,cmd)
self.__agentconn.tochild.close()
if debug:
print "NM4agent: waiting for response"
pass
retval = xmlrpclib.loads(self.__agentconn.fromchild.read())
if debug:
print "NM4agent: response = '%s'" % str(retval)
print "NM4: xmlrpc response(%s/%s): '%s'" % (self.nodeid,
self.IP,
str(retval))
pass
self.__agentconn.wait()
if debug:
print "NM4agent: _xcall complete"
print "NM4: xmlrpc done(%s/%s)" % (self.nodeid,self.IP)
pass
self._close()
except:
......@@ -193,12 +193,13 @@ class NM4agent:
def deliver_ticket(self,ticket):
if debug:
print "NM4agent: delivering ticket '%s'" % str(ticket)
print "NM4: deliver_ticket(%s/%s)" % (self.nodeid,self.IP)
return self._xcall('Ticket',(ticket,))
def create_sliver(self,slice_name,tries=2,interval=5):
if debug:
print "NM4agent: creating sliver for slice %s" % slice_name
print "NM4: create_sliver(%s/%s), slice %s" % (self.nodeid,self.IP,
slice_name)
pass
(success,rtries) = (False,tries)
while not success and rtries > 0:
......@@ -210,8 +211,8 @@ class NM4agent:
if rtries == 0:
raise
else:
print "Warning: create_sliver for slice %s failed" \
% slice_name
print "NM4: create_sliver(%s/%s) failed" \
% (self.nodeid,self.IP)
time.sleep(interval)
pass
pass
......@@ -220,13 +221,20 @@ class NM4agent:
def delete_sliver(self,slice_name):
if debug:
print "NM4agent: destroying sliver for slice %s" % slice_name
print "NM4: delete_sliver(%s/%s), slice %s" % (self.nodeid,self.IP,
slice_name)
return self._xcall('Destroy',(slice_name,))
def start_sliver(self,slice_name):
if debug:
print "NM4: start_sliver(%s/%s), slice %s" % (self.nodeid,self.IP,
slice_name)
return self._xcall('Start',(slice_name,))
def stop_sliver(self,slice_name):
if debug:
print "NM4: stop_sliver(%s/%s), slice %s" % (self.nodeid,self.IP,
slice_name)
return self._xcall('Stop',(slice_name,))
# NM v4 does not have a version method...
......@@ -245,6 +253,8 @@ class NMagent_wrapper:
# first try a tcp connection to the legacy NM port; if timeout,
# try default agent right away.
self.__agent = None
self.IP = IP
self.nodeid = nodeid
if DEF_NM_LEGACY_AGENT != None:
legacy_nm = False
......@@ -254,28 +264,29 @@ class NMagent_wrapper:
try:
#sock.connect((str(IP),int(DEF_NM_LEGACY_PORT)))
tmp_agent = DEF_NM_LEGACY_AGENT(IP,nodeid)
tmp_agent = DEF_NM_LEGACY_AGENT(self.IP,self.nodeid)
tmp_agent.version()
legacy_nm = True
if debug:
print "NM %s (%s) IS legacy" % (IP,nodeid)
print "NM on %s/%s is legacy." % (self.nodeid,self.IP)
pass
except:
print "NM on %s (%s) does not appear to be legacy." % (IP,
nodeid)
if debug:
print "NM on %s/%s does not appear to be legacy." \
% (self.nodeid,self.IP)
#traceback.print_exc()
pass
if legacy_nm:
self.__agent = DEF_NM_LEGACY_AGENT(IP,nodeid)
self.__agent = DEF_NM_LEGACY_AGENT(self.IP,self.nodeid)
pass
else:
self.__agent = DEF_NM_AGENT(IP,nodeid)
self.__agent = DEF_NM_AGENT(self.IP,self.nodeid)
pass
pass
else:
self.__agent = DEF_NM_AGENT(IP,nodeid)
self.__agent = DEF_NM_AGENT(self.IP,self.nodeid)
pass
pass
......@@ -301,31 +312,23 @@ class NMagent_wrapper:
try:
res = tryXmlrpcCmd(self.__agent.deliver_ticket,ticketdata)
if res[0] == 0:
print "Warning: while trying to deliver ticket for slice %s: %s" % (slicename,str(res[1]))
else:
if debug:
print "Ticket delivery succeeded for slice %s" % slicename
pass
print "Warning: deliver_ticket(%s/%s), slice %s: %s" \
% (self.nodeid,self.IP,slicename,str(res[1]))
pass
pass
except:
print "WARNING: exception while delivering ticket for slice %s" % slicename
traceback.print_exc()
print "Warning: deliver_ticket(%s/%s), slice %s: exception" \
"\n%s" \
% (self.nodeid,self.IP,slicename,
traceback.format_exc())
#traceback.print_exc()
pass
pass
res = tryXmlrpcCmd(self.__agent.create_sliver,arg)
if self.__agent.__class__ == NM4agent:
#
# XXX - fix later
#
# return the new way -- we don't want to store a ticket
# until rollout is mostly done.
return (res,'')
else:
if debug:
print "res is %s" % str(res)
pass
retval = (res,None)
try:
retval = (res,cPickle.dumps(res[1][0]))
......@@ -519,6 +522,13 @@ class PLCagent:
def AuthCheck(self):
return self.__server.AuthCheck(self.__auth)
def SliceAddAttribute(self,attrname,attrvalue):
if attrname == None or attrvalue == None \
or attrname == '' or attrvalue == '':
return 0
return self.__server.AddSliceAttribute(self.__auth,self.__slicename,
attrname,attrvalue)
pass # end of PLCagent class
......@@ -540,7 +550,7 @@ class mod_PLC4:
mod_PLC4.password = lines[1].strip('\n')
pass
except:
print "Failed to retrive master passwd from %s" % DEF_PLC_PASS_FILE
print "Failed to retrive passwd from %s" % DEF_PLC_PASS_FILE
raise
return
......@@ -589,6 +599,27 @@ class mod_PLC4:
print "Failed to add nodes to slice %s" % slice.slicename
raise
# XXX: this is currently locked out to pi/user roles, although the docs
# say otherwise, so we can't use it automatically yet.
#
# Add a proper_op, mount_dir, so that we can eventually replace
# our current rootball load mechanism with proper.
# NOTE: this is secure, even though it seems like we're not specifying
# any access control. ACLs consist of ".exportdir" and ".importdir"
# files in the vserver directories to be imported into ("reverse
# export") or exported.
#try:
# res = tryXmlrpcCmd(agent.SliceAddAttribute,('proper_op',
# 'mount_dir',))
# if debug:
# print "SliceAddAttribute result: %s" % str(res)
# pass
# pass
#except:
# print "Failed to add proper_op:mount_dir to slice %s" \
# % slice.slicename
# raise
(PLCticket,PLCticket_legacy) = ('','')
try:
# XXX - fix for new NM and rollout.
......@@ -741,9 +772,6 @@ class mod_PLC4:
res = tryXmlrpcCmd(plcagent.SliceNodesAdd, node.hostname,
OKstrs = ["already assigned"])
if debug:
print "mod_PLC4: createNode: res = %s" % str(res)
pass
# Make sure node is running compatible interface
# try:
......@@ -760,10 +788,6 @@ class mod_PLC4:
# pass
try:
if debug:
print "DEBUG: using ticketdata = '%s'" % str(ticketdata)
pass
res = node.nmagent.create_sliver(node.slice.slicename,ticketdata)
if debug:
print res
......@@ -772,15 +796,13 @@ class mod_PLC4:
realres = res[0]
if not realres[0] == 0:
raise RuntimeError, "create_sliver failed: %d, %s" % \
(realres[0], realres[1])
raise RuntimeError, "create_sliver(%s/%s) failed: %d, %s" % \
(node.nodeid,node.IP,realres[0], realres[1])
pass
except:
print "Failed to create sliver %s on slice %s" % \
(node.nodeid, node.slice.slicename)
if debug:
traceback.print_exc()
pass
print "create_sliver(%s/%s), slice %s: exception\n%s" \
% (node.nodeid,node.IP,node.slice.slicename,
traceback.format_exc())
# XXX: Can we clean up on the plab side here?
# delete_sliver requires an rcap, but we don't have one
# in this case (since sliver creation failed).
......@@ -812,8 +834,8 @@ class mod_PLC4:
raise RuntimeError, "delete_sliver failed: %d" % res[0]
pass
except:
print "Failed to release node %s from slice %s" % \
(node.nodeid, node.slice.slicename)
print "Failed to release node %s/%s from slice %s" % \
(node.nodeid,node.IP,node.slice.slicename)
raise
return res
......@@ -852,8 +874,6 @@ class mod_PLC4:
# GetSlices in PLC 4 doesn't give you everything if you ask for
# nothing.
#
if debug:
print "calling getSliceExpTime with slicename %s" % slicename
sdict = tryXmlrpcCmd(agent.SliceInfo,[slicename])
# bug in PLC return filter...
# ([slicename],['name','expires']))
......
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