Class: VagrantPlugins::OpenStack::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/vagrant-openstack/config.rb', line 73

def initialize
  @api_key  = UNSET_VALUE
  @endpoint = UNSET_VALUE
  @region = UNSET_VALUE
  @flavor   = UNSET_VALUE
  @image    = UNSET_VALUE
  @server_name = UNSET_VALUE
  @username = UNSET_VALUE
  @keypair_name = UNSET_VALUE
  @ssh_username = UNSET_VALUE
  @user_data = UNSET_VALUE
  @metadata = UNSET_VALUE
  @public_network_name = UNSET_VALUE
  @networks = UNSET_VALUE
  @tenant = UNSET_VALUE
  @scheduler_hints = UNSET_VALUE
end

Instance Attribute Details

#api_keyString

The API key to access OpenStack.

Returns:

  • (String)


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

def api_key
  @api_key
end

#endpointString

The endpoint to access OpenStack.

Returns:

  • (String)


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

def endpoint
  @endpoint
end

#flavorObject

The flavor of server to launch, either the ID or name. This can also be a regular expression to partially match a name.



23
24
25
# File 'lib/vagrant-openstack/config.rb', line 23

def flavor
  @flavor
end

#imageObject

The name or ID of the image to use. This can also be a regular expression to partially match a name.



27
28
29
# File 'lib/vagrant-openstack/config.rb', line 27

def image
  @image
end

#keypair_nameString

The name of the keypair to use.

Returns:

  • (String)


42
43
44
# File 'lib/vagrant-openstack/config.rb', line 42

def keypair_name
  @keypair_name
end

#metadataHash

Metadata to be sent to the newly created OpenStack instance.

Returns:



59
60
61
# File 'lib/vagrant-openstack/config.rb', line 59

def 
  @metadata
end

#networksString

Returns:

  • (String)


65
66
67
# File 'lib/vagrant-openstack/config.rb', line 65

def networks
  @networks
end

#public_network_nameString

Returns:

  • (String)


62
63
64
# File 'lib/vagrant-openstack/config.rb', line 62

def public_network_name
  @public_network_name
end

#regionString

Openstack region, if your openstack instance uses these. Rackspace typically uses these. You need to provide their three letter acronym (for example: DFW)

Returns:

  • (String)


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

def region
  @region
end

#scheduler_hintsHash

Returns:



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

def scheduler_hints
  @scheduler_hints
end

#server_nameObject

The name of the server. This defaults to the name of the machine defined by Vagrant (via ‘config.vm.define`), but can be overriden here.



32
33
34
# File 'lib/vagrant-openstack/config.rb', line 32

def server_name
  @server_name
end

#ssh_usernameString

The SSH username to use with this OpenStack instance. This overrides the ‘config.ssh.username` variable.

Returns:

  • (String)


48
49
50
# File 'lib/vagrant-openstack/config.rb', line 48

def ssh_username
  @ssh_username
end

#tenantString

Returns:

  • (String)


68
69
70
# File 'lib/vagrant-openstack/config.rb', line 68

def tenant
  @tenant
end

#user_dataString

User data to be sent to the newly created OpenStack instance. Use this e.g. to inject a script at boot time.

Returns:

  • (String)


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

def user_data
  @user_data
end

#usernameString

The username to access OpenStack.

Returns:

  • (String)


37
38
39
# File 'lib/vagrant-openstack/config.rb', line 37

def username
  @username
end

Instance Method Details

#finalize!Object



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/vagrant-openstack/config.rb', line 91

def finalize!
  @api_key  = nil if @api_key == UNSET_VALUE
  @endpoint = nil if @endpoint == UNSET_VALUE
  @region = nil if @region == UNSET_VALUE
  @flavor   = /m1.tiny/ if @flavor == UNSET_VALUE
  @image    = /cirros/ if @image == UNSET_VALUE
  @server_name = nil if @server_name == UNSET_VALUE
  @username = nil if @username == UNSET_VALUE

  # Keypair defaults to nil
  @keypair_name = nil if @keypair_name == UNSET_VALUE

  # The SSH values by default are nil, and the top-level config
  # `config.ssh` values are used.
  @ssh_username = nil if @ssh_username == UNSET_VALUE

  @user_data = "" if @user_data == UNSET_VALUE
  @metadata = {} if @metadata == UNSET_VALUE

  @public_network_name = "public" if @public_network_name == UNSET_VALUE
  @networks = [@public_network_name] if @networks == UNSET_VALUE
  @tenant = nil if @tenant == UNSET_VALUE
  @scheduler_hints = {} if @scheduler_hints == UNSET_VALUE
end

#validate(machine) ⇒ Object



116
117
118
119
120
121
122
123
# File 'lib/vagrant-openstack/config.rb', line 116

def validate(machine)
  errors = []

  errors << I18n.t("vagrant_openstack.config.api_key_required") if !@api_key
  errors << I18n.t("vagrant_openstack.config.username_required") if !@username

  { "OpenStack Provider" => errors }
end