10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/models/volume.rb', line 10
def self.import(aws_volume)
volume = Volume.where(remote_id: aws_volume.id).first || Volume.new(remote_id: aws_volume.id)
volume.attributes = {
name: aws_volume.tags["Name"],
remote_id: aws_volume.id,
state: aws_volume.state,
volume_type: aws_volume.type,
iops: aws_volume.iops,
size: aws_volume.size,
server: Server.where(remote_id: aws_volume.server_id).first,
availability_zone: AvailabilityZone.find_or_create_by(name: aws_volume.availability_zone),
created_at: aws_volume.created_at,
deleted_at: nil
}
volume.save!
aws_volume.tags.each do |key, value|
volume.tags.find_or_create_by(name: key.downcase).update_attributes(value: value.downcase)
end
volume
end
|