Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Death to Syck! Long live Psych

  • Loading branch information...
commit ad60ba5aa28d1628c4cfcf0a207b0d6aba42ceb1 1 parent 870cdbd
Alex Jackson and Amit Gupta authored
Showing with 298 additions and 313 deletions.
  1. +3 −3 aws/bin/ami
  2. +1 −1  bat/lib/deployment.rb
  3. +1 −1  bat/lib/stemcell.rb
  4. +1 −1  bat/spec/helpers/deployment_helper.rb
  5. +1 −1  blobstore_client/bin/blobstore_client_console
  6. +0 −2  bosh_agent/lib/bosh_agent.rb
  7. +2 −2 bosh_agent/lib/bosh_agent/apply_plan/job.rb
  8. +1 −1  bosh_agent/lib/bosh_agent/http_handler.rb
  9. +4 −4 bosh_agent/lib/bosh_agent/state.rb
  10. +7 −7 bosh_agent/spec/unit/apply_plan/job_spec.rb
  11. +1 −1  bosh_agent/spec/unit/heartbeat_spec.rb
  12. +1 −1  bosh_agent/spec/unit/message/drain_spec.rb
  13. +2 −2 bosh_agent/spec/unit/state_spec.rb
  14. +4 −4 bosh_aws_bootstrap/spec/functional/aws_spec.rb
  15. +2 −2 bosh_aws_bootstrap/spec/functional/bootstrap_spec.rb
  16. +2 −2 bosh_aws_bootstrap/spec/unit/bat_manifest_spec.rb
  17. +2 −2 bosh_aws_bootstrap/spec/unit/bosh_manifest_spec.rb
  18. +2 −2 bosh_aws_bootstrap/spec/unit/microbosh_manifest_spec.rb
  19. +1 −1  bosh_aws_cpi/bin/bosh_aws_console
  20. +0 −4 bosh_cli/lib/cli.rb
  21. +1 −1  bosh_cli/lib/cli/blob_manager.rb
  22. +1 −1  bosh_cli/lib/cli/commands/biff.rb
  23. +2 −2 bosh_cli/lib/cli/commands/deployment.rb
  24. +1 −1  bosh_cli/lib/cli/commands/job_management.rb
  25. +4 −4 bosh_cli/lib/cli/commands/job_rename.rb
  26. +1 −1  bosh_cli/lib/cli/commands/release.rb
  27. +1 −1  bosh_cli/lib/cli/commands/stemcell.rb
  28. +2 −2 bosh_cli/lib/cli/config.rb
  29. +1 −1  bosh_cli/lib/cli/core_ext.rb
  30. +3 −3 bosh_cli/lib/cli/deployment_helper.rb
  31. +4 −4 bosh_cli/lib/cli/release.rb
  32. +1 −1  bosh_cli/lib/cli/release_builder.rb
  33. +1 −1  bosh_cli/lib/cli/stemcell.rb
  34. +1 −1  bosh_cli/lib/cli/versions_index.rb
  35. +30 −32 bosh_cli/lib/cli/yaml_helper.rb
  36. +14 −0 bosh_cli/spec/assets/manifests/new_extra_changes_manifest.yml
  37. +15 −0 bosh_cli/spec/assets/manifests/new_extra_job_rename_manifest.yml
  38. +15 −0 bosh_cli/spec/assets/manifests/new_manifest.yml
  39. +15 −0 bosh_cli/spec/assets/manifests/new_manifest_missing_new_job.yml
  40. +14 −0 bosh_cli/spec/assets/manifests/new_manifest_with_some_deletions.yml
  41. +15 −0 bosh_cli/spec/assets/manifests/old_manifest.yml
  42. +5 −5 bosh_cli/spec/unit/blob_manager_spec.rb
  43. +1 −1  bosh_cli/spec/unit/cli_commands/base_command_spec.rb
  44. +1 −1  bosh_cli/spec/unit/cli_commands/cli_commands_spec.rb
  45. +6 −101 bosh_cli/spec/unit/cli_commands/job_rename_spec.rb
  46. +1 −1  bosh_cli/spec/unit/config_spec.rb
  47. +1 −1  bosh_cli/spec/unit/core_ext_spec.rb
  48. +2 −2 bosh_cli/spec/unit/deployment_helper_spec.rb
  49. +1 −1  bosh_cli/spec/unit/job_builder_spec.rb
  50. +2 −2 bosh_cli/spec/unit/release_builder_spec.rb
  51. +1 −1  bosh_deployer/lib/deployer/config.rb
  52. +3 −3 bosh_deployer/lib/deployer/instance_manager.rb
  53. +1 −1  bosh_deployer/lib/deployer/instance_manager/aws.rb
  54. +1 −1  bosh_deployer/lib/deployer/instance_manager/openstack.rb
  55. +1 −1  bosh_deployer/lib/deployer/specification.rb
  56. +1 −1  bosh_deployer/spec/functional/deployer_test_spec.rb
  57. +4 −4 bosh_deployer/spec/unit/aws/config_spec.rb
  58. +3 −3 bosh_deployer/spec/unit/aws/instance_manager_spec.rb
  59. +3 −3 bosh_deployer/spec/unit/config_spec.rb
  60. +3 −3 bosh_deployer/spec/unit/instance_mananager_spec.rb
  61. +4 −4 bosh_deployer/spec/unit/openstack/config_spec.rb
  62. +3 −3 bosh_deployer/spec/unit/openstack/instance_manager_spec.rb
  63. +3 −3 bosh_deployer/spec/unit/vcloud/config_spec.rb
  64. +3 −3 bosh_deployer/spec/unit/vcloud/instance_manager_spec.rb
  65. +1 −1  bosh_openstack_cpi/bin/bosh_openstack_console
  66. +1 −1  bosh_registry/lib/bosh_registry/yaml_helper.rb
  67. +2 −2 bosh_registry/spec/unit/runner_spec.rb
  68. +2 −2 bosh_vcloud_cpi/spec/spec_helper.rb
  69. +1 −1  director/bin/console
  70. +1 −1  director/bin/director
  71. +1 −1  director/bin/drain_workers
  72. +1 −1  director/bin/migrate
  73. +2 −2 director/bin/worker
  74. +1 −1  director/db/migrations/director/20110617211923_add_deployments_release_versions.rb
  75. +1 −1  director/lib/director.rb
  76. +1 −1  director/lib/director/configuration_hasher.rb
  77. +1 −1  director/lib/director/jobs/update_deployment.rb
  78. +2 −2 director/lib/director/jobs/update_release.rb
  79. +1 −1  director/lib/director/jobs/update_stemcell.rb
  80. +1 −1  director/spec/cpi/sandbox.rb
  81. +8 −8 director/spec/functional/director_controller_spec.rb
  82. +2 −2 director/spec/spec_helper.rb
  83. +1 −1  director/spec/unit/api_controller_spec.rb
  84. +1 −1  director/spec/unit/config_spec.rb
  85. +1 −1  director/spec/unit/jobs/delete_release_spec.rb
  86. +1 −1  director/spec/unit/jobs/update_deployment_spec.rb
  87. +1 −1  health_monitor/lib/health_monitor/yaml_helper.rb
  88. +1 −1  health_monitor/spec/unit/agent_manager_spec.rb
  89. +5 −5 package_compiler/lib/package_compiler/compiler.rb
  90. +2 −2 package_compiler/spec/unit/basic_spec.rb
  91. +2 −2 rake/spec.rake
  92. +5 −5 rake/stemcell.rake
  93. +1 −1  release/jobs/micro_aws/prepare
  94. +1 −1  release/jobs/micro_openstack/prepare
  95. +1 −1  release/jobs/micro_vcloud/prepare
  96. +1 −1  release/jobs/micro_vsphere/prepare
  97. +1 −1  release/jobs/utility/prepare
  98. +1 −1  ruby_vcloud_sdk/spec/spec_helper.rb
  99. +1 −1  simple_blobstore_server/bin/simple_blobstore_server
  100. +2 −2 spec/integration/cli_spec.rb
  101. +2 −2 spec/publish_ami.rb
  102. +1 −1  spec/spec_helper.rb
  103. +1 −1  stemcell_builder/stages/stemcell/apply.sh
  104. +1 −1  stemcell_builder/stages/stemcell_openstack/apply.sh
