Sha256: 3fb7be175f1c9357c9700f12bb8c54e800b64eeb738247b391282a6b8cb0e5da

Contents?: true

Size: 968 Bytes

Versions: 11

Compression:

Stored size: 968 Bytes

Contents

module VagrantPlugins
  module OVirtProvider
    module Action

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

        def call(env)
          dir_name = env[:root_path].basename.to_s.dup.gsub(/[^-a-z0-9_]/i, "")
          timestamp = "_#{Time.now.to_f}"
          max_dir_name_length = dir_name.length-[(dir_name + timestamp).length-(@@MAX_NAME_LENGTH-1), 0].max
          env[:domain_name] = dir_name[0..max_dir_name_length] << timestamp

          # 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

11 entries across 11 versions & 1 rubygems

Version Path
vagrant-ovirt3-1.9.3 lib/vagrant-ovirt3/action/set_name_of_domain.rb
vagrant-ovirt3-1.9.2 lib/vagrant-ovirt3/action/set_name_of_domain.rb
vagrant-ovirt3-1.9.1 lib/vagrant-ovirt3/action/set_name_of_domain.rb
vagrant-ovirt3-1.9.0 lib/vagrant-ovirt3/action/set_name_of_domain.rb
vagrant-ovirt3-1.8.2 lib/vagrant-ovirt3/action/set_name_of_domain.rb
vagrant-ovirt3-1.7.1 lib/vagrant-ovirt3/action/set_name_of_domain.rb
vagrant-ovirt3-1.7.0 lib/vagrant-ovirt3/action/set_name_of_domain.rb
vagrant-ovirt3-1.6.2 lib/vagrant-ovirt3/action/set_name_of_domain.rb
vagrant-ovirt3-1.6.1 lib/vagrant-ovirt3/action/set_name_of_domain.rb
vagrant-ovirt3-1.6.0 lib/vagrant-ovirt3/action/set_name_of_domain.rb
vagrant-ovirt3-1.5.0 lib/vagrant-ovirt3/action/set_name_of_domain.rb