chef 0.10.0.beta.10 → 0.10.0.qs.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. data/distro/arch/etc/conf.d/{chef-solr-indexer.conf → chef-expander.conf} +2 -2
  2. data/distro/arch/etc/rc.d/{chef-solr-indexer → chef-expander} +4 -4
  3. data/distro/common/html/chef-client.8.html +1 -1
  4. data/distro/common/html/{chef-expander-cluster.8.html → chef-expander.8.html} +11 -11
  5. data/distro/common/html/chef-expanderctl.8.html +1 -1
  6. data/distro/common/html/chef-server-webui.8.html +1 -1
  7. data/distro/common/html/chef-server.8.html +1 -1
  8. data/distro/common/html/chef-solo.8.html +1 -1
  9. data/distro/common/html/chef-solr.8.html +1 -1
  10. data/distro/common/html/knife-bootstrap.1.html +1 -1
  11. data/distro/common/html/knife-client.1.html +1 -1
  12. data/distro/common/html/knife-configure.1.html +1 -1
  13. data/distro/common/html/knife-cookbook-site.1.html +4 -3
  14. data/distro/common/html/knife-cookbook.1.html +1 -1
  15. data/distro/common/html/knife-data-bag.1.html +1 -1
  16. data/distro/common/html/knife-environment.1.html +1 -1
  17. data/distro/common/html/knife-exec.1.html +1 -1
  18. data/distro/common/html/knife-index.1.html +1 -1
  19. data/distro/common/html/knife-node.1.html +4 -4
  20. data/distro/common/html/knife-recipe.1.html +1 -1
  21. data/distro/common/html/knife-role.1.html +1 -1
  22. data/distro/common/html/knife-search.1.html +1 -1
  23. data/distro/common/html/knife-ssh.1.html +1 -1
  24. data/distro/common/html/knife-status.1.html +1 -1
  25. data/distro/common/html/knife-tag.1.html +1 -1
  26. data/distro/common/html/knife.1.html +1 -1
  27. data/distro/common/html/shef.1.html +1 -1
  28. data/distro/common/man/man1/knife-bootstrap.1 +1 -1
  29. data/distro/common/man/man1/knife-client.1 +1 -1
  30. data/distro/common/man/man1/knife-configure.1 +1 -1
  31. data/distro/common/man/man1/knife-cookbook-site.1 +5 -1
  32. data/distro/common/man/man1/knife-cookbook.1 +1 -1
  33. data/distro/common/man/man1/knife-data-bag.1 +1 -1
  34. data/distro/common/man/man1/knife-environment.1 +1 -1
  35. data/distro/common/man/man1/knife-exec.1 +1 -1
  36. data/distro/common/man/man1/knife-index.1 +1 -1
  37. data/distro/common/man/man1/knife-node.1 +1 -1
  38. data/distro/common/man/man1/knife-role.1 +1 -1
  39. data/distro/common/man/man1/knife-search.1 +1 -1
  40. data/distro/common/man/man1/knife-ssh.1 +1 -1
  41. data/distro/common/man/man1/knife-status.1 +1 -1
  42. data/distro/common/man/man1/knife-tag.1 +1 -1
  43. data/distro/common/man/man1/knife.1 +1 -1
  44. data/distro/common/man/man1/shef.1 +1 -1
  45. data/distro/common/man/man8/chef-client.8 +1 -1
  46. data/distro/common/man/man8/{chef-expander-cluster.8 → chef-expander.8} +5 -5
  47. data/distro/common/man/man8/chef-expanderctl.8 +1 -1
  48. data/distro/common/man/man8/chef-server-webui.8 +1 -1
  49. data/distro/common/man/man8/chef-server.8 +1 -1
  50. data/distro/common/man/man8/chef-solo.8 +1 -1
  51. data/distro/common/man/man8/chef-solr.8 +1 -1
  52. data/distro/common/markdown/man1/knife-cookbook-site.mkd +2 -0
  53. data/distro/common/markdown/man8/{chef-expander-cluster.mkd → chef-expander.mkd} +4 -4
  54. data/distro/debian/etc/default/{chef-solr-indexer → chef-expander} +2 -1
  55. data/distro/debian/etc/init.d/{chef-solr-indexer → chef-expander} +43 -43
  56. data/distro/debian/etc/init/chef-expander.conf +17 -0
  57. data/distro/redhat/etc/init.d/{chef-solr-indexer → chef-expander} +9 -9
  58. data/distro/redhat/etc/init.d/chef-server +2 -2
  59. data/distro/redhat/etc/init.d/chef-solr +1 -1
  60. data/distro/redhat/etc/logrotate.d/chef-expander +8 -0
  61. data/distro/redhat/etc/sysconfig/chef-expander +7 -0
  62. data/lib/chef.rb +1 -0
  63. data/lib/chef/api_client.rb +6 -0
  64. data/lib/chef/application.rb +5 -6
  65. data/lib/chef/application/client.rb +9 -0
  66. data/lib/chef/cookbook_uploader.rb +4 -1
  67. data/lib/chef/cookbook_version.rb +12 -15
  68. data/lib/chef/data_bag_item.rb +3 -3
  69. data/lib/chef/handler/error_report.rb +33 -0
  70. data/lib/chef/knife.rb +21 -4
  71. data/lib/chef/knife/bootstrap.rb +9 -5
  72. data/lib/chef/knife/bootstrap/archlinux-gems.erb +2 -1
  73. data/lib/chef/knife/bootstrap/centos5-gems.erb +9 -14
  74. data/lib/chef/knife/bootstrap/fedora13-gems.erb +6 -13
  75. data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +6 -15
  76. data/lib/chef/knife/cookbook_list.rb +0 -1
  77. data/lib/chef/knife/cookbook_site_download.rb +26 -14
  78. data/lib/chef/knife/core/bootstrap_context.rb +81 -0
  79. data/lib/chef/knife/data_bag_create.rb +14 -12
  80. data/lib/chef/knife/data_bag_edit.rb +2 -2
  81. data/lib/chef/knife/data_bag_from_file.rb +2 -2
  82. data/lib/chef/knife/data_bag_show.rb +2 -2
  83. data/lib/chef/knife/search.rb +3 -0
  84. data/lib/chef/knife/ssh.rb +2 -0
  85. data/lib/chef/mixin/language.rb +1 -0
  86. data/lib/chef/monkey_patches/object.rb +9 -0
  87. data/lib/chef/provider/deploy.rb +1 -1
  88. data/lib/chef/provider/subversion.rb +1 -1
  89. data/lib/chef/recipe.rb +1 -0
  90. data/lib/chef/resource.rb +9 -8
  91. data/lib/chef/rest.rb +10 -6
  92. data/lib/chef/shell_out.rb +1 -1
  93. data/lib/chef/solr_query.rb +1 -1
  94. data/lib/chef/version.rb +1 -1
  95. metadata +16 -13
  96. data/distro/debian/etc/init/chef-solr-indexer.conf +0 -17
  97. data/distro/redhat/etc/logrotate.d/chef-solr-indexer +0 -8
  98. data/distro/redhat/etc/sysconfig/chef-solr-indexer +0 -7
