Class: Fog::Compute::Aliyun::Image

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

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Image

Returns a new instance of Image.



31
32
33
34
35
36
# File 'lib/fog/aliyun/models/compute/image.rb', line 31

def initialize(attributes)
  unless attributes['DiskDeviceMappings']['DiskDeviceMapping'].empty?
    self.snapshot_id = attributes['DiskDeviceMappings']['DiskDeviceMapping'][0]['SnapshotId']
  end
  super
end

Instance Method Details

#destroyObject



47
48
49
50
51
# File 'lib/fog/aliyun/models/compute/image.rb', line 47

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

#ready?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/fog/aliyun/models/compute/image.rb', line 53

def ready?
  state == 'Available'
end

#save(options = {}) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/fog/aliyun/models/compute/image.rb', line 38

def save(options = {})
  requires :snapshot_id
  options[:name] = name if name
  options[:description] = description if description
  data = Fog::JSON.decode(service.create_image(snapshot_id, options).body)
  merge_attributes(data)
  true
end

#snapshotObject



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

def snapshot
  requires :snapshot_id
  Fog::Compute::Aliyun::Snapshots.new(service: service).all(snapshotIds: [snapshot_id])[0]
end