Sha256: 9fd2ca0086e21d07fdaff198202c8da47429b5a360f9e4b137ff6f8bf01e1c23

Contents?: true

Size: 1.26 KB

Versions: 4

Compression:

Stored size: 1.26 KB

Contents

# -*- coding: utf-8 -*-

module Dcmgr::Models
  # Metadata catalogs for bootable image file.
  class Image < AccountResource
    taggable 'wmi'
    with_timestamps

    BOOT_DEV_SAN=1
    BOOT_DEV_LOCAL=2

    inheritable_schema do
      Fixnum :boot_dev_type, :null=>false, :default=>BOOT_DEV_SAN
      Text :source, :null=>false
      String :arch, :size=>10, :null=>false
      Text :description
      #Fixnum :parent_image_id

      String :state, :size=>20, :null=>false, :default=>:init.to_s
    end

    # serialize plugin must be defined at the bottom of all class
    # method calls.
    # Possible source column data:
    # vdc volume:
    # {:type=>:vdcvol, :account_id=>'a-xxxxx', :snapshot_id=>'snap-xxxxxx'}
    # {:type=>:http, :uri=>'http://localhost/xxx/xxx'}
    plugin :serialization
    serialize_attributes :yaml, :source
    
    def validate
      unless [BOOT_DEV_SAN, BOOT_DEV_LOCAL].member?(self.boot_dev_type)
        errors.add(:boot_dev_type, "Invalid boot dev type: #{self.boot_dev_type}")
      end
      
      unless HostPool::SUPPORTED_ARCH.member?(self.arch)
        errors.add(:arch, "Unsupported arch type: #{self.arch}")
      end
    end

    def to_hash
      super.merge({:source=>self.source.dup, :description=>description.to_s})
    end
    
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
wakame-vdc-dcmgr-10.12.0 lib/dcmgr/models/image.rb
wakame-vdc-agents-10.12.0 lib/dcmgr/models/image.rb
wakame-vdc-dcmgr-10.11.0 lib/dcmgr/models/image.rb
wakame-vdc-agents-10.11.0 lib/dcmgr/models/image.rb