@@ -8,13 +8,15 @@ if [ ! -f /usr/bin/chef-client ]; then
8
8
  cd rubygems-1.3.7
9
9
  ruby setup.rb --no-format-executable
10
10
  fi
11
- gem install ohai chef --no-rdoc --no-ri --verbose <%= '--prerelease' if @config[:prerelease] %>
11
+
12
+ gem install ohai --no-rdoc --no-ri --verbose
13
+ gem install chef --no-rdoc --no-ri --verbose <%= bootstrap_version_string %>
12
14
 
13
15
  mkdir -p /etc/chef
14
16
 
15
17
  (
16
18
  cat <<'EOP'
17
- <%= IO.read(Chef::Config[:validation_key]) %>
19
+ <%= validation_key %>
18
20
  EOP
19
21
  ) > /tmp/validation.pem
20
22
  awk NF /tmp/validation.pem > /etc/chef/validation.pem
@@ -22,18 +24,7 @@ rm /tmp/validation.pem
22
24
 
23
25
  (
24
26
  cat <<'EOP'
25
- log_level :info
26
- log_location STDOUT
27
- chef_server_url "<%= Chef::Config[:chef_server_url] %>"
28
- validation_client_name "<%= Chef::Config[:validation_client_name] %>"
29
- <% if @config[:chef_node_name] == nil %>
30
- # Using default node name (fqdn)
31
- <% else %>
32
- node_name "<%= @config[:chef_node_name] %>"
33
- <% end %>
34
- <% if Chef::Config[:environment] != nil %>
35
- environment "<%= Chef::Config[:environment]%>"
36
- <% end %>
27
+ <%= config_content %>
37
28
  EOP
38
29
  ) > /etc/chef/client.rb
