Class: VagrantPlugins::Kubevirt::Action::SetDomainName
- Inherits:
-
Object
- Object
- VagrantPlugins::Kubevirt::Action::SetDomainName
- Defined in:
- lib/vagrant-kubevirt/action/set_domain_name.rb
Overview
Setup name for domain.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ SetDomainName
constructor
A new instance of SetDomainName.
Constructor Details
#initialize(app, env) ⇒ SetDomainName
Returns a new instance of SetDomainName.
7 8 9 |
# File 'lib/vagrant-kubevirt/action/set_domain_name.rb', line 7 def initialize(app, env) @app = app end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/vagrant-kubevirt/action/set_domain_name.rb', line 11 def call(env) env[:domain_name] = env[:root_path].basename.to_s.dup env[:domain_name].gsub!(/([_.])/, '-') # Check if the domain name is not already taken kubevirt = env[:kubevirt_compute] begin kubevirt.vms.get(env[:domain_name]) rescue Fog::Kubevirt::Errors::ClientError => e msg = e. unless msg.include? '404' raise Errors::FogError, :message => msg end end @app.call(env) end |