Revision 42e84185 src/vmm_mad/remotes/lib/vcenter_driver/datacenter.rb

View differences:

src/vmm_mad/remotes/lib/vcenter_driver/datacenter.rb
126 126

  
127 127
            datastore_folder.items.values.each do |ds|
128 128

  
129
                name, capacity, freeSpace = ds.item.collect("name","summary.capacity","summary.freeSpace")
130

  
131
                ds_name = "[#{vcenter_instance_name} - #{dc_name}] #{name}"
132
                ds_total_mb =  ((capacity.to_i / 1024) / 1024)
133
                ds_free_mb = ((freeSpace.to_i / 1024) / 1024)
134

  
129 135
                if ds.instance_of? VCenterDriver::Datastore
130 136
                    hosts_in_ds = ds['host']
131 137
                    clusters_in_ds = {}
......
138 144
                    end
139 145

  
140 146
                    clusters_in_ds.each do |ccr_ref, ccr_name|
147
                        ds_hash = {}
148

  
149
                        ds_hash[:name] = "#{ds_name} - #{ccr_name.tr(" ", "_")}"
150
                        ds_hash[:total_mb] = ds_total_mb
151
                        ds_hash[:free_mb]  = ds_free_mb
152
                        ds_hash[:cluster]  = ccr_name
153
                        ds_hash[:ds]      = []
154

  
141 155
                        already_image_ds = VCenterDriver::Storage.exists_one_by_ref_ccr_and_type?(ds["_ref"], ccr_ref, vcenter_uuid, "IMAGE_DS", dpool)
142 156

  
143 157
                        if !already_image_ds
144
                            object = ds.to_one_template(one_clusters[dc_name], ccr_ref, ccr_name, "IMAGE_DS", vcenter_uuid, vcenter_instance_name, dc_name)
145
                            ds_objects[dc_name] << object if !object.nil?
158
                            object = ds.to_one_template(one_clusters[dc_name], ds_hash[:name], ccr_ref, "IMAGE_DS", vcenter_uuid)
159
                            ds_hash[:ds] << object if !object.nil?
146 160
                        end
147 161

  
148 162
                        already_system_ds = VCenterDriver::Storage.exists_one_by_ref_ccr_and_type?(ds["_ref"], ccr_ref, vcenter_uuid, "SYSTEM_DS", dpool)
149 163

  
150 164
                        if !already_system_ds
151
                            object = ds.to_one_template(one_clusters[dc_name], ccr_ref, ccr_name, "SYSTEM_DS", vcenter_uuid, vcenter_instance_name, dc_name)
152
                            ds_objects[dc_name] << object if !object.nil?
165
                            object = ds.to_one_template(one_clusters[dc_name], ds_hash[:name], ccr_ref, "SYSTEM_DS", vcenter_uuid)
166
                            ds_hash[:ds] << object if !object.nil?
153 167
                        end
168

  
169
                        ds_objects[dc_name] << ds_hash if !ds_hash[:ds].empty?
154 170
                    end
155 171
                end
156 172

  
......
169 185
                    end
170 186

  
171 187
                    clusters_in_spod.each do |ccr_ref, ccr_name|
188
                        ds_hash = {}
189
                        ds_hash[:name] = "#{ds_name} - #{ccr_name.tr(" ", "_")} [StorPod]"
190
                        ds_hash[:total_mb] = ds_total_mb
191
                        ds_hash[:free_mb]  = ds_free_mb
192
                        ds_hash[:cluster]  = ccr_name
193
                        ds_hash[:ds]      = []
194

  
195
                        ds_hash[:ds] = []
172 196
                        already_system_ds = VCenterDriver::Storage.exists_one_by_ref_ccr_and_type?(ds["_ref"], ccr_ref, vcenter_uuid, "SYSTEM_DS", dpool)
173 197

  
174 198
                        if !already_system_ds
175
                            object = ds.to_one_template(one_clusters[dc_name], ccr_ref, ccr_name, "SYSTEM_DS", vcenter_uuid, vcenter_instance_name, dc_name)
176
                            ds_objects[dc_name] << object if !object.nil?
199
                            object = ds.to_one_template(one_clusters[dc_name], ds_hash[:name], ccr_ref, "SYSTEM_DS", vcenter_uuid)
200
                            ds_hash[:ds] << object if !object.nil?
177 201
                        end
202

  
203
                        ds_objects[dc_name] << ds_hash if !ds_hash[:ds].empty?
178 204
                    end
179 205
                end
180 206
            end

Also available in: Unified diff