Class: Fog::AWS::Compute::Volumes

Inherits:
Collection
  • Object
show all
Defined in:
lib/fog/compute/models/aws/volumes.rb

Instance Attribute Summary

Attributes inherited from Collection

#connection

Instance Method Summary collapse

Methods inherited from Collection

#clear, #create, #inspect, #load, model, #model, #reload, #table, #to_json

Methods included from Fog::Attributes::ClassMethods

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

Methods included from Fog::Attributes::InstanceMethods

#_dump, #attributes, #identity, #identity=, #merge_attributes, #new_record?, #requires

Constructor Details

#initialize(attributes) ⇒ Volumes

Used to create a volume. There are 3 arguments and availability_zone and size are required. You can generate a new key_pair as follows: AWS.volumes.create(:availability_zone => ‘us-east-1a’, :size => ‘t1.micro’)

Returns

<Fog::AWS::Compute::Volume

id="vol-1e2028b9",
attached_at=nil,
availability_zone="us-east-1a",
created_at=Tue Nov 23 23:30:29 -0500 2010,
delete_on_termination=nil,
device=nil,
server_id=nil,
size="t1.micro",
snapshot_id=nil,
state="creating",
tags=nil

>

The volume can be retreived by running AWS.volumes.get(“vol-1e2028b9”). See get method below.



37
38
39
40
# File 'lib/fog/compute/models/aws/volumes.rb', line 37

def initialize(attributes)
  self.filters ||= {}
  super
end

Instance Method Details

#all(filters = filters) ⇒ Object

Used to return all volumes. AWS.volumes.all

Returns

>>AWS.volumes.all <Fog::AWS::Compute::Volume

id="vol-1e2028b9",
attached_at=nil,
availability_zone="us-east-1a",
created_at=Tue Nov 23 23:30:29 -0500 2010,
delete_on_termination=nil,
device=nil,
server_id=nil,
size="t1.micro",
snapshot_id=nil,
state="creating",
tags=nil

>

The volume can be retreived by running AWS.volumes.get(“vol-1e2028b9”). See get method below.



65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/fog/compute/models/aws/volumes.rb', line 65

def all(filters = filters)
  unless filters.is_a?(Hash)
    Formatador.display_line("[yellow][WARN] all with #{filters.class} param is deprecated, use all('volume-id' => []) instead[/] [light_black](#{caller.first})[/]")
    filters = {'volume-id' => [*filters]}
  end
  self.filters = filters
  data = connection.describe_volumes(filters).body
  load(data['volumeSet'])
  if server
    self.replace(self.select {|volume| volume.server_id == server.id})
  end
  self
end

#get(volume_id) ⇒ Object

Used to retreive a volume volume_id is required to get the associated volume information.

You can run the following command to get the details: AWS.volumes.get(“vol-1e2028b9”)

Returns

>> AWS.volumes.get(“vol-1e2028b9”) <Fog::AWS::Compute::Volume

  id="vol-1e2028b9",
  attached_at=nil,
  availability_zone="us-east-1a",
  created_at=Tue Nov 23 23:30:29 -0500 2010,
  delete_on_termination=nil,
  device=nil,
  server_id=nil,
  size="t1.micro",
  snapshot_id=nil,
  state="available",
  tags={}
>


103
104
105
106
107
# File 'lib/fog/compute/models/aws/volumes.rb', line 103

def get(volume_id)
  if volume_id
    self.class.new(:connection => connection).all('volume-id' => volume_id).first
  end
end

#new(attributes = {}) ⇒ Object



109
110
111
112
113
114
115
# File 'lib/fog/compute/models/aws/volumes.rb', line 109

def new(attributes = {})
  if server
    super({ :server => server }.merge!(attributes))
  else
    super
  end
end