Class: VagrantPlugins::Skytap::Config
- Defined in:
- lib/vagrant-skytap/config.rb
Instance Attribute Summary collapse
-
#api_token ⇒ String
The secret API token for accessing Skytap.
-
#base_url ⇒ String
The base URL for Skytap API calls.
-
#cpus ⇒ Integer
The total number of virtual CPUs for this VM.
-
#cpuspersocket ⇒ Integer
The number of virtual CPUs per socket.
-
#guestos ⇒ String
The VMware guest OS setting for this machine.
-
#instance_ready_timeout ⇒ Fixnum
The timeout to wait for a VM to become ready.
-
#ram ⇒ Integer
The RAM to use for this machine (measured in MB).
-
#username ⇒ String
The user id for accessing Skytap.
-
#vm_url ⇒ String
The url of the source VM to use.
-
#vpn_url ⇒ String
The url of the VPN to use for connecting to the VM.
Instance Method Summary collapse
-
#finalize! ⇒ Object
——————————————————————- Internal methods.
-
#initialize(region_specific = false) ⇒ Config
constructor
A new instance of Config.
- #validate(machine) ⇒ Object
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_token ⇒ String
The secret API token for accessing Skytap.
36 37 38 |
# File 'lib/vagrant-skytap/config.rb', line 36 def api_token @api_token end |
#base_url ⇒ String
The base URL for Skytap API calls.
41 42 43 |
# File 'lib/vagrant-skytap/config.rb', line 41 def base_url @base_url end |
#cpus ⇒ Integer
The total number of virtual CPUs for this VM.
61 62 63 |
# File 'lib/vagrant-skytap/config.rb', line 61 def cpus @cpus end |
#cpuspersocket ⇒ Integer
The number of virtual CPUs per socket.
66 67 68 |
# File 'lib/vagrant-skytap/config.rb', line 66 def cpuspersocket @cpuspersocket end |
#guestos ⇒ String
The VMware guest OS setting for this machine.
76 77 78 |
# File 'lib/vagrant-skytap/config.rb', line 76 def guestos @guestos end |
#instance_ready_timeout ⇒ Fixnum
The timeout to wait for a VM to become ready.
56 57 58 |
# File 'lib/vagrant-skytap/config.rb', line 56 def instance_ready_timeout @instance_ready_timeout end |
#ram ⇒ Integer
The RAM to use for this machine (measured in MB).
71 72 73 |
# File 'lib/vagrant-skytap/config.rb', line 71 def ram @ram end |
#username ⇒ String
The user id for accessing Skytap.
31 32 33 |
# File 'lib/vagrant-skytap/config.rb', line 31 def username @username end |
#vm_url ⇒ String
The url of the source VM to use.
46 47 48 |
# File 'lib/vagrant-skytap/config.rb', line 46 def vm_url @vm_url end |
#vpn_url ⇒ String
The url of the VPN to use for connecting to the VM.
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 |