Class: Fog::Compute::HPV2::Image

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/hp/models/compute_v2/image.rb

Instance Attribute Summary

Attributes inherited from Model

#collection, #service

Instance Method Summary collapse

Methods inherited from Model

#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Fog::Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#architectureObject



77
78
79
80
# File 'lib/fog/hp/models/compute_v2/image.rb', line 77

def architecture
  m = @metadata.detect {|md| md.key == 'architecture'}
  m.value unless m.nil?
end

#bootable_volume?Boolean

The following are built-in metadata for each image, exposed as helpers

Returns:

  • (Boolean)


47
48
49
50
# File 'lib/fog/hp/models/compute_v2/image.rb', line 47

def bootable_volume?
  m = @metadata.detect {|md| md.key == 'com.hp__1__bootable_volume'}
  m.value unless m.nil?
end

#destroyObject



36
37
38
39
40
# File 'lib/fog/hp/models/compute_v2/image.rb', line 36

def destroy
  requires :id
  service.delete_image(id)
  true
end

#licenseObject



67
68
69
70
# File 'lib/fog/hp/models/compute_v2/image.rb', line 67

def license
  m = @metadata.detect {|md| md.key == 'hp_image_license'}
  m.value unless m.nil?
end

#metadataObject

attribute :metadata # lazy load metadata as needed per model



21
22
23
24
25
26
27
28
# File 'lib/fog/hp/models/compute_v2/image.rb', line 21

def 
  @metadata ||= begin
    Fog::Compute::HPV2::Metadata.new({
      :service => service,
      :parent => self
    })
  end
end

#metadata=(new_metadata = {}) ⇒ Object



30
31
32
33
34
# File 'lib/fog/hp/models/compute_v2/image.rb', line 30

def metadata=(={})
  metas = []
  .each_pair {|k,v| metas << {'key' => k, 'value' => v} }
  .load(metas)
end

#os_distroObject



57
58
59
60
# File 'lib/fog/hp/models/compute_v2/image.rb', line 57

def os_distro
  m = @metadata.detect {|md| md.key == 'com.hp__1__os_distro'}
  m.value unless m.nil?
end

#os_versionObject



62
63
64
65
# File 'lib/fog/hp/models/compute_v2/image.rb', line 62

def os_version
  m = @metadata.detect {|md| md.key == 'com.hp__1__os_version'}
  m.value unless m.nil?
end

#providerObject



52
53
54
55
# File 'lib/fog/hp/models/compute_v2/image.rb', line 52

def provider
  m = @metadata.detect {|md| md.key == 'com.hp__1__provider'}
  m.value unless m.nil?
end

#ready?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/fog/hp/models/compute_v2/image.rb', line 42

def ready?
  status == 'ACTIVE'
end

#typeObject



72
73
74
75
# File 'lib/fog/hp/models/compute_v2/image.rb', line 72

def type
  m = @metadata.detect {|md| md.key == 'com.hp__1__image_type'}
  m.value unless m.nil?
end