Class: Cheftacular::CloudProvider
- Inherits:
-
Object
- Object
- Cheftacular::CloudProvider
- Defined in:
- lib/cheftacular/cloud_provider.rb
Instance Method Summary collapse
-
#initialize(options, config) ⇒ CloudProvider
constructor
A new instance of CloudProvider.
-
#parse_addresses_from_server_create_hash(server_hash) ⇒ Object
public address, private address.
- #parse_server_root_password_from_server_create_hash(server_hash, real_node_name) ⇒ Object
Constructor Details
#initialize(options, config) ⇒ CloudProvider
Returns a new instance of CloudProvider.
4 5 6 |
# File 'lib/cheftacular/cloud_provider.rb', line 4 def initialize , config , @config = , config end |
Instance Method Details
#parse_addresses_from_server_create_hash(server_hash) ⇒ Object
public address, private address
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/cheftacular/cloud_provider.rb', line 9 def parse_addresses_from_server_create_hash server_hash ap server_hash case ['preferred_cloud'] when 'rackspace' [server_hash['ipv4_address'], server_hash['addresses']['private'][0]['addr']] when 'digitalocean' [ server_hash['networks']['v4'].select { |hash| hash['type'] == 'public' }.first['ip_address'], server_hash['networks']['v4'].select { |hash| hash['type'] == 'private' }.first['ip_address'] ] else raise "CRITICAL! Encountered unsupported preferred cloud #{ @options['preferred_cloud'] }" end end |
#parse_server_root_password_from_server_create_hash(server_hash, real_node_name) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/cheftacular/cloud_provider.rb', line 23 def parse_server_root_password_from_server_create_hash server_hash, real_node_name case ['preferred_cloud'] when 'rackspace' begin server_hash['admin_passwords']["#{ real_node_name }"] rescue NoMethodError => e raise "Unable to locate an admin pass for server #{ @options['node_name'] }, does the server already exist?" end when 'digitalocean' #we use sshkey authentication for initial server create for digitalocean else raise "CRITICAL! Encountered unsupported preferred cloud #{ @options['preferred_cloud'] }" end end |