Sorry for being off topic. am trying the following and yaml fails to construct the object: The inventory document, from Puppet dashboard inventory service, looks like: --- !ruby/object:Puppet::Node::Facts name: pirates.uis.example.com values: productname: VMware Virtual Platform kernelmajversion: "2.6" My code: class PuppetFacts(yaml.YAMLObject): yaml_tag = u''!ruby/object:Puppet::Node::Facts'' def __init__(self, name, values): self.name = name self.values = values The attempt to load the doc results in: ConstructorError: could not determine a constructor for the tag ''!ruby/object:Puppet::Node::Facts'' in "<byte string>", line 1, column 5 Thanks a lot, Mohamed. -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Wed, 12 Oct 2011 11:01:28 -0400, Mohamed Lrhazi wrote:> > Sorry for being off topic. am trying the following and yaml fails to > construct the object: > > The inventory document, from Puppet dashboard inventory service, looks like: > > --- !ruby/object:Puppet::Node::Facts > name: pirates.uis.example.com > values: > productname: VMware Virtual Platform > kernelmajversion: "2.6" > > > My code: > > class PuppetFacts(yaml.YAMLObject): > yaml_tag = u''!ruby/object:Puppet::Node::Facts'' > def __init__(self, name, values): > self.name = name > self.values = values > > > The attempt to load the doc results in: > > > ConstructorError: could not determine a constructor for the tag > ''!ruby/object:Puppet::Node::Facts'' > in "<byte string>", line 1, column 5 > > > Thanks a lot, > Mohamed. >Hm. Looks like you''re doing exactly what was suggested in a couple of older threads[0][1] about exactly this kind of issue. Could it be a loading issue where your class isn''t actually getting loaded? [0] https://groups.google.com/d/topic/puppet-dev/bWMaEHZIBNg/discussion [1] https://groups.google.com/forum/#!topic/puppet-users/7e2modoyywA -- Jacob Helwig
On Wed, Oct 12, 2011 at 5:04 PM, Jacob Helwig <jacob@puppetlabs.com> wrote:> On Wed, 12 Oct 2011 11:01:28 -0400, Mohamed Lrhazi wrote: >> >> Sorry for being off topic. am trying the following and yaml fails to >> construct the object: >> >> The inventory document, from Puppet dashboard inventory service, looks like: >> >> --- !ruby/object:Puppet::Node::Facts >> name: pirates.uis.example.com >> values: >> productname: VMware Virtual Platform >> kernelmajversion: "2.6" >> >> >> My code: >> >> class PuppetFacts(yaml.YAMLObject): >> yaml_tag = u''!ruby/object:Puppet::Node::Facts'' >> def __init__(self, name, values): >> self.name = name >> self.values = values >> >> >> The attempt to load the doc results in: >> >> >> ConstructorError: could not determine a constructor for the tag >> ''!ruby/object:Puppet::Node::Facts'' >> in "<byte string>", line 1, column 5 >> >> >> Thanks a lot, >> Mohamed. >> > > Hm. Looks like you''re doing exactly what was suggested in a couple of > older threads[0][1] about exactly this kind of issue. > > Could it be a loading issue where your class isn''t actually getting > loaded? > > [0] https://groups.google.com/d/topic/puppet-dev/bWMaEHZIBNg/discussion > [1] https://groups.google.com/forum/#!topic/puppet-users/7e2modoyywA > > -- > Jacob Helwig >It does sound like it... am have not used the python yaml lib before... Here is an entire script reproducing the issue: http://paste.ubuntu.com/706994/ Thanks a lot, Mohamed. -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Wed, 12 Oct 2011 17:13:36 -0400, Mohamed Lrhazi wrote:> > On Wed, Oct 12, 2011 at 5:04 PM, Jacob Helwig <jacob@puppetlabs.com> wrote: > > On Wed, 12 Oct 2011 11:01:28 -0400, Mohamed Lrhazi wrote: > >> > >> Sorry for being off topic. am trying the following and yaml fails to > >> construct the object: > >> > >> The inventory document, from Puppet dashboard inventory service, looks like: > >> > >> --- !ruby/object:Puppet::Node::Facts > >> name: pirates.uis.example.com > >> values: > >> productname: VMware Virtual Platform > >> kernelmajversion: "2.6" > >> > >> > >> My code: > >> > >> class PuppetFacts(yaml.YAMLObject): > >> yaml_tag = u''!ruby/object:Puppet::Node::Facts'' > >> def __init__(self, name, values): > >> self.name = name > >> self.values = values > >> > >> > >> The attempt to load the doc results in: > >> > >> > >> ConstructorError: could not determine a constructor for the tag > >> ''!ruby/object:Puppet::Node::Facts'' > >> in "<byte string>", line 1, column 5 > >> > >> > >> Thanks a lot, > >> Mohamed. > >> > > > > Hm. Looks like you''re doing exactly what was suggested in a couple of > > older threads[0][1] about exactly this kind of issue. > > > > Could it be a loading issue where your class isn''t actually getting > > loaded? > > > > [0] https://groups.google.com/d/topic/puppet-dev/bWMaEHZIBNg/discussion > > [1] https://groups.google.com/forum/#!topic/puppet-users/7e2modoyywA > > > > -- > > Jacob Helwig > > > > It does sound like it... am have not used the python yaml lib before... > > Here is an entire script reproducing the issue: http://paste.ubuntu.com/706994/ > > Thanks a lot, > Mohamed. >With everything in the same file, it shouldn''t be the kind of loading issue I was thinking about. It''s been so long since I''ve done any Python that I don''t think I''ll be much help. Hopefully someone with Python skills sharper than my extremely rusty ones will chime in. -- Jacob Helwig
I guessed my way into making this work, by massaging puppet''s yaml to fit my understanding of Python''s yaml lib: facts_raw2 = facts_raw.replace( """--- !ruby/object:Puppet::Node::Facts""", """--- !!python/object:__main__.PuppetFacts""") facts_raw2 = facts_raw2.replace(''"--- !ruby/sym _timestamp":'', ''timestamp:'') Thanks, Mohamed. On Wed, Oct 12, 2011 at 5:23 PM, Jacob Helwig <jacob@puppetlabs.com> wrote:> On Wed, 12 Oct 2011 17:13:36 -0400, Mohamed Lrhazi wrote: >> >> On Wed, Oct 12, 2011 at 5:04 PM, Jacob Helwig <jacob@puppetlabs.com> wrote: >> > On Wed, 12 Oct 2011 11:01:28 -0400, Mohamed Lrhazi wrote: >> >> >> >> Sorry for being off topic. am trying the following and yaml fails to >> >> construct the object: >> >> >> >> The inventory document, from Puppet dashboard inventory service, looks like: >> >> >> >> --- !ruby/object:Puppet::Node::Facts >> >> name: pirates.uis.example.com >> >> values: >> >> productname: VMware Virtual Platform >> >> kernelmajversion: "2.6" >> >> >> >> >> >> My code: >> >> >> >> class PuppetFacts(yaml.YAMLObject): >> >> yaml_tag = u''!ruby/object:Puppet::Node::Facts'' >> >> def __init__(self, name, values): >> >> self.name = name >> >> self.values = values >> >> >> >> >> >> The attempt to load the doc results in: >> >> >> >> >> >> ConstructorError: could not determine a constructor for the tag >> >> ''!ruby/object:Puppet::Node::Facts'' >> >> in "<byte string>", line 1, column 5 >> >> >> >> >> >> Thanks a lot, >> >> Mohamed. >> >> >> > >> > Hm. Looks like you''re doing exactly what was suggested in a couple of >> > older threads[0][1] about exactly this kind of issue. >> > >> > Could it be a loading issue where your class isn''t actually getting >> > loaded? >> > >> > [0] https://groups.google.com/d/topic/puppet-dev/bWMaEHZIBNg/discussion >> > [1] https://groups.google.com/forum/#!topic/puppet-users/7e2modoyywA >> > >> > -- >> > Jacob Helwig >> > >> >> It does sound like it... am have not used the python yaml lib before... >> >> Here is an entire script reproducing the issue: http://paste.ubuntu.com/706994/ >> >> Thanks a lot, >> Mohamed. >> > > With everything in the same file, it shouldn''t be the kind of loading > issue I was thinking about. > > It''s been so long since I''ve done any Python that I don''t think I''ll be > much help. Hopefully someone with Python skills sharper than my > extremely rusty ones will chime in. > > -- > Jacob Helwig >-- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.