class NCC::Connection::AWS
/* Copyright 2013 Proofpoint, Inc. All rights reserved.
Copyright 2014 Evernote Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */
Public Instance Methods
connection_params()
click to toggle source
# File lib/ncc/connection/aws.rb, line 52 def connection_params ['aws_access_key_id', 'aws_secret_access_key'] end
console_log(instance_id)
click to toggle source
# File lib/ncc/connection/aws.rb, line 80 def console_log(instance_id) begin do_fog do |fog| fog.get_console_output(instance_id).body end rescue Fog::Compute::AWS::NotFound instance_not_found instance_id rescue Exception => e communication_error e.message end end
instance_image(server)
click to toggle source
# File lib/ncc/connection/aws.rb, line 68 def instance_image(server) map_from_raw_provider_id(:image, server.image_id) end
instance_ip_address(server)
click to toggle source
# File lib/ncc/connection/aws.rb, line 76 def instance_ip_address(server) server.private_ip_address end
instance_name(server)
click to toggle source
# File lib/ncc/connection/aws.rb, line 56 def instance_name(server) if ! server.tags.nil? and server.tags.has_key? 'Name' server.tags['Name'] else nil end end
instance_size(server)
click to toggle source
# File lib/ncc/connection/aws.rb, line 64 def instance_size(server) map_from_raw_provider_id(:size, server.flavor_id) end
instance_status(server)
click to toggle source
# File lib/ncc/connection/aws.rb, line 72 def instance_status(server) map_to_status(server.state) end
map_to_provider_status(abstract_status)
click to toggle source
# File lib/ncc/connection/aws.rb, line 120 def map_to_provider_status(abstract_status) case abstract_status when 'active', 'error', 'hard-reboot', 'reboot', 'provider-operation', 'unknown', 'needs-verify' 'running' when 'build' 'pending' when 'terminated' 'terminated' when 'shutting-down' 'shutting-down' when 'suspending' 'stopping' when 'suspend' 'stopped' else 'running' end end
map_to_status(aws_status)
click to toggle source
# File lib/ncc/connection/aws.rb, line 101 def map_to_status(aws_status) case aws_status when 'running' 'active' when 'pending' 'build' when 'terminated' 'terminated' when 'shutting-down' 'shutting-down' when 'stopping' 'suspending' when 'stopped' 'suspend' else 'unknown' end end
provider()
click to toggle source
# File lib/ncc/connection/aws.rb, line 39 def provider 'aws' end
provider_request_of(instance)
click to toggle source
# File lib/ncc/connection/aws.rb, line 92 def provider_request_of(instance) { :name => instance.name, :flavor_id => sizes(instance.size)['provider_id'], :image_id => images(instance.image)['provider_id'], :tags => { 'Name' => instance.name } }.merge(instance.extra provider) end
translate_image(provider_image)
click to toggle source
# File lib/ncc/connection/aws.rb, line 30 def translate_image(provider_image) generic_translate(:image, provider_image). merge({ 'description' => provider_image.description, 'ramdisk_id' => provider_image.ramdisk_id, 'kernel_id' => provider_image.kernel_id }) end
translate_size(flavor)
click to toggle source
# File lib/ncc/connection/aws.rb, line 20 def translate_size(flavor) generic_translate(:size, flavor). merge({ 'ram' => flavor.ram, 'disk' => flavor.disk, 'cores' => flavor.cores, 'description' => flavor.name }) end
use_only_mapped(type)
click to toggle source
# File lib/ncc/connection/aws.rb, line 43 def use_only_mapped(type) case type when :image true when :size false end end