summaryrefslogtreecommitdiff
path: root/chef-server-webui/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'chef-server-webui/app/controllers')
-rw-r--r--chef-server-webui/app/controllers/databag_items.rb4
-rw-r--r--chef-server-webui/app/controllers/nodes.rb6
-rw-r--r--chef-server-webui/app/controllers/roles.rb16
3 files changed, 13 insertions, 13 deletions
diff --git a/chef-server-webui/app/controllers/databag_items.rb b/chef-server-webui/app/controllers/databag_items.rb
index 00310008f0..c3da721740 100644
--- a/chef-server-webui/app/controllers/databag_items.rb
+++ b/chef-server-webui/app/controllers/databag_items.rb
@@ -38,7 +38,7 @@ class DatabagItems < Application
begin
@databag_item = Chef::DataBagItem.new
@databag_item.data_bag params[:databag_id]
- @databag_item.raw_data = JSON.parse(params[:json_data])
+ @databag_item.raw_data = Chef::JSON.from_json(params[:json_data])
raise ArgumentError, "Updating id is not allowed" unless @databag_item.raw_data['id'] == params[:id] #to be consistent with other objects, changing id is not allowed.
@databag_item.save
redirect(url(:databag_databag_items, :databag_id => params[:databag_id], :id => @databag_item.name), :message => { :notice => "Updated Databag Item #{@databag_item.name}" })
@@ -61,7 +61,7 @@ class DatabagItems < Application
@databag_name = params[:databag_id]
@databag_item = Chef::DataBagItem.new
@databag_item.data_bag @databag_name
- @databag_item.raw_data = JSON.parse(params[:json_data])
+ @databag_item.raw_data = Chef::JSON.from_json(params[:json_data])
@databag_item.create
redirect(url(:databag_databag_items, :databag_id => @databag_name), :message => { :notice => "Databag item created successfully" })
rescue => e
diff --git a/chef-server-webui/app/controllers/nodes.rb b/chef-server-webui/app/controllers/nodes.rb
index f2b9cbb30e..f28ccac668 100644
--- a/chef-server-webui/app/controllers/nodes.rb
+++ b/chef-server-webui/app/controllers/nodes.rb
@@ -89,14 +89,14 @@ class Nodes < Application
begin
@node = Chef::Node.new
@node.name params[:name]
- @node.normal_attrs = JSON.parse(params[:attributes])
+ @node.normal_attrs = Chef::JSON.from_json(params[:attributes])
@node.run_list.reset!(params[:for_node] ? params[:for_node] : [])
raise ArgumentError, "Node name cannot be blank" if (params[:name].nil? || params[:name].length==0)
@node.create
redirect(url(:nodes), :message => { :notice => "Created Node #{@node.name}" })
rescue => e
Chef::Log.error("#{e}\n#{e.backtrace.join("\n")}")
- @node.normal_attrs = JSON.parse(params[:attributes])
+ @node.normal_attrs = Chef::JSON.from_json(params[:attributes])
@available_recipes = get_available_recipes
@available_roles = Chef::Role.list.keys.sort
@node.run_list params[:for_node]
@@ -110,7 +110,7 @@ class Nodes < Application
begin
@node = Chef::Node.load(params[:id])
@node.run_list.reset!(params[:for_node] ? params[:for_node] : [])
- @node.normal_attrs = JSON.parse(params[:attributes])
+ @node.normal_attrs = Chef::JSON.from_json(params[:attributes])
@node.save
@_message = { :notice => "Updated Node" }
render :show
diff --git a/chef-server-webui/app/controllers/roles.rb b/chef-server-webui/app/controllers/roles.rb
index 12a663912b..bdf3186124 100644
--- a/chef-server-webui/app/controllers/roles.rb
+++ b/chef-server-webui/app/controllers/roles.rb
@@ -90,8 +90,8 @@ class Roles < Application
@role.name(params[:name])
@role.run_list(params[:for_role] ? params[:for_role] : [])
@role.description(params[:description]) if params[:description] != ''
- @role.default_attributes(JSON.parse(params[:default_attributes])) if params[:default_attributes] != ''
- @role.override_attributes(JSON.parse(params[:override_attributes])) if params[:override_attributes] != ''
+ @role.default_attributes(Chef::JSON.from_json(params[:default_attributes])) if params[:default_attributes] != ''
+ @role.override_attributes(Chef::JSON.from_json(params[:override_attributes])) if params[:override_attributes] != ''
@role.create
redirect(url(:roles), :message => { :notice => "Created Role #{@role.name}" })
rescue => e
@@ -99,8 +99,8 @@ class Roles < Application
@available_recipes = get_available_recipes
@available_roles = Chef::Role.list.keys.sort
@role = Chef::Role.new
- @role.default_attributes(JSON.parse(params[:default_attributes])) if params[:default_attributes] != ''
- @role.override_attributes(JSON.parse(params[:override_attributes])) if params[:override_attributes] != ''
+ @role.default_attributes(Chef::JSON.from_json(params[:default_attributes])) if params[:default_attributes] != ''
+ @role.override_attributes(Chef::JSON.from_json(params[:override_attributes])) if params[:override_attributes] != ''
@run_list = Chef::RunList.new.reset!(Array(params[:for_role]))
@_message = { :error => "Could not create role" }
render :new
@@ -113,8 +113,8 @@ class Roles < Application
@role = Chef::Role.load(params[:id])
@role.run_list(params[:for_role] ? params[:for_role] : [])
@role.description(params[:description]) if params[:description] != ''
- @role.default_attributes(JSON.parse(params[:default_attributes])) if params[:default_attributes] != ''
- @role.override_attributes(JSON.parse(params[:override_attributes])) if params[:override_attributes] != ''
+ @role.default_attributes(Chef::JSON.from_json(params[:default_attributes])) if params[:default_attributes] != ''
+ @role.override_attributes(Chef::JSON.from_json(params[:override_attributes])) if params[:override_attributes] != ''
@role.save
@_message = { :notice => "Updated Role" }
render :show
@@ -124,8 +124,8 @@ class Roles < Application
@available_roles = Chef::Role.list.keys.sort
@run_list = Chef::RunList.new.reset!( Array(params[:for_role]))
Chef::Log.error(@run_list.inspect)
- @role.default_attributes(JSON.parse(params[:default_attributes])) if params[:default_attributes] != ''
- @role.override_attributes(JSON.parse(params[:override_attributes])) if params[:override_attributes] != ''
+ @role.default_attributes(Chef::JSON.from_json(params[:default_attributes])) if params[:default_attributes] != ''
+ @role.override_attributes(Chef::JSON.from_json(params[:override_attributes])) if params[:override_attributes] != ''
@_message = {:error => "Could not update role #{params[:id]}"}
render :edit
end