Class: AWSTracker::EBSVolume
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- AWSTracker::EBSVolume
- Includes:
- Taggable
- Defined in:
- lib/aws_tracker/models/ebs_volume.rb
Class Method Summary collapse
Instance Method Summary collapse
- #update_from_right_hash(right_hash) ⇒ Object
-
#update_instance(instance_id) ⇒ Object
Resets the instance attribute given an AWS instance ID.
Methods included from Taggable
Class Method Details
.refresh_from_account(acc) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/aws_tracker/models/ebs_volume.rb', line 14 def self.refresh_from_account(acc) acc.log.info "Updating EBS volumes for account '#{acc.name}'" right_aws_array = acc.ec2.describe_volumes right_aws_array.each do |right_aws_hash| aws_id = right_aws_hash[:aws_id] volume = EBSVolume.find_or_initialize_by_volume_id(aws_id) do |vol| acc.ebs_volumes << vol vol.account = acc end volume.update_from_right_hash(right_aws_hash) if not volume.save acc.log.error "Failed to save volume #{aws_id}: #{volume.errors}" end end acc.log.info "Account '#{acc.name}' reports "+ "#{right_aws_array.count} EBS volumes" end |
Instance Method Details
#update_from_right_hash(right_hash) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/aws_tracker/models/ebs_volume.rb', line 32 def update_from_right_hash(right_hash) self.volume_id = right_hash[:aws_id] self.size = right_hash[:aws_size] self.status = right_hash[:aws_status] self.availability_zone = right_hash[:zone] self.snapshot_id = right_hash[:snapshot_id] self.create_time = right_hash[:aws_created_at] self.attach_time = right_hash[:aws_attached_at] self. = right_hash[:aws_attachment_status] self.device = right_hash[:aws_device] self.update_instance right_hash[:aws_instance_id] end |
#update_instance(instance_id) ⇒ Object
Resets the instance attribute given an AWS instance ID
46 47 48 49 50 51 52 53 |
# File 'lib/aws_tracker/models/ebs_volume.rb', line 46 def update_instance(instance_id) if instance_id == nil self.instance = nil else self.instance = self.account.instances.find(:first, :conditions => {:instance_id => instance_id}) end end |