Class: CloudProviders::ElasticBlockStore
- Inherits:
-
Ec2Helper
- Object
- CloudProvider
- Ec2Helper
- CloudProviders::ElasticBlockStore
- Defined in:
- lib/cloud_providers/ec2/helpers/elastic_block_store.rb
Instance Attribute Summary collapse
-
#attachments ⇒ Object
readonly
instance methods.
-
#availabilityZone ⇒ Object
(also: #availability_zone)
readonly
instance methods.
-
#createTime(create_time) ⇒ Object
readonly
Returns the value of attribute createTime.
-
#device ⇒ Object
readonly
instance methods.
-
#instanceId ⇒ Object
(also: #instance_id)
readonly
instance methods.
-
#size ⇒ Object
readonly
instance methods.
-
#snapshotId ⇒ Object
(also: #snapshot_id)
readonly
instance methods.
-
#status ⇒ Object
readonly
instance methods.
-
#volumeId ⇒ Object
(also: #volume_id)
readonly
instance methods.
Attributes inherited from CloudProvider
Instance Method Summary collapse
- #attach(ec2_instance, device) ⇒ Object
- #attached?(fn_instance_id = nil) ⇒ Boolean
- #available? ⇒ Boolean
-
#create_time ⇒ Object
Returns the value of attribute createTime.
- #delete! ⇒ Object
- #detach ⇒ Object
- #detach! ⇒ Object
-
#initialize(raw_response, init_opts = {}, &block) ⇒ ElasticBlockStore
constructor
A new instance of ElasticBlockStore.
- #parse_raw_response(raw_response) ⇒ Object
- #update! ⇒ Object
Methods inherited from Ec2Helper
#as, #ec2, #elb, #pool, property, #rds
Methods inherited from CloudProvider
#after_initialized, #bootstrap_nodes!, #default_keypair_path, default_keypair_path, #method_missing, #run
Constructor Details
#initialize(raw_response, init_opts = {}, &block) ⇒ ElasticBlockStore
Returns a new instance of ElasticBlockStore.
21 22 23 24 |
# File 'lib/cloud_providers/ec2/helpers/elastic_block_store.rb', line 21 def initialize(raw_response,init_opts={},&block) parse_raw_response(raw_response) super(volumeId,init_opts,&block) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class CloudProviders::CloudProvider
Instance Attribute Details
#attachments ⇒ Object (readonly)
instance methods
5 6 7 |
# File 'lib/cloud_providers/ec2/helpers/elastic_block_store.rb', line 5 def @attachments end |
#availabilityZone ⇒ Object (readonly) Also known as: availability_zone
instance methods
5 6 7 |
# File 'lib/cloud_providers/ec2/helpers/elastic_block_store.rb', line 5 def availabilityZone @availabilityZone end |
#createTime(create_time) ⇒ Object (readonly)
Returns the value of attribute createTime.
6 7 8 |
# File 'lib/cloud_providers/ec2/helpers/elastic_block_store.rb', line 6 def createTime @createTime end |
#device ⇒ Object (readonly)
instance methods
5 6 7 |
# File 'lib/cloud_providers/ec2/helpers/elastic_block_store.rb', line 5 def device @device end |
#instanceId ⇒ Object (readonly) Also known as: instance_id
instance methods
5 6 7 |
# File 'lib/cloud_providers/ec2/helpers/elastic_block_store.rb', line 5 def instanceId @instanceId end |
#size ⇒ Object (readonly)
instance methods
5 6 7 |
# File 'lib/cloud_providers/ec2/helpers/elastic_block_store.rb', line 5 def size @size end |
#snapshotId ⇒ Object (readonly) Also known as: snapshot_id
instance methods
5 6 7 |
# File 'lib/cloud_providers/ec2/helpers/elastic_block_store.rb', line 5 def snapshotId @snapshotId end |
#status ⇒ Object (readonly)
instance methods
5 6 7 |
# File 'lib/cloud_providers/ec2/helpers/elastic_block_store.rb', line 5 def status @status end |
#volumeId ⇒ Object (readonly) Also known as: volume_id
instance methods
5 6 7 |
# File 'lib/cloud_providers/ec2/helpers/elastic_block_store.rb', line 5 def volumeId @volumeId end |
Instance Method Details
#attach(ec2_instance, device) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/cloud_providers/ec2/helpers/elastic_block_store.rb', line 50 def attach(ec2_instance,device) if ec2.attach_volume(:volume_id => volume_id, :instance_id => ec2_instance.instance_id, :device => device).return=="true" update! return true end false end |
#attached?(fn_instance_id = nil) ⇒ Boolean
39 40 41 42 43 44 |
# File 'lib/cloud_providers/ec2/helpers/elastic_block_store.rb', line 39 def attached?(fn_instance_id=nil) return false unless @status=="in-use" or @status=="attaching" return true if fn_instance_id.nil? return true if fn_instance_id == instance_id return false end |
#available? ⇒ Boolean
46 47 48 |
# File 'lib/cloud_providers/ec2/helpers/elastic_block_store.rb', line 46 def available? @status=="available" end |
#create_time ⇒ Object
Returns the value of attribute createTime.
11 12 13 |
# File 'lib/cloud_providers/ec2/helpers/elastic_block_store.rb', line 11 def createTime @createTime end |
#delete! ⇒ Object
70 71 72 |
# File 'lib/cloud_providers/ec2/helpers/elastic_block_store.rb', line 70 def delete! ec2.delete(:volume_id => volume_id).return == "true" end |
#detach ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/cloud_providers/ec2/helpers/elastic_block_store.rb', line 58 def detach if ec2.detach_volume(:volume_id => volume_id).return=="true" update! return true end false end |
#detach! ⇒ Object
66 67 68 |
# File 'lib/cloud_providers/ec2/helpers/elastic_block_store.rb', line 66 def detach! ec2.detach_volume(:volume_id => volume_id, :force => true).return=="true" end |
#parse_raw_response(raw_response) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/cloud_providers/ec2/helpers/elastic_block_store.rb', line 26 def parse_raw_response(raw_response) @raw_respons = raw_response raw_response.each{|k,v| instance_variable_set("@"+k,v) if respond_to?(k) } unless raw_response..nil? @attachments=raw_response..item @attachments.each{|attch| if attch.status=="attached" or attch.status=="attaching" @instanceId=attch.instanceId @device=attch.device end } end end |
#update! ⇒ Object
74 75 76 |
# File 'lib/cloud_providers/ec2/helpers/elastic_block_store.rb', line 74 def update! parse_raw_response ec2.describe_volumes(:volume_id => volume_id) end |