diff --git a/src/cloud/occi/lib/ImageOCCI.rb b/src/cloud/occi/lib/ImageOCCI.rb index 11c60ae79a..cd573554c3 100755 --- a/src/cloud/occi/lib/ImageOCCI.rb +++ b/src/cloud/occi/lib/ImageOCCI.rb @@ -23,17 +23,15 @@ class ImageOCCI < Image <%= self.id.to_s %> <%= self.name %> - <% if self['TEMPLATE/TYPE'] != nil %> - <%= self['TEMPLATE/TYPE'] %> + <% if self['TYPE'] != nil %> + <%= self['TYPE'] %> <% end %> <% if self['TEMPLATE/DESCRIPTION'] != nil %> <%= self['TEMPLATE/DESCRIPTION'] %> <% end %> - <% if size != nil %> - <%= size.to_i / 1024 %> - <% end %> - <% if fstype != nil %> - <%= fstype %> + <%= self['SIZE'] %> + <% if self['FSTYPE'] != nil %> + <%= self['FSTYPE'] %> <% end %> <%= self['PUBLIC'] == "0" ? "NO" : "YES"%> <%= self['PERSISTENT'] == "0" ? "NO" : "YES"%> @@ -84,25 +82,18 @@ class ImageOCCI < Image # Creates the OCCI representation of an Image def to_occi(base_url) - size = nil - begin - if self['SOURCE'] != nil and File.exists?(self['SOURCE']) - size = File.stat(self['SOURCE']).size - size = size / 1024 - end - - fstype = self['TEMPLATE/FSTYPE'] if self['TEMPLATE/FSTYPE'] + occi_im = ERB.new(OCCI_IMAGE) + occi_im_text = occi_im.result(binding) rescue Exception => e error = OpenNebula::Error.new(e.message) return error end - occi = ERB.new(OCCI_IMAGE) - return occi.result(binding).gsub(/\n\s*/,'') + return occi_im_text.gsub(/\n\s*/,'') end - def to_one_template() + def to_one_template if @image_info == nil error_msg = "Missing STORAGE section in the XML body" error = OpenNebula::Error.new(error_msg)