Class/Module Index [+]

Quicksearch

CIMI::Model::Volume

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Public Class Methods

all(context) click to toggle source
# File lib/cimi/model/volume.rb, line 45
def self.all(context); find(:all, context); end
create_from_json(json_in, context) click to toggle source
# File lib/cimi/model/volume.rb, line 47
def self.create_from_json(json_in, context)
  json = JSON.parse(json_in)
  volume_config_id = json["volumeTemplate"]["volumeConfig"]["href"].split("/").last
  volume_image_id = (json["volumeTemplate"].has_key?("volumeImage") ?
              json["volumeTemplate"]["volumeImage"]["href"].split("/").last  : nil)
  create_volume({:volume_config_id=>volume_config_id, :volume_image_id=>volume_image_id}, context)
end
create_from_xml(xml_in, context) click to toggle source
# File lib/cimi/model/volume.rb, line 55
def self.create_from_xml(xml_in, context)
  xml = XmlSimple.xml_in(xml_in)
  volume_config_id = xml["volumeTemplate"][0]["volumeConfig"][0]["href"].split("/").last
  volume_image_id = (xml["volumeTemplate"][0].has_key?("volumeImage") ?
           xml["volumeTemplate"][0]["volumeImage"][0]["href"].split("/").last  : nil)
  create_volume({:volume_config_id=>volume_config_id, :volume_image_id=>volume_image_id}, context)
end
delete!(id, context) click to toggle source
# File lib/cimi/model/volume.rb, line 63
def self.delete!(id, context)
  context.driver.destroy_storage_volume(context.credentials, {:id=>id} )
end
find(id, context) click to toggle source
# File lib/cimi/model/volume.rb, line 36
def self.find(id, context)
  volumes = []
  opts = ( id == :all ) ? {} : { :id => id }
  volumes = self.driver.storage_volumes(context.credentials, opts)
  volumes.collect!{ |volume| from_storage_volume(volume, context) }
  return volumes.first unless volumes.length > 1
  return volumes
end
find_to_attach_from_json(json_in, context) click to toggle source
# File lib/cimi/model/volume.rb, line 67
def self.find_to_attach_from_json(json_in, context)
  json = JSON.parse(json_in)
  volumes = json["volumes"].map{|v| {:volume=>self.find(v["volume"]["href"].split("/volumes/").last, context),
                                     :attachment_point=>v["attachmentPoint"]  }}
end
find_to_attach_from_xml(xml_in, context) click to toggle source
# File lib/cimi/model/volume.rb, line 73
def self.find_to_attach_from_xml(xml_in, context)
  xml = XmlSimple.xml_in(xml_in)
  volumes = xml["volume"].map{|v| {:volume => self.find(v["href"].split("/volumes/").last, context),
                                    :attachment_point=>v["attachmentPoint"] }}
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.