Class: Bosh::Clouds::Dummy::CommandTransport
- 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
-
#initialize(base_dir, logger) ⇒ CommandTransport
constructor
A new instance of CommandTransport.
- #make_configure_networks_not_supported(vm_id) ⇒ Object
- #make_create_vm_always_use_dynamic_ip(ip_address) ⇒ Object
- #next_configure_networks_cmd(vm_id) ⇒ Object
- #next_create_vm_cmd ⇒ Object
Constructor Details
#initialize(base_dir, logger) ⇒ CommandTransport
Returns a new instance of CommandTransport.
283 284 285 286 |
# File 'lib/cloud/dummy.rb', line 283 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
288 289 290 291 292 293 |
# File 'lib/cloud/dummy.rb', line 288 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
303 304 305 306 307 308 |
# File 'lib/cloud/dummy.rb', line 303 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
295 296 297 298 299 300 301 |
# File 'lib/cloud/dummy.rb', line 295 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_cmd ⇒ Object
310 311 312 313 314 315 |
# File 'lib/cloud/dummy.rb', line 310 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 |