tag_type.add_role(role_obj)
except:
# xxx todo find a more appropriate way of notifying this
- print "Accessor.locate_or_create_tag: Could not add role %r to tag_type %s"%(role,tagname)
+ print >> log, "Accessor.locate_or_create_tag: Could not add role %r to tag_type %s"%(role,tagname)
self.set_cache(tagname,tag_type)
return tag_type
clip_part += " ORDER BY " + ",".join(sorts)
if clips:
clip_part += " " + " ".join(clips)
- if Filter.debug: print 'Filter.sql: where_part=',where_part,'clip_part',clip_part
+ if Filter.debug:
+ print >> log, 'Filter.sql: where_part=',where_part,'clip_part',clip_part
return (where_part,clip_part)
where_part += " %s %s(%s)" %(self.join_with,self.negation[k],method(self,self.local[k]))
except Exception,e:
raise PLCInvalidArgument,"LeaseFilter: something wrong with filter key %s, val was %r -- %r"%(k,v,e)
- if Filter.debug: print 'LeaseFilter.sql: where_part=',where_part,'clip_part',clip_part
+ if Filter.debug:
+ print >> log, 'LeaseFilter.sql: where_part=',where_part,'clip_part',clip_part
return (where_part,clip_part)
######## xxx not sure where this belongs yet
from PLC.Namespace import email_to_hrn
from PLC.TagTypes import TagTypes
+from PLC.Debug import log
+
class AddPersonToSite(Method):
"""
Adds the specified person to the specified site. If the person is
person_tag['value'] = hrn
person_tag.sync()
except Exception,e:
- print "BEG Warning, cannot maintain person's hrn, %s"%e
+ print >> log, "BEG Warning, cannot maintain person's hrn, %s"%e
import traceback
- traceback.print_exc()
- print "END Warning, cannot maintain person's hrn, %s"%e
+ traceback.print_exc(file=log)
+ print >> log, "END Warning, cannot maintain person's hrn, %s"%e
return 1
from PLC.Methods.AddSliceTag import AddSliceTag
from PLC.Methods.UpdateSliceTag import UpdateSliceTag
+from PLC.Debug import log
+
can_update = ['name', 'instantiation', 'url', 'description', 'max_nodes']
class AddSlice(Method):
for value in values:
AddSliceTag(self.api).__call__(auth,slice['slice_id'],'vsys',value)
except:
- print "Could not set vsys tags as configured in PLC_VSYS_DEFAULTS"
+ print >> log, "Could not set vsys tags as configured in PLC_VSYS_DEFAULTS"
import traceback
- traceback.print_exc()
+ traceback.print_exc(file=log)
self.event_objects = {'Slice': [slice['slice_id']]}
self.message = "Slice %d created" % slice['slice_id']
from PLC.InterfaceTags import InterfaceTag, InterfaceTags
from PLC.NodeTags import NodeTag, NodeTags
+from PLC.Debug import log
+
from PLC.Accessors.Accessors_standard import * # import node accessors
# could not define this in the class..
def cleantrash (self):
for file in self.trash:
if self.DEBUG:
- print 'DEBUG -- preserving',file
+ print >> log, 'DEBUG -- preserving',file
else:
os.unlink(file)
log_file)
if self.DEBUG:
- print "The build command line is %s" % command
+ print >> log, "The build command line is %s" % command
return command
raise PLCInvalidArgument, "No such node %r"%node_id_or_hostname
node = nodes[0]
- if self.DEBUG: print "%s required on node %s. Node type is: %s" \
+ if self.DEBUG:
+ print >> log, "%s requested on node %s. Node type is: %s" \
% (action, node['node_id'], node['node_type'])
# check the required action against the node type
result = file(node_image).read()
self.trash.append(node_image)
self.cleantrash()
- return base64.b64encode(result)
+ print >> log, "GetBootMedium - done with build.sh"
+ encoded_result = base64.b64encode(result)
+ print >> log, "GetBootMedium - done with base64 encoding - lengths=%s - %s"\
+ %(len(result),len(encoded_result))
+ return encoded_result
except:
self.cleantrash()
raise
for assign in assigns:
(left,right)=[x.strip() for x in assign.split(':')]
if right not in GetNodeFlavour.known_virts:
- print "GetNodeFlavour, unknown 'virt' %s - ignored" % right
+ print >> log, "GetNodeFlavour, unknown 'virt' %s - ignored" % right
continue
for fcdistro in [ x.strip() for x in left.split(',')]:
map[fcdistro]=right
except:
- print "GetNodeFlavour, issue with parsing PLC_FLAVOUR_VIRT_MAP=%s - returning '%s'"%\
+ print >> log, "GetNodeFlavour, issue with parsing PLC_FLAVOUR_VIRT_MAP=%s - returning '%s'"%\
(self.api.config.PLC_FLAVOUR_VIRT_MAP,GetNodeFlavour.default_virt)
- traceback.print_exc()
+ traceback.print_exc(file=log)
return GetNodeFlavour.default_virt
# print 'virt_from_virt_map, using map',map
if node_fcdistro in map: return map[node_fcdistro]
file_lock.unlock()
message("RefreshPeer caught exception - BEG")
import traceback
- traceback.print_exc()
+ traceback.print_exc(file=log)
message("RefreshPeer caught exception - END")
raise Exception, e
file_lock.unlock()
return True
else:
result=True
- print 'COMPARING ',
+# print >> log, 'COMPARING ',
for column in columns:
test= object[column] == peer_object[column]
- print column,test,
+# print >> log, column,test,
if not test: result=False
- print '=>',result
+# print >> log, '=>',result
return result
# Add/update new/existing objects
if UpdateLeases.debug:
print 'lease_fields',lease_fields
for k in [ 't_from', 't_until'] :
- if k in lease_fields: print k,'aka',Timestamp.sql_validate_utc(lease_fields[k])
+ if k in lease_fields:
+ print k,'aka',Timestamp.sql_validate_utc(lease_fields[k])
lease.update(lease_fields)
lease.sync()
tags = {'hrn': hrn}
Node(self.api, node).update_tags(tags)
except:
- print >>log, "WARNING: (beg) could not find out hrn on hostname=%s"%node['hostname']
- traceback.print_exc(5,log)
- print >>log, "WARNING: (end) could not find out hrn on hostname=%s"%node['hostname']
+ print >> log, "WARNING: (beg) could not find out hrn on hostname=%s"%node['hostname']
+ traceback.print_exc(5,file=log)
+ print >> log, "WARNING: (end) could not find out hrn on hostname=%s"%node['hostname']
def remove_node(self, node, commit = True):
"""