Class: VagrantPlugins::Skytap::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(region_specific = false) ⇒ Config

Returns a new instance of Config.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/vagrant-skytap/config.rb', line 78

def initialize(region_specific=false)
  @username               = UNSET_VALUE
  @api_token              = UNSET_VALUE
  @base_url               = UNSET_VALUE
  @vm_url                 = UNSET_VALUE
  @vpn_url                = UNSET_VALUE
  @instance_ready_timeout = UNSET_VALUE
  @region                 = UNSET_VALUE

  @cpus                   = UNSET_VALUE
  @cpuspersocket          = UNSET_VALUE
  @ram                    = UNSET_VALUE
  @guestos                = UNSET_VALUE
end

Instance Attribute Details

#api_tokenString

The secret API token for accessing Skytap.

Returns:



36
37
38
# File 'lib/vagrant-skytap/config.rb', line 36

def api_token
  @api_token
end

#base_urlString

The base URL for Skytap API calls.

Returns:



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

def base_url
  @base_url
end

#cpusInteger

The total number of virtual CPUs for this VM.

Returns:

  • (Integer)


61
62
63
# File 'lib/vagrant-skytap/config.rb', line 61

def cpus
  @cpus
end

#cpuspersocketInteger

The number of virtual CPUs per socket.

Returns:

  • (Integer)


66
67
68
# File 'lib/vagrant-skytap/config.rb', line 66

def cpuspersocket
  @cpuspersocket
end

#guestosString

The VMware guest OS setting for this machine.

Returns:



76
77
78
# File 'lib/vagrant-skytap/config.rb', line 76

def guestos
  @guestos
end

#instance_ready_timeoutFixnum

The timeout to wait for a VM to become ready.

Returns:

  • (Fixnum)


56
57
58
# File 'lib/vagrant-skytap/config.rb', line 56

def instance_ready_timeout
  @instance_ready_timeout
end

#ramInteger

The RAM to use for this machine (measured in MB).

Returns:

  • (Integer)


71
72
73
# File 'lib/vagrant-skytap/config.rb', line 71

def ram
  @ram
end

#usernameString

The user id for accessing Skytap.

Returns:



31
32
33
# File 'lib/vagrant-skytap/config.rb', line 31

def username
  @username
end

#vm_urlString

The url of the source VM to use.

Returns:



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

def vm_url
  @vm_url
end

#vpn_urlString

The url of the VPN to use for connecting to the VM.

Returns:



51
52
53
# File 'lib/vagrant-skytap/config.rb', line 51

def vpn_url
  @vpn_url
end

Instance Method Details

#finalize!Object


Internal methods.




97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/vagrant-skytap/config.rb', line 97

def finalize!
  # Try to get access keys from standard Skytap environment variables; they
  # will default to nil if the environment variables are not present.
  @username  = ENV['VAGRANT_SKYTAP_USERNAME']  if @username  == UNSET_VALUE
  @api_token = ENV['VAGRANT_SKYTAP_API_TOKEN'] if @api_token == UNSET_VALUE

  # Base URL for API calls.
  @base_url = "https://cloud.skytap.com/" if @base_url == UNSET_VALUE

  # Source VM url must be set.
  @vm_url = nil if @vm_url == UNSET_VALUE

  # VPN to use for connection to VM
  @vpn_url = nil if @vpn_url == UNSET_VALUE

  # Set the default timeout for runstate changes (e.g. running a VM)
  @instance_ready_timeout = 300 if @instance_ready_timeout == UNSET_VALUE

  # Hardware settings default to nil (will be obtained
  # from the source VM)
  @cpus          = nil if @cpus          == UNSET_VALUE
  @cpuspersocket = nil if @cpuspersocket == UNSET_VALUE
  @ram           = nil if @ram           == UNSET_VALUE
  @guestos       = nil if @guestos       == UNSET_VALUE

  # Mark that we finalized
  @__finalized = true
end

#validate(machine) ⇒ Object



126
127
128
129
130
131
132
133
134
# File 'lib/vagrant-skytap/config.rb', line 126

def validate(machine)
  errors = _detected_errors

  errors << I18n.t('vagrant_skytap.config.username_required') unless username
  errors << I18n.t('vagrant_skytap.config.api_token_required') unless api_token
  errors << I18n.t('vagrant_skytap.config.vm_url_required') unless vm_url

  { "Skytap Provider" => errors }
end