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.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/vagrant-skytap/config.rb', line 56

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:



14
15
16
# File 'lib/vagrant-skytap/config.rb', line 14

def api_token
  @api_token
end

#base_urlString

The base URL for Skytap API calls.

Returns:



19
20
21
# File 'lib/vagrant-skytap/config.rb', line 19

def base_url
  @base_url
end

#cpusInteger

The total number of virtual CPUs for this VM.

Returns:

  • (Integer)


39
40
41
# File 'lib/vagrant-skytap/config.rb', line 39

def cpus
  @cpus
end

#cpuspersocketInteger

The number of virtual CPUs per socket.

Returns:

  • (Integer)


44
45
46
# File 'lib/vagrant-skytap/config.rb', line 44

def cpuspersocket
  @cpuspersocket
end

#guestosString

The VMware guest OS setting for this machine.

Returns:



54
55
56
# File 'lib/vagrant-skytap/config.rb', line 54

def guestos
  @guestos
end

#instance_ready_timeoutFixnum

The timeout to wait for a VM to become ready.

Returns:

  • (Fixnum)


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

def instance_ready_timeout
  @instance_ready_timeout
end

#ramInteger

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

Returns:

  • (Integer)


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

def ram
  @ram
end

#usernameString

The user id for accessing Skytap.

Returns:



9
10
11
# File 'lib/vagrant-skytap/config.rb', line 9

def username
  @username
end

#vm_urlString

The url of the source VM to use.

Returns:



24
25
26
# File 'lib/vagrant-skytap/config.rb', line 24

def vm_url
  @vm_url
end

#vpn_urlString

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

Returns:



29
30
31
# File 'lib/vagrant-skytap/config.rb', line 29

def vpn_url
  @vpn_url
end

Instance Method Details

#finalize!Object


Internal methods.




75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/vagrant-skytap/config.rb', line 75

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 waiting for an instance to be ready
  @instance_ready_timeout = 120 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



104
105
106
107
108
109
110
111
112
# File 'lib/vagrant-skytap/config.rb', line 104

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