Class: VagrantPlugins::Openstack::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::Openstack::Config
- Defined in:
- lib/vagrant-openstack-provider/config.rb
Instance Attribute Summary collapse
-
#availability_zone ⇒ String
Availability Zone.
-
#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.
-
#floating_ip_pool ⇒ String
The floating IP pool from where new IPs will be allocated.
-
#floating_ip_pool_always_allocate ⇒ Boolean
if set to true, vagrant will always allocate floating ip instead of trying to reuse unassigned ones default to false.
-
#image ⇒ Object
The name or ID of the image to use.
-
#keypair_name ⇒ String
The name of the keypair to use.
-
#metadata ⇒ Hash
A Hash of metadata that will be sent to the instance for configuration.
-
#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.
-
#openstack_volume_url ⇒ Object
The block storage service url to access Openstack.
-
#password ⇒ Object
The API key to access Openstack.
-
#public_key_path ⇒ Array
Public key path to create OpenStack keypair.
-
#rsync_includes ⇒ Array
Opt files/directories in to the rsync operation performed by this provider.
-
#scheduler_hints ⇒ Object
Pass hints to the OpenStack scheduler, e.g.
-
#security_groups ⇒ Array[String]
List of strings representing the security groups to apply.
-
#server_name ⇒ Object
The name of the server.
-
#ssh_disabled ⇒ Boolean
Flag to enable/disable all SSH actions (to use for instance on private networks).
-
#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.
-
#user_data ⇒ String
User data to be sent to the newly created OpenStack instance.
-
#username ⇒ String
The username to access Openstack.
-
#volume_boot ⇒ Object
Volume to boot the vm from.
-
#volumes ⇒ Array
Volumes list that will be attached to the VM.
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.
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/vagrant-openstack-provider/config.rb', line 144 def initialize @password = UNSET_VALUE @openstack_compute_url = UNSET_VALUE @openstack_network_url = UNSET_VALUE @openstack_volume_url = UNSET_VALUE @openstack_auth_url = UNSET_VALUE @flavor = UNSET_VALUE @image = UNSET_VALUE @volume_boot = 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 @floating_ip_pool = UNSET_VALUE @floating_ip_pool_always_allocate = UNSET_VALUE @sync_method = UNSET_VALUE @availability_zone = UNSET_VALUE @networks = [] @volumes = [] @public_key_path = UNSET_VALUE @scheduler_hints = UNSET_VALUE @security_groups = UNSET_VALUE @user_data = UNSET_VALUE @metadata = UNSET_VALUE @ssh_disabled = UNSET_VALUE end |
Instance Attribute Details
#availability_zone ⇒ String
Availability Zone
117 118 119 |
# File 'lib/vagrant-openstack-provider/config.rb', line 117 def availability_zone @availability_zone end |
#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.
31 32 33 |
# File 'lib/vagrant-openstack-provider/config.rb', line 31 def flavor @flavor end |
#floating_ip ⇒ String
The floating IP address from the IP pool which will be assigned to the instance.
81 82 83 |
# File 'lib/vagrant-openstack-provider/config.rb', line 81 def floating_ip @floating_ip end |
#floating_ip_pool ⇒ String
The floating IP pool from where new IPs will be allocated
86 87 88 |
# File 'lib/vagrant-openstack-provider/config.rb', line 86 def floating_ip_pool @floating_ip_pool end |
#floating_ip_pool_always_allocate ⇒ Boolean
if set to true, vagrant will always allocate floating ip instead of trying to reuse unassigned ones default to false
92 93 94 |
# File 'lib/vagrant-openstack-provider/config.rb', line 92 def floating_ip_pool_always_allocate @floating_ip_pool_always_allocate end |
#image ⇒ Object
The name or ID of the image to use. This can also be a regular expression to partially match a name.
35 36 37 |
# File 'lib/vagrant-openstack-provider/config.rb', line 35 def image @image end |
#keypair_name ⇒ String
The name of the keypair to use.
59 60 61 |
# File 'lib/vagrant-openstack-provider/config.rb', line 59 def keypair_name @keypair_name end |
#metadata ⇒ Hash
A Hash of metadata that will be sent to the instance for configuration
137 138 139 |
# File 'lib/vagrant-openstack-provider/config.rb', line 137 def @metadata end |
#networks ⇒ Array
Network list the VM will be connected to
102 103 104 |
# File 'lib/vagrant-openstack-provider/config.rb', line 102 def networks @networks end |
#openstack_auth_url ⇒ Object
The authentication endpoint. This defaults to Openstack’s global authentication endpoint.
27 28 29 |
# File 'lib/vagrant-openstack-provider/config.rb', line 27 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
14 15 16 |
# File 'lib/vagrant-openstack-provider/config.rb', line 14 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
19 20 21 |
# File 'lib/vagrant-openstack-provider/config.rb', line 19 def openstack_network_url @openstack_network_url end |
#openstack_volume_url ⇒ Object
The block storage service url to access Openstack. If nil, it will read from hypermedia catalog form REST API
24 25 26 |
# File 'lib/vagrant-openstack-provider/config.rb', line 24 def openstack_volume_url @openstack_volume_url end |
#password ⇒ Object
The API key to access Openstack.
9 10 11 |
# File 'lib/vagrant-openstack-provider/config.rb', line 9 def password @password end |
#public_key_path ⇒ Array
Public key path to create OpenStack keypair
112 113 114 |
# File 'lib/vagrant-openstack-provider/config.rb', line 112 def public_key_path @public_key_path end |
#rsync_includes ⇒ Array
Opt files/directories in to the rsync operation performed by this provider
76 77 78 |
# File 'lib/vagrant-openstack-provider/config.rb', line 76 def rsync_includes @rsync_includes end |
#scheduler_hints ⇒ Object
Pass hints to the OpenStack scheduler, e.g. { “cell”: “some cell name” }
120 121 122 |
# File 'lib/vagrant-openstack-provider/config.rb', line 120 def scheduler_hints @scheduler_hints end |
#security_groups ⇒ Array[String]
List of strings representing the security groups to apply. e.g. [‘ssh’, ‘http’]
126 127 128 |
# File 'lib/vagrant-openstack-provider/config.rb', line 126 def security_groups @security_groups 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.
49 50 51 |
# File 'lib/vagrant-openstack-provider/config.rb', line 49 def server_name @server_name end |
#ssh_disabled ⇒ Boolean
Flag to enable/disable all SSH actions (to use for instance on private networks)
142 143 144 |
# File 'lib/vagrant-openstack-provider/config.rb', line 142 def ssh_disabled @ssh_disabled 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
71 72 73 |
# File 'lib/vagrant-openstack-provider/config.rb', line 71 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.
65 66 67 |
# File 'lib/vagrant-openstack-provider/config.rb', line 65 def ssh_username @ssh_username end |
#sync_method ⇒ String
Sync folder method. Can be either “rsync” or “none”
97 98 99 |
# File 'lib/vagrant-openstack-provider/config.rb', line 97 def sync_method @sync_method end |
#tenant_name ⇒ Object
The name of the openstack project on witch the vm will be created.
44 45 46 |
# File 'lib/vagrant-openstack-provider/config.rb', line 44 def tenant_name @tenant_name end |
#user_data ⇒ String
User data to be sent to the newly created OpenStack instance. Use this e.g. to inject a script at boot time.
132 133 134 |
# File 'lib/vagrant-openstack-provider/config.rb', line 132 def user_data @user_data end |
#username ⇒ String
The username to access Openstack.
54 55 56 |
# File 'lib/vagrant-openstack-provider/config.rb', line 54 def username @username end |
#volume_boot ⇒ Object
Volume to boot the vm from
39 40 41 |
# File 'lib/vagrant-openstack-provider/config.rb', line 39 def volume_boot @volume_boot end |
#volumes ⇒ Array
Volumes list that will be attached to the VM
107 108 109 |
# File 'lib/vagrant-openstack-provider/config.rb', line 107 def volumes @volumes end |
Instance Method Details
#finalize! ⇒ Object
rubocop:disable Style/CyclomaticComplexity
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/vagrant-openstack-provider/config.rb', line 176 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_volume_url = nil if @openstack_volume_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 @volume_boot = nil if @volume_boot == 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 @floating_ip_pool = nil if @floating_ip_pool == UNSET_VALUE @floating_ip_pool_always_allocate = false if floating_ip_pool_always_allocate == UNSET_VALUE @sync_method = 'rsync' if @sync_method == UNSET_VALUE @keypair_name = nil if @keypair_name == UNSET_VALUE @public_key_path = nil if @public_key_path == UNSET_VALUE @availability_zone = nil if @availability_zone == UNSET_VALUE @scheduler_hints = nil if @scheduler_hints == UNSET_VALUE @security_groups = nil if @security_groups == UNSET_VALUE @user_data = nil if @user_data == UNSET_VALUE @metadata = nil if @metadata == UNSET_VALUE @ssh_disabled = false if @ssh_disabled == 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? @volumes = nil if @volumes.empty? end |
#rsync_include(inc) ⇒ Object
rubocop:enable Style/CyclomaticComplexity
211 212 213 |
# File 'lib/vagrant-openstack-provider/config.rb', line 211 def rsync_include(inc) @rsync_includes << inc end |
#validate(machine) ⇒ Object
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/vagrant-openstack-provider/config.rb', line 215 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 validate_ssh_username(machine, errors) validate_ssh_timeout(errors) if machine.config.ssh.private_key_path puts I18n.t('vagrant_openstack.config.keypair_name_required').yellow unless @keypair_name || @public_key_path else errors << I18n.t('vagrant_openstack.config.private_key_missing') if @keypair_name || @public_key_path end { openstack_compute_url: @openstack_compute_url, openstack_network_url: @openstack_network_url, openstack_volume_url: @openstack_volume_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 |