Class: VagrantPlugins::DigitalOcean::Actions::SetupKey
- Inherits:
-
Object
- Object
- VagrantPlugins::DigitalOcean::Actions::SetupKey
- Includes:
- Helpers::Client
- Defined in:
- lib/vagrant-chassis-digitalocean/actions/setup_key.rb
Instance Method Summary collapse
-
#call(env) ⇒ Object
TODO check the content of the key to see if it has changed.
-
#initialize(app, env) ⇒ SetupKey
constructor
A new instance of SetupKey.
Methods included from Helpers::Client
Constructor Details
#initialize(app, env) ⇒ SetupKey
Returns a new instance of SetupKey.
9 10 11 12 13 14 |
# File 'lib/vagrant-chassis-digitalocean/actions/setup_key.rb', line 9 def initialize(app, env) @app = app @machine = env[:machine] @client = client @logger = Log4r::Logger.new('vagrant::digitalocean::setup_key') end |
Instance Method Details
#call(env) ⇒ Object
TODO check the content of the key to see if it has changed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/vagrant-chassis-digitalocean/actions/setup_key.rb', line 17 def call(env) ssh_key_name = @machine.provider_config.ssh_key_name begin # assigns existing ssh key id to env for use by other commands env[:ssh_key_id] = @client .request('/v2/account/keys') .find_id(:ssh_keys, :name => ssh_key_name) env[:ui].info I18n.t('vagrant_digital_ocean.info.using_key', { :name => ssh_key_name }) rescue Errors::ResultMatchError env[:ssh_key_id] = create_ssh_key(ssh_key_name, env) end @app.call(env) end |