Sha256: 25101270d642f81cd22e75962844b218faab6c87fa37bad53d7935e3b6a57266
Contents?: true
Size: 1.46 KB
Versions: 3
Compression:
Stored size: 1.46 KB
Contents
module VagrantPlugins module Vultr class Config < Vagrant.plugin(2, :config) attr_accessor :token attr_accessor :region attr_accessor :os attr_accessor :snapshot attr_accessor :plan # @api private attr_accessor :ssh_key_id def initialize @token = UNSET_VALUE @region = UNSET_VALUE @os = UNSET_VALUE @snapshot = UNSET_VALUE @plan = UNSET_VALUE end def finalize! @token = ENV['VULTR_TOKEN'] if @token == UNSET_VALUE @region = 'Seattle' if @region == UNSET_VALUE @os = 'Ubuntu 14.04 x64' if @os == UNSET_VALUE && @snapshot == UNSET_VALUE @plan = '768 MB RAM,15 GB SSD,1.00 TB BW' if @plan == UNSET_VALUE @snapshot = nil if @snapshot == UNSET_VALUE end def validate(machine) errors = [] key = machine.config.ssh.private_key_path key = key.first if key.is_a?(Array) if !key errors << 'You have to specify config.ssh.private_key_path.' elsif !File.file?(File.expand_path("#{key}.pub", machine.env.root_path)) errors << "Cannot find SSH public key: #{key}.pub." end if both_os_and_snapshot_provided? errors << 'You have to specify one of provider.os or provider.snapshot.' end {'vultr' => errors} end private def both_os_and_snapshot_provided? @os != UNSET_VALUE && @snapshot end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
vagrant-vultr-0.1.2 | lib/vagrant-vultr/config.rb |
vagrant-vultr-0.1.1 | lib/vagrant-vultr/config.rb |
vagrant-vultr-0.1.0 | lib/vagrant-vultr/config.rb |