Class: Larrow::Qingcloud::Image
- Defined in:
- lib/larrow/qingcloud/image.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#platform ⇒ Object
Returns the value of attribute platform.
-
#provider ⇒ Object
Returns the value of attribute provider.
Attributes inherited from Base
Class Method Summary collapse
- .create(instance_id) ⇒ Object
- .create_from_snapshot(snapshot_id) ⇒ Object
- .list(provider = :system, ids: []) ⇒ Object
Instance Method Summary collapse
Methods inherited from Base
conn, #conn, describe, destroy_action, #initialize, #method_missing, #model_name, model_name, #param_by, param_by, plural_name, #show, singular_name
Methods included from Logger
Constructor Details
This class inherits a constructor from Larrow::Qingcloud::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Larrow::Qingcloud::Base
Instance Attribute Details
#platform ⇒ Object
Returns the value of attribute platform.
4 5 6 |
# File 'lib/larrow/qingcloud/image.rb', line 4 def platform @platform end |
#provider ⇒ Object
Returns the value of attribute provider.
4 5 6 |
# File 'lib/larrow/qingcloud/image.rb', line 4 def provider @provider end |
Class Method Details
.create(instance_id) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/larrow/qingcloud/image.rb', line 17 def self.create instance_id result = conn.get 'CaptureInstance', instance: instance_id info "image created(instance: #{instance_id}): #{result}" image = new result['image_id'] promise(timeout:90){ image.wait_for :available } end |
.create_from_snapshot(snapshot_id) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/larrow/qingcloud/image.rb', line 24 def self.create_from_snapshot snapshot_id result = conn.get 'CaptureInstanceFromSnapshot', snapshot: snapshot_id info "image created(snapshot: #{snapshot_id}): #{result}" image = new result['image_id'] promise(timeout:90){ image.wait_for :available } end |
.list(provider = :system, ids: []) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/larrow/qingcloud/image.rb', line 7 def self.list(provider=:system,ids:[]) describe(ids,{:provider => provider,:'status.1' => :available}) do |hash| new(hash['image_id'], {'status' => hash['status'], 'platform' => hash['platform'], 'provider' => hash['provider']} ) end end |
Instance Method Details
#wait_for(status) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/larrow/qingcloud/image.rb', line 31 def wait_for status super do |data| self.status = status self.platform = data['platform'] self.provider = data['provider'] end end |