Sha256: 99f3d9685c0459f9aa0b1cb8c3e7090c89e76c8859077d997b6110c0d7ae429a

Contents?: true

Size: 1.76 KB

Versions: 2

Compression:

Stored size: 1.76 KB

Contents

# 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.

class CIMI::Model::VolumeImage < CIMI::Model::Base

  href :image_location
  text :image_data
  text :bootable
  array :operations do
    scalar :rel, :href
  end

  def self.find(id, context)
    storage_snapshots = []
    opts = ( id==:all  ) ? {}  : { :id=>id }
    storage_snapshots = context.driver.storage_snapshots(context.credentials, opts)
    storage_snapshots.collect!{ |snapshot| from_storage_snapshot(snapshot, context) }
    return storage_snapshots.first unless storage_snapshots.length > 1
    return storage_snapshots
  end

  def self.all(context); find(:all, context); end

  private

  def self.from_storage_snapshot(snapshot, context)
    self.new( {
               :name => snapshot.id,
               :description => snapshot.id,
               :created => snapshot.created,
               :id => context.volume_image_url(snapshot.id),
               :image_location => {:href=>context.volume_url(snapshot.storage_volume_id)},
               :bootable => "false"  #FIXME
            } )
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
deltacloud-core-1.0.3 lib/cimi/models/volume_image.rb
deltacloud-core-1.0.2 lib/cimi/models/volume_image.rb