Availability Zone
@return [String]
Specify the #endpoint_type to use : publicURL, adminURL, or internalURL (default is publicURL)
@return [String]
The flavor of server to launch, either the ID or name. This can also be a regular expression to partially match a name.
The floating IP address from the IP pool which will be assigned to the instance.
@return [String]
The floating IP pool from where new IPs will be allocated
@return [String]
if set to true, vagrant will always allocate floating ip instead of trying to reuse unassigned ones default to false
@return [Boolean]
@return [HttpConfig]
The name or ID of the image to use. This can also be a regular expression to partially match a name.
The name of the keypair to use.
@return [String]
@return [Boolean]
A Hash of metadata that will be sent to the instance for configuration
@return [Hash]
Network list the VM will be connected to
@return [Array]
The authentication endpoint. This defaults to Openstack's global authentication endpoint.
The compute service url to access Openstack. If nil, it will read from hypermedia catalog form REST API
The image service url to access Openstack. If nil, it will read from hypermedia catalog form REST API
The network service url to access Openstack. If nil, it will read from hypermedia catalog form REST API
The orchestration service url to access Openstack. If nil, it will read from hypermedia catalog form REST API
The block storage service url to access Openstack. If nil, it will read from hypermedia catalog form REST API
Public key path to create OpenStack keypair
@return [Array]
Openstack region
Sync folder ignore files. A list of files containing exclude patterns to ignore in the rsync operation
performed by this provider
@return [Array]
Opt files/directories in to the rsync operation performed by this provider
@return [Array]
Pass hints to the OpenStack scheduler, e.g. { “cell”: “some cell name” }
List of strings representing the security groups to apply. e.g. ['ssh', 'http']
@return [Array]
@return [Integer]
@return [Integer]
@return [Integer]
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.
@return [Integer]
Flag to enable/disable all SSH actions (to use for instance on private networks)
@return [Boolean]
The SSH timeout use after server creation.
Deprecated. Use config.vm.boot_timeout instead.
@return [Integer]
The SSH username to use with this OpenStack instance. This overrides the `config.ssh.username` variable.
@return [String]
@return [Integer]
@return [Integer]
Stack that will be created and associated to the instances
@return [Array]
Sync folder method. Can be either “rsync” or “none”
@return [String]
The name of the openstack project on witch the vm will be created.
User data to be sent to the newly created OpenStack instance. Use this e.g. to inject a script at boot time.
@return [String]
The username to access Openstack.
@return [String]
Volume to boot the vm from
Volumes list that will be attached to the VM
@return [Array]
# File lib/vagrant-openstack-provider/config.rb, line 202 def initialize @password = UNSET_VALUE @openstack_compute_url = UNSET_VALUE @openstack_network_url = UNSET_VALUE @openstack_volume_url = UNSET_VALUE @openstack_orchestration_url = UNSET_VALUE @openstack_image_url = UNSET_VALUE @openstack_auth_url = UNSET_VALUE @endpoint_type = UNSET_VALUE @region = 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 = [] @rsync_ignore_files = [] @keypair_name = UNSET_VALUE @ssh_username = UNSET_VALUE @ssh_timeout = UNSET_VALUE @floating_ip = UNSET_VALUE @floating_ip_pool = [] @floating_ip_pool_always_allocate = UNSET_VALUE @sync_method = UNSET_VALUE @availability_zone = UNSET_VALUE @networks = [] @stacks = [] @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 @server_create_timeout = UNSET_VALUE @server_active_timeout = UNSET_VALUE @server_stop_timeout = UNSET_VALUE @server_delete_timeout = UNSET_VALUE @stack_create_timeout = UNSET_VALUE @stack_delete_timeout = UNSET_VALUE @meta_args_support = UNSET_VALUE @http = HttpConfig.new end
rubocop:disable Metrics/CyclomaticComplexity
# File lib/vagrant-openstack-provider/config.rb, line 286 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_orchestration_url = nil if @openstack_orchestration_url == UNSET_VALUE @openstack_volume_url = nil if @openstack_volume_url == UNSET_VALUE @openstack_image_url = nil if @openstack_image_url == UNSET_VALUE @openstack_auth_url = nil if @openstack_auth_url == UNSET_VALUE @endpoint_type = 'publicURL' if @endpoint_type == UNSET_VALUE @region = nil if @region == 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? @rsync_ignore_files = nil if @rsync_ignore_files.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` and `config.vm.boot_timeout` values are used. @ssh_username = nil if @ssh_username == UNSET_VALUE @ssh_timeout = nil if @ssh_timeout == UNSET_VALUE @server_create_timeout = 200 if @server_create_timeout == UNSET_VALUE @server_active_timeout = 200 if @server_active_timeout == UNSET_VALUE @server_stop_timeout = 200 if @server_stop_timeout == UNSET_VALUE @server_delete_timeout = 200 if @server_delete_timeout == UNSET_VALUE @stack_create_timeout = 200 if @stack_create_timeout == UNSET_VALUE @stack_delete_timeout = 200 if @stack_delete_timeout == UNSET_VALUE @meta_args_support = false if @meta_args_support == UNSET_VALUE @networks = nil if @networks.empty? @volumes = nil if @volumes.empty? @stacks = nil if @stacks.empty? @http.finalize! end
# File lib/vagrant-openstack-provider/config.rb, line 247 def merge(other) result = self.class.new # Set all of our instance variables on the new class [self, other].each do |obj| obj.instance_variables.each do |key| # Ignore keys that start with a double underscore. This allows # configuration classes to still hold around internal state # that isn't propagated. next if key.to_s.start_with?('@__') # Let user inputs a string or an array for floating ip pool attribute obj.floating_ip_pool = [obj.floating_ip_pool].flatten if key.eql?(:@floating_ip_pool) && !obj.floating_ip_pool.nil? # Let user inputs a string or an array for networks attribute obj.networks = [obj.networks].flatten if key.eql?(:@networks) && !obj.networks.nil? # Don't set the value if it is the unset value, either. value = obj.instance_variable_get(key) if [:@networks, :@volumes, :@rsync_includes, :@rsync_ignore_files, :@floating_ip_pool, :@stacks].include? key result.instance_variable_set(key, value) unless value.empty? elsif [:@http].include? key result.instance_variable_set(key, instance_variable_get(key).merge(other.instance_variable_get(key))) if value != UNSET_VALUE else result.instance_variable_set(key, value) if value != UNSET_VALUE end end end # Persist through the set of invalid methods this_invalid = @__invalid_methods || Set.new other_invalid = other.instance_variable_get(:"@__invalid_methods") || Set.new result.instance_variable_set(:"@__invalid_methods", this_invalid + other_invalid) result end
rubocop:enable Metrics/CyclomaticComplexity
# File lib/vagrant-openstack-provider/config.rb, line 336 def rsync_include(inc) @rsync_includes << inc end
# File lib/vagrant-openstack-provider/config.rb, line 340 def validate(machine) errors = _detected_errors errors << I18n.t('vagrant_openstack.config.password_required') if @password.nil? || @password.empty? errors << I18n.t('vagrant_openstack.config.username_required') if @username.nil? || @username.empty? errors << I18n.t('vagrant_openstack.config.tenant_name_required') if @tenant_name.nil? || @tenant_name.empty? errors << I18n.t('vagrant_openstack.config.invalid_endpoint_type') unless %w(publicURL adminURL internalURL).include?(@endpoint_type) validate_ssh_username(machine, errors) validate_stack_config(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_orchestration_url: @openstack_orchestration_url, openstack_image_url: @openstack_image_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
# File lib/vagrant-openstack-provider/config.rb, line 392 def valid_uri?(value) uri = URI.parse value uri.is_a?(URI::HTTP) end
# File lib/vagrant-openstack-provider/config.rb, line 385 def validate_ssh_timeout(errors) return if @ssh_timeout.nil? || @ssh_timeout == UNSET_VALUE @ssh_timeout = Integer(@ssh_timeout) if @ssh_timeout.is_a? String rescue ArgumentError errors << I18n.t('vagrant_openstack.config.invalid_value_for_parameter', parameter: 'ssh_timeout', value: @ssh_timeout) end
# File lib/vagrant-openstack-provider/config.rb, line 380 def validate_ssh_username(machine, errors) puts I18n.t('vagrant_openstack.config.ssh_username_deprecated').yellow if @ssh_username errors << I18n.t('vagrant_openstack.config.ssh_username_required') unless @ssh_username || machine.config.ssh.username end
# File lib/vagrant-openstack-provider/config.rb, line 374 def validate_stack_config(errors) @stacks.each do |stack| errors << I18n.t('vagrant_openstack.config.invalid_stack') unless stack[:name] && stack[:template] end unless @stacks.nil? end