Class: VagrantPlugins::Skytap::Action::SetHostname
- Includes:
- ActionHelpers
- Defined in:
- lib/vagrant-skytap/action/set_hostname.rb
Overview
sets VM hostname via the API
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ SetHostname
constructor
A new instance of SetHostname.
Methods included from ActionHelpers
Constructor Details
#initialize(app, env) ⇒ SetHostname
34 35 36 37 |
# File 'lib/vagrant-skytap/action/set_hostname.rb', line 34 def initialize(app, env) @app = app @logger = Log4r::Logger.new("vagrant_skytap::action::set_hostname") end |
Instance Method Details
#call(env) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/vagrant-skytap/action/set_hostname.rb', line 39 def call(env) if hostname = env[:machine].config.vm.hostname if vm = current_vm(env) if nic = vm.interfaces.first if hostname != nic.get_api_attribute('hostname') @logger.info("Updating hostname: #{hostname}") nic.update(hostname: hostname) end end end end @app.call(env) end |