Skip to content

Commit

Permalink
Merge pull request #585 from agx/libvirt-lxc
Browse files Browse the repository at this point in the history
Libvirt LXC: allow to check for container existence and status
  • Loading branch information
mizzy committed Oct 11, 2016
2 parents afe58bd + 3253eb2 commit f5bb203
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/specinfra/command/linux/base/lxc_container.rb
@@ -1,11 +1,17 @@
class Specinfra::Command::Linux::Base::LxcContainer < Specinfra::Command::Base::LxcContainer
class << self
def check_exists(container)
"lxc-ls -1 | grep -w #{escape(container)}"
[
"lxc-ls -1 | grep -w #{escape(container)}",
"virsh -c lxc:/// list --all --name | grep -w '^#{escape(container)}$'"
].join(' || ')
end

def check_is_running(container)
"lxc-info -n #{escape(container)} -s | grep -w RUNNING"
[
"lxc-info -n #{escape(container)} -s | grep -w RUNNING",
"virsh -c lxc:/// list --all --name --state-running | grep -w '^#{escape(container)}$'"
].join(' || ')
end
end
end

0 comments on commit f5bb203

Please sign in to comment.