<commit_before>require 'vagrant'

module VagrantPlugins
  module VSphere
    class Config < Vagrant.plugin('2', :config)
      attr_accessor :host
      attr_accessor :insecure
      attr_accessor :user
      attr_accessor :password
      attr_accessor :data_center_name
      attr_accessor :compute_resource_name
      attr_accessor :resource_pool_name
      attr_accessor :clone_from_vm
      attr_accessor :template_name
      attr_accessor :name
      attr_accessor :customization_spec_name
      attr_accessor :data_store_name

      def validate(machine)
        errors = _detected_errors

        #TODO: add blank?
        errors << I18n.t('config.host') if host.nil?
        errors <<  I18n.t('config.user') if user.nil?
        errors <<  I18n.t('config.password') if password.nil?
        errors <<  I18n.t('config.name') if name.nil?
        errors <<  I18n.t('config.template') if template_name.nil?

        #These are only required if we're cloning from an actual template
        errors << I18n.t('config.compute_resource') if compute_resource_name.nil? and not clone_from_vm
        errors << I18n.t('config.resource_pool') if resource_pool_name.nil? and not clone_from_vm

        { 'vSphere Provider' => errors }
      end
    end
  end
end<commit_msg>Enable auto-naming for multiple-VMs scenario<commit_after>require 'vagrant'

module VagrantPlugins
  module VSphere
    class Config < Vagrant.plugin('2', :config)
      attr_accessor :host
      attr_accessor :insecure
      attr_accessor :user
      attr_accessor :password
      attr_accessor :data_center_name
      attr_accessor :compute_resource_name
      attr_accessor :resource_pool_name
      attr_accessor :clone_from_vm
      attr_accessor :template_name
      attr_accessor :name
      attr_accessor :customization_spec_name
      attr_accessor :data_store_name

      def validate(machine)
        errors = _detected_errors

        #TODO: add blank?
        errors << I18n.t('config.host') if host.nil?
        errors <<  I18n.t('config.user') if user.nil?
        errors <<  I18n.t('config.password') if password.nil?
        if name.nil?
          prefix = "#{machine.name}"
          prefix.gsub!(/[^-a-z0-9_]/i, "")
          # milliseconds + random number suffix to allow for simultaneous `vagrant up` of the same box in different dirs
          machine.provider_config.name = prefix + "_#{(Time.now.to_f * 1000.0).to_i}_#{rand(100000)}"
        end
        errors <<  I18n.t('config.template') if template_name.nil?

        #These are only required if we're cloning from an actual template
        errors << I18n.t('config.compute_resource') if compute_resource_name.nil? and not clone_from_vm
        errors << I18n.t('config.resource_pool') if resource_pool_name.nil? and not clone_from_vm

        { 'vSphere Provider' => errors }
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.09078163336838416, 'fraction_numerical': 0.014370837714686295, 'mean_word_length': 2.898907103825137, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5750516', 'n_tokens_mistral': 925, 'n_tokens_neox': 887, 'n_words': 212}