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.
250 251 252 253 |
# File 'lib/cloud/dummy.rb', line 250 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
255 256 257 258 259 260 |
# File 'lib/cloud/dummy.rb', line 255 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
270 271 272 273 274 275 |
# File 'lib/cloud/dummy.rb', line 270 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
262 263 264 265 266 267 268 |
# File 'lib/cloud/dummy.rb', line 262 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
277 278 279 280 281 282 |
# File 'lib/cloud/dummy.rb', line 277 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) CreareVmCommand.new(ip_address) end |