From 0644377c60bc677168501a9fa984af8a8274c598 Mon Sep 17 00:00:00 2001 From: Ohad Levy Date: Mon, 26 Mar 2012 15:07:26 +0200 Subject: [PATCH] [vsphere] force poweroff of instance of vmware tools are not installed --- lib/fog/vsphere/models/compute/server.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/fog/vsphere/models/compute/server.rb b/lib/fog/vsphere/models/compute/server.rb index fd0aeac5b..a3521162f 100644 --- a/lib/fog/vsphere/models/compute/server.rb +++ b/lib/fog/vsphere/models/compute/server.rb @@ -53,7 +53,7 @@ module Fog end def stop(options = {}) - options = { :force => false }.merge(options) + options = { :force => !tools_installed? }.merge(options) requires :instance_uuid connection.vm_power_off('instance_uuid' => instance_uuid, 'force' => options[:force]) end @@ -100,6 +100,14 @@ module Fog new_vm end + def ready? + power_state == "poweredOn" + end + + def tools_installed? + tools_state != "toolsNotInstalled" + end + end end