Class: Kitchen::Driver::Openvz

Inherits:
SSHBase
  • Object
show all
Defined in:
lib/kitchen/driver/openvz.rb

Constant Summary collapse

DEFAULT_CONTAINER_ID =
101
DEFAULT_CONTAINER_IP_ADDRESS =
'10.1.1.1'

Instance Method Summary collapse

Instance Method Details

#create(state) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/kitchen/driver/openvz.rb', line 26

def create(state)
  state[:container_id] = config[:container_id] || next_container_id
  state[:hostname] = config[:hostname] || next_ip_address
  create_container(state)
  start_container(state)
  mount_folders(state)
  wait_for_sshd(state[:hostname])
  # If ssh is responding then the template has been exploded so we can deploy the ssh key
  deploy_ssh_key(state)
end

#destroy(state) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/kitchen/driver/openvz.rb', line 37

def destroy(state)
  if state[:container_id] && container_exists(state[:container_id])
    unmount_folders(state) rescue nil
    debug("Destroying container #{state[:container_id]}")
    run_command("vzctl stop #{state[:container_id]}")
    run_command("vzctl destroy #{state[:container_id]}")
  end
end