39
30
 
@@ -43,4 +34,4 @@ cat <<'EOP'
43
34
  EOP
44
35
  ) > /etc/chef/first-boot.json
45
36
 
46
- /usr/bin/chef-client -j /etc/chef/first-boot.json'
37
+ <%= start_chef %>'
@@ -39,7 +39,6 @@ class Chef
39
39
  env = config[:environment]
40
40
  num_versions = config[:all_versions] ? "num_versions=all" : "num_versions=1"
41
41
  api_endpoint = env ? "/environments/#{env}/cookbooks?#{num_versions}" : "/cookbooks?#{num_versions}"
42
- ui.info("Showing latest versions. Use --show-all to list all available versions.") unless config[:all_versions]
43
42
  cookbook_versions = rest.get_rest(api_endpoint)
44
43
  format_cookbook_list_for_display(cookbook_versions).each do |line|
45
44
  ui.msg(line)
@@ -5,9 +5,9 @@
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
7
7
  # You may obtain a copy of the License at
8
- #
8
+ #
9
9
  # http://www.apache.org/licenses/LICENSE-2.0
10
- #
10
+ #
11
11
  # Unless required by applicable law or agreed to in writing, software
12
12
  # distributed under the License is distributed on an "AS IS" BASIS,
13
13
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -27,26 +27,38 @@ class Chef
27
27
  category "cookbook site"
28
28
 
29
29
  option :file,
30
- :short => "-f FILE",
31
- :long => "--file FILE",
32
- :description => "The filename to write to"
30
+ :short => "-f FILE",
31
+ :long => "--file FILE",
32
+ :description => "The filename to write to"
33
+
34
+ option :force,
35
+ :long => "--force",
36
+ :description => "Force download deprecated version"
33
37
 
34
38
  def run
35
- if @name_args.length == 1
36
- current = noauth_rest.get_rest("http://cookbooks.opscode.com/api/v1/cookbooks/#{name_args[0]}")
37
- cookbook_data = noauth_rest.get_rest(current["latest_version"])
38
- else
39
- cookbook_data = noauth_rest.get_rest("http://cookbooks.opscode.com/api/v1/cookbooks/#{name_args[0]}/versions/#{name_args[1].gsub('.', '_')}")
39
+ current = noauth_rest.get_rest("http://cookbooks.opscode.com/api/v1/cookbooks/#{name_args[0]}")
40
+ if current["deprecated"] == true
41
+ replacement = File.basename(current["replacement"])
42
+ ui.warn("DEPRECATION: This cookbook has been deprecated. It has been replaced by #{replacement}.")
43
+ unless config[:force]
44
+ ui.warn("Use --force to force download deprecated cookbook.")
45
+ return
46
+ end
40
47
  end
48
+ cookbook_data = if @name_args.length == 1
49
+ noauth_rest.get_rest(current["latest_version"])
50
+ else
51
+ noauth_rest.get_rest("http://cookbooks.opscode.com/api/v1/cookbooks/#{name_args[0]}/versions/#{name_args[1].gsub('.', '_')}")
52
+ end
41
53
 
42
54
  @version = cookbook_data['version']
43
-
44
- ui.info("Downloading #{@name_args[0]} from the cookbooks site at version #{cookbook_data['version']} to #{config[:file]}")
45
- noauth_rest.sign_on_redirect = false
46
- tf = noauth_rest.get_rest(cookbook_data["file"], true)
47
55
  unless config[:file]
48
56
  config[:file] = File.join(Dir.pwd, "#{@name_args[0]}-#{cookbook_data['version']}.tar.gz")
49
57
  end
58
+ ui.info("Downloading #{@name_args[0]} from the cookbooks site at version #{cookbook_data['version']} to #{config[:file]}")
59
+ noauth_rest.sign_on_redirect = false
60
+ tf = noauth_rest.get_rest(cookbook_data["file"], true)
61
+
50
62
  FileUtils.cp(tf.path, config[:file])
