Permalink
Browse files

Merge pull request #441 from mpapis/bugfix/fix_plus_in_definition_name

allow definition name to contain plus
  • Loading branch information...
jedi4ever committed Dec 12, 2012
2 parents 5bab6b7 + 11a96a6 commit dcb4e7ac9710a18efa20483ec8ef9d903d8fb777
Showing with 12 additions and 10 deletions.
  1. +12 −10 lib/veewee/provider/virtualbox/box/helper/status.rb
@@ -4,23 +4,25 @@ module Virtualbox
module BoxCommand
def exists?
- command="#{@vboxcmd} list vms"
- shell_results=shell_exec("#{command}",{:mute => true})
- exists=shell_results.stdout.split(/\n/).grep(/\"#{name}\"/).size!=0
-
- env.logger.info("Vm exists? #{exists}")
- return exists
+ return check?(:exists)
end
def running?
- command="#{@vboxcmd} list runningvms"
+ return check?(:running)
+ end
+
+ private
+
+ def check? type
+ command = COMMANDS[type] % @vboxcmd
shell_results=shell_exec("#{command}",{:mute => true})
- running=shell_results.stdout.split(/\n/).grep(/\"#{name}\"/).size!=0
+ status=shell_results.stdout.split(/\n/).grep(/\"#{Regexp.escape(name)}\"/).size!=0
- env.logger.info("Vm running? #{running}")
- return running
+ env.logger.info("Vm #{type}? #{status}")
+ return status
end
+ COMMANDS = { :running => "%s list runningvms", :exists => "%s list vms" }
end
end
end

0 comments on commit dcb4e7a

Please sign in to comment.