Class: VagrantPlugins::Openstack::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::Openstack::Config
- Defined in:
- lib/vagrant-openstack-provider/config.rb
Instance Attribute Summary collapse
-
#flavor ⇒ Object
The flavor of server to launch, either the ID or name.
-
#floating_ip ⇒ String
The floating IP address from the IP pool which will be assigned to the instance.
-
#image ⇒ Object
The name or ID of the image to use.
-
#keypair_name ⇒ String
The name of the keypair to use.
-
#networks ⇒ Array
Network list the VM will be connected to.
-
#openstack_auth_url ⇒ Object
The authentication endpoint.
-
#openstack_compute_url ⇒ Object
The compute service url to access Openstack.
-
#openstack_network_url ⇒ Object
The network service url to access Openstack.
-
#password ⇒ Object
The API key to access Openstack.
-
#rsync_includes ⇒ Array
Opt files/directories in to the rsync operation performed by this provider.
-
#server_name ⇒ Object
The name of the server.
-
#ssh_timeout ⇒ Integer
The SSH timeout use after server creation.
-
#ssh_username ⇒ String
The SSH username to use with this OpenStack instance.
-
#sync_method ⇒ String
Sync folder method.
-
#tenant_name ⇒ Object
The name of the openstack project on witch the vm will be created.
-
#username ⇒ String
The username to access Openstack.
Instance Method Summary collapse
-
#finalize! ⇒ Object
rubocop:disable Style/CyclomaticComplexity.
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#rsync_include(inc) ⇒ Object
rubocop:enable Style/CyclomaticComplexity.
- #validate(_machine) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/vagrant-openstack-provider/config.rb', line 83 def initialize @password = UNSET_VALUE @openstack_compute_url = UNSET_VALUE @openstack_network_url = UNSET_VALUE @openstack_auth_url = UNSET_VALUE @flavor = UNSET_VALUE @image = UNSET_VALUE @tenant_name = UNSET_VALUE @server_name = UNSET_VALUE @username = UNSET_VALUE @rsync_includes = [] @keypair_name = UNSET_VALUE @ssh_username = UNSET_VALUE @ssh_timeout = UNSET_VALUE @floating_ip = UNSET_VALUE @sync_method = UNSET_VALUE @networks = [] end |
Instance Attribute Details
#flavor ⇒ Object
The flavor of server to launch, either the ID or name. This can also be a regular expression to partially match a name.
25 26 27 |
# File 'lib/vagrant-openstack-provider/config.rb', line 25 def flavor @flavor end |
#floating_ip ⇒ String
The floating IP address from the IP pool which will be assigned to the instance.
71 72 73 |
# File 'lib/vagrant-openstack-provider/config.rb', line 71 def floating_ip @floating_ip end |
#image ⇒ Object
The name or ID of the image to use. This can also be a regular expression to partially match a name.
29 30 31 |
# File 'lib/vagrant-openstack-provider/config.rb', line 29 def image @image end |
#keypair_name ⇒ String
The name of the keypair to use.
49 50 51 |
# File 'lib/vagrant-openstack-provider/config.rb', line 49 def keypair_name @keypair_name end |
#networks ⇒ Array
Network list the VM will be connected to
81 82 83 |
# File 'lib/vagrant-openstack-provider/config.rb', line 81 def networks @networks end |
#openstack_auth_url ⇒ Object
The authentication endpoint. This defaults to Openstack’s global authentication endpoint.
21 22 23 |
# File 'lib/vagrant-openstack-provider/config.rb', line 21 def openstack_auth_url @openstack_auth_url end |
#openstack_compute_url ⇒ Object
The compute service url to access Openstack. If nil, it will read from hypermedia catalog form REST API
13 14 15 |
# File 'lib/vagrant-openstack-provider/config.rb', line 13 def openstack_compute_url @openstack_compute_url end |
#openstack_network_url ⇒ Object
The network service url to access Openstack. If nil, it will read from hypermedia catalog form REST API
18 19 20 |
# File 'lib/vagrant-openstack-provider/config.rb', line 18 def openstack_network_url @openstack_network_url end |
#password ⇒ Object
The API key to access Openstack.
8 9 10 |
# File 'lib/vagrant-openstack-provider/config.rb', line 8 def password @password end |
#rsync_includes ⇒ Array
Opt files/directories in to the rsync operation performed by this provider
66 67 68 |
# File 'lib/vagrant-openstack-provider/config.rb', line 66 def rsync_includes @rsync_includes end |
#server_name ⇒ Object
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.
39 40 41 |
# File 'lib/vagrant-openstack-provider/config.rb', line 39 def server_name @server_name end |
#ssh_timeout ⇒ Integer
The SSH timeout use after server creation. If server startup is too long the timeout value can be increase with this variable. Default is 60 seconds
61 62 63 |
# File 'lib/vagrant-openstack-provider/config.rb', line 61 def ssh_timeout @ssh_timeout end |
#ssh_username ⇒ String
The SSH username to use with this OpenStack instance. This overrides the ‘config.ssh.username` variable.
55 56 57 |
# File 'lib/vagrant-openstack-provider/config.rb', line 55 def ssh_username @ssh_username end |
#sync_method ⇒ String
Sync folder method. Can be either “rsync” or “none”
76 77 78 |
# File 'lib/vagrant-openstack-provider/config.rb', line 76 def sync_method @sync_method end |
#tenant_name ⇒ Object
The name of the openstack project on witch the vm will be created.
34 35 36 |
# File 'lib/vagrant-openstack-provider/config.rb', line 34 def tenant_name @tenant_name end |
#username ⇒ String
The username to access Openstack.
44 45 46 |
# File 'lib/vagrant-openstack-provider/config.rb', line 44 def username @username end |
Instance Method Details
#finalize! ⇒ Object
rubocop:disable Style/CyclomaticComplexity
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/vagrant-openstack-provider/config.rb', line 103 def finalize! @password = nil if @password == UNSET_VALUE @openstack_compute_url = nil if @openstack_compute_url == UNSET_VALUE @openstack_network_url = nil if @openstack_network_url == UNSET_VALUE @openstack_auth_url = nil if @openstack_auth_url == UNSET_VALUE @flavor = nil if @flavor == UNSET_VALUE @image = nil if @image == UNSET_VALUE @tenant_name = nil if @tenant_name == UNSET_VALUE @server_name = nil if @server_name == UNSET_VALUE @username = nil if @username == UNSET_VALUE @rsync_includes = nil if @rsync_includes.empty? @floating_ip = nil if @floating_ip == UNSET_VALUE @sync_method = 'rsync' if @sync_method == UNSET_VALUE @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 @ssh_timeout = 180 if @ssh_timeout == UNSET_VALUE @networks = nil if @networks.empty? end |
#rsync_include(inc) ⇒ Object
rubocop:enable Style/CyclomaticComplexity
126 127 128 |
# File 'lib/vagrant-openstack-provider/config.rb', line 126 def rsync_include(inc) @rsync_includes << inc end |
#validate(_machine) ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/vagrant-openstack-provider/config.rb', line 130 def validate(_machine) errors = _detected_errors errors << I18n.t('vagrant_openstack.config.password_required') unless @password errors << I18n.t('vagrant_openstack.config.username_required') unless @username errors << I18n.t('vagrant_openstack.config.keypair_name_required') unless @keypair_name { openstack_compute_url: @openstack_compute_url, openstack_network_url: @openstack_network_url, openstack_auth_url: @openstack_auth_url }.each_pair do |key, value| errors << I18n.t('vagrant_openstack.config.invalid_uri', key: key, uri: value) unless value.nil? || valid_uri?(value) end { 'Openstack Provider' => errors } end |