Revision 42e84185

View differences:

src/sunstone/etc/sunstone-views/admin_vcenter.yaml
17 17
    - datastores-tab
18 18
    - images-tab
19 19
    #- files-tab
20
    #- marketplaces-tab
21
    #- marketplaceapps-tab
20
    - marketplaces-tab
21
    - marketplaceapps-tab
22 22
    - network-top-tab
23 23
    - vnets-tab
24 24
    - vnets-topology-tab
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
src/vmm_mad/remotes/lib/vcenter_driver/datastore.rb
154 154
        return one
155 155
    end
156 156

  
157
    def to_one_template(one_clusters, ccr_ref, ccr_name, type, vcenter_uuid, vcenter_instance_name, dc_name)
157
    def to_one_template(one_clusters, name, ccr_ref, type, vcenter_uuid)
158 158

  
159 159
        one_cluster = one_clusters.select { |ccr| ccr[:ref] == ccr_ref }.first rescue nil
160 160

  
161 161
        return nil if one_cluster.nil?
162 162

  
163
        name, capacity, freeSpace = @item.collect("name","summary.capacity","summary.freeSpace")
164

  
165 163
        ds_name = ""
166 164

  
167 165
        if type == "IMAGE_DS"
168
            ds_name << "[#{vcenter_instance_name} - #{dc_name}] #{name} - #{ccr_name.tr(" ", "_")} (IMG)"
166
            ds_name << "#{name} (IMG)"
169 167
        else
170
            ds_name << "[#{vcenter_instance_name} - #{dc_name}] #{name} - #{ccr_name.tr(" ", "_")} (SYS)"
168
            ds_name << "#{name} (SYS)"
171 169
            ds_name << " [StorDRS]" if self.class == VCenterDriver::StoragePod
172 170
        end
173 171

  
174 172
        one_tmp = {
175
            :name     => ds_name,
176
            :total_mb => ((capacity.to_i / 1024) / 1024),
177
            :free_mb  => ((freeSpace.to_i / 1024) / 1024),
178
            :cluster  => ccr_name,
179 173
            :one  => to_one(ds_name, vcenter_uuid, ccr_ref, one_cluster[:host_id])
180 174
        }
181 175

  
src/vmm_mad/remotes/lib/vcenter_driver/importer.rb
666 666
            end
667 667

  
668 668
            tmps.each{ |d|
669
                one_cluster_id = nil
670 669
                if !use_defaults
671 670
                    STDOUT.print "\n  * Datastore found:\n"\
672 671
                                    "      - Name      : #{d[:name]}\n"\
......
676 675
                                    "    Import this as Datastore [y/n]? "
677 676

  
678 677
                    next if STDIN.gets.strip.downcase != 'y'
679
                end
680 678

  
681
                one_d = VCenterDriver::VIHelper.new_one_item(OpenNebula::Datastore)
679
                    STDOUT.print "\n    NOTE: For each vcenter datastore a SYSTEM and IMAGE datastore\n"\
680
                                 "    will be created in OpenNebula except for a StorageDRS which is \n"\
681
                                 "    represented as a SYSTEM datastore only.\n"
682 682

  
683
                if one_cluster_id
684
                    rc = one_d.allocate(d[:one], one_cluster_id.to_i)
685
                else
686
                    rc = one_d.allocate(d[:one])
687 683
                end
688 684

  
689
                if ::OpenNebula.is_error?(rc)
690
                    STDOUT.puts "    \nError creating datastore: #{rc.message}\n"\
691
                                "    One datastore can exist only once, and "\
692
                                "can be used in any vCenter Cluster that "\
693
                                "has access to it. Also, no spaces allowed "\
694
                                "in datastore name (rename it in vCenter "\
695
                                "and try again)"
696
                else
697
                    STDOUT.puts "    \nOpenNebula datastore #{one_d.id} created!\n"
685
                ds_allocate_error = false
686
                d[:ds].each do |ds|
687
                    one_d = VCenterDriver::VIHelper.new_one_item(OpenNebula::Datastore)
688
                    rc = one_d.allocate(ds[:one])
689
                    if ::OpenNebula.is_error?(rc)
690
                        STDOUT.puts "    \n    Error creating datastore: #{rc.message}"
691
                        ds_allocate_error = true
692
                    else
693
                        STDOUT.puts "    \n    OpenNebula datastore #{one_d.id} created!\n"
694
                    end
698 695
                end
699 696
            }
700 697
        }

Also available in: Unified diff