View
6 aws/bin/ami
@@ -14,7 +14,7 @@ REGIONS = %w[
]
config_file = ARGV[0]
-config = YAML.load_file(config_file)
+config = Psych.load_file(config_file)
fog = Bosh::Ami::Fog.new(config)
@@ -24,9 +24,9 @@ end
begin
File.open(config_file, "w") do |file|
- YAML.dump(config, file)
+ Psych.dump(config, file)
end
rescue => e
puts "failed to save host file: #{e.message}"
- puts YAML.dump(config)
+ puts Psych.dump(config)
end
View
2  bat/lib/deployment.rb
@@ -29,7 +29,7 @@ def generate_deployment_manifest(spec)
erb = ERB.new(load_template(@context.spec.cpi))
result = erb.result(@context.get_binding)
puts result if debug?
- @yaml = YAML::load(result)
+ @yaml = Psych::load(result)
store_manifest(result)
end
View
2  bat/lib/stemcell.rb
@@ -11,7 +11,7 @@ def self.from_path(path)
Dir.mktmpdir do |dir|
sh("tar xzf #{path} --directory=#{dir} stemcell.MF")
stemcell_manifest = "#{dir}/stemcell.MF"
- st = YAML.load_file(stemcell_manifest)
+ st = Psych.load_file(stemcell_manifest)
Stemcell.new(st['name'], st['version'], st['cloud_properties']['infrastructure'], path)
end
end
View
2  bat/spec/helpers/deployment_helper.rb
@@ -125,7 +125,7 @@ def reload_deployment_spec
end
def load_deployment_spec
- @spec ||= YAML.load_file(BH::read_environment('BAT_DEPLOYMENT_SPEC'))
+ @spec ||= Psych.load_file(BH::read_environment('BAT_DEPLOYMENT_SPEC'))
# Always set the batlight.missing to something, or deployments will fail.
# It is used for negative testing.
@spec["properties"]["batlight"] ||= {}
View
2  blobstore_client/bin/blobstore_client_console
@@ -34,7 +34,7 @@ unless @provider && config_file
exit(1)
end
-@config = YAML.load_file(config_file)
+@config = Psych.load_file(config_file)
module ConsoleHelpers
def bsc
View
2  bosh_agent/lib/bosh_agent.rb
@@ -67,8 +67,6 @@ module Bosh
require "bosh_agent/handler"
-YAML::ENGINE.yamler = 'syck' if defined?(YAML::ENGINE.yamler)
-
module Bosh::Agent
BOSH_APP = BOSH_APP_USER = BOSH_APP_GROUP = "vcap"
View
4 bosh_agent/lib/bosh_agent/apply_plan/job.rb
@@ -87,8 +87,8 @@ def bind_configuration
FileUtils.mkdir_p(bin_dir)
begin
- manifest = YAML.load_file(manifest_path)
- rescue ArgumentError
+ manifest = Psych.load_file(manifest_path)
+ rescue Psych::SyntaxError
install_failed("malformed job manifest #{manifest_path}")
end
View
2  bosh_agent/lib/bosh_agent/http_handler.rb
@@ -90,7 +90,7 @@ def release_apply_spec
end
def apply_spec
- YAML.load_file(release_apply_spec)
+ Psych.load_file(release_apply_spec)
end
end
end
View
8 bosh_agent/lib/bosh_agent/state.rb
@@ -48,7 +48,7 @@ def ips
def read
@lock.synchronize do
if File.exists?(@state_file)
- state = YAML.load_file(@state_file) || default_state
+ state = Psych.load_file(@state_file) || default_state
unless state.kind_of?(Hash)
raise_format_error(state)
end
@@ -61,7 +61,7 @@ def read
self
rescue SystemCallError => e
raise StateError, "Cannot read agent state file `#{@state_file}': #{e}"
- rescue YAML::Error
+ rescue Psych::SyntaxError
raise StateError, "Malformed agent state: #{e}"
end
@@ -74,13 +74,13 @@ def write(new_state)
@lock.synchronize do
File.open(@state_file, "w") do |f|
- f.puts(YAML.dump(new_state))
+ f.puts(Psych.dump(new_state))
end
@data = new_state
end
true
- rescue SystemCallError, YAML::Error => e
+ rescue SystemCallError, Psych::SyntaxError => e
raise StateError, "Cannot write agent state file `#{@state_file}': #{e}"
end
View
14 bosh_agent/spec/unit/apply_plan/job_spec.rb
@@ -106,7 +106,7 @@ def mock_template(blobstore_id, checksum, path)
}
mock_template("beefdad", "badcafe", job.install_path) do |template|
- template.add_file("job.MF", YAML.dump(manifest))
+ template.add_file("job.MF", Psych.dump(manifest))
template.add_file("templates/foo.erb", "<%= spec.key1 %>")
template.add_file("templates/bar.erb", "<%= spec.key2 %>")
template.add_file("templates/test", "<%= \"\#{name}, \#{index}\" %>")
@@ -211,7 +211,7 @@ def template_for(job)
}
template_for(job) do |template|
- template.add_file("job.MF", YAML.dump(manifest))
+ template.add_file("job.MF", Psych.dump(manifest))
end
expect {
@@ -230,7 +230,7 @@ def template_for(job)
}
template_for(job) do |template|
- template.add_file("job.MF", YAML.dump(manifest))
+ template.add_file("job.MF", Psych.dump(manifest))
end
template_path = File.join(job.install_path, "templates", "foo.erb")
@@ -250,7 +250,7 @@ def template_for(job)
}
template_for(job) do |template|
- template.add_file("job.MF", YAML.dump(manifest))
+ template.add_file("job.MF", Psych.dump(manifest))
template.add_file("templates/foo.erb", "<%= properties.foo.bar %>")
end
@@ -273,7 +273,7 @@ def template_for(job)
}
template_for(job) do |template|
- template.add_file("job.MF", YAML.dump(manifest))
+ template.add_file("job.MF", Psych.dump(manifest))
template.add_file("templates/foo.erb", "<%= p('foo.bar') %>")
end
@@ -303,7 +303,7 @@ def template_for(job)
job = make_job(JOB_NAME, valid_spec["name"], valid_spec, config_binding)
mock_template("beefdad", "badcafe", job.install_path) do |template|
- template.add_file("job.MF", YAML.dump({}))
+ template.add_file("job.MF", Psych.dump({}))
template.add_file("monit", "check process ccdb\nmode manual\n" +
"<%= properties.foo %>")
template.add_file("extra.monit", "check process ccdb_extra\n")
@@ -343,7 +343,7 @@ def template_for(job)
job = make_job(JOB_NAME, valid_spec["name"], valid_spec, config_binding)
mock_template("beefdad", "badcafe", job.install_path) do |template|
- template.add_file("job.MF", YAML.dump({}))
+ template.add_file("job.MF", Psych.dump({}))
template.add_file("monit", "check process ccdb\nmode manual\n" +
"<%= properties.foo.bar %>")
end
View
2  bosh_agent/spec/unit/heartbeat_spec.rb
@@ -6,7 +6,7 @@
before(:each) do
state_file = Tempfile.new("state")
- state_file.write(YAML.dump({ "job" => {"name" => "mutator" }, "index" => 3, "configuration_hash" => "deadbeef" }))
+ state_file.write(Psych.dump({ "job" => {"name" => "mutator" }, "index" => 3, "configuration_hash" => "deadbeef" }))
state_file.close
@state = Bosh::Agent::State.new(state_file.path)
View
2  bosh_agent/spec/unit/message/drain_spec.rb
@@ -7,7 +7,7 @@
def set_state(state)
state_file = Tempfile.new("agent-state")
- state_file.write(YAML.dump(state))
+ state_file.write(Psych.dump(state))
state_file.close
Bosh::Agent::Config.state = Bosh::Agent::State.new(state_file.path)
end
View
4 bosh_agent/spec/unit/state_spec.rb
@@ -39,14 +39,14 @@ def make_state(file)
Time.stub!(:now).and_return(ts)
File.open(@state_file, "w") do |f|
- f.write(YAML.dump({ "a" => 1, "b" => 2}))
+ f.write(Psych.dump({ "a" => 1, "b" => 2}))
end
state = make_state(@state_file)
state.to_hash.should == { "a" => 1, "b" => 2 }
File.open(@state_file, "w") do |f|
- f.write(YAML.dump({ "a" => 2, "b" => 3}))
+ f.write(Psych.dump({ "a" => 2, "b" => 3}))
end
# Someone else re-wrote the file, we don't know about that
View
8 bosh_aws_bootstrap/spec/functional/aws_spec.rb
@@ -25,7 +25,7 @@
end
it "uses some of the normal director keys" do
- @micro_bosh_yaml = YAML.load_file("micro_bosh.yml")
+ @micro_bosh_yaml = Psych.load_file("micro_bosh.yml")
@micro_bosh_yaml['name'].should == "micro-dev102"
@micro_bosh_yaml['network']['vip'].should == "50.200.100.1"
@@ -48,7 +48,7 @@
aws.stub(:target_required)
aws.stub_chain(:director, :uuid).and_return("deadbeef")
aws.create_bosh_manifest(create_vpc_output_yml, route53_receipt_yml)
- YAML.load_file("bosh.yml")['name'].should == "vpc-bosh-dev102"
+ Psych.load_file("bosh.yml")['name'].should == "vpc-bosh-dev102"
end
end
end
@@ -173,7 +173,7 @@ def make_fake_vpc!(overrides = {})
aws.output_state["vpc"]["id"].should == "vpc id"
aws.output_state["vpc"]["subnets"].should == {"bosh" => "amz-subnet1", "name2" => "amz-subnet2"}
- aws.output_state["original_configuration"].should == YAML.load_file(config_file)
+ aws.output_state["original_configuration"].should == Psych.load_file(config_file)
end
context "when the VPC is not immediately available" do
@@ -703,7 +703,7 @@ def make_fake_rds!(opts = {})
# TODO: Where are the assertions for this test? Buried in `make_fake_rds!`? Fix this!
it "should create all rds databases with option overrides" do
- ccdb_opts = YAML.load_file(config_file)["rds"].find { |db_opts| db_opts["name"] == "ccdb" }
+ ccdb_opts = Psych.load_file(config_file)["rds"].find { |db_opts| db_opts["name"] == "ccdb" }
make_fake_rds!(aws_creation_options: ccdb_opts["aws_creation_options"])
aws.create_rds_dbs(config_file, receipt_file)
end
View
4 bosh_aws_bootstrap/spec/functional/bootstrap_spec.rb
@@ -13,7 +13,7 @@
around do |example|
@bosh_config = Tempfile.new("bosh_config")
- @bosh_config.puts File.read(bosh_config)
+ FileUtils.cp(bosh_config, @bosh_config.path)
aws.add_option(:config, @bosh_config.path)
FileUtils.cp(asset("id_spec_rsa"), "/tmp/somekey")
@@ -288,7 +288,7 @@
aws.bootstrap_bosh(bosh_repository_path)
config_file = File.read(@bosh_config.path)
- config = YAML.load(config_file)
+ config = Psych.load(config_file)
config["target"].should == "http://50.200.100.3:25555"
end
View
4 bosh_aws_bootstrap/spec/unit/bat_manifest_spec.rb
@@ -1,9 +1,9 @@
require 'spec_helper'
describe Bosh::Aws::BatManifest do
- let(:vpc_receipt) { YAML.load_file(asset "test-output.yml") }
+ let(:vpc_receipt) { Psych.load_file(asset "test-output.yml") }
let(:vpc_config) { vpc_receipt['original_configuration'] }
- let(:route53_receipt) { YAML.load_file(asset "test-aws_route53_receipt.yml") }
+ let(:route53_receipt) { Psych.load_file(asset "test-aws_route53_receipt.yml") }
let(:stemcell_version) { '1.1.1.pre' }
let(:manifest) { Bosh::Aws::BatManifest.new(vpc_receipt, route53_receipt, stemcell_version, 'deadbeef') }
View
4 bosh_aws_bootstrap/spec/unit/bosh_manifest_spec.rb
@@ -1,8 +1,8 @@
require 'spec_helper'
describe Bosh::Aws::BoshManifest do
- let(:vpc_receipt) { YAML.load_file(asset "test-output.yml") }
- let(:route53_receipt) { YAML.load_file(asset "test-aws_route53_receipt.yml") }
+ let(:vpc_receipt) { Psych.load_file(asset "test-output.yml") }
+ let(:route53_receipt) { Psych.load_file(asset "test-aws_route53_receipt.yml") }
it "sets the correct elastic ip" do
described_class.new(vpc_receipt, route53_receipt, 'deadbeef').vip.should == "50.200.100.3"
View
4 bosh_aws_bootstrap/spec/unit/microbosh_manifest_spec.rb
@@ -1,8 +1,8 @@
require 'spec_helper'
describe Bosh::Aws::MicroboshManifest do
- let(:vpc_receipt) { YAML.load_file(asset "test-output.yml") }
- let(:route53_receipt) { YAML.load_file(asset "test-aws_route53_receipt.yml") }
+ let(:vpc_receipt) { Psych.load_file(asset "test-output.yml") }
+ let(:route53_receipt) { Psych.load_file(asset "test-aws_route53_receipt.yml") }
let(:vpc_config) { vpc_receipt['original_configuration'] }
let(:manifest) { Bosh::Aws::MicroboshManifest.new(vpc_receipt, route53_receipt) }
View
2  bosh_aws_cpi/bin/bosh_aws_console
@@ -25,7 +25,7 @@ unless config_file
exit(1)
end
-@config = YAML.load_file(config_file)
+@config = Psych.load_file(config_file)
module ConsoleHelpers
def cpi
View
4 bosh_cli/lib/cli.rb
@@ -81,10 +81,6 @@ module Cli
require "cli/runner"
require "cli/base_command"
-if defined?(YAML::ENGINE.yamler)
- YAML::ENGINE.yamler = RUBY_VERSION >= "2.0.0" ? "psych" : "syck"
-end
-
tmpdir = Dir.mktmpdir
at_exit { FileUtils.rm_rf(tmpdir) }
ENV["TMPDIR"] = tmpdir
View
2  bosh_cli/lib/cli/blob_manager.rb
@@ -352,7 +352,7 @@ def strip_blobs_dir(path)
# Updates blobs index
def update_index
- yaml = YAML.dump(@index).gsub(/\s*$/, "")
+ yaml = Psych.dump(@index).gsub(/\s*$/, "")
index_file = Tempfile.new("blob_index")
index_file.puts(yaml)
View
2  bosh_cli/lib/cli/commands/biff.rb
@@ -210,7 +210,7 @@ def load_template_as_yaml
temp_data = File.read(@template_file)
temp_data.gsub!(/<%=.*%>/, "INSERT_DATA_HERE")
temp_data.gsub!(/[ ]*<%.*%>[ ]*\n/, "")
- YAML::load(temp_data)
+ Psych::load(temp_data)
end
# Gets the network's network/mask for configuring things such as the
View
4 bosh_cli/lib/cli/commands/deployment.rb
@@ -91,7 +91,7 @@ def perform
:yaml => true, :resolve_properties => true)
if interactive?
- inspect_deployment_changes(YAML.load(manifest_yaml))
+ inspect_deployment_changes(Psych.load(manifest_yaml))
say("Please review all changes carefully".yellow)
end
@@ -273,7 +273,7 @@ def row_for_deployments_table(deployment)
def row_for_deployments_table_by_manifest(deployment_name)
raw_manifest = director.get_deployment(deployment_name)
if (raw_manifest.has_key?("manifest"))
- manifest = YAML.load(raw_manifest["manifest"])
+ manifest = Psych.load(raw_manifest["manifest"])
stemcells = manifest["resource_pools"].map { |rp|
rp["stemcell"].values_at("name", "version").join("/")
View
2  bosh_cli/lib/cli/commands/job_management.rb
@@ -43,7 +43,7 @@ def recreate_job(job, index = nil)
def change_job_state(operation, job, index)
auth_required
manifest_yaml = prepare_deployment_manifest(:yaml => true)
- manifest = YAML.load(manifest_yaml)
+ manifest = Psych.load(manifest_yaml)
unless [:start, :stop, :restart, :recreate].include?(operation)
err("Unknown operation `#{operation}': supported operations are " +
View
8 bosh_cli/lib/cli/commands/job_rename.rb
@@ -12,7 +12,7 @@ class JobRename < Base
def rename(old_name, new_name)
auth_required
manifest_yaml = prepare_deployment_manifest(:yaml => true)
- manifest = YAML.load(manifest_yaml)
+ manifest = Psych.load(manifest_yaml)
force = options[:force]
say("You are about to rename `#{old_name.green}' to `#{new_name.green}'")
@@ -33,7 +33,7 @@ def rename(old_name, new_name)
def sanity_check_job_rename(manifest_yaml, old_name, new_name)
# Makes sure the new deployment manifest contains the renamed job
- manifest = YAML.load(manifest_yaml)
+ manifest = Psych.load(manifest_yaml)
new_jobs = manifest["jobs"].map { |job| job["name"] }
unless new_jobs.include?(new_name)
err("Please update your deployment manifest to include the " +
@@ -52,7 +52,7 @@ def sanity_check_job_rename(manifest_yaml, old_name, new_name)
"`#{manifest["name"]}'")
end
- current_manifest = YAML.load(current_deployment["manifest"])
+ current_manifest = Psych.load(current_deployment["manifest"])
jobs = current_manifest["jobs"].map { |job| job["name"] }
unless jobs.include?(old_name)
err("Trying to rename a non existent job `#{old_name}'")
@@ -99,7 +99,7 @@ def sanity_check_job_rename(manifest_yaml, old_name, new_name)
end
# Now the manifests should be the same
- manifest = YAML.load(manifest_yaml)
+ manifest = Psych.load(manifest_yaml)
if deployment_changed?(current_manifest.dup, manifest.dup)
err("You cannot have any other changes to your manifest during " +
"rename. Please revert the above changes and retry.")
View
2  bosh_cli/lib/cli/commands/release.rb
@@ -26,7 +26,7 @@ def init(base = nil)
# Initialize an empty blobs index
File.open(File.join("config", "blobs.yml"), "w") do |f|
- YAML.dump({}, f)
+ Psych.dump({}, f)
end
say("Release directory initialized".green)
View
2  bosh_cli/lib/cli/commands/stemcell.rb
@@ -234,7 +234,7 @@ def get_public_stemcell_list
if status_code != HTTP::Status::OK
err("Received HTTP #{status_code} from #{PUBLIC_STEMCELL_INDEX_URL}.")
end
- YAML.load(response.body)
+ Psych.load(response.body)
end
end
View
4 bosh_cli/lib/cli/config.rb
@@ -45,7 +45,7 @@ def initialize(filename, work_dir = Dir.pwd)
@work_dir = work_dir
unless File.exists?(@filename)
- File.open(@filename, "w") { |f| YAML.dump({}, f) }
+ File.open(@filename, "w") { |f| Psych.dump({}, f) }
File.chmod(0600, @filename)
end
@@ -191,7 +191,7 @@ def write_global(attr, value)
def save
File.open(@filename, "w") do |f|
- YAML.dump(@config_file, f)
+ Psych.dump(@config_file, f)
end
rescue SystemCallError => e
View
2  bosh_cli/lib/cli/core_ext.rb
@@ -67,7 +67,7 @@ def format_time(time)
def load_yaml_file(path, expected_type = Hash)
err("Cannot find file `#{path}'".red) unless File.exist?(path)
- yaml = YAML::load(ERB.new(File.read(path)).result)
+ yaml = Psych::load(ERB.new(File.read(path)).result)
if expected_type && !yaml.is_a?(expected_type)
err("Incorrect file format in `#{path}', #{expected_type} expected")
View
6 bosh_cli/lib/cli/deployment_helper.rb
@@ -42,7 +42,7 @@ def prepare_deployment_manifest(options = {})
hash
end
- manifest = YAML.load(compiler.result)
+ manifest = Psych.load(compiler.result)
end
if manifest["name"].blank? || manifest["director_uuid"].blank?
@@ -62,7 +62,7 @@ def prepare_deployment_manifest(options = {})
resolve_release_aliases(manifest)
resolve_stemcell_aliases(manifest)
- options[:yaml] ? YAML.dump(manifest) : manifest
+ options[:yaml] ? Psych.dump(manifest) : manifest
end
# Check if the 2 deployments are different.
@@ -106,7 +106,7 @@ def inspect_deployment_changes(manifest, options = { })
# but it turned out to be confusing to many users and thus has
# been removed.
return if current_deployment["manifest"].nil?
- current_manifest = YAML.load(current_deployment["manifest"])
+ current_manifest = Psych.load(current_deployment["manifest"])
unless current_manifest.is_a?(Hash)
err("Current deployment manifest format is invalid, " +
View
8 bosh_cli/lib/cli/release.rb
@@ -113,11 +113,11 @@ def blobstore
def save_config
# TODO: introduce write_yaml helper
File.open(@dev_config_file, "w") do |f|
- YAML.dump(@dev_config, f)
+ Psych.dump(@dev_config, f)
end
File.open(@final_config_file, "w") do |f|
- YAML.dump(@final_config, f)
+ Psych.dump(@final_config, f)
end
end
@@ -184,7 +184,7 @@ def migrate_legacy_configs
@dev_config = new_dev_config
File.open(@dev_config_file, "w") do |f|
- YAML.dump(@dev_config, f)
+ Psych.dump(@dev_config, f)
end
say("Migrated dev config file format".green)
end
@@ -211,7 +211,7 @@ def migrate_legacy_configs
@final_config = new_final_config
- File.open(@final_config_file, "w") { |f| YAML.dump(@final_config, f) }
+ File.open(@final_config_file, "w") { |f| Psych.dump(@final_config, f) }
say("Migrated final config file format".green)
end
end
View
2  bosh_cli/lib/cli/release_builder.rb
@@ -150,7 +150,7 @@ def generate_manifest
end
manifest["version"] = @version
- manifest_yaml = YAML.dump(manifest)
+ manifest_yaml = Psych.dump(manifest)
say("Writing manifest...")
File.open(File.join(build_dir, "release.MF"), "w") do |f|
View
2  bosh_cli/lib/cli/stemcell.rb
@@ -65,7 +65,7 @@ def perform_validation(options = {})
@cache.write(cache_key, manifest_yaml)
end
- manifest = YAML.load(manifest_yaml)
+ manifest = Psych.load(manifest_yaml)
step("Stemcell properties",
"Manifest should contain valid name, " +
View
2  bosh_cli/lib/cli/versions_index.rb
@@ -82,7 +82,7 @@ def add_version(fingerprint, item, tmp_file_path = nil)
end
File.open(@index_file, "w") do |f|
- f.write(YAML.dump(@data))
+ f.write(Psych.dump(@data))
end
File.expand_path(filename(version))
View
62 bosh_cli/lib/cli/yaml_helper.rb
@@ -6,56 +6,54 @@ class << self
private
def process_object(o)
case o
- when @syck_class::Map
- process_map(o)
- when @syck_class::Seq
- process_seq(o)
- when @syck_class::Scalar
- else
- err("Unhandled class #{o.class}, fix yaml duplicate check")
+ when Psych::Nodes::Mapping
+ process_mapping(o)
+ when Psych::Nodes::Sequence
+ process_sequence(o)
+ when Psych::Nodes::Scalar
+ else
+ err("Unhandled class #{o.class}, fix yaml duplicate check")
end
end
- def process_seq(s)
- s.value.each do |v|
+ def process_sequence(s)
+ s.children.each do |v|
process_object(v)
end
end
- def process_map(m)
- return if m.class != @syck_class::Map
+ def process_mapping(m)
+ return unless m.children
s = Set.new
- m.value.each_key do |k|
- raise "Found dup key #{k.value}" if s.include?(k.value)
- s.add(k.value)
+
+ m.children.each_with_index do |key_or_value, index|
+ next if index.odd? # skip the values
+ key = key_or_value.value # Sorry this is confusing, Psych mappings don't behave nicely like maps
+ raise "Found duplicate key #{key}" if s.include?(key)
+ s.add(key)
end
- m.value.each_value do |v|
- process_object(v)
+ m.children.each_with_index do |key_or_value, index|
+ next if index.even? # skip the keys
+ process_object(key_or_value)
end
end
public
def check_duplicate_keys(path)
- # Some Ruby builds on Ubuntu seem to expose a bug
- # with the opposite order of Syck check, so we first
- # check for Syck and then for YAML::Syck
- if defined?(Syck)
- @syck_class = Syck
- elsif defined?(YAML::Syck)
- @syck_class = YAML::Syck
- else
- raise "Cannot find Syck parser for YAML, " +
- "please check your Ruby installation"
- end
-
begin
- yaml = ERB.new(File.read(path)).result
- process_map(YAML.parse(yaml))
+ string_with_erb = File.read(path)
+ yaml = ERB.new(string_with_erb).result
+ document = Psych.parse(yaml)
+ process_mapping(document.root) if document

I found I have had to change 'document.root' to just 'document' to get this change to work. If left I would get the error;

Incorrect YAML structure in /Users/danhigham/.bosh_config': undefined methodroot' for #Psych::Nodes::Mapping:0x007fcacad8ece8

@drnic
drnic added a note

Who did document.root work for and underwhat circumstances? The build is green, but the rake task doesn't work for @danhigham, @rkoster, nor myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
rescue => e
- raise "Bad yaml file #{path}, " + e.message
+ if e.message.include? "Found duplicate key"
+ raise "Bad YAML file when parsing file: #{path}\n#{e.message}"
+ else
+ raise e
+ end
end
end
end
end
-end
+end
View
14 bosh_cli/spec/assets/manifests/new_extra_changes_manifest.yml
@@ -0,0 +1,14 @@
+name: test
+networks:
+- name: default
+resource_pools:
+- name: rp
+jobs:
+- name: job1
+ template: xyz
+ networks:
+ - name: default
+- name: new_job
+ template: changed_templated_causing_failure
+ networks:
+ - name: default
View
15 bosh_cli/spec/assets/manifests/new_extra_job_rename_manifest.yml
@@ -0,0 +1,15 @@
+---
+name: test
+networks:
+- name: default
+resource_pools:
+- name: rp
+jobs:
+- name: new_job1
+ template: xyz
+ networks:
+ - name: default
+- name: new_job
+ template: changed_templated_causing_failure
+ networks:
+ - name: default
View
15 bosh_cli/spec/assets/manifests/new_manifest.yml
@@ -0,0 +1,15 @@
+---
+name: test
+networks:
+- name: default
+resource_pools:
+- name: rp
+jobs:
+- name: job1
+ template: xyz
+ networks:
+ - name: default
+- name: new_job
+ template: xyz
+ networks:
+ - name: default
View
15 bosh_cli/spec/assets/manifests/new_manifest_missing_new_job.yml
@@ -0,0 +1,15 @@
+---
+name: test
+networks:
+- name: default
+resource_pools:
+- name: rp
+jobs:
+- name: job1
+ template: xyz
+ networks:
+ - name: default
+- name: old_job
+ template: xyz
+ networks:
+ - name: default
View
14 bosh_cli/spec/assets/manifests/new_manifest_with_some_deletions.yml
@@ -0,0 +1,14 @@
+---
+name: test
+resource_pools:
+- name: rp
+networks:
+- name: default
+jobs:
+- name: job1
+ networks:
+ - name: default
+- name: new_job
+ template: xyz
+ networks:
+ - name: default
View
15 bosh_cli/spec/assets/manifests/old_manifest.yml
@@ -0,0 +1,15 @@
+---
+name: test
+resource_pools:
+- name: rp
+networks:
+- name: default
+jobs:
+- name: job1
+ template: xyz
+ networks:
+ - name: default
+- name: old_job
+ template: xyz
+ networks:
+ - name: default
View
10 bosh_cli/spec/unit/blob_manager_spec.rb
@@ -47,7 +47,7 @@ def make_manager(release)
it "doesn't like bad index file'" do
File.open(File.join(@config_dir, "blobs.yml"), "w") do |f|
- YAML.dump("string", f)
+ Psych.dump("string", f)
end
expect {
make_manager(@release)
@@ -59,12 +59,12 @@ def make_manager(release)
test_hash = { "foo" => "bar" }
File.open(legacy_file, "w") do |f|
- YAML.dump({ "foo" => "bar" }, f)
+ Psych.dump({ "foo" => "bar" }, f)
end
make_manager(@release)
File.exists?(legacy_file).should be_false
- YAML.load_file(File.join(@config_dir, "blobs.yml")).should == test_hash
+ Psych.load_file(File.join(@config_dir, "blobs.yml")).should == test_hash
end
end
@@ -163,7 +163,7 @@ def make_manager(release)
}
File.open(File.join(@config_dir, "blobs.yml"), "w") do |f|
- YAML.dump(index, f)
+ Psych.dump(index, f)
end
@manager = make_manager(@release)
@@ -264,7 +264,7 @@ def make_manager(release)
}
File.open(File.join(@config_dir, "blobs.yml"), "w") do |f|
- YAML.dump(index, f)
+ Psych.dump(index, f)
end
foo = Tempfile.new("foo")
View
2  bosh_cli/spec/unit/cli_commands/base_command_spec.rb
@@ -12,7 +12,7 @@
def add_config(object)
File.open(@config_file, "w") do |f|
- f.write(YAML.dump(object))
+ f.write(Psych.dump(object))
end
end
View
2  bosh_cli/spec/unit/cli_commands/cli_commands_spec.rb
@@ -333,7 +333,7 @@
describe Bosh::Cli::Command::JobManagement do
before :each do
@manifest_path = spec_asset("deployment.MF")
- @manifest_yaml = YAML.dump({"name" => "foo"})
+ @manifest_yaml = Psych.dump({"name" => "foo"})
@cmd = Bosh::Cli::Command::JobManagement.new
@cmd.add_option(:non_interactive, true)
View
107 bosh_cli/spec/unit/cli_commands/job_rename_spec.rb
@@ -79,122 +79,27 @@
end
def old_manifest_yaml
- <<-eos
- ---
- name: test
- resource_pools:
- - name: rp
- networks:
- - name: default
- jobs:
- - name: job1
- template: xyz
- networks:
- - name: default
- - name: old_job
- template: xyz
- networks:
- - name: default
- eos
+ File.read(spec_asset("manifests/old_manifest.yml"))
end
def new_manifest_with_some_deletions
- <<-eos
- ---
- name: test
- resource_pools:
- - name: rp
- networks:
- - name: default
- jobs:
- - name: job1
- networks:
- - name: default
- - name: new_job
- template: xyz
- networks:
- - name: default
- eos
+ File.read(spec_asset("manifests/new_manifest_with_some_deletions.yml"))
end
def new_manifest_yaml
- <<-eos
- ---
- name: test
- networks:
- - name: default
- resource_pools:
- - name: rp
- jobs:
- - name: job1
- template: xyz
- networks:
- - name: default
- - name: new_job
- template: xyz
- networks:
- - name: default
- eos
+ File.read(spec_asset("manifests/new_manifest.yml"))
end
def new_extra_changes_manifest
- <<-eos
- ---
- name: test
- networks:
- - name: default
- resource_pools:
- - name: rp
- jobs:
- - name: job1
- template: xyz
- networks:
- - name: default
- - name: new_job
- template: changed_templated_causing_failure
- networks:
- - name: default
- eos
+ File.read(spec_asset("manifests/new_extra_changes_manifest.yml"))
end
def new_extra_job_rename_manifest
- <<-eos
- ---
- name: test
- networks:
- - name: default
- resource_pools:
- - name: rp
- jobs:
- - name: new_job1
- template: xyz
- networks:
- - name: default
- - name: new_job
- template: changed_templated_causing_failure
- networks:
- - name: default
- eos
+ File.read(spec_asset("manifests/new_extra_job_rename_manifest.yml"))
end
def new_missing_new_job
- <<-eos
- ---
- name: test
- networks:
- - name: default
- resource_pools:
- - name: rp
- jobs:
- - name: job1
- template: xyz
- networks:
- - name: default
- - name: old_job
- template: xyz
- networks:
- - name: default
- eos
+ File.read(spec_asset("manifests/new_manifest_missing_new_job.yml"))
end
end
end
View
2  bosh_cli/spec/unit/config_spec.rb
@@ -10,7 +10,7 @@
def add_config(object)
File.open(@config, "w") do |f|
- f.write(YAML.dump(object))
+ f.write(Psych.dump(object))
end
end
View
2  bosh_cli/spec/unit/core_ext_spec.rb
@@ -98,7 +98,7 @@
end
it "gives a nice error when the parsed YAML produces a hash with repeated keys" do
- expect { load_yaml_file(spec_asset("duplicate_keys.yml")) }.to raise_error(RuntimeError, /Bad yaml file/)
+ expect { load_yaml_file(spec_asset("duplicate_keys.yml")) }.to raise_error(RuntimeError, /Bad YAML file/)
end
end
end
View
4 bosh_cli/spec/unit/deployment_helper_spec.rb
@@ -197,7 +197,7 @@ def make_cmd(options = {})
}
manifest_file = Tempfile.new("manifest")
- YAML.dump(manifest, manifest_file)
+ Psych.dump(manifest, manifest_file)
manifest_file.close
director = mock(Bosh::Cli::Director)
@@ -225,7 +225,7 @@ def make_cmd(options = {})
}
manifest_file = Tempfile.new("manifest")
- YAML.dump(manifest, manifest_file)
+ Psych.dump(manifest, manifest_file)
manifest_file.close
director = mock(Bosh::Cli::Director, :uuid => "deadbeef")
View
2  bosh_cli/spec/unit/job_builder_spec.rb
@@ -211,7 +211,7 @@ def remove_templates(job_name, *files)
"packages" => ["bar", "baz"],
"templates" => ["a.conf", "b.yml"]
}
- spec_yaml = YAML.dump(spec)
+ spec_yaml = Psych.dump(spec)
script = <<-SCRIPT.gsub(/^\s*/, "")
#!/bin/sh
View
4 bosh_cli/spec/unit/release_builder_spec.rb
@@ -35,7 +35,7 @@ def new_builder
builder = Bosh::Cli::ReleaseBuilder.new(@release, [], [], options)
builder.build
- manifest = YAML.load_file(builder.manifest_path)
+ manifest = Psych.load_file(builder.manifest_path)
manifest['commit_hash'].should == '12345678'
manifest['uncommitted_changes'].should be_true
end
@@ -121,7 +121,7 @@ def new_builder
builder.build
- manifest = YAML.load_file(builder.manifest_path)
+ manifest = Psych.load_file(builder.manifest_path)
manifest["jobs"][0]["fingerprint"].should == "deadbeef"
manifest["packages"][0]["fingerprint"].should == "deadcafe"
View
2  bosh_deployer/lib/deployer/config.rb
@@ -146,7 +146,7 @@ def deep_merge(src, dst)
def load_defaults(provider)
file = File.join(File.dirname(File.expand_path(__FILE__)), "../../config/#{provider}_defaults.yml")
- YAML.load_file(file)
+ Psych.load_file(file)
end
end
end
View
6 bosh_deployer/lib/deployer/instance_manager.rb
@@ -450,7 +450,7 @@ def delete_vm
def load_deployments
if File.exists?(@state_yml)
logger.info("Loading existing deployment data from: #{@state_yml}")
- YAML.load_file(@state_yml)
+ Psych.load_file(@state_yml)
else
logger.info("No existing deployments found (will save to #{@state_yml})")
{ "instances" => [], "disks" => [] }
@@ -473,7 +473,7 @@ def load_stemcell_manifest(dir)
def load_spec(file)
yield unless File.exist?(file)
logger.info("Loading yaml from #{file}")
- YAML.load_file(file)
+ Psych.load_file(file)
end
def generate_unique_name
@@ -503,7 +503,7 @@ def save_state
@deployments["disks"] = disk_model.map { |disk| disk.values } if disk_model
File.open(@state_yml, "w") do |file|
- file.write(YAML.dump(@deployments))
+ file.write(Psych.dump(@deployments))
end
end
View
2  bosh_deployer/lib/deployer/instance_manager/aws.rb
@@ -58,7 +58,7 @@ def configure
}
@registry_config = Tempfile.new("bosh_registry_yml")
- @registry_config.write(YAML.dump(registry_config))
+ @registry_config.write(Psych.dump(registry_config))
@registry_config.close
end
View
2  bosh_deployer/lib/deployer/instance_manager/openstack.rb
@@ -58,7 +58,7 @@ def configure
}
@registry_config = Tempfile.new("bosh_registry_yml")
- @registry_config.write(YAML.dump(registry_config))
+ @registry_config.write(Psych.dump(registry_config))
@registry_config.close
end
View
2  bosh_deployer/lib/deployer/specification.rb
@@ -12,7 +12,7 @@ def self.load_apply_spec(dir)
unless File.exist?(apply_spec)
err "this isn't a micro bosh stemcell - #{file} missing"
end
- YAML.load_file(apply_spec)
+ Psych.load_file(apply_spec)
end
attr_accessor :spec
View
2  bosh_deployer/spec/functional/deployer_test_spec.rb
@@ -7,7 +7,7 @@
def setup(config_yml)
@stemcell_tgz = ENV['BOSH_STEMCELL_TGZ']
@dir = ENV['BOSH_DEPLOYER_DIR'] || Dir.mktmpdir("bd_spec")
- config = YAML.load_file(spec_asset(config_yml))
+ config = Psych.load_file(spec_asset(config_yml))
config["dir"] = @dir
@deployer = Bosh::Deployer::InstanceManager.new(config)
end
View
8 bosh_deployer/spec/unit/aws/config_spec.rb
@@ -18,7 +18,7 @@
end
it "should default agent properties" do
- config = YAML.load_file(spec_asset("test-bootstrap-config-aws.yml"))
+ config = Psych.load_file(spec_asset("test-bootstrap-config-aws.yml"))
config["dir"] = @dir
Bosh::Deployer::Config.configure(config)
@@ -29,7 +29,7 @@
end
it "should map network properties" do
- config = YAML.load_file(spec_asset("test-bootstrap-config-aws.yml"))
+ config = Psych.load_file(spec_asset("test-bootstrap-config-aws.yml"))
config["dir"] = @dir
Bosh::Deployer::Config.configure(config)
@@ -69,7 +69,7 @@
end
it "should configure agent using mbus property" do
- config = YAML.load_file(spec_asset("test-bootstrap-config-aws.yml"))
+ config = Psych.load_file(spec_asset("test-bootstrap-config-aws.yml"))
config["dir"] = @dir
Bosh::Deployer::Config.configure(config)
agent = Bosh::Deployer::Config.agent
@@ -77,7 +77,7 @@
end
it "should have ec2 and registry object access" do
- config = YAML.load_file(spec_asset("test-bootstrap-config-aws.yml"))
+ config = Psych.load_file(spec_asset("test-bootstrap-config-aws.yml"))
config["dir"] = @dir
Bosh::Deployer::Config.configure(config)
cloud = Bosh::Deployer::Config.cloud
View
6 bosh_deployer/spec/unit/aws/instance_manager_spec.rb
@@ -7,7 +7,7 @@
describe Bosh::Deployer::InstanceManager do
before(:each) do
@dir = Dir.mktmpdir("bdim_spec")
- @config = YAML.load_file(spec_asset("test-bootstrap-config-aws.yml"))
+ @config = Psych.load_file(spec_asset("test-bootstrap-config-aws.yml"))
@config["dir"] = @dir
@config["name"] = "spec-#{SecureRandom.uuid}"
@config["logging"] = { "file" => "#{@dir}/bmim.log" }
@@ -45,7 +45,7 @@ def discover_bosh_ip(ip, id)
it "should create a Bosh instance" do
@deployer.stub!(:service_ip).and_return("10.0.0.10")
- spec = YAML.load_file(spec_asset("apply_spec_aws.yml"))
+ spec = Psych.load_file(spec_asset("apply_spec_aws.yml"))
Bosh::Deployer::Specification.should_receive(:load_apply_spec).and_return(spec)
@deployer.stub!(:run_command)
@@ -108,7 +108,7 @@ def discover_bosh_ip(ip, id)
it "should update a Bosh instance" do
@deployer.stub!(:service_ip).and_return("10.0.0.10")
- spec = YAML.load_file(spec_asset("apply_spec_aws.yml"))
+ spec = Psych.load_file(spec_asset("apply_spec_aws.yml"))
Bosh::Deployer::Specification.should_receive(:load_apply_spec).and_return(spec)
disk_cid = "22"
View
6 bosh_deployer/spec/unit/config_spec.rb
@@ -18,7 +18,7 @@
end
it "should default agent properties" do
- config = YAML.load_file(spec_asset("test-bootstrap-config.yml"))
+ config = Psych.load_file(spec_asset("test-bootstrap-config.yml"))
config["dir"] = @dir
Bosh::Deployer::Config.configure(config)
@@ -29,7 +29,7 @@
end
it "should map network properties" do
- config = YAML.load_file(spec_asset("test-bootstrap-config.yml"))
+ config = Psych.load_file(spec_asset("test-bootstrap-config.yml"))
config["dir"] = @dir
Bosh::Deployer::Config.configure(config)
@@ -68,7 +68,7 @@
end
it "should configure agent using mbus property" do
- config = YAML.load_file(spec_asset("test-bootstrap-config.yml"))
+ config = Psych.load_file(spec_asset("test-bootstrap-config.yml"))
config["dir"] = @dir
Bosh::Deployer::Config.configure(config)
agent = Bosh::Deployer::Config.agent
View
6 bosh_deployer/spec/unit/instance_mananager_spec.rb
@@ -7,7 +7,7 @@
describe Bosh::Deployer::InstanceManager do
before(:each) do
@dir = Dir.mktmpdir("bdim_spec")
- @config = YAML.load_file(spec_asset("test-bootstrap-config.yml"))
+ @config = Psych.load_file(spec_asset("test-bootstrap-config.yml"))
@config["dir"] = @dir
@config["name"] = "spec-#{SecureRandom.uuid}"
@config["logging"] = {"file" => "#{@dir}/bmim.log"}
@@ -41,7 +41,7 @@ def load_deployment
end
it "should create a Bosh instance" do
- spec = YAML.load_file(spec_asset("apply_spec.yml"))
+ spec = Psych.load_file(spec_asset("apply_spec.yml"))
Bosh::Deployer::Specification.should_receive(:load_apply_spec).and_return(spec)
Bosh::Deployer::Config.stub(:agent_properties).and_return({})
@@ -102,7 +102,7 @@ def load_deployment
end
it "should update a Bosh instance" do
- spec = YAML.load_file(spec_asset("apply_spec.yml"))
+ spec = Psych.load_file(spec_asset("apply_spec.yml"))
Bosh::Deployer::Specification.should_receive(:load_apply_spec).and_return(spec)
Bosh::Deployer::Config.stub(:agent_properties).and_return({})
View
8 bosh_deployer/spec/unit/openstack/config_spec.rb
@@ -19,7 +19,7 @@
end
it "should default agent properties" do
- config = YAML.load_file(spec_asset("test-bootstrap-config-openstack.yml"))
+ config = Psych.load_file(spec_asset("test-bootstrap-config-openstack.yml"))
config["dir"] = @dir
Bosh::Deployer::Config.configure(config)
@@ -30,7 +30,7 @@
end
it "should map network properties" do
- config = YAML.load_file(spec_asset("test-bootstrap-config-openstack.yml"))
+ config = Psych.load_file(spec_asset("test-bootstrap-config-openstack.yml"))
config["dir"] = @dir
Bosh::Deployer::Config.configure(config)
@@ -70,7 +70,7 @@
end
it "should configure agent using mbus property" do
- config = YAML.load_file(spec_asset("test-bootstrap-config-openstack.yml"))
+ config = Psych.load_file(spec_asset("test-bootstrap-config-openstack.yml"))
config["dir"] = @dir
Bosh::Deployer::Config.configure(config)
agent = Bosh::Deployer::Config.agent
@@ -78,7 +78,7 @@
end
it "should have openstack and registry object access" do
- config = YAML.load_file(spec_asset("test-bootstrap-config-openstack.yml"))
+ config = Psych.load_file(spec_asset("test-bootstrap-config-openstack.yml"))
config["dir"] = @dir
Bosh::Deployer::Config.configure(config)
openstack = double(Fog::Compute)
View
6 bosh_deployer/spec/unit/openstack/instance_manager_spec.rb
@@ -7,7 +7,7 @@
describe Bosh::Deployer::InstanceManager do
before(:each) do
@dir = Dir.mktmpdir("bdim_spec")
- @config = YAML.load_file(spec_asset("test-bootstrap-config-openstack.yml"))
+ @config = Psych.load_file(spec_asset("test-bootstrap-config-openstack.yml"))
@config["dir"] = @dir
@config["name"] = "spec-#{SecureRandom.uuid}"
@config["logging"] = { "file" => "#{@dir}/bmim.log" }
@@ -46,7 +46,7 @@ def discover_bosh_ip(ip, id)
it "should create a Bosh instance" do
@deployer.stub!(:service_ip).and_return("10.0.0.10")
- spec = YAML.load_file(spec_asset("apply_spec_openstack.yml"))
+ spec = Psych.load_file(spec_asset("apply_spec_openstack.yml"))
Bosh::Deployer::Specification.should_receive(:load_apply_spec).and_return(spec)
@deployer.stub!(:run_command)
@@ -109,7 +109,7 @@ def discover_bosh_ip(ip, id)
it "should update a Bosh instance" do
@deployer.stub!(:service_ip).and_return("10.0.0.10")
- spec = YAML.load_file(spec_asset("apply_spec_openstack.yml"))
+ spec = Psych.load_file(spec_asset("apply_spec_openstack.yml"))
Bosh::Deployer::Specification.should_receive(:load_apply_spec).and_return(spec)
disk_cid = "22"
View
6 bosh_deployer/spec/unit/vcloud/config_spec.rb
@@ -18,7 +18,7 @@
end
it "should default agent properties" do
- config = YAML.load_file(spec_asset("test-bootstrap-config-vcloud.yml"))
+ config = Psych.load_file(spec_asset("test-bootstrap-config-vcloud.yml"))
config["dir"] = @dir
Bosh::Deployer::Config.configure(config)
@@ -29,7 +29,7 @@
end
it "should map network properties" do
- config = YAML.load_file(spec_asset("test-bootstrap-config-vcloud.yml"))
+ config = Psych.load_file(spec_asset("test-bootstrap-config-vcloud.yml"))
config["dir"] = @dir
Bosh::Deployer::Config.configure(config)
@@ -69,7 +69,7 @@
end
it "should configure agent using mbus property" do
- config = YAML.load_file(spec_asset("test-bootstrap-config-vcloud.yml"))
+ config = Psych.load_file(spec_asset("test-bootstrap-config-vcloud.yml"))
config["dir"] = @dir
Bosh::Deployer::Config.configure(config)
agent = Bosh::Deployer::Config.agent
View
6 bosh_deployer/spec/unit/vcloud/instance_manager_spec.rb
@@ -7,7 +7,7 @@
describe Bosh::Deployer::InstanceManager do
before(:each) do
@dir = Dir.mktmpdir("bdim_spec")
- @config = YAML.load_file(spec_asset("test-bootstrap-config-vcloud.yml"))
+ @config = Psych.load_file(spec_asset("test-bootstrap-config-vcloud.yml"))
@config["dir"] = @dir
@config["name"] = "spec-#{SecureRandom.uuid}"
@config["logging"] = { "file" => "#{@dir}/bmim.log" }
@@ -35,7 +35,7 @@ def load_deployment
it "should create a Bosh instance" do
@deployer.stub!(:service_ip).and_return("10.0.0.10")
- spec = YAML.load_file(spec_asset("apply_spec_vcloud.yml"))
+ spec = Psych.load_file(spec_asset("apply_spec_vcloud.yml"))
Bosh::Deployer::Specification.should_receive(:load_apply_spec).and_return(spec)
Bosh::Deployer::Config.stub(:agent_properties).and_return({})
@@ -98,7 +98,7 @@ def load_deployment
it "should update a Bosh instance" do
@deployer.stub!(:service_ip).and_return("10.0.0.10")
- spec = YAML.load_file(spec_asset("apply_spec_vcloud.yml"))
+ spec = Psych.load_file(spec_asset("apply_spec_vcloud.yml"))
disk_cid = "22"
Bosh::Deployer::Specification.should_receive(:load_apply_spec).and_return(spec)
Bosh::Deployer::Config.stub(:agent_properties).and_return({})
View
2  bosh_openstack_cpi/bin/bosh_openstack_console
@@ -30,7 +30,7 @@ unless config_file
exit(1)
end
-@config = YAML.load_file(config_file)
+@config = Psych.load_file(config_file)
module ConsoleHelpers
def cpi
View
2  bosh_registry/lib/bosh_registry/yaml_helper.rb
@@ -8,7 +8,7 @@ def load_yaml_file(path, expected_type = Hash)
raise(ConfigError, "Cannot find file `#{path}'")
end
- yaml = YAML.load_file(path)
+ yaml = Psych.load_file(path)
if expected_type && !yaml.is_a?(expected_type)
raise ConfigError, "Incorrect file format in `#{path}', " \
View
4 bosh_registry/spec/unit/runner_spec.rb
@@ -10,7 +10,7 @@ def make_runner(config_file)
def write_config(file, config)
File.open(file, "w") do |f|
- YAML.dump(config, f)
+ Psych.dump(config, f)
end
end
@@ -44,7 +44,7 @@ def write_config(file, config)
config_file = Tempfile.new("config")
write_config(config_file.path, { "foo" => "bar" })
- YAML.stub!(:load_file).and_raise(SystemCallError.new("baz"))
+ Psych.stub!(:load_file).and_raise(SystemCallError.new("baz"))
expect {
make_runner(config_file.path)
View
4 bosh_vcloud_cpi/spec/spec_helper.rb
@@ -10,7 +10,7 @@ def spec_asset(filename)
end
def test_configuration
- @@test_config ||= YAML.load_file(spec_asset("test-director-config.yml"))
+ @@test_config ||= Psych.load_file(spec_asset("test-director-config.yml"))
end
def vcd_settings
@@ -29,7 +29,7 @@ def get_vcd_settings
def test_deployment_manifest
@@test_manifest ||=
- YAML.load_file(spec_asset("test-deployment-manifest.yml"))
+ Psych.load_file(spec_asset("test-deployment-manifest.yml"))
end
def generate_unique_name
View
2  director/bin/console
@@ -41,7 +41,7 @@ module Bosh
end
puts "=> Loading #{config_file}"
- Bosh::Director::Config.configure(YAML.load(File.read(config_file)))
+ Bosh::Director::Config.configure(Psych.load(File.read(config_file)))
context.instance_eval do
include BD::Models
View
2  director/bin/director
@@ -14,7 +14,7 @@ end
opts.parse!(ARGV.dup)
config_file ||= ::File.expand_path("../../config/bosh-director.yml", __FILE__)
-config = YAML.load_file(config_file)
+config = Psych.load_file(config_file)
Bosh::Director::Config.configure(config)
View
2  director/bin/drain_workers
@@ -18,7 +18,7 @@ end
opts.parse!(ARGV.dup)
config_file ||= ::File.expand_path("../../config/bosh-director.yml", __FILE__)
-config = YAML.load_file(config_file)
+config = Psych.load_file(config_file)
Bosh::Director::Config.configure(config)
View
2  director/bin/migrate
@@ -20,7 +20,7 @@ if config_file.nil?
exit 1
end
-config = YAML.load_file(config_file)
+config = Psych.load_file(config_file)
unless config["db"] && config["db"]["database"]
abort ("Director database config missing from config file")
end
View
4 director/bin/worker
@@ -41,9 +41,9 @@ if erb
template = ERB.new(File.read(config_file), 0, "%<>-")
contents = template.result(ConfigBindingHelper.new(index).get_binding)
- config = YAML.load(contents)
+ config = Psych.load(contents)
else
- config = YAML.load_file(config_file)
+ config = Psych.load_file(config_file)
end
Bosh::Director::Config.configure(config)
View
2  director/db/migrations/director/20110617211923_add_deployments_release_versions.rb
@@ -10,7 +10,7 @@
end
self[:deployments].each do |deployment|
- manifest = YAML.load(deployment[:manifest])
+ manifest = Psych.load(deployment[:manifest])
unless manifest.is_a?(Hash) && manifest["release"] && manifest["release"]["version"]
raise "Invalid manifest for `#{deployment[:name]}', no version data"
View
2  director/lib/director.rb
@@ -457,7 +457,7 @@ def authorized?
end
post "/packages/matches", :consumes => :yaml do
- manifest = YAML.load(request.body)
+ manifest = Psych.load(request.body)
unless manifest.is_a?(Hash) && manifest["packages"].is_a?(Array)
raise BadManifest, "Manifest doesn't have a usable packages section"
end
View
2  director/lib/director/configuration_hasher.rb
@@ -30,7 +30,7 @@ def extract_template(template)
# @param [DeploymentPlan::Template]
def process_template(job_template)
template_dir = extract_template(job_template)
- manifest = YAML.load_file(File.join(template_dir, "job.MF"))
+ manifest = Psych.load_file(File.join(template_dir, "job.MF"))
monit_template = erb(File.join(template_dir, "monit"))
monit_template.filename = File.join(job_template.name, "monit")
View
2  director/lib/director/jobs/update_deployment.rb
@@ -26,7 +26,7 @@ def initialize(manifest_file, options = {})
"job_rename" => options["job_rename"] || {}
}
- manifest_as_hash = YAML.load(@manifest)
+ manifest_as_hash = Psych.load(@manifest)
@deployment_plan = DeploymentPlan.new(manifest_as_hash, plan_options)
@deployment_plan.parse
logger.info("Created deployment plan")
View
4 director/lib/director/jobs/update_release.rb
@@ -89,7 +89,7 @@ def verify_manifest
raise ReleaseManifestNotFound, "Release manifest not found"
end
- @manifest = YAML.load_file(manifest_file)
+ @manifest = Psych.load_file(manifest_file)
normalize_manifest
@name = @manifest["name"]
@@ -508,7 +508,7 @@ def create_job(job_meta)
"Missing job manifest for `#{template.name}'"
end
- job_manifest = YAML.load_file(manifest_file)
+ job_manifest = Psych.load_file(manifest_file)
if job_manifest["templates"]
job_manifest["templates"].each_key do |relative_path|
View
2  director/lib/director/jobs/update_stemcell.rb
@@ -33,7 +33,7 @@ def perform
track_and_log("Verifying stemcell manifest") do
stemcell_manifest_file = File.join(stemcell_dir, "stemcell.MF")
- stemcell_manifest = YAML.load_file(stemcell_manifest_file)
+ stemcell_manifest = Psych.load_file(stemcell_manifest_file)
@name = safe_property(stemcell_manifest, "name", :class => String)
@version = safe_property(stemcell_manifest, "version", :class => String)
View
2  director/spec/cpi/sandbox.rb
@@ -8,7 +8,7 @@ class Sandbox
class << self
def start
run_with_pid("nats-server -p #{NATS_PORT}", NATS_PID)
- test_config = YAML.load(spec_asset("test-cpi-config.yml"))
+ test_config = Psych.load(spec_asset("test-cpi-config.yml"))
test_config["cloud"]["properties"]["mbus"] = "nats://localhost:#{NATS_PORT}"
test_config["mbus"] = "nats://localhost:#{NATS_PORT}"
test_config
View
16 director/spec/functional/director_controller_spec.rb
@@ -13,7 +13,7 @@
FileUtils.mkdir_p(@blobstore_dir)
FileUtils.mkdir_p(@temp_dir)
- test_config = YAML.load(spec_asset("test-director-config.yml"))
+ test_config = Psych.load(spec_asset("test-director-config.yml"))
test_config["dir"] = @temp_dir
test_config["blobstore"] = {
"provider" => "local",
@@ -150,7 +150,7 @@ def payload(content_type, params)
describe "job management" do
it "allows putting jobs into different states" do
BD::Models::Deployment.
- create(:name => "foo", :manifest => YAML.dump({"foo" => "bar"}))
+ create(:name => "foo", :manifest => Psych.dump({"foo" => "bar"}))
put "/deployments/foo/jobs/nats?state=stopped", {},
payload("text/yaml", spec_asset("test_conf.yaml"))
expect_redirect_to_queued_task(last_response)
@@ -158,7 +158,7 @@ def payload(content_type, params)
it "allows putting job instances into different states" do
BD::Models::Deployment.
- create(:name => "foo", :manifest => YAML.dump({"foo" => "bar"}))
+ create(:name => "foo", :manifest => Psych.dump({"foo" => "bar"}))
put "/deployments/foo/jobs/dea/2?state=stopped", {},
payload("text/yaml", spec_asset("test_conf.yaml"))
expect_redirect_to_queued_task(last_response)
@@ -174,7 +174,7 @@ def payload(content_type, params)
describe "log management" do
it "allows fetching logs from a particular instance" do
deployment = BD::Models::Deployment.
- create(:name => "foo", :manifest => YAML.dump({"foo" => "bar"}))
+ create(:name => "foo", :manifest => Psych.dump({"foo" => "bar"}))
instance = BD::Models::Instance.
create(:deployment => deployment, :job => "nats",
:index => "0", :state => "started")
@@ -189,7 +189,7 @@ def payload(content_type, params)
it "404 if no deployment" do
deployment = BD::Models::Deployment.
- create(:name => "bar", :manifest => YAML.dump({"foo" => "bar"}))
+ create(:name => "bar", :manifest => Psych.dump({"foo" => "bar"}))
get "/deployments/bar/jobs/nats/0/logs", {}
last_response.status.should == 404
end
@@ -313,12 +313,12 @@ def payload(content_type, params)
it "returns manifest" do
deployment = BD::Models::Deployment.
create(:name => "test_deployment",
- :manifest => YAML.dump({"foo" => "bar"}))
+ :manifest => Psych.dump({"foo" => "bar"}))
get "/deployments/test_deployment"
last_response.status.should == 200
body = Yajl::Parser.parse(last_response.body)
- YAML.load(body["manifest"]).should == {"foo" => "bar"}
+ Psych.load(body["manifest"]).should == {"foo" => "bar"}
end
end
@@ -326,7 +326,7 @@ def payload(content_type, params)
it "returns a list of agent_ids, jobs and indices" do
deployment = BD::Models::Deployment.
create(:name => "test_deployment",
- :manifest => YAML.dump({"foo" => "bar"}))
+ :manifest => Psych.dump({"foo" => "bar"}))
vms = []
15.times do |i|
View
4 director/spec/spec_helper.rb
@@ -353,7 +353,7 @@ def create_release_tarball(manifest)
"packages" => job["packages"]
}
File.open(File.join(job_dir, "job.MF"), "w") do |f|
- YAML.dump(spec, f)
+ Psych.dump(spec, f)
end
templates_dir = File.join(job_dir, "templates")
@@ -402,7 +402,7 @@ def create_release_tarball(manifest)
end
File.open(File.join(tmp_dir, "release.MF"), "w") do |f|
- YAML.dump(manifest, f)
+ Psych.dump(manifest, f)
end
Dir.chdir(release_dir) do
View
2  director/spec/unit/api_controller_spec.rb
@@ -13,7 +13,7 @@
FileUtils.mkdir_p(@blobstore_dir)
FileUtils.mkdir_p(@temp_dir)
- test_config = YAML.load(spec_asset('test-director-config.yml'))
+ test_config = Psych.load(spec_asset('test-director-config.yml'))
test_config['dir'] = @temp_dir
test_config['blobstore'] = {
'provider' => 'local',
View
2  director/spec/unit/config_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
describe Bosh::Director::Config do
- let(:test_config) { YAML.load(spec_asset("test-director-config.yml")) }
+ let(:test_config) { Psych.load(spec_asset("test-director-config.yml")) }
context "max_tasks" do
it "can set max_tasks in config" do
View
2  director/spec/unit/jobs/delete_release_spec.rb
@@ -73,7 +73,7 @@
rv1 = BDM::ReleaseVersion.make(:release => release, :version => "1")
rv2 = BDM::ReleaseVersion.make(:release => release, :version => "2")
- manifest = YAML.dump(
+ manifest = Psych.dump(
"release" => {"name" => "test_release", "version" => "2"})
deployment = BDM::Deployment.make(:name => "test_deployment",
View
2  director/spec/unit/jobs/update_deployment_spec.rb
@@ -28,7 +28,7 @@
f.write("manifest")
end
- YAML.stub!(:load).with("manifest").and_return(@manifest)
+ Psych.stub!(:load).with("manifest").and_return(@manifest)
Bosh::Director::DeploymentPlan.stub!(:new).with(@manifest, "recreate" => false, "job_states" => { },
"job_rename" => { }).and_return(@deployment_plan)
View
2  health_monitor/lib/health_monitor/yaml_helper.rb
@@ -3,7 +3,7 @@ module YamlHelper
def load_yaml_file(path, expected_type = Hash)
raise(ConfigError, "Cannot find file `#{path}'") unless File.exists?(path)
- yaml = YAML.load_file(path)
+ yaml = Psych.load_file(path)
if expected_type && !yaml.is_a?(expected_type)
raise ConfigError, "Incorrect file format in `#{path}', #{expected_type} expected"
View
2  health_monitor/spec/unit/agent_manager_spec.rb
@@ -165,7 +165,7 @@ def make_manager
let(:mock_nats) { mock('nats') }
before do
- Bhm::config=YAML.load_file(sample_config)
+ Bhm::config=Psych.load_file(sample_config)
mock_nats.stub(:subscribe)
Bhm.stub(:nats).and_return(mock_nats)
end
View
10 package_compiler/lib/package_compiler/compiler.rb
@@ -50,14 +50,14 @@ def connect_to_agent
def compile
@logger.info("Compiling #{@options["manifest"]} with tarball #{@options["release"]}")
connect_to_agent
- deployment_mf = YAML.load_file(File.expand_path(@options["manifest"]))
+ deployment_mf = Psych.load_file(File.expand_path(@options["manifest"]))
@spec = prep_spec(deployment_mf)
@packages = {}
@spec["job"] = { "name" => @options[:job] }