Class: VagrantPlugins::Joyent::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(datacenter_specific = false) ⇒ Config

Returns a new instance of Config.



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/vagrant-joyent/config.rb', line 18

def initialize(datacenter_specific=false)
  @username    = UNSET_VALUE
  @password    = UNSET_VALUE
  @keyname    = UNSET_VALUE
  @keyfile    = UNSET_VALUE
  @api_url     = UNSET_VALUE
  @ssl_verify_peer = UNSET_VALUE
  @dataset            = UNSET_VALUE
  @flavor             = UNSET_VALUE
  @node_name          = UNSET_VALUE
  @ssh_username       = UNSET_VALUE
end

Instance Attribute Details

#api_urlObject

Returns the value of attribute api_url.



11
12
13
# File 'lib/vagrant-joyent/config.rb', line 11

def api_url
  @api_url
end

#datasetObject

Returns the value of attribute dataset.



12
13
14
# File 'lib/vagrant-joyent/config.rb', line 12

def dataset
  @dataset
end

#flavorObject

Returns the value of attribute flavor.



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

def flavor
  @flavor
end

#keyfileObject

Returns the value of attribute keyfile.



10
11
12
# File 'lib/vagrant-joyent/config.rb', line 10

def keyfile
  @keyfile
end

#keynameObject

Returns the value of attribute keyname.



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

def keyname
  @keyname
end

#node_nameObject

Returns the value of attribute node_name.



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

def node_name
  @node_name
end

#passwordObject

Returns the value of attribute password.



8
9
10
# File 'lib/vagrant-joyent/config.rb', line 8

def password
  @password
end

#ssh_usernameObject

Returns the value of attribute ssh_username.



15
16
17
# File 'lib/vagrant-joyent/config.rb', line 15

def ssh_username
  @ssh_username
end

#ssl_verify_peerObject

Returns the value of attribute ssl_verify_peer.



16
17
18
# File 'lib/vagrant-joyent/config.rb', line 16

def ssl_verify_peer
  @ssl_verify_peer
end

#usernameObject

Returns the value of attribute username.



7
8
9
# File 'lib/vagrant-joyent/config.rb', line 7

def username
  @username
end

Instance Method Details

#finalize!Object


Internal methods.




35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/vagrant-joyent/config.rb', line 35

def finalize!
  # API
  @username = nil if @username == UNSET_VALUE
  @password = nil if @username == UNSET_VALUE
  @keyname = nil if @keyname == UNSET_VALUE
  @keyfile = nil if @keyfile == UNSET_VALUE
  @api_url  = nil if @api_url  == UNSET_VALUE

  # SSL
  @ssl_verify_peer = true if @ssl_verify_peer = UNSET_VALUE

  # Machines
  @dataset = nil if @dataset == UNSET_VALUE
  @flavor = "Small 1GB" if @instance_type == UNSET_VALUE
  @node_name = nil if @node_name == UNSET_VALUE
  @ssh_username = nil if @ssh_username == UNSET_VALUE
end

#validate(machine) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/vagrant-joyent/config.rb', line 53

def validate(machine)
  config = self.class.new(true)

  errors = []
  errors << I18n.t("vagrant_joyent.config.username_required") if config.username.nil?
  errors << I18n.t("vagrant_joyent.config.keyname_required") if config.keyname.nil?
  errors << I18n.t("vagrant_joyent.config.keyfile_required") if config.keyfile.nil?
  errors << I18n.t("vagrant_joyent.config.api_url_required") if config.api_url.nil?
  errors << I18n.t("vagrant_joyent.config.dataset_required") if config.dataset.nil?
  errors << I18n.t("vagrant_joyent.config.flavor_required") if config.flavor.nil?
  errors << I18n.t("vagrant_joyent.config.ssh_username_required") if config.ssh_username.nil?

  { "Joyent Provider" => errors }
end