Sha256: cca7d1efa7f2c18d6097aba02dc20ae63b4857cb729c158b54adb941b117aa04
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
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, deleted_at: null } 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
crop-duster-0.0.10 | lib/models/server.rb |