Class: Fog::QingCloud::Model

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/qingcloud/model.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.inherited(child) ⇒ Object

Define a common modify_attributes method for some resources



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fog/qingcloud/model.rb', line 9

def self.inherited(child)
  resource_type = Fog::QingCloud.underscore_string(child.to_s.split(':').last)
  aliased_resource_type = {
    'server' => 'instance',
    'address' => 'eip',
    'key_pair' => 'keypair'
  }
  resource_type = aliased_resource_type.fetch(resource_type, resource_type)

  attributes_modifable_resources = ['instance', 'volume', 'vxnet', 'eip', 
    'security_group', 'keypair', 'image']
  if attributes_modifable_resources.include?(resource_type)
    child.class_eval "      def modify_attributes(name, description)\n        requires :id\n        raise Fog::QingCloud::Errors::CommonClientError, \"name or description must be specified\" unless name || description\n        service.modify_resource_attributes(id, '\#{resource_type}', name, description)\n        merge_attributes('\#{resource_type}_name' => name, 'description' => description)\n        true\n      end\n    EOS\n  end\nend\n", __FILE__, __LINE__

Instance Method Details

#wait_for(&block) ⇒ Object



33
34
35
36
# File 'lib/fog/qingcloud/model.rb', line 33

def wait_for(&block)
  wait_policy = lambda { |retries| retries < 8 ? 9 - retries : 1 }
  super(Fog::QingCloud.wait_timeout, wait_policy, &block)
end