Revision 918bce77 src/vmm_mad/remotes/lib/vcenter_driver/datastore.rb

View differences:

src/vmm_mad/remotes/lib/vcenter_driver/datastore.rb
68 68
        end
69 69
    end
70 70

  
71
    def self.get_image_import_template(ds_name, image_path, image_type, ipool)
72
        one_image = ""
73

  
74
        # Remove ds info from path
75
        image_path.sub!(/^\[#{ds_name}\] /, "")
76

  
77
        # Get image name
78
        file_name = File.basename(image_path).reverse.sub("kdmv.","").reverse
79
        image_name = "#{file_name} - #{ds_name}"
80

  
81
        #Chek if the image has already been imported
82
        if VCenterDriver::VIHelper.find_by_name(OpenNebula::ImagePool,
83
                                                image_name,
84
                                                ipool,
85
                                                false).nil?
86
            #Set template
87
            one_image << "NAME=\"#{image_name}\"\n"
88
            one_image << "PATH=\"vcenter://#{image_path}\"\n"
89
            one_image << "TYPE=\"#{image_type}\"\n"
90
            one_image << "PERSISTENT=\"NO\"\n"
91
            one_image << "OPENNEBULA_MANAGED=\"YES\"\n"
92
        end
93

  
94
        return one_image
95
    end
96

  
97
    def self.get_one_image_ds_by_ref_and_ccr(ref, ccr_ref, vcenter_uuid, pool = nil)
98
        pool = VCenterDriver::VIHelper.one_pool(OpenNebula::DatastorePool, false) if pool.nil?
99
        element = pool.select{|e|
100
            e["TEMPLATE/TYPE"] == "IMAGE_DS" &&
101
            e["TEMPLATE/VCENTER_DS_REF"] == ref &&
102
            e["TEMPLATE/VCENTER_CCR_REF"] == ccr_ref &&
103
            e["TEMPLATE/VCENTER_INSTANCE_ID"] == vcenter_uuid}.first rescue nil
104

  
105
        return element
106
    end
107

  
108

  
71 109
    def monitor
72 110
        summary = self['summary']
73 111

  

Also available in: Unified diff