Does anyone have any idea how to work around the following error?

yaml.constructor.ConstructorError: expected a mapping node, but found
scalar
  in "/etc/puppet/reports/albacore/201108292003.yaml", line 3, column
5

i've created classes to handle all the mapping node data (99% of the
puppet report), but a few lines have this scalar node data that I have
no idea how to handle/convert.  Here are the classes for the mapping
nodes:

class PuppetReport(yaml.YAMLObject):
  yaml_tag = u'!ruby/object:Puppet::Transaction::Report'
  def __init__(self, data):
    self.host = data["host"]
    self.logs = PuppetLog(data["logs"])
    self.metrics = PuppetMetrics(data["metrics"])
    self.time = data["time"]
    self.external_times = ruby_sym(data["external_times"])
    self.resource_statuses =
PuppetResourceStatus(data["resource_statuses"])
  def __repr__(self):
    return "(host=%r, logs=%r, metrics=%r, time=%r)" % (self.host,
self.logs, self.metrics, self.time)

class ruby_sym(yaml.YAMLObject):
  yaml_tag = u'!ruby/sym'
  def __init__(self):
    self.attr = attr
  def __repr__(self):
    return "(attr=%r)" % (self.attr)

class PuppetLog(yaml.YAMLObject):
  yaml_tag = u'!ruby/object:Puppet::Util::Log'
  def __init__(self, log):
    self.source = log["source"]
    self.message = log["message"]
    self.tags = log["tags"]
    self.time = log["time"]
  def __repr__(self):
    return "(source=%r, message=%r, tags=%r, time=%r)" % (self.source,
self.message, self.tags, self.time)

class PuppetMetrics(yaml.YAMLObject):
  def __init__(self, metric):
     self.time = submetric(metric["time"])
     self.resources = submetric(metric["resource"])
     self.changes = submetric(metric["changes"])
     self.events = submetric(metric["events"])
  def __repr__(self):
    return "(time=%r, resource=%r, changes=%r, events=%r)" %
(self.time, self.resource, self.changes, self.events)

class submetric(yaml.YAMLObject):
  yaml_tag = u'!ruby/object:Puppet::Util::Metric'
  def __init__(self, submetric):
    self.label = submetric["label"]
    self.name = submetric["name"]
    self.values = submetric["values"]
  def __repr__(self):
    return "(label=%r, name=%r, values=%r)" % (self.label, self.name,
self.values)

class PuppetResourceStatus(yaml.YAMLObject):
  yaml_tag = u'!ruby/object:Puppet::Resource::Status'
  def __init__(self, resource_status):
    self.evaluation_time = resource_status["evaluation_time"]
    self.events = resource_status["events"]
    self.file = resource_status["file"]
    self.line = resource_status["line"]
    self.resource = resource_status["resource"]
    self.source_description = resource_status["source_description"]
    self.tags = resource_status["tags"]
    self.time = resource_status["time"]
    self.version = resource_status["version"]
  def __repr__(self):
    return "(evaluation=%r, events=%r, file=%r, line=%r, resource=%r,
source_description=%r, tags=%r, time=%r, version=%r)" %
(self.evaluation, self.events, self.file, self.line, self.resource,
self.source_description, self.tags, self.time, self.version)


-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to