51
63
  ui.info("Cookbook saved: #{config[:file]}")
52
64
  end
@@ -0,0 +1,81 @@
1
+ #
2
+ # Author:: Daniel DeLeo (<dan@opscode.com>)
3
+ # Copyright:: Copyright (c) 2011 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'chef/run_list'
20
+ class Chef
21
+ class Knife
22
+ module Core
23
+ # Instances of BootstrapContext are the context objects (i.e., +self+) for
24
+ # bootstrap templates. For backwards compatability, they +must+ set the
25
+ # following instance variables:
26
+ # * @config - a hash of knife's config values
27
+ # * @run_list - the run list for the node to boostrap
28
+ #
29
+ class BootstrapContext
30
+
31
+ def initialize(config, run_list, chef_config)
32
+ @config = config
33
+ @run_list = run_list
34
+ @chef_config = chef_config
35
+ end
36
+
37
+ def bootstrap_version_string
38
+ if @config[:prerelease]
39
+ "--prerelease"
40
+ else
41
+ version = knife_config[:bootstrap_version] || Chef::VERSION
42
+ "--version #{version}"
43
+ end
44
+ end
45
+
46
+ def bootstrap_environment
47
+ @chef_config[:environment] || '_default'
48
+ end
49
+
50
+ def validation_key
51
+ IO.read(@chef_config[:validation_key])
52
+ end
53
+
54
+ def config_content
55
+ client_rb = <<-CONFIG
56
+ log_level :info
57
+ log_location STDOUT
58
+ chef_server_url "#{@chef_config[:chef_server_url]}"
59
+ validation_client_name "#{@chef_config[:validation_client_name]}"
60
+ CONFIG
61
+ if @config[:chef_node_name]
62
+ client_rb << %Q{node_name "#{@config[:chef_node_name]}"\n}
63
+ else
64
+ client_rb << "# Using default node name (fqdn)\n"
65
+ end
66
+ client_rb
67
+ end
68
+
69
+ def start_chef
70
+ "/usr/bin/chef-client -j /etc/chef/first-boot.json -E #{bootstrap_environment}"
71
+ end
72
+
73
+ def knife_config
74
+ @chef_config.key?(:knife) ? @chef_config[:knife] : {}
75
+ end
76
+
77
+ end
78
+ end
79
+ end
80
+ end
81
+
@@ -7,9 +7,9 @@
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
8
8
  # you may not use this file except in compliance with the License.
9
9
  # You may obtain a copy of the License at
10
- #
10
+ #
11
11
  # http://www.apache.org/licenses/LICENSE-2.0
12
- #
12
+ #
13
13
  # Unless required by applicable law or agreed to in writing, software
14
14
  # distributed under the License is distributed on an "AS IS" BASIS,
15
15
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,6 +25,7 @@ class Chef
25
25
 
26
26
  deps do
27
27
  require 'chef/data_bag'
28
+ require 'chef/encrypted_data_bag_item'
28
29
  end
29
30
 
30
31
  banner "knife data bag create BAG [ITEM] (options)"
@@ -36,7 +37,7 @@ class Chef
36
37
  :description => "The secret key to use to encrypt data bag item values"
37
38
 
38
39
  option :secret_file,
39
- :long => "--secret_file SECRET_FILE",
40
+ :long => "--secret-file SECRET_FILE",
40
41
  :description => "A file containing the secret key to use to encrypt data bag item values"
41
42
 
42
43
  def read_secret
@@ -49,7 +50,7 @@ class Chef
49
50
 
50
51
  def use_encryption
51
52
  if config[:secret] && config[:secret_file]
52
- stdout.puts "please specify only one of --secret, --secret_file"
53
+ stdout.puts "please specify only one of --secret, --secret-file"
53
54
  exit(1)
54
55
  end
55
56
  config[:secret] || config[:secret_file]
@@ -63,7 +64,7 @@ class Chef
63
64
  stdout.puts("You must specify a data bag name")
64
65
  exit 1
65
66
  end
66
-
67
+
67
68
  # create the data bag
68
69
  begin
69
70
  rest.post_rest("data", { "name" => @data_bag_name })
@@ -72,16 +73,17 @@ class Chef
72
73
  raise unless e.to_s =~ /^409/
