class Server
Public Class Methods
import(aws_host)
click to toggle source
# File lib/models/server.rb, line 9 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: nil } 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