Class: Knife::Clc::CloudExtensions::CloudAdapter
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Knife::Clc::CloudExtensions::CloudAdapter
- Defined in:
- lib/knife-clc/cloud_extensions/cloud_adapter.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
- #ensure_server_powered_on(server) ⇒ Object
- #get_private_ip(server) ⇒ Object
- #get_public_ip(server) ⇒ Object
- #get_server_credentials(server) ⇒ Object
-
#initialize(params) ⇒ CloudAdapter
constructor
A new instance of CloudAdapter.
Constructor Details
#initialize(params) ⇒ CloudAdapter
Returns a new instance of CloudAdapter.
7 8 9 10 |
# File 'lib/knife-clc/cloud_extensions/cloud_adapter.rb', line 7 def initialize(params) @connection = params.fetch(:connection) super(@connection) end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
5 6 7 |
# File 'lib/knife-clc/cloud_extensions/cloud_adapter.rb', line 5 def connection @connection end |
Instance Method Details
#ensure_server_powered_on(server) ⇒ Object
17 18 19 20 21 |
# File 'lib/knife-clc/cloud_extensions/cloud_adapter.rb', line 17 def ensure_server_powered_on(server) return unless server['details']['powerState'] == 'stopped' links = connection.power_on_server(server['id']) connection.wait_for(links['operation']['id']) end |
#get_private_ip(server) ⇒ Object
23 24 25 26 |
# File 'lib/knife-clc/cloud_extensions/cloud_adapter.rb', line 23 def get_private_ip(server) private_ips = server['details']['ipAddresses'].map { |addr| addr['internal'] }.compact private_ips.first end |
#get_public_ip(server) ⇒ Object
28 29 30 31 |
# File 'lib/knife-clc/cloud_extensions/cloud_adapter.rb', line 28 def get_public_ip(server) public_ips = server['details']['ipAddresses'].map { |addr| addr['public'] }.compact public_ips.first end |
#get_server_credentials(server) ⇒ Object
12 13 14 15 |
# File 'lib/knife-clc/cloud_extensions/cloud_adapter.rb', line 12 def get_server_credentials(server) creds_link = server['links'].find { |link| link['rel'] == 'credentials' } connection.follow(creds_link) if creds_link end |