From 5c3b1ae609d1b72f68eb370549f5d997817bb4a1 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Mon, 23 Feb 2015 19:46:15 +0100 Subject: [PATCH] Bug #3610: some cases of Poweroff monitoring in hybrid changed --- src/vmm_mad/remotes/az/az_driver.rb | 8 ++- src/vmm_mad/remotes/ec2/ec2_driver.rb | 70 +++++++++++++++------------ src/vmm_mad/remotes/sl/sl_driver.rb | 8 ++- 3 files changed, 52 insertions(+), 34 deletions(-) diff --git a/src/vmm_mad/remotes/az/az_driver.rb b/src/vmm_mad/remotes/az/az_driver.rb index 63379a32d6f..92ccda98020 100755 --- a/src/vmm_mad/remotes/az/az_driver.rb +++ b/src/vmm_mad/remotes/az/az_driver.rb @@ -370,6 +370,7 @@ def get_deployment_info(host, xml_text) # Retrive the vm information from the Azure instance def parse_poll(instance) + begin info = "#{POLL_ATTRIBUTE[:usedmemory]}=0 " \ "#{POLL_ATTRIBUTE[:usedcpu]}=0 " \ "#{POLL_ATTRIBUTE[:nettx]}=0 " \ @@ -385,7 +386,7 @@ def parse_poll(instance) when "Suspended", "Stopping", VM_STATE[:paused] else - VM_STATE[:deleted] + VM_STATE[:unknown] end end info << "#{POLL_ATTRIBUTE[:state]}=#{state} " @@ -408,6 +409,11 @@ def parse_poll(instance) } info + rescue + # Unkown state if exception occurs retrieving information from + # an instance + "#{POLL_ATTRIBUTE[:state]}=#{VM_STATE[:unknown]} " + end end def format_endpoints(endpoints) diff --git a/src/vmm_mad/remotes/ec2/ec2_driver.rb b/src/vmm_mad/remotes/ec2/ec2_driver.rb index 9f205361175..31746ed0b8a 100755 --- a/src/vmm_mad/remotes/ec2/ec2_driver.rb +++ b/src/vmm_mad/remotes/ec2/ec2_driver.rb @@ -421,42 +421,48 @@ def get_deployment_info(host, xml_text) # Retrive the vm information from the EC2 instance def parse_poll(instance) - info = "#{POLL_ATTRIBUTE[:usedmemory]}=0 " \ - "#{POLL_ATTRIBUTE[:usedcpu]}=0 " \ - "#{POLL_ATTRIBUTE[:nettx]}=0 " \ - "#{POLL_ATTRIBUTE[:netrx]}=0 " - - state = "" - if !instance.exists? - state = VM_STATE[:deleted] - else - state = case instance.status - when :pending - VM_STATE[:active] - when :running - VM_STATE[:active] - when :'shutting-down', :terminated - VM_STATE[:deleted] + begin + info = "#{POLL_ATTRIBUTE[:usedmemory]}=0 " \ + "#{POLL_ATTRIBUTE[:usedcpu]}=0 " \ + "#{POLL_ATTRIBUTE[:nettx]}=0 " \ + "#{POLL_ATTRIBUTE[:netrx]}=0 " + + state = "" + if !instance.exists? + state = VM_STATE[:deleted] else - VM_STATE[:deleted] - end - end - info << "#{POLL_ATTRIBUTE[:state]}=#{state} " - - EC2_POLL_ATTRS.map { |key| - value = instance.send(key) - if !value.nil? && !value.empty? - if value.is_a?(Array) - value = value.map {|v| - v.security_group_id if v.is_a?(AWS::EC2::SecurityGroup) - }.join(",") + state = case instance.status + when :pending + VM_STATE[:active] + when :running + VM_STATE[:active] + when :'shutting-down', :terminated + VM_STATE[:deleted] + else + VM_STATE[:unknown] end - - info << "AWS_#{key.to_s.upcase}=#{URI::encode(value)} " end - } + info << "#{POLL_ATTRIBUTE[:state]}=#{state} " + + EC2_POLL_ATTRS.map { |key| + value = instance.send(key) + if !value.nil? && !value.empty? + if value.is_a?(Array) + value = value.map {|v| + v.security_group_id if v.is_a?(AWS::EC2::SecurityGroup) + }.join(",") + end + + info << "AWS_#{key.to_s.upcase}=#{URI::encode(value)} " + end + } - info + info + rescue + # Unkown state if exception occurs retrieving information from + # an instance + "#{POLL_ATTRIBUTE[:state]}=#{VM_STATE[:unknown]} " + end end # Execute an EC2 command diff --git a/src/vmm_mad/remotes/sl/sl_driver.rb b/src/vmm_mad/remotes/sl/sl_driver.rb index d60945377ff..64884ff7a6e 100644 --- a/src/vmm_mad/remotes/sl/sl_driver.rb +++ b/src/vmm_mad/remotes/sl/sl_driver.rb @@ -381,6 +381,7 @@ def get_deployment_info(host, xml_text) # Retrieve the VM information from the SoftLayer instance def parse_poll(vm) + begin info = "#{POLL_ATTRIBUTE[:usedmemory]}=0 " \ "#{POLL_ATTRIBUTE[:usedcpu]}=0 " \ "#{POLL_ATTRIBUTE[:nettx]}=0 " \ @@ -409,7 +410,7 @@ def parse_poll(vm) when "PAUSED" VM_STATE[:paused] else - VM_STATE[:deleted] + VM_STATE[:unknown] end end info << "#{POLL_ATTRIBUTE[:state]}=#{state} " @@ -428,6 +429,11 @@ def parse_poll(vm) info << "SL_CRED_USER=#{user} SL_CRED_PASSWORD=#{pwd}" if user and pwd info + rescue + # Unkown state if exception occurs retrieving information from + # an instance + "#{POLL_ATTRIBUTE[:state]}=#{VM_STATE[:unknown]} " + end end # Execute a SoftLayer command