73
74
  ui.info("Data bag #{@data_bag_name} already exists")
74
75
  end
75
-
76
+
76
77
  # if an item is specified, create it, as well
77
78
  if @data_bag_item_name
78
79
  create_object({ "id" => @data_bag_item_name }, "data_bag_item[#{@data_bag_item_name}]") do |output|
79
- item = if use_encryption
80
- Chef::EncryptedDataBagItem.encrypt_data_bag_item(output,
81
- read_secret)
82
- else
83
- output
84
- end
80
+ item = Chef::DataBagItem.from_hash(
81
+ if use_encryption
82
+ Chef::EncryptedDataBagItem.encrypt_data_bag_item(output, read_secret)
83
+ else
84
+ output
85
+ end)
86
+ item.data_bag(@data_bag_name)
85
87
  rest.post_rest("data/#{@data_bag_name}", item)
86
88
  end
87
89
  end
@@ -37,7 +37,7 @@ class Chef
37
37
  :description => "The secret key to use to encrypt data bag item values"
38
38
 
39
39
  option :secret_file,
40
- :long => "--secret_file SECRET_FILE",
40
+ :long => "--secret-file SECRET_FILE",
41
41
  :description => "A file containing the secret key to use to encrypt data bag item values"
42
42
 
43
43
  def read_secret
@@ -50,7 +50,7 @@ class Chef
50
50
 
51
51
  def use_encryption
52
52
  if config[:secret] && config[:secret_file]
53
- stdout.puts "please specify only one of --secret, --secret_file"
53
+ stdout.puts "please specify only one of --secret, --secret-file"
54
54
  exit(1)
55
55
  end
56
56
  config[:secret] || config[:secret_file]
@@ -40,7 +40,7 @@ class Chef
40
40
  :description => "The secret key to use to encrypt data bag item values"
41
41
 
42
42
  option :secret_file,
43
- :long => "--secret_file SECRET_FILE",
43
+ :long => "--secret-file SECRET_FILE",
44
44
  :description => "A file containing the secret key to use to encrypt data bag item values"
45
45
 
46
46
  def read_secret
@@ -53,7 +53,7 @@ class Chef
53
53
 
54
54
  def use_encryption
55
55
  if config[:secret] && config[:secret_file]
56
- stdout.puts "please specify only one of --secret, --secret_file"
56
+ stdout.puts "please specify only one of --secret, --secret-file"
57
57
  exit(1)
58
58
  end
59
59
  config[:secret] || config[:secret_file]
@@ -37,7 +37,7 @@ class Chef
37
37
  :description => "The secret key to use to decrypt data bag item values"
38
38
 
39
39
  option :secret_file,
40
- :long => "--secret_file SECRET_FILE",
40
+ :long => "--secret-file SECRET_FILE",
41
41
  :description => "A file containing the secret key to use to decrypt data bag item values"
42
42
 
43
43
  def read_secret
@@ -50,7 +50,7 @@ class Chef
50
50
 
51
51
  def use_encryption
52
52
  if config[:secret] && config[:secret_file]
53
- stdout.puts "please specify only one of --secret, --secret_file"
53
+ stdout.puts "please specify only one of --secret, --secret-file"
54
54
  exit(1)
55
55
  end
56
56
  config[:secret] || config[:secret_file]
@@ -24,6 +24,9 @@ class Chef
24
24
  class Search < Knife
25
25
 
26
26
  deps do
27
+ require 'chef/node'
28
+ require 'chef/environment'
29
+ require 'chef/api_client'
27
30
  require 'chef/search/query'
28
31
  end
29
32
 
@@ -27,6 +27,7 @@ class Chef
27
27
  require 'net/ssh/multi'
28
28
  require 'readline'
29
29
  require 'chef/search/query'
30
+ require 'chef/mixin/command'
30
31
  end
31
32
 
32
33
  attr_writer :password
@@ -300,6 +301,7 @@ class Chef
300
301
  end
301
302
 
302
303
  def run
304
+ extend Chef::Mixin::Command
303
305
 
304
306
  @longest = 0
305
307
 
@@ -19,6 +19,7 @@
19
19
  require 'chef/search/query'
20
20
  require 'chef/data_bag'
