deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject git commit: Report Instance state more accurately for OpenStack - addresses JIRA DTACLOUD_209
Date Fri, 01 Jun 2012 13:27:55 GMT
Updated Branches:
  refs/heads/master cdc488e6d -> fde9be980


Report Instance state more accurately for OpenStack - addresses JIRA DTACLOUD_209

https://issues.apache.org/jira/browse/DTACLOUD-209


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/fde9be98
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/fde9be98
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/fde9be98

Branch: refs/heads/master
Commit: fde9be9804e4c7b5bc63d9b0f07289d07b89cdf0
Parents: cdc488e
Author: marios <marios@redhat.com>
Authored: Fri Jun 1 16:16:33 2012 +0300
Committer: marios <marios@redhat.com>
Committed: Fri Jun 1 16:22:46 2012 +0300

----------------------------------------------------------------------
 .../drivers/openstack/openstack_driver.rb          |   19 ++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/fde9be98/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/openstack/openstack_driver.rb b/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
index 18cc0c1..da4c9a5 100644
--- a/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
+++ b/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
@@ -280,7 +280,7 @@ private
             :owner_id => owner,
             :description => server.send(op, :name),
             :name => server.send(op, :name),
-            :state => (server.send(op, :status) == 'ACTIVE') ? 'RUNNING' : 'PENDING',
+            :state => convert_instance_state(server.send(op, :status).downcase),
             :architecture => 'x86_64',
             :image_id => image[:id] || image["id"],
             :instance_profile => InstanceProfile::new(flavor[:id] || flavor["id"]),
@@ -294,6 +294,23 @@ private
           inst
         end
 
+        def convert_instance_state(openstack_state)
+          case openstack_state
+            when /.*reboot/
+              "PENDING"
+            when /.*deleting/
+              "STOPPING"
+            when /.*deleted/
+              "STOPPED"
+            when /build.*$/
+              "PENDING"
+            when /active/
+              "RUNNING"
+            else
+              "UNKOWN"
+          end
+        end
+
         def convert_server_addresses(server, type)
           op, address_label = (server.class == Hash)? [:fetch, :addr] : [:send, :address]
           addresses = (server.send(op, :addresses)[type] || []).collect do |addr|


Mime
View raw message