class Bosh::Clouds::Dummy::CommandTransport
Example file system layout for arranging commands information. Currently uses file system as transport but could be switch to use NATS.
base_dir/cpi/create_vm/next -> {"something": true}
Public Class Methods
new(base_dir, logger)
click to toggle source
# File lib/cloud/dummy.rb, line 479 def initialize(base_dir, logger) @cpi_commands = File.join(base_dir, 'cpi_commands') @logger = logger end
Public Instance Methods
allow_create_vm_to_succeed()
click to toggle source
# File lib/cloud/dummy.rb, line 533 def allow_create_vm_to_succeed @logger.info("Allowing create_vm method to succeed (removing any mandatory failures)") FileUtils.rm(failed_path) end
make_create_vm_always_fail()
click to toggle source
# File lib/cloud/dummy.rb, line 527 def make_create_vm_always_fail @logger.info("Making create_vm method always fail") FileUtils.mkdir_p(File.dirname(failed_path)) File.write(failed_path, "") end
make_create_vm_always_use_dynamic_ip(ip_address)
click to toggle source
# File lib/cloud/dummy.rb, line 515 def make_create_vm_always_use_dynamic_ip(ip_address) @logger.info("Making create_vm method to set ip address #{ip_address}") FileUtils.mkdir_p(File.dirname(always_path)) File.write(always_path, ip_address) end
next_create_vm_cmd()
click to toggle source
# File lib/cloud/dummy.rb, line 538 def next_create_vm_cmd @logger.info('Reading create_vm configuration') ip_address = File.read(always_path) if File.exists?(always_path) azs_to_ip = File.exists?(azs_path) ? JSON.load(File.read(azs_path)) : {} failed = File.exists?(failed_path) CreateVmCommand.new(ip_address, azs_to_ip, failed) end
pause_delete_vms()
click to toggle source
# File lib/cloud/dummy.rb, line 484 def pause_delete_vms @logger.info("Pausing delete_vms") path = File.join(@cpi_commands, 'pause_delete_vms') FileUtils.mkdir_p(File.dirname(path)) File.write(path, 'marker') end
set_dynamic_ips_for_azs(az_to_ips)
click to toggle source
# File lib/cloud/dummy.rb, line 521 def set_dynamic_ips_for_azs(az_to_ips) @logger.info("Making create_vm method to set #{az_to_ips.inspect}") FileUtils.mkdir_p(File.dirname(azs_path)) File.write(azs_path, JSON.generate(az_to_ips)) end
unpause_delete_vms()
click to toggle source
# File lib/cloud/dummy.rb, line 491 def unpause_delete_vms @logger.info("Unpausing delete_vms") FileUtils.rm_rf File.join(@cpi_commands, 'pause_delete_vms') FileUtils.rm_rf File.join(@cpi_commands, 'wait_for_unpause_delete_vms') end
wait_for_delete_vms()
click to toggle source
# File lib/cloud/dummy.rb, line 497 def wait_for_delete_vms @logger.info("Wait for delete_vms") path = File.join(@cpi_commands, 'wait_for_unpause_delete_vms') sleep(0.1) until File.exists?(path) end
wait_for_unpause_delete_vms()
click to toggle source
# File lib/cloud/dummy.rb, line 503 def wait_for_unpause_delete_vms path = File.join(@cpi_commands, 'wait_for_unpause_delete_vms') FileUtils.mkdir_p(File.dirname(path)) File.write(path, 'marker') path = File.join(@cpi_commands, 'pause_delete_vms') if File.exists?(path) @logger.info("Wait for unpausing delete_vms") end sleep(0.1) while File.exists?(path) end
Private Instance Methods
always_path()
click to toggle source
# File lib/cloud/dummy.rb, line 552 def always_path File.join(@cpi_commands, 'create_vm', 'always') end
azs_path()
click to toggle source
# File lib/cloud/dummy.rb, line 548 def azs_path File.join(@cpi_commands, 'create_vm', 'az_ips') end
failed_path()
click to toggle source
# File lib/cloud/dummy.rb, line 556 def failed_path File.join(@cpi_commands, 'create_vm', 'fail') end