21
21
  require 'chef/data_bag_item'
22
+ require 'chef/encrypted_data_bag_item'
22
23
 
23
24
  class Chef
24
25
  module Mixin
@@ -0,0 +1,9 @@
1
+ class Object
2
+ unless new.respond_to?(:tap)
3
+ def tap
4
+ yield self
5
+ return self
6
+ end
7
+ end
8
+ end
9
+
@@ -307,7 +307,7 @@ class Chef
307
307
  gems = YAML.load(IO.read("#{release_path}/gems.yml"))
308
308
 
309
309
  gems.map do |g|
310
- r = Chef::Resource::GemPackage.new(g[:name])
310
+ r = Chef::Resource::GemPackage.new(g[:name], run_context)
311
311
  r.version g[:version]
312
312
  r.action :install
313
313
  r.source "http://gems.github.com"
@@ -31,7 +31,7 @@ class Chef
31
31
  def load_current_resource
32
32
  @current_resource = Chef::Resource::Subversion.new(@new_resource.name)
33
33
 
34
- unless [:export, :force_export].include?(@new_resource.action.first)
34
+ unless [:export, :force_export].include?(Array(@new_resource.action).first)
35
35
  if current_revision = find_current_revision
36
36
  @current_resource.revision current_revision
37
37
  end
@@ -88,6 +88,7 @@ class Chef
88
88
  def tag(*tags)
89
89
  if tags.length > 0
90
90
  tags.each do |tag|
91
+ tag = tag.to_s
91
92
  run_context.node[:tags] << tag unless run_context.node[:tags].include?(tag)
92
93
  end
93
94
  run_context.node[:tags]
@@ -70,6 +70,7 @@ F
70
70
 
71
71
  end
72
72
 
73
+ FORBIDDEN_IVARS = [:@run_context, :@node]
73
74
  HIDDEN_IVARS = [:@allowed_actions, :@resource_name, :@source_line, :@run_context, :@name, :@node]
74
75
 
75
76
  include Chef::Mixin::CheckHelper
@@ -320,7 +321,7 @@ F
320
321
  end
321
322
 
322
323
  def inspect
323
- ivars = instance_variables.map { |ivar| ivar.to_sym } - HIDDEN_IVARS
324
+ ivars = instance_variables.map { |ivar| ivar.to_sym } - FORBIDDEN_IVARS
324
325
  ivars.inject("<#{to_s}") do |str, ivar|
325
326
  str << " #{ivar}: #{instance_variable_get(ivar).inspect}"
326
327
  end << ">"
@@ -328,11 +329,10 @@ F
328
329
 
329
330
  # Serialize this object as a hash
330
331
  def to_json(*a)
332
+ safe_ivars = instance_variables.map { |ivar| ivar.to_sym } - FORBIDDEN_IVARS
331
333
  instance_vars = Hash.new
332
- self.instance_variables.each do |iv|
333
- unless iv == "@run_context"
334
- instance_vars[iv] = self.instance_variable_get(iv)
335
- end
334
+ safe_ivars.each do |iv|
335
+ instance_vars[iv.to_s.sub(/^@/, '')] = instance_variable_get(iv)
336
336
  end
337
337
  results = {
338
338
  'json_class' => self.class.name,
@@ -342,10 +342,11 @@ F
342
342
  end
343
343
 
344
344
  def to_hash
345
+ safe_ivars = instance_variables.map { |ivar| ivar.to_sym } - FORBIDDEN_IVARS
345
346
  instance_vars = Hash.new
346
- self.instance_variables.each do |iv|
347
+ safe_ivars.each do |iv|
347
348
  key = iv.to_s.sub(/^@/,'').to_sym
348
- instance_vars[key] = self.instance_variable_get(iv) unless (key == :run_context) || (key == :node)
349
+ instance_vars[key] = instance_variable_get(iv)
349
350
  end
350
351
  instance_vars
351
352
  end
@@ -444,7 +445,7 @@ F
444
445
  def json_create(o)
445
446
  resource = self.new(o["instance_vars"]["@name"])
446
447
  o["instance_vars"].each do |k,v|
447
- resource.instance_variable_set(k.to_sym, v)
448
+ resource.instance_variable_set("@#{k}".to_sym, v)
448
449
  end
449
450
  resource
450
451
  end