1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-23 22:50:09 +03:00

Bug #3610: some cases of Poweroff monitoring in hybrid changed

This commit is contained in:
Tino Vazquez 2015-02-23 19:46:15 +01:00
parent 49c19673e2
commit 5c3b1ae609
3 changed files with 51 additions and 33 deletions

View File

@ -370,6 +370,7 @@ private
# 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 @@ private
when "Suspended", "Stopping",
VM_STATE[:paused]
else
VM_STATE[:deleted]
VM_STATE[:unknown]
end
end
info << "#{POLL_ATTRIBUTE[:state]}=#{state} "
@ -408,6 +409,11 @@ private
}
info
rescue
# Unkown state if exception occurs retrieving information from
# an instance
"#{POLL_ATTRIBUTE[:state]}=#{VM_STATE[:unknown]} "
end
end
def format_endpoints(endpoints)

View File

@ -421,42 +421,48 @@ private
# 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 "
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
state = case instance.status
when :pending
VM_STATE[:active]
when :running
VM_STATE[:active]
when :'shutting-down', :terminated
VM_STATE[:deleted]
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} "
info
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
rescue
# Unkown state if exception occurs retrieving information from
# an instance
"#{POLL_ATTRIBUTE[:state]}=#{VM_STATE[:unknown]} "
end
end
# Execute an EC2 command

View File

@ -381,6 +381,7 @@ private
# 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 @@ private
when "PAUSED"
VM_STATE[:paused]
else
VM_STATE[:deleted]
VM_STATE[:unknown]
end
end
info << "#{POLL_ATTRIBUTE[:state]}=#{state} "
@ -428,6 +429,11 @@ private
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