Class: AWS::Instance

Inherits:
Object
  • Object
show all
Includes:
AWS
Defined in:
lib/aws_cloud_map.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from AWS

connect, ec2

Constructor Details

#initialize(attributes) ⇒ Instance

Returns a new instance of Instance.



81
82
83
# File 'lib/aws_cloud_map.rb', line 81

def initialize(attributes)
  @attributes = attributes
end

Class Method Details

.allObject



201
202
203
# File 'lib/aws_cloud_map.rb', line 201

def self.all
  @@ec2.describe_instances.map { |instance| new(instance) }
end

.find(instance_id) ⇒ Object



205
206
207
# File 'lib/aws_cloud_map.rb', line 205

def self.find(instance_id)
  new(@@ec2.describe_instances([instance_id]).first)
end

Instance Method Details

#addressObject



163
164
165
# File 'lib/aws_cloud_map.rb', line 163

def address
  #TODO
end

#ami_launch_indexObject



113
114
115
# File 'lib/aws_cloud_map.rb', line 113

def ami_launch_index
  @attributes[:ami_launch_index]
end

#associate!(address_or_ip) ⇒ Object

TODO test TODO allow for address case TODO refresh attributes



196
197
198
199
# File 'lib/aws_cloud_map.rb', line 196

def associate!(address_or_ip)
  @@ec2.associate_address(id, address_or_ip)
  @address = nil
end

#attach!(volume_or_id, device) ⇒ Object

TODO test TODO also add to volume TODO allow for volume case



180
181
182
183
# File 'lib/aws_cloud_map.rb', line 180

def attach!(volume_or_id, device)
  @@ec2.attach_volume(volume_or_id, id, device)
  @volumes = nil
end

#aws_availability_zoneObject



133
134
135
# File 'lib/aws_cloud_map.rb', line 133

def aws_availability_zone
  @attributes[:aws_availability_zone]
end

#aws_groupsObject



97
98
99
# File 'lib/aws_cloud_map.rb', line 97

def aws_groups
  @attributes[:aws_groups]
end

#aws_image_idObject



137
138
139
# File 'lib/aws_cloud_map.rb', line 137

def aws_image_id
  @attributes[:aws_image_id]
end

#aws_instance_idObject Also known as: id



141
142
143
# File 'lib/aws_cloud_map.rb', line 141

def aws_instance_id
  @attributes[:aws_instance_id]
end

#aws_instance_typeObject



93
94
95
# File 'lib/aws_cloud_map.rb', line 93

def aws_instance_type
  @attributes[:aws_instance_type]
end

#aws_kernel_idObject



105
106
107
# File 'lib/aws_cloud_map.rb', line 105

def aws_kernel_id
  @attributes[:aws_kernel_id]
end

#aws_launch_timeObject



109
110
111
# File 'lib/aws_cloud_map.rb', line 109

def aws_launch_time
  @attributes[:aws_launch_time]
end

#aws_ownerObject



121
122
123
# File 'lib/aws_cloud_map.rb', line 121

def aws_owner
  @attributes[:aws_owner]
end

#aws_product_codesObject



145
146
147
# File 'lib/aws_cloud_map.rb', line 145

def aws_product_codes
  @attributes[:aws_product_codes]
end

#aws_ramdisk_idObject



129
130
131
# File 'lib/aws_cloud_map.rb', line 129

def aws_ramdisk_id
  @attributes[:aws_ramdisk_id]
end

#aws_reasonObject



149
150
151
# File 'lib/aws_cloud_map.rb', line 149

def aws_reason
  @attributes[:aws_reason]
end

#aws_reservation_idObject



85
86
87
# File 'lib/aws_cloud_map.rb', line 85

def aws_reservation_id
  @attributes[:aws_reservation_id]
end

#aws_stateObject



117
118
119
# File 'lib/aws_cloud_map.rb', line 117

def aws_state
  @attributes[:aws_state]
end

#aws_state_codeObject



153
154
155
# File 'lib/aws_cloud_map.rb', line 153

def aws_state_code
  @attributes[:aws_state_code]
end

#detach!(volume_or_id) ⇒ Object

TODO test TODO also add to volume TODO allow for volume case



188
189
190
191
# File 'lib/aws_cloud_map.rb', line 188

def detach!(volume_or_id)
  @@ec2.detach_volume(volume_or_id, id, device)
  @volumes = nil
end

#dns_nameObject



89
90
91
# File 'lib/aws_cloud_map.rb', line 89

def dns_name
  @attributes[:dns_name]
end

#imageObject



159
160
161
# File 'lib/aws_cloud_map.rb', line 159

def image
  @image ||= Image.find(aws_image_id)
end

#private_dns_nameObject



101
102
103
# File 'lib/aws_cloud_map.rb', line 101

def private_dns_name
  @attributes[:private_dns_name]
end

#ssh_key_nameObject



125
126
127
# File 'lib/aws_cloud_map.rb', line 125

def ssh_key_name
  @attributes[:ssh_key_name]
end

#terminate!Object

TODO test



173
174
175
# File 'lib/aws_cloud_map.rb', line 173

def terminate!
  @@ec2.terminate_instances [id]
end

#volumesObject



167
168
169
170
# File 'lib/aws_cloud_map.rb', line 167

def volumes
  #TODO
  []
end