Sha256: 34f9712e2c9f743aaf98f3ec0f43498a72c6de3ebed98be0fdbc11306f176304

Contents?: true

Size: 799 Bytes

Versions: 2

Compression:

Stored size: 799 Bytes

Contents

module VagrantPlugins
  module OVirtProvider
    module Action

      # Setup name for domain and domain volumes.
      class SetNameOfDomain
        def initialize(app, env)
          @app = app
        end

        def call(env)
          env[:domain_name] = env[:root_path].basename.to_s.dup
          env[:domain_name].gsub!(/[^-a-z0-9_]/i, "")
          env[:domain_name] << "_#{Time.now.to_f}"

          # Check if the domain name is not already taken
          domain = OVirtProvider::Util::Collection.find_matching(
            env[:ovirt_compute].servers.all, env[:domain_name])
          if domain != nil
            raise Vagrant::Errors::DomainNameExists,
              :domain_name => env[:domain_name]
          end

          @app.call(env)
        end
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vagrant-ovirt3-1.3.0 lib/vagrant-ovirt3/action/set_name_of_domain.rb
vagrant-ovirt3-1.4.0 lib/vagrant-ovirt3/action/set_name_of_domain.rb