Class: Bosh::Clouds::Dummy::CommandTransport

Inherits:
Object
  • Object
show all
Defined in:
lib/cloud/dummy.rb

Overview

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}
base_dir/cpi/configure_networks/<vm_id> -> (presence)

Instance Method Summary collapse

Constructor Details

#initialize(base_dir, logger) ⇒ CommandTransport

Returns a new instance of CommandTransport.



282
283
284
285
# File 'lib/cloud/dummy.rb', line 282

def initialize(base_dir, logger)
  @cpi_commands = File.join(base_dir, 'cpi_commands')
  @logger = logger
end

Instance Method Details

#make_configure_networks_not_supported(vm_id) ⇒ Object



287
288
289
290
291
292
# File 'lib/cloud/dummy.rb', line 287

def make_configure_networks_not_supported(vm_id)
  @logger.info("Making configure_networks for #{vm_id} raise NotSupported")
  path = File.join(@cpi_commands, 'configure_networks', vm_id)
  FileUtils.mkdir_p(File.dirname(path))
  File.write(path, 'marker')
end

#make_create_vm_always_use_dynamic_ip(ip_address) ⇒ Object



302
303
304
305
306
307
# File 'lib/cloud/dummy.rb', line 302

def make_create_vm_always_use_dynamic_ip(ip_address)
  @logger.info("Making create_vm method to set ip address #{ip_address}")
  always_path = File.join(@cpi_commands, 'create_vm', 'always')
  FileUtils.mkdir_p(File.dirname(always_path))
  File.write(always_path, ip_address)
end

#next_configure_networks_cmd(vm_id) ⇒ Object



294
295
296
297
298
299
300
# File 'lib/cloud/dummy.rb', line 294

def next_configure_networks_cmd(vm_id)
  @logger.info("Reading configure_networks configuration for #{vm_id}")
  vm_path = File.join(@cpi_commands, 'configure_networks', vm_id)
  vm_supported = File.exists?(vm_path)
  FileUtils.rm_rf(vm_path)
  ConfigureNetworksCommand.new(vm_supported)
end

#next_create_vm_cmdObject



309
310
311
312
313
314
# File 'lib/cloud/dummy.rb', line 309

def next_create_vm_cmd
  @logger.info('Reading create_vm configuration')
  always_path = File.join(@cpi_commands, 'create_vm', 'always')
  ip_address = File.read(always_path) if File.exists?(always_path)
  CreateVmCommand.new(ip_address)
end