Skip to content
Browse files

style cleanup

  • Loading branch information...
1 parent 6904ae5 commit 83964d464d4d0230311ee938e5b76282631ef0ff Vadim Spivak committed Feb 28, 2011
View
2 director/.autotest
@@ -4,7 +4,7 @@ require 'autotest/restart'
require 'autotest/timestamp'
Autotest.add_hook :initialize do |at|
- %w{.git vendor spec/functional}.each {|exception| at.add_exception(exception)}
+ %w{.git vendor spec/functional}.each { |exception| at.add_exception(exception) }
at.clear_mappings
at.add_mapping(%r%^spec/unit/.*_spec\.rb$%) { |filename, _| filename }
View
2 director/bin/drain_workers
@@ -28,7 +28,7 @@ logger = Bosh::Director::Config.logger
loop do
logger.info("Checking for any workers that are still processing..")
- worker = Resque::Worker.all.find {|worker| worker.working? }
+ worker = Resque::Worker.all.find { |worker| worker.working? }
if worker.nil?
logger.info("All workers are idle")
break
View
2 director/lib/director.rb
@@ -71,7 +71,7 @@ module Bosh; module Director; end; end
module Bosh::Director
class Controller
- PUBLIC_URLS = [ "/status" ]
+ PUBLIC_URLS = ["/status"]
def call(env)
api_controller = ApiController.new
View
2 director/lib/director/client.rb
@@ -20,7 +20,7 @@ def method_missing(method_name, *args)
cond = result.new_cond
timeout_time = Time.now.to_f + @timeout
- request = { :method => method_name, :arguments => args }
+ request = {:method => method_name, :arguments => args}
request_id = @nats_rpc.send("#{@service_name}.#{@client_id}", request) do |response|
result.synchronize do
result.merge!(response)
View
8 director/lib/director/cloud.rb
@@ -36,13 +36,13 @@ def delete_stemcell(stemcell)
# the provided disk so it won't have to move when the disk is attached later.
#
# Sample networking config:
- # {"network_a"=>
+ # {"network_a" =>
# {
# "netmask" => "255.255.248.0",
# "ip" => "172.30.41.40",
# "gateway" => "172.30.40.1",
- # "dns" => [ "172.30.22.153", "172.30.22.154" ],
- # "cloud_properties" => { "name" => "VLAN444" }
+ # "dns" => ["172.30.22.153", "172.30.22.154"],
+ # "cloud_properties" => {"name" => "VLAN444"}
# }
# }
#
@@ -53,7 +53,7 @@ def delete_stemcell(stemcell)
# "cpu" => 1
# }
# or similar for EC2:
- # { "name" => "m1.small" }
+ # {"name" => "m1.small"}
#
# @param [String] agent_id UUID for the agent that will be used later on by the director
# to locate and talk to the agent
View
6 director/lib/director/cloud/vsphere/client.rb
@@ -45,7 +45,7 @@ def get_properties(obj, type, properties, options = {})
if obj.is_a?(ManagedObjectReference)
object_spec = ObjectSpec.new(nil, nil, obj, false)
else
- object_spec = obj.collect {|o| ObjectSpec.new(nil, nil, o, false)}
+ object_spec = obj.collect { |o| ObjectSpec.new(nil, nil, o, false) }
end
filter_spec = PropertyFilterSpec.new(nil, nil, property_specs, object_spec)
@@ -210,7 +210,7 @@ def move_disk(source_datacenter, source_path, destination_datacenter, destinatio
def find_by_inventory_path(path)
path = [path] unless path.kind_of?(Array)
- path = path.flatten.collect {|name| name.gsub("/", "%2f")}.join("/")
+ path = path.flatten.collect { |name| name.gsub("/", "%2f") }.join("/")
find_request = FindByInventoryPathRequestType.new(@service_content.searchIndex, path)
@service.findByInventoryPath(find_request).returnval
end
@@ -294,7 +294,7 @@ def get_all_properties(request)
result = []
until response.nil?
- response.objects.each {|object_content| result << object_content}
+ response.objects.each { |object_content| result << object_content }
break if response.token.nil?
View
20 director/lib/director/cloud/vsphere/cloud.rb
@@ -78,7 +78,7 @@ def create_stemcell(image, _)
output = `tar -C #{temp_dir} -xzf #{image} 2>&1`
raise "Corrupt image, tar exit status: #{$?.exitstatus} output: #{output}" if $?.exitstatus != 0
- ovf_file = Dir.entries(temp_dir).find {|entry| File.extname(entry) == ".ovf"}
+ ovf_file = Dir.entries(temp_dir).find { |entry| File.extname(entry) == ".ovf" }
raise "Missing OVF" if ovf_file.nil?
ovf_file = File.join(temp_dir, ovf_file)
@@ -106,7 +106,7 @@ def create_stemcell(image, _)
config = VirtualMachineConfigSpec.new
config.deviceChange = []
- nics = devices.select {|device| device.kind_of?(VirtualEthernetCard)}
+ nics = devices.select { |device| device.kind_of?(VirtualEthernetCard) }
nics.each do |nic|
nic_config = create_delete_device_spec(nic)
config.deviceChange << nic_config
@@ -172,8 +172,8 @@ def create_vm(agent_id, stemcell, resource_pool, networks, disk_locality = nil)
config.numCPUs = cpu
config.deviceChange = []
- system_disk = devices.find {|device| device.kind_of?(VirtualDisk)}
- pci_controller = devices.find {|device| device.kind_of?(VirtualPCIController)}
+ system_disk = devices.find { |device| device.kind_of?(VirtualDisk) }
+ pci_controller = devices.find { |device| device.kind_of?(VirtualPCIController) }
file_name = "[#{datastore.name}] #{name}/ephemeral_disk.vmdk"
ephemeral_disk_config = create_disk_config_spec(datastore.mob, file_name, system_disk.controllerKey, disk,
@@ -188,7 +188,7 @@ def create_vm(agent_id, stemcell, resource_pool, networks, disk_locality = nil)
config.deviceChange << nic_config
end
- nics = devices.select {|device| device.kind_of?(VirtualEthernetCard)}
+ nics = devices.select { |device| device.kind_of?(VirtualEthernetCard) }
nics.each do |nic|
nic_config = create_delete_device_spec(nic)
config.deviceChange << nic_config
@@ -301,12 +301,12 @@ def configure_networks(vm_cid, networks)
datacenter = client.find_parent(vm, "Datacenter")
datacenter_name = client.get_property(datacenter, "Datacenter", "name")
- pci_controller = devices.find {|device| device.kind_of?(VirtualPCIController)}
+ pci_controller = devices.find { |device| device.kind_of?(VirtualPCIController) }
config = VirtualMachineConfigSpec.new
config.deviceChange = []
- nics = devices.select {|device| device.kind_of?(VirtualEthernetCard)}
+ nics = devices.select { |device| device.kind_of?(VirtualEthernetCard) }
nics.each do |nic|
nic_config = create_delete_device_spec(nic)
config.deviceChange << nic_config
@@ -400,7 +400,7 @@ def attach_disk(vm_cid, disk_cid)
config = VirtualMachineConfigSpec.new
config.deviceChange = []
- system_disk = devices.find {|device| device.kind_of?(VirtualDisk)}
+ system_disk = devices.find { |device| device.kind_of?(VirtualDisk) }
vmdk_path = "#{disk.path}.vmdk"
attached_disk_config = create_disk_config_spec(vm_datastore_by_name[disk.datastore], vmdk_path,
@@ -663,10 +663,10 @@ def generate_env_iso(env)
Dir.mktmpdir do |path|
env_path = File.join(path, "env")
iso_path = File.join(path, "env.iso")
- File.open(env_path, "w") {|f| f.write(env)}
+ File.open(env_path, "w") { |f| f.write(env) }
output = `genisoimage -o #{iso_path} #{env_path} 2>&1`
raise "#{$?.exitstatus} -#{output}" if $?.exitstatus != 0
- File.open(iso_path, "r") {|f| f.read}
+ File.open(iso_path, "r") { |f| f.read }
end
end
View
8 director/lib/director/cloud/vsphere/resources.rb
@@ -180,7 +180,7 @@ def fetch_cluster_utilization(cluster, host_mobs)
def average_csv(csv)
values = csv.split(",")
result = 0
- values.each {|v| result += v.to_f}
+ values.each { |v| result += v.to_f }
result / values.size
end
@@ -212,8 +212,8 @@ def find_least_loaded_cluster(memory)
raise "No available clusters" if clusters.empty?
- clusters.sort! {|cluster_1, cluster_2| score_cluster(cluster_2, memory, max_free_memory) -
- score_cluster(cluster_1, memory, max_free_memory)}
+ clusters.sort! { |cluster_1, cluster_2| score_cluster(cluster_2, memory, max_free_memory) -
+ score_cluster(cluster_1, memory, max_free_memory) }
clusters = clusters[0..2]
cluster_scores = clusters.collect do |cluster|
@@ -241,7 +241,7 @@ def find_least_loaded_datastore(cluster, space)
raise "No available datastore" if datastores.empty?
- datastores.sort!{|ds1, ds2| score_datastore(ds2, space) - score_datastore(ds1, space)}
+ datastores.sort! { |ds1, ds2| score_datastore(ds2, space) - score_datastore(ds1, space) }
result = datastores.first
@logger.debug("Picked: #{result.inspect}")
View
2 director/lib/director/config.rb
@@ -137,7 +137,7 @@ def connect(server)
retries < 20
end
- connection_pragmas.each{|s| log_yield(s){db.execute_batch(s)}}
+ connection_pragmas.each { |s| log_yield(s) { db.execute_batch(s) } }
class << db
attr_reader :prepared_statements
View
2 director/lib/director/cycle_helper.rb
@@ -22,7 +22,7 @@ def self.check_for_cycle_helper(path, valid_vertices, vertex, connected_vertices
if path.include?(edge)
vertex_path = []
path = path.invert
- path.size.times {|index| vertex_path << path[index + 1]}
+ path.size.times { |index| vertex_path << path[index + 1] }
raise "Cycle: #{vertex_path.join("=>")}=>#{edge}"
end
check_for_cycle_helper(path, valid_vertices, edge, connected_vertices, &block)
View
2 director/lib/director/deployment_plan.rb
@@ -252,7 +252,7 @@ def initialize(network, subnet_spec)
first_ip = @range.first(:Objectify => true)
last_ip = @range.last(:Objectify => true)
- (first_ip.to_i .. last_ip.to_i).each {|ip| @available_dynamic_ips << ip}
+ (first_ip.to_i .. last_ip.to_i).each { |ip| @available_dynamic_ips << ip }
@available_dynamic_ips.delete(@gateway.to_i)
@available_dynamic_ips.delete(@range.network(:Objectify => true).to_i)
View
2 director/lib/director/jobs/update_deployment.rb
@@ -9,7 +9,7 @@ def initialize(manifest_file)
@logger = Config.logger
@logger.info("Reading deployment manifest")
@manifest_file = manifest_file
- @manifest = File.open(@manifest_file) {|f| f.read}
+ @manifest = File.open(@manifest_file) { |f| f.read }
@logger.debug("Manifest:\n#{@manifest}")
@logger.info("Creating deployment plan")
@deployment_plan = DeploymentPlan.new(YAML.load(@manifest))
View
2 director/lib/director/jobs/update_release.rb
@@ -95,7 +95,7 @@ def resolve_package_dependencies(packages)
packages_by_name[package["name"]] = package
package["dependencies"] ||= []
end
- dependency_lookup = lambda {|package_name| packages_by_name[package_name]["dependencies"]}
+ dependency_lookup = lambda { |package_name| packages_by_name[package_name]["dependencies"] }
result = CycleHelper.check_for_cycle(packages_by_name.keys, :connected_vertices=> true, &dependency_lookup)
packages.each do |package|
@logger.info("Resolving package dependencies for: #{package["name"]}, " +
View
20 director/spec/Rakefile
@@ -31,7 +31,7 @@ namespace "redis" do
false
end
- system "redis-server #{REDIS_CNF}" unless redis_running
+ system "redis-server #{REDIS_CNF}" unless redis_running
end
desc "Stop Redis instance"
@@ -41,33 +41,33 @@ namespace "redis" do
FileUtils.rm REDIS_PID
end
end
-
+
end
-task :spec => [ "spec:all" ]
+task :spec => ["spec:all"]
namespace "spec" do
gemfile = "../Gemfile"
spec_opts = ["--format", "documentation", "--colour"]
desc "Run unit tests"
- task "unit" => [ "run_unit" ]
+ task "unit" => ["run_unit"]
desc "Run functional tests"
task "functional" => ["redis:start", "run_functional", "redis:stop" ]
- task "all" => [ "redis:start", "run_all", "redis:stop" ]
+ task "all" => ["redis:start", "run_all", "redis:stop"]
desc "Run specs for rcov"
- task "rcov" => [ "redis:start", "run_rcov", "redis:stop" ]
+ task "rcov" => ["redis:start", "run_rcov", "redis:stop"]
desc "Run specs for ci"
- task "ci" => [ "ci:setup:rspec", "spec:rcov", "convert_rcov_to_clover" ]
+ task "ci" => ["ci:setup:rspec", "spec:rcov", "convert_rcov_to_clover"]
RSpec::Core::RakeTask.new("run_all") do |t|
t.gemfile = gemfile
t.rspec_opts = spec_opts
- t.pattern = "**/*_spec.rb"
+ t.pattern = "**/*_spec.rb"
end
RSpec::Core::RakeTask.new("run_unit") do |t|
@@ -96,9 +96,9 @@ namespace "spec" do
clover_output = File.join(coverage_dir, "clover.xml")
sh("bundle exec rcov_analyzer #{dump_file} #{ignore_pattern} > #{clover_output}")
- FileUtils.rm_rf(dump_file)
+ FileUtils.rm_rf(dump_file)
end
-
+
end
View
18 director/spec/spec_helper.rb
@@ -58,7 +58,7 @@ def spec_asset(filename)
def gzip(string)
result = StringIO.new
- zio = Zlib::GzipWriter.new(result)
+ zio = Zlib::GzipWriter.new(result, nil, nil)
zio.mtime = 1
zio.write(string)
zio.close
@@ -75,8 +75,8 @@ def create_stemcell(name, version, cloud_properties, image)
}
Archive::Tar::Minitar::Writer.open(io) do |tar|
- tar.add_file("stemcell.MF", {:mode => "0644", :mtime => 0}) {|os, _| os.write(manifest.to_yaml)}
- tar.add_file("image", {:mode => "0644", :mtime => 0}) {|os, _| os.write(image)}
+ tar.add_file("stemcell.MF", {:mode => "0644", :mtime => 0}) { |os, _| os.write(manifest.to_yaml) }
+ tar.add_file("image", {:mode => "0644", :mtime => 0}) { |os, _| os.write(image) }
end
io.close
@@ -96,8 +96,8 @@ def create_job(name, monit, configuration_files)
end
Archive::Tar::Minitar::Writer.open(io) do |tar|
- tar.add_file("job.MF", {:mode => "0644", :mtime => 0}) {|os, _| os.write(manifest.to_yaml)}
- tar.add_file("monit", {:mode => "0644", :mtime => 0}) {|os, _| os.write(monit)}
+ tar.add_file("job.MF", {:mode => "0644", :mtime => 0}) { |os, _| os.write(manifest.to_yaml) }
+ tar.add_file("monit", {:mode => "0644", :mtime => 0}) { |os, _| os.write(monit) }
tar.mkdir("templates", {:mode => "0755", :mtime => 0})
configuration_files.each do |path, configuration_file|
@@ -121,14 +121,14 @@ def create_release(name, version, jobs, packages)
}
Archive::Tar::Minitar::Writer.open(io) do |tar|
- tar.add_file("release.MF", {:mode => "0644", :mtime => 0}) {|os, _| os.write(manifest.to_yaml)}
+ tar.add_file("release.MF", {:mode => "0644", :mtime => 0}) { |os, _| os.write(manifest.to_yaml) }
tar.mkdir("packages", {:mode => "0755"})
packages.each do |package|
- tar.add_file("packages/#{package[:name]}.tgz", {:mode => "0644", :mtime => 0}) {|os, _| os.write("package")}
+ tar.add_file("packages/#{package[:name]}.tgz", {:mode => "0644", :mtime => 0}) { |os, _| os.write("package") }
end
tar.mkdir("jobs", {:mode => "0755"})
jobs.each do |job|
- tar.add_file("jobs/#{job[:name]}.tgz", {:mode => "0644", :mtime => 0}) {|os, _| os.write("job")}
+ tar.add_file("jobs/#{job[:name]}.tgz", {:mode => "0644", :mtime => 0}) { |os, _| os.write("job") }
end
end
@@ -141,7 +141,7 @@ def create_package(files)
Archive::Tar::Minitar::Writer.open(io) do |tar|
files.each do |key, value|
- tar.add_file(key, {:mode => "0644", :mtime => 0}) {|os, _| os.write(value)}
+ tar.add_file(key, {:mode => "0644", :mtime => 0}) { |os, _| os.write(value) }
end
end
View
8 director/spec/unit/client_spec.rb
@@ -8,15 +8,15 @@
Bosh::Director::Config.stub!(:nats_rpc).and_return(nats_rpc)
nats_rpc.should_receive(:send).with("test_service.test_service_id",
- {:arguments=>["arg 1", 2, {:test=>"blah"}], :method=>:test_method}
+ {:arguments => ["arg 1", 2, {:test => "blah"}], :method => :test_method}
).and_return { |*args|
callback = args[2]
callback.call({"value" => 5})
"3"
}
@client = Bosh::Director::Client.new("test_service", "test_service_id")
- @client.test_method("arg 1", 2, {:test =>"blah"}).should eql(5)
+ @client.test_method("arg 1", 2, {:test => "blah"}).should eql(5)
end
it "should handle exceptions" do
@@ -25,7 +25,7 @@
Bosh::Director::Config.stub!(:nats_rpc).and_return(nats_rpc)
nats_rpc.should_receive(:send).with("test_service.test_service_id",
- {:arguments=>["arg 1", 2, {:test=>"blah"}], :method=>:test_method}
+ {:arguments => ["arg 1", 2, {:test => "blah"}], :method => :test_method}
).and_return { |*args|
callback = args[2]
callback.call({"exception" => "test"})
@@ -42,7 +42,7 @@
Bosh::Director::Config.stub!(:nats_rpc).and_return(nats_rpc)
nats_rpc.should_receive(:send).with("test_service.test_service_id",
- {:arguments=>["arg 1", 2, {:test=>"blah"}], :method=>:test_method}
+ {:arguments => ["arg 1", 2, {:test => "blah"}], :method => :test_method}
).and_return("4")
nats_rpc.should_receive(:cancel).with("4")
View
14 director/spec/unit/cycle_helper_spec.rb
@@ -8,7 +8,7 @@
:B => [:A]
}
- lambda {Bosh::Director::CycleHelper.check_for_cycle([:A, :B, :C]) {|vertex| graph[vertex]}}.should raise_exception
+ lambda { Bosh::Director::CycleHelper.check_for_cycle([:A, :B, :C]) { |vertex| graph[vertex] } }.should raise_exception
end
it "should detect more complicated cycles" do
@@ -19,7 +19,7 @@
:D => [:B]
}
- lambda {Bosh::Director::CycleHelper.check_for_cycle([:A, :B, :C]) {|vertex| graph[vertex]}}.should raise_exception
+ lambda { Bosh::Director::CycleHelper.check_for_cycle([:A, :B, :C]) { |vertex| graph[vertex] } }.should raise_exception
end
it "should not detect cycles when it's acyclic" do
@@ -28,7 +28,7 @@
:B => [:C]
}
- Bosh::Director::CycleHelper.check_for_cycle([:A, :B, :C]) {|vertex| graph[vertex]}
+ Bosh::Director::CycleHelper.check_for_cycle([:A, :B, :C]) { |vertex| graph[vertex] }
end
it "should return connected vertices when requested" do
@@ -38,10 +38,10 @@
}
result = Bosh::Director::CycleHelper.check_for_cycle(
- [:A, :B, :C], :connected_vertices => true) {|vertex| graph[vertex]}
+ [:A, :B, :C], :connected_vertices => true) { |vertex| graph[vertex] }
- result[:connected_vertices].each {|key, value| result[:connected_vertices][key] = Set.new(value)}
- result.should eql({:connected_vertices=>{:C=>Set.new([]), :A=>Set.new([:C, :B]), :B=>Set.new([:C])}})
+ result[:connected_vertices].each { |key, value| result[:connected_vertices][key] = Set.new(value) }
+ result.should eql({:connected_vertices => {:C => Set.new([]), :A => Set.new([:C, :B]), :B => Set.new([:C])}})
end
it "should raise an exception when an referenced edge is not found" do
@@ -50,7 +50,7 @@
:B => [:D]
}
- lambda { Bosh::Director::CycleHelper.check_for_cycle([:A, :B, :C]) {|vertex| graph[vertex]} }.should raise_exception
+ lambda { Bosh::Director::CycleHelper.check_for_cycle([:A, :B, :C]) { |vertex| graph[vertex] } }.should raise_exception
end
end
View
2 director/spec/unit/deployment_plan_compiler_spec.rb
@@ -37,7 +37,7 @@
"dns" => ["1.2.3.4"]
}
},
- "properties" => {"key"=>"value"}
+ "properties" => {"key" => "value"}
}
before(:each) do
View
56 director/spec/unit/deployment_plan_spec.rb
@@ -193,7 +193,7 @@
"netmask" => "255.255.255.0",
"ip" => "10.0.0.100",
"gateway" => "10.0.0.1",
- "cloud_properties" => {"name"=>"net_a"},
+ "cloud_properties" => {"name" => "net_a"},
"dns" => ["1.2.3.4"]
}})
@@ -263,7 +263,7 @@
compilation_settings = deployment_plan.compilation
compilation_settings.workers.should eql(2)
compilation_settings.network.should eql(deployment_plan.network("network_a"))
- compilation_settings.cloud_properties.should eql({"ram"=>"512mb", "cpu"=>1, "disk"=>"2gb"})
+ compilation_settings.cloud_properties.should eql({"ram" => "512mb", "cpu" => 1, "disk" => "2gb"})
end
it "should parse deployment properties" do
@@ -281,7 +281,7 @@
deployment_plan = Bosh::Director::DeploymentPlan.new(manifest)
deployment_plan.properties.should eql({"foo" => "bar", "test" => {"a" => 5, "b" => 6}})
- deployment_plan.job("job_a").properties.should eql({"foo"=>"bar", "test"=>{"a"=>5, "b"=>7}})
+ deployment_plan.job("job_a").properties.should eql({"foo" => "bar", "test" => {"a" => 5, "b" => 7}})
end
end
@@ -292,7 +292,7 @@
manifest = BASIC_MANIFEST._deep_copy
job = manifest["jobs"].first
job["instances"] = 1
- job["networks"] = [ { "name" => "network_a" } ]
+ job["networks"] = [{"name" => "network_a"}]
5.times do |index|
new_job = job._deep_copy
@@ -381,14 +381,14 @@
"netmask" => "255.255.255.0",
"ip" => "10.0.0.20",
"gateway" => "10.0.0.1",
- "cloud_properties" => {"name"=>"net_a"},
+ "cloud_properties" => {"name" => "net_a"},
"dns" => ["1.2.3.4"]
}
},
"resource_pool" => {
"stemcell" => {"name" => "jeos", "version" => "1"},
"name" => "small",
- "cloud_properties" => {"cpu"=>1, "ram"=>"512mb", "disk"=>"2gb"}
+ "cloud_properties" => {"cpu" => 1, "ram" => "512mb", "disk" => "2gb"}
}
}
@@ -413,14 +413,14 @@
"netmask" => "255.255.255.0",
"ip" => "10.0.0.20",
"gateway" => "10.0.0.1",
- "cloud_properties" => {"name"=>"net_a"},
+ "cloud_properties" => {"name" => "net_a"},
"dns" => ["1.2.3.4"]
}
},
"resource_pool" => {
"stemcell" => {"name" => "jeos", "version" => "1"},
"name" => "small",
- "cloud_properties" => {"cpu"=>1, "ram"=>"512mb", "disk"=>"2gb"}
+ "cloud_properties" => {"cpu" => 1, "ram" => "512mb", "disk" => "2gb"}
}
}
@@ -445,14 +445,14 @@
"netmask" => "255.255.255.0",
"ip" => "10.0.0.20",
"gateway" => "10.0.0.1",
- "cloud_properties" => {"name"=>"net_a"},
+ "cloud_properties" => {"name" => "net_a"},
"dns" => ["1.2.3.4"]
}
},
"resource_pool" => {
"stemcell" => {"name" => "jeos", "version" => "1"},
"name" => "small",
- "cloud_properties" => {"cpu"=>2, "ram"=>"512mb", "disk"=>"2gb"}
+ "cloud_properties" => {"cpu" => 2, "ram" => "512mb", "disk" => "2gb"}
}
}
@@ -699,17 +699,17 @@
}
},
"resource_pool" => {
- "name"=>"small",
+ "name" => "small",
"stemcell" => {"name" => "jeos", "version" => "1"},
"cloud_properties" => {"ram" => "512mb", "cpu" => 1, "disk" => "2gb"}
},
"configuration_hash" => "config_hash",
"packages" => {
"test_package"=> {
- "name"=>"test_package",
- "blobstore_id"=>"pkg-blob-id",
- "sha1"=>"pkg-sha1",
- "version"=>"33.1"
+ "name" => "test_package",
+ "blobstore_id" => "pkg-blob-id",
+ "sha1" => "pkg-sha1",
+ "version" => "33.1"
}
},
"persistent_disk" => 2048,
@@ -805,7 +805,7 @@
it "should track instance changes compared to the current state (packages change)" do
current_state = CURRENT_STATE._deep_copy
- current_state["packages"] = {"pkg_a"=>{"name"=>"pkg_a", "sha1"=>"a_sha1", "version"=>1}}
+ current_state["packages"] = {"pkg_a" => {"name" => "pkg_a", "sha1" => "a_sha1", "version" => 1}}
@instance.current_state = current_state
@instance.networks_changed?.should be_false
@@ -836,32 +836,32 @@
"configuration_hash" => "config_hash",
"packages" => {
"test_package"=> {
- "name"=>"test_package",
- "blobstore_id"=>"pkg-blob-id",
- "sha1"=>"pkg-sha1",
- "version"=>"33.1"
+ "name" => "test_package",
+ "blobstore_id" => "pkg-blob-id",
+ "sha1" => "pkg-sha1",
+ "version" => "33.1"
}
},
"resource_pool" => {
"stemcell" => {"name" => "jeos", "version" => "1"},
"name" => "small",
- "cloud_properties" => { "ram" => "512mb", "cpu"=>1, "disk"=>"2gb" }
+ "cloud_properties" => {"ram" => "512mb", "cpu" => 1, "disk" => "2gb"}
},
"networks" => {
"network_a" => {
"netmask" => "255.255.255.0",
"ip" => "10.0.0.100",
"gateway" => "10.0.0.1",
- "cloud_properties" => { "name"=>"net_a" },
- "dns" => [ "1.2.3.4" ]
+ "cloud_properties" => {"name" => "net_a"},
+ "dns" => ["1.2.3.4"]
}
},
"index" => 0,
- "job" => { "name" => "job_a", "blobstore_id"=>"template_blob", "sha1" => "job-sha1", "version" => "1" },
+ "job" => {"name" => "job_a", "blobstore_id" => "template_blob", "sha1" => "job-sha1", "version" => "1"},
"persistent_disk" => 2048,
- "release" => { "name" => "test_release", "version" => "1" },
+ "release" => {"name" => "test_release", "version" => "1"},
"deployment" => "test_deployment",
- "properties" => { "test" => "property" }
+ "properties" => {"test" => "property"}
})
end
@@ -888,8 +888,8 @@
job.add_package(package_a, compiled_package_a)
job.add_package(package_b, compiled_package_b)
- job.package_spec.should eql({"a"=>{"name"=>"a", "blobstore_id"=>"blob-a", "sha1"=>"sha1-a", "version"=>"1.1"},
- "b"=>{"name"=>"b", "blobstore_id"=>"blob-b", "sha1"=>"sha1-b", "version"=>"2.3"}})
+ job.package_spec.should eql({"a" => {"name" => "a", "blobstore_id" => "blob-a", "sha1" => "sha1-a", "version" => "1.1"},
+ "b" => {"name" => "b", "blobstore_id" => "blob-b", "sha1" => "sha1-b", "version" => "2.3"}})
end
end
View
6 director/spec/unit/instance_updater_spec.rb
@@ -9,8 +9,8 @@
"blobstore_id" => "job_blob"
},
"release"=> {
- "name"=>"test_release",
- "version"=>99
+ "name" => "test_release",
+ "version" => 99
},
"index" => 5,
"configuration_hash" => "config_hash",
@@ -40,7 +40,7 @@
"dns" => ["1.2.3.4"]
}
},
- "properties" => {"key"=>"value"}
+ "properties" => {"key" => "value"}
}
IDLE_PLAN = {
"deployment" => "test_deployment",
View
6 director/spec/unit/jobs/update_release_spec.rb
@@ -66,7 +66,7 @@
it "should normalize nil dependencies" do
packages = [{"name" => "A"}, {"name" => "B", "dependencies" => ["A"]}]
@update_release_job.resolve_package_dependencies(packages)
- packages.should eql([{"dependencies"=>[], "name"=>"A"}, {"dependencies"=>["A"], "name"=>"B"}])
+ packages.should eql([{"dependencies" => [], "name" => "A"}, {"dependencies" => ["A"], "name" => "B"}])
end
it "should not allow cycles" do
@@ -77,8 +77,8 @@
it "should resolve nested dependencies" do
packages = [{"name" => "A", "dependencies" => ["B"]}, {"name" => "B", "dependencies" => ["C"]}, {"name" => "C"}]
@update_release_job.resolve_package_dependencies(packages)
- packages.should eql([{"dependencies"=>["B", "C"], "name"=>"A"}, {"dependencies"=>["C"], "name"=>"B"},
- {"dependencies"=>[], "name"=>"C"}])
+ packages.should eql([{"dependencies" => ["B", "C"], "name" => "A"}, {"dependencies" => ["C"], "name" => "B"},
+ {"dependencies" => [], "name" => "C"}])
end
end
View
6 director/spec/unit/jobs/update_stemcell_spec.rb
@@ -12,7 +12,7 @@
stemcell_contents = create_stemcell("jeos", 5, {"ram" => "2gb"}, "image contents")
@stemcell_file = Tempfile.new("stemcell_contents")
- File.open(@stemcell_file.path, "w") {|f| f.write(stemcell_contents)}
+ File.open(@stemcell_file.path, "w") { |f| f.write(stemcell_contents) }
end
after(:each) do
@@ -22,7 +22,7 @@
it "should upload the stemcell" do
@cloud.should_receive(:create_stemcell).with(anything(), {"ram" => "2gb"}).and_return do |image, _|
- contents = File.open(image) {|f| f.read}
+ contents = File.open(image) { |f| f.read }
contents.should eql("image contents")
"stemcell-cid"
end
@@ -37,7 +37,7 @@
it "should cleanup the stemcell file" do
@cloud.should_receive(:create_stemcell).with(anything(), {"ram" => "2gb"}).and_return do |image, _|
- contents = File.open(image) {|f| f.read}
+ contents = File.open(image) { |f| f.read }
contents.should eql("image contents")
"stemcell-cid"
end
View
32 director/spec/unit/package_compiler_spec.rb
@@ -75,12 +75,12 @@
agent = mock("agent")
Bosh::Director::AgentClient.should_receive(:new).with("agent-1").and_return(agent)
- @cloud.should_receive(:create_vm).with("agent-1", "stemcell-id", {"ram"=>"2gb"},
- {"network_a"=>{"ip"=>"1.2.3.4"}}).and_return("vm-1")
+ @cloud.should_receive(:create_vm).with("agent-1", "stemcell-id", {"ram" => "2gb"},
+ {"network_a" => {"ip" => "1.2.3.4"}}).and_return("vm-1")
agent.should_receive(:wait_until_ready)
- agent.should_receive(:apply).with(({"resource_pool"=>"package_compiler",
- "networks"=>{"network_a"=>{"ip"=>"1.2.3.4"}},
- "deployment"=>"test_deployment"})).and_return({"state" => "done"})
+ agent.should_receive(:apply).with(({"resource_pool" => "package_compiler",
+ "networks" => {"network_a" => {"ip" => "1.2.3.4"}},
+ "deployment" => "test_deployment"})).and_return({"state" => "done"})
agent.should_receive(:compile_package).with("package-blob", "package sha1", "test_pkg", "33.1", {}).
and_return({
"state" => "done",
@@ -139,12 +139,12 @@
agent_a = mock("agent")
Bosh::Director::AgentClient.should_receive(:new).with("agent-a").and_return(agent_a)
- @cloud.should_receive(:create_vm).with("agent-a", "stemcell-id", {"ram"=>"2gb"},
- {"network_a"=>{"ip"=>"1.2.3.4"}}).and_return("vm-1")
+ @cloud.should_receive(:create_vm).with("agent-a", "stemcell-id", {"ram" => "2gb"},
+ {"network_a" => {"ip" => "1.2.3.4"}}).and_return("vm-1")
agent_a.should_receive(:wait_until_ready)
- agent_a.should_receive(:apply).with(({"resource_pool"=>"package_compiler",
- "networks"=>{"network_a"=>{"ip"=>"1.2.3.4"}},
- "deployment"=>"test_deployment"})).and_return({"state" => "done"})
+ agent_a.should_receive(:apply).with(({"resource_pool" => "package_compiler",
+ "networks" => {"network_a" => {"ip" => "1.2.3.4"}},
+ "deployment" => "test_deployment"})).and_return({"state" => "done"})
agent_a.should_receive(:compile_package).with("dep-blb-id", "dep-sha1", "dependency", "77.1", {}).
and_return({
"state" => "done",
@@ -157,16 +157,16 @@
agent_b = mock("agent-b")
Bosh::Director::AgentClient.should_receive(:new).with("agent-b").and_return(agent_b)
- @cloud.should_receive(:create_vm).with("agent-b", "stemcell-id", {"ram"=>"2gb"},
- {"network_a"=>{"ip"=>"1.2.3.4"}}).and_return("vm-2")
+ @cloud.should_receive(:create_vm).with("agent-b", "stemcell-id", {"ram" => "2gb"},
+ {"network_a" => {"ip" => "1.2.3.4"}}).and_return("vm-2")
agent_b.should_receive(:wait_until_ready)
- agent_b.should_receive(:apply).with(({"resource_pool"=>"package_compiler",
- "networks"=>{"network_a"=>{"ip"=>"1.2.3.4"}},
- "deployment"=>"test_deployment"})).and_return({"state" => "done"})
+ agent_b.should_receive(:apply).with(({"resource_pool" => "package_compiler",
+ "networks" => {"network_a" => {"ip" => "1.2.3.4"}},
+ "deployment" => "test_deployment"})).and_return({"state" => "done"})
agent_b.should_receive(:compile_package).with("package-blob", "package sha1", "test_pkg", "33.1",
- {"dependency" => {"name"=>"dependency",
+ {"dependency" => {"name" => "dependency",
"blobstore_id" => "compiled-dep-blb-id",
"sha1" => "compiled-dep-sha1",
"version" => "77.1"}}).
View
16 director/spec/unit/resource_pool_updater_spec.rb
@@ -49,7 +49,7 @@
idle_vm.stub!(:network_settings).and_return({"network_a" => {"ip" => "1.2.3.4"}})
idle_vm.stub!(:vm).and_return(nil)
- @cloud.should_receive(:create_vm).with("agent-1", "stemcell-id", {"ram"=>"2gb"},
+ @cloud.should_receive(:create_vm).with("agent-1", "stemcell-id", {"ram" => "2gb"},
{"network_a" => {"ip" => "1.2.3.4"}}).and_return("vm-1")
Bosh::Director::AgentClient.stub!(:new).with("agent-1").and_return(agent)
@@ -64,8 +64,8 @@
end
agent.should_receive(:wait_until_ready)
- agent.should_receive(:apply).with({"resource_pool"=>{"name"=>"foo"}, "networks"=>{"network_a"=>{"ip"=>"1.2.3.4"}},
- "deployment"=>"deployment_name"}).
+ agent.should_receive(:apply).with({"resource_pool" => {"name" => "foo"}, "networks" => {"network_a" => {"ip" => "1.2.3.4"}},
+ "deployment" => "deployment_name"}).
and_return({"agent_task_id" => 5, "state" => "done"})
agent.should_receive(:get_state).and_return({"state" => "testing"})
idle_vm.should_receive(:current_state=).with({"state" => "testing"})
@@ -113,17 +113,17 @@
idle_vm.stub!(:vm).and_return {current_vm}
@cloud.should_receive(:delete_vm).with("vm-1")
- @cloud.should_receive(:create_vm).with("agent-1", "stemcell-id", {"ram"=>"2gb"},
- {"ip"=>"1.2.3.4"}).and_return("vm-2")
+ @cloud.should_receive(:create_vm).with("agent-1", "stemcell-id", {"ram" => "2gb"},
+ {"ip" => "1.2.3.4"}).and_return("vm-2")
Bosh::Director::AgentClient.stub!(:new).with("agent-1").and_return(agent)
- idle_vm.should_receive(:vm=).with(nil).and_return {|vm| current_vm = vm}
+ idle_vm.should_receive(:vm=).with(nil).and_return { |vm| current_vm = vm }
idle_vm.should_receive(:current_state=).with(nil)
agent.should_receive(:wait_until_ready)
- agent.should_receive(:apply).with({"resource_pool"=>{"name"=>"foo"}, "networks"=>{"ip"=>"1.2.3.4"},
- "deployment"=>"deployment_name"}).
+ agent.should_receive(:apply).with({"resource_pool" => {"name" => "foo"}, "networks" => {"ip" => "1.2.3.4"},
+ "deployment" => "deployment_name"}).
and_return({"agent_task_id" => 5, "state" => "done"})
agent.should_receive(:get_state).and_return({"state" => "testing"})
idle_vm.should_receive(:vm=).with { |vm|

0 comments on commit 83964d4

Please sign in to comment.
Something went wrong with that request. Please try again.