Class: Bosh::Registry::InstanceManager::Aws
- Inherits:
-
Bosh::Registry::InstanceManager
- Object
- Bosh::Registry::InstanceManager
- Bosh::Registry::InstanceManager::Aws
- Defined in:
- lib/bosh/registry/instance_manager/aws.rb
Constant Summary collapse
- AWS_MAX_RETRIES =
2
Instance Method Summary collapse
-
#initialize(cloud_config) ⇒ Aws
constructor
A new instance of Aws.
-
#instance_ips(instance_id) ⇒ Object
Get the list of IPs belonging to this instance.
- #validate_options(cloud_config) ⇒ Object
Methods inherited from Bosh::Registry::InstanceManager
#delete_settings, #read_settings, #update_settings
Constructor Details
#initialize(cloud_config) ⇒ Aws
Returns a new instance of Aws.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/bosh/registry/instance_manager/aws.rb', line 11 def initialize(cloud_config) (cloud_config) @logger = Bosh::Registry.logger @aws_properties = cloud_config["aws"] @aws_options = { :access_key_id => @aws_properties["access_key_id"], :secret_access_key => @aws_properties["secret_access_key"], :max_retries => @aws_properties["max_retries"] || AWS_MAX_RETRIES, :ec2_endpoint => @aws_properties['ec2_endpoint'] || "ec2.#{@aws_properties['region']}.amazonaws.com", :logger => @logger } # configure optional parameters %w( ssl_verify_peer ssl_ca_file ssl_ca_path ).each do |k| @aws_options[k.to_sym] = @aws_properties[k] unless @aws_properties[k].nil? end @ec2 = AWS::EC2.new(@aws_options) end |
Instance Method Details
#instance_ips(instance_id) ⇒ Object
Get the list of IPs belonging to this instance
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/bosh/registry/instance_manager/aws.rb', line 47 def instance_ips(instance_id) instance = @ec2.instances[instance_id] ips = [instance.private_ip_address, instance.public_ip_address] if instance.has_elastic_ip? ips << instance.elastic_ip.public_ip end ips rescue AWS::Errors::Base => e raise Bosh::Registry::AwsError, "AWS error: #{e}" end |
#validate_options(cloud_config) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/bosh/registry/instance_manager/aws.rb', line 36 def (cloud_config) unless cloud_config.has_key?("aws") && cloud_config["aws"].is_a?(Hash) && cloud_config["aws"]["access_key_id"] && cloud_config["aws"]["secret_access_key"] && cloud_config["aws"]["region"] raise ConfigError, "Invalid AWS configuration parameters" end end |