Sha256: 28b3e110a25b4877e57975562c37ea4dd4761dcf831280fe6568905ab1cf9dbe
Contents?: true
Size: 1012 Bytes
Versions: 3
Compression:
Stored size: 1012 Bytes
Contents
class Server < ActiveRecord::Base belongs_to :availability_zone, inverse_of: :servers belongs_to :flavor, inverse_of: :servers has_many :volumes, inverse_of: :server has_many :tags, as: :taggable def self.import(aws_host) server = Server.where(remote_id: aws_host.id).first || Server.new(remote_id: aws_host.id) server.attributes = { name: aws_host.tags["Name"], server_type: aws_host.tags["type"], account_id: aws_host.tags["account_id"], state: aws_host.state, remote_id: aws_host.id, ebs_optimized: aws_host.ebs_optimized, availability_zone: AvailabilityZone.find_or_create_by(name: aws_host.availability_zone), flavor: Flavor.find_or_create_by(name: aws_host.flavor_id), created_at: aws_host.created_at } print "." server.save! aws_host.tags.each do |key, value| next if value.nil? server.tags.find_or_create_by(name: key.downcase).update_attributes(value: value.downcase) end server end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
crop-duster-0.0.9 | lib/models/server.rb |
crop-duster-0.0.8 | lib/models/server.rb |
crop-duster-0.0.7 | lib/models/server.rb |