Class: Kitchen::Driver::LxdCli
- Inherits:
-
Base
- Object
- Base
- Kitchen::Driver::LxdCli
- Defined in:
- lib/kitchen/driver/lxd_cli.rb
Overview
LxdCli driver for Kitchen.
Instance Method Summary collapse
Instance Method Details
#create(state) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/kitchen/driver/lxd_cli.rb', line 43 def create(state) unless exists? image_name = create_image_if_missing profile = "-p #{config[:profile]}" if config[:profile] lxc_config = "-c #{config[:config]}" if config[:config] info("Initializing container #{instance.name}") run_lxc_command("init #{image_name} #{instance.name} #{profile} #{lxc_config}") end config_and_start_container unless running? configure_dns lxc_ip = wait_for_ip_address state[:hostname] = lxc_ip setup_ssh_access end |
#destroy(state) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/kitchen/driver/lxd_cli.rb', line 59 def destroy(state) if exists? if running? info("Stopping container #{instance.name}") run_lxc_command("stop #{instance.name}") end info("Deleting container #{instance.name}") run_lxc_command("delete #{instance.name}") unless config[:stop_instead_of_destroy] end state.delete(:hostname) end |