Class: KnifeLxc::LxcServerDelete

Inherits:
Chef::Knife
  • Object
show all
Includes:
Toft
Defined in:
lib/chef/knife/lxc_server_delete.rb

Instance Method Summary collapse

Instance Method Details

#container_exists?(name) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/chef/knife/lxc_server_delete.rb', line 25

def container_exists?(name)
  `lxc-ls` =~ /#{name}/
end

#runObject

This method will be executed when you run this knife command.



18
19
20
21
22
23
# File 'lib/chef/knife/lxc_server_delete.rb', line 18

def run
  puts "Delete container #{config[:node_name]}"
  raise "Container not exists!! " unless container_exists? config[:node_name]
  n = Node.new(config[:node_name])
  n.destroy
end