diff options
author | Max Martin <max@puppetlabs.com> | 2011-04-21 16:47:44 -0700 |
---|---|---|
committer | Max Martin <max@puppetlabs.com> | 2011-04-21 16:47:44 -0700 |
commit | 17d176b9a9be0d85f74b61d67ab6ad0f76013dbc (patch) | |
tree | 6cdb41b17c78072c0b36fd117f598109010fe68d | |
parent | 3c2f66d56c000d3c28d7752aa74a3574a1f6dc50 (diff) | |
download | puppet-17d176b9a9be0d85f74b61d67ab6ad0f76013dbc.tar.gz puppet-17d176b9a9be0d85f74b61d67ab6ad0f76013dbc.tar.xz puppet-17d176b9a9be0d85f74b61d67ab6ad0f76013dbc.zip |
Revert "Adding json support to Puppet::Node"
This reverts commit d3c94e62386ec03617015f6e6269b1de805954ea.
The JSON patch series has caused problems with the inventory service,
and further discussion is needed to decide how to serialize objects to
PSON with regards to future compatibility.
Conflicts (Manually resolved):
spec/unit/node_spec.rb
Paired-with: Matt Robinson <matt@puppetlabs.com>
-rw-r--r-- | lib/puppet/node.rb | 23 | ||||
-rwxr-xr-x | spec/unit/node_spec.rb | 63 |
2 files changed, 0 insertions, 86 deletions
diff --git a/lib/puppet/node.rb b/lib/puppet/node.rb index 4bd4d1de6..5b0a98615 100644 --- a/lib/puppet/node.rb +++ b/lib/puppet/node.rb @@ -20,29 +20,6 @@ class Puppet::Node attr_accessor :name, :classes, :source, :ipaddress, :parameters attr_reader :time - def self.from_pson(pson) - raise ArgumentError, "No name provided in pson data" unless name = pson['name'] - - node = new(name) - node.classes = pson['classes'] - node.parameters = pson['parameters'] - node.environment = pson['environment'] - node - end - - def to_pson(*args) - result = { - 'document_type' => "Puppet::Node", - 'data' => {} - } - result['data']['name'] = name - result['data']['classes'] = classes unless classes.empty? - result['data']['parameters'] = parameters unless parameters.empty? - result['data']['environment'] = environment.name - - result.to_pson(*args) - end - def environment return super if @environment diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb index e8f826dca..169a9cdcf 100755 --- a/spec/unit/node_spec.rb +++ b/spec/unit/node_spec.rb @@ -36,69 +36,6 @@ describe Puppet::Node do node.environment.name.should == :bar end end - - describe "when converting to json" do - before do - @node = Puppet::Node.new("mynode") - end - - it "should provide its name" do - @node.should set_json_attribute('name').to("mynode") - end - - it "should include the classes if set" do - @node.classes = %w{a b c} - @node.should set_json_attribute("classes").to(%w{a b c}) - end - - it "should not include the classes if there are none" do - @node.should_not set_json_attribute('classes') - end - - it "should include parameters if set" do - @node.parameters = {"a" => "b", "c" => "d"} - @node.should set_json_attribute('parameters').to({"a" => "b", "c" => "d"}) - end - - it "should not include the parameters if there are none" do - @node.should_not set_json_attribute('parameters') - end - - it "should include the environment" do - @node.environment = "production" - @node.should set_json_attribute('environment').to('production') - end - end - - describe "when converting from json" do - before do - @node = Puppet::Node.new("mynode") - @format = Puppet::Network::FormatHandler.format('pson') - end - - def from_json(json) - @format.intern(Puppet::Node, json) - end - - it "should set its name" do - Puppet::Node.should read_json_attribute('name').from(@node.to_pson).as("mynode") - end - - it "should include the classes if set" do - @node.classes = %w{a b c} - Puppet::Node.should read_json_attribute('classes').from(@node.to_pson).as(%w{a b c}) - end - - it "should include parameters if set" do - @node.parameters = {"a" => "b", "c" => "d"} - Puppet::Node.should read_json_attribute('parameters').from(@node.to_pson).as({"a" => "b", "c" => "d"}) - end - - it "should include the environment" do - @node.environment = "production" - Puppet::Node.should read_json_attribute('environment').from(@node.to_pson).as(Puppet::Node::Environment.new(:production)) - end - end end describe Puppet::Node, "when initializing" do |