Navigation Menu

Skip to content

Commit

Permalink
Bug #3610: some cases of Poweroff monitoring in hybrid changed
Browse files Browse the repository at this point in the history
  • Loading branch information
tinova committed Feb 24, 2015
1 parent 49c1967 commit 5c3b1ae
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 34 deletions.
8 changes: 7 additions & 1 deletion src/vmm_mad/remotes/az/az_driver.rb
Expand Up @@ -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 " \
Expand All @@ -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} "
Expand All @@ -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)
Expand Down
70 changes: 38 additions & 32 deletions src/vmm_mad/remotes/ec2/ec2_driver.rb
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion src/vmm_mad/remotes/sl/sl_driver.rb
Expand Up @@ -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 " \
Expand Down Expand Up @@ -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} "
Expand All @@ -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
Expand Down

0 comments on commit 5c3b1ae

Please sign in to comment.