Class: VagrantPlugins::WindowsDomain::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-windows-domain/config.rb

Overview

The “Configuration” represents a configuration of how the WindowsDomain provisioner should behave: authentication mechanism etc.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/vagrant-windows-domain/config.rb', line 51

def initialize
  super
  @domain            = UNSET_VALUE
  @computer_name     = UNSET_VALUE
  @username          = UNSET_VALUE
  @password          = UNSET_VALUE
  @join_options      = {}
  @ou_path           = UNSET_VALUE
  @unsecure          = UNSET_VALUE
  @rename            = UNSET_VALUE
  @logger            = Log4r::Logger.new("vagrant::vagrant_windows_domain")
end

Instance Attribute Details

#computer_nameObject

The new Computer Name to use when joining the domain. Specifies a new name for the computer in the new domain. Uses the -NameName Option.



17
18
19
# File 'lib/vagrant-windows-domain/config.rb', line 17

def computer_name
  @computer_name
end

#domainObject

The Windows Domain to join.

Setting this will result in an additional restart.



13
14
15
# File 'lib/vagrant-windows-domain/config.rb', line 13

def domain
  @domain
end

#join_optionsObject

The set of Advanced options to pass when joining the Domain.

See (technet.microsoft.com/en-us/library/hh849798.aspx) for detail. NOTE: If we user :computer_name from above this needs to be merged!!



34
35
36
# File 'lib/vagrant-windows-domain/config.rb', line 34

def join_options
  @join_options
end

#ou_pathObject

Organisational Unit path in AD.

Specifies an organizational unit (OU) for the domain account. Enter the full distinguished name of the OU in quotation marks. The default value is the default OU for machine objects in the domain.



41
42
43
# File 'lib/vagrant-windows-domain/config.rb', line 41

def ou_path
  @ou_path
end

#passwordObject

The Password to use when authenticating against the Domain.

Specifies the password of a user account that has permission to join the computers to a new domain.



28
29
30
# File 'lib/vagrant-windows-domain/config.rb', line 28

def password
  @password
end

#renameObject

The trigger whether plugin should rename the computer or omit the renaming



49
50
51
# File 'lib/vagrant-windows-domain/config.rb', line 49

def rename
  @rename
end

#unsecureObject

Performs an unsecure join to the specified domain.

When this option is used username/password are not required



46
47
48
# File 'lib/vagrant-windows-domain/config.rb', line 46

def unsecure
  @unsecure
end

#usernameObject

The Username to use when authenticating against the Domain.

Specifies a user account that has permission to join the computers to a new domain.



22
23
24
# File 'lib/vagrant-windows-domain/config.rb', line 22

def username
  @username
end

Instance Method Details

#finalize!Object

Final step of the Configuration lifecyle prior to validation.

Ensures all attributes are set to defaults if not provided.



68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/vagrant-windows-domain/config.rb', line 68

def finalize!
  super

  # Null checks
  @domain            = nil if @domain == UNSET_VALUE || @domain == ""
  @computer_name     = nil if @computer_name == UNSET_VALUE || @computer_name == ""
  @username          = nil if @username == UNSET_VALUE || @username == ""
  @password          = nil if @password == UNSET_VALUE || @password == ""
  @join_options      = [] if @join_options == UNSET_VALUE
  @ou_path           = nil if @ou_path == UNSET_VALUE
  @unsecure          = false if @unsecure == UNSET_VALUE
  @rename            = true if @rename == UNSET_VALUE
end

#validate(machine) ⇒ Hash

Validate configuration and return a hash of errors.

Validation happens after finalize!.

Parameters:

  • The (Machine)

    current Machine

Returns:

  • (Hash)

    Any errors or {} if no errors found



88
89
90
91
92
93
94
95
96
97
# File 'lib/vagrant-windows-domain/config.rb', line 88

def validate(machine)        
  errors = _detected_errors

  # Need to supply one of them!
  if ( (@username != nil && @password != nil) && @unsecure == true)
    errors << I18n.t("vagrant_windows_domain.errors.both_credentials_provided")
  end
  
  { "windows domain provisioner" => errors }
end