deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alfredo Moralejo (Commented) (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DTACLOUD-103) vSphere driver does not work when objects are grouped into folders
Date Fri, 18 Nov 2011 10:48:51 GMT

    [ https://issues.apache.org/jira/browse/DTACLOUD-103?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13152773#comment-13152773
] 

Alfredo Moralejo commented on DTACLOUD-103:
-------------------------------------------

Hi,

I applied following patch and it seems to be working fine:

--- /usr/share/deltacloud-core/lib/deltacloud/drivers/vsphere/vsphere_driver.rb	2011-11-09
15:19:33.000000000 +0000
+++ /usr/share/deltacloud-core-tiws/lib/deltacloud/drivers/vsphere/vsphere_driver.rb	2011-11-18
10:21:59.275333873 +0000
@@ -384,12 +384,16 @@
     end
 
     def convert_realm(datastore)
-      Realm::new(
-        :id => datastore.name,
-        :name => datastore.name,
-        :limit => datastore.summary.freeSpace,
-        :state => datastore.summary.accessible ? 'AVAILABLE' : 'UNAVAILABLE'
-      )
+      if datastore.class.to_s == 'Folder'
+        datastore.childEntity.collect { |datastorenew| convert_realm(datastorenew) }
+      else
+        Realm::new(
+          :id => datastore.name,
+          :name => datastore.name,
+          :limit => datastore.summary.freeSpace,
+          :state => datastore.summary.accessible ? 'AVAILABLE' : 'UNAVAILABLE'
+        )
+      end
     end
 
     def convert_state(object, state)








--- /usr/share/deltacloud-core/lib/deltacloud/drivers/vsphere/vsphere_client.rb	2011-11-09
15:19:33.000000000 +0000
+++ /usr/share/deltacloud-core-tiws/lib/deltacloud/drivers/vsphere/vsphere_client.rb	2011-11-18
10:34:36.698334455 +0000
@@ -32,7 +32,8 @@
         rootFolder = vsphere.serviceInstance.content.rootFolder
         vm = {}
         rootFolder.childEntity.grep(RbVmomi::VIM::Datacenter).each do |dc|
-          dc.datastoreFolder.childEntity.collect do |datastore|
+          dslist = list_datastores(dc.datastoreFolder)
+	    dslist.each do |datastore|
             vm[:instance] = datastore.vm.find { |x| x.name == name }
             if vm[:instance]
               vm[:datastore] = datastore.name
@@ -63,6 +64,7 @@
         dc = rootFolder.childEntity.grep(RbVmomi::VIM::Datacenter).select do |dc|
           dc.datastoreFolder.childEntity.find { |d| d.name == name }.nil? == false
         end.flatten.compact.first
+        dc = rootFolder.childEntity.grep(RbVmomi::VIM::Datacenter).first
         dc.hostFolder.childEntity.collect.first.resourcePool
       end
     end
@@ -77,8 +79,12 @@
       safely do
         rootFolder = vsphere.serviceInstance.content.rootFolder
         rootFolder.childEntity.grep(RbVmomi::VIM::Datacenter).collect do |dc|
-          dc.datastoreFolder.childEntity.find { |d| d.name == name }
-        end.flatten.compact.first
+          list_datastores(dc.datastoreFolder).each do  |d| 
+            if d.name == name
+              return d
+            end
+          end
+        end
       end
     end
 
@@ -90,7 +96,7 @@
       vms = []
       rootFolder = vsphere.serviceInstance.content.rootFolder
       rootFolder.childEntity.grep(RbVmomi::VIM::Datacenter).each do |dc|
-        dc.datastoreFolder.childEntity.each do |datastore|
+        list_datastores(dc.datastoreFolder).each do  |datastore|
           vms += datastore.vm.collect { |vm| { :instance => vm, :datastore => datastore.name
} unless vm.nil? }
           stored_tasks(datastore, vsphere) do |task|
             if task.info.entity.class == RbVmomi::VIM::VirtualMachine
@@ -102,6 +108,21 @@
       vms.flatten.compact
     end
 
+    # This helper will traverse across all datacenters and folders and gather
+    # all datastores available on vSphere
+    # 
+    def list_datastores(df)
+    datastores = []
+    df.childEntity.each do |object|      
+      if object.class.to_s == 'Folder'
+        datastores += list_datastores(object)
+      else
+        datastores << object
+      end
+    end
+    datastores
+    end
+
     # Map given instance to task. Task name is used as a filename.
     #
     def map_task_to_instance(datastore, task_key, new_instance)



Regards,

Alfredo
                
> vSphere driver does not work when objects are grouped into folders
> ------------------------------------------------------------------
>
>                 Key: DTACLOUD-103
>                 URL: https://issues.apache.org/jira/browse/DTACLOUD-103
>             Project: DeltaCloud
>          Issue Type: Bug
>          Components: Server
>         Environment: DeltaCloud 0.4.1-5 (included with Aeolus 0.5.0)
> Aeolus 0.5.0 on RHEL 6.1
> vSphere 4.1
>            Reporter: Javier Peña
>            Assignee: Michal Fojtik
>              Labels: vsphere
>
> We are trying to setup an Aeolus environment with vSphere as the virtualization backend.
Our environment groups datastores and VMs into folders, and this is causing DeltaCloud errors
when it is trying to find them. The vSphere hierarchy looks as follows (ASCII art):
> Datacenters
> |-datacenter-21
>   |-group-s24 (Datastores)
>   | |-group-s2583 (Folder)
>   | | |-datastore-2335
>   | | |-datastore-2336
>   |-group-d23 (Hosts)
>   | |-domain-c2310 (ComputeResource)
>   | | |-host-2326
>   | | |-host-2327
>   |-group-v22 (vms)
>   | |-group-v316 (Folder)
>   | | |-group-v23042 (Folder)
>   | | | |-vm-23452
>   | | | |-vm-23453
> Some of the methods that failed in vsphere_client.rb are find_datastore() and list_virtual_machines().
For vsphere_driver.rb, convert_realm() fails as well.
> Please feel free to contact me if you need any additional information.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

Mime
View raw message