Class: VagrantPlugins::Sakura::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::Sakura::Config
- Defined in:
- lib/vagrant-sakura/config.rb
Instance Attribute Summary collapse
-
#access_token ⇒ String
The ACCESS TOKEN to access Sakura Cloud API.
-
#access_token_secret ⇒ String
The ACCESS TOKEN SECRET to access Sakura Cloud API.
-
#disk_id ⇒ Fixnum
The ID of the disk to be connected to the server.
-
#disk_plan ⇒ Fixnum
The plan ID of the disk to be connected to the server.
-
#disk_source_archive ⇒ String
The source archive of the disk image to be copied to the instance.
-
#public_key_path ⇒ String
The pathname of the SSH public key to register on the server.
-
#server_name ⇒ String
The name of the server.
-
#server_plan ⇒ Fixnum
The Plan ID of the server.
-
#sshkey_id ⇒ String
The resource ID of the SSH public key to login the server.
-
#use_insecure_key ⇒ Boolean
Use insecure default key to login the server.
-
#zone_id ⇒ Object
The ID of the zone.
Instance Method Summary collapse
- #finalize! ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #validate(machine) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/vagrant-sakura/config.rb', line 59 def initialize @access_token = UNSET_VALUE @access_token_secret = UNSET_VALUE @disk_id = UNSET_VALUE @disk_plan = UNSET_VALUE @disk_source_archive = UNSET_VALUE @public_key_path = UNSET_VALUE @server_name = UNSET_VALUE @server_plan = UNSET_VALUE @sshkey_id = UNSET_VALUE @use_insecure_key = UNSET_VALUE @zone_id = UNSET_VALUE end |
Instance Attribute Details
#access_token ⇒ String
The ACCESS TOKEN to access Sakura Cloud API.
9 10 11 |
# File 'lib/vagrant-sakura/config.rb', line 9 def access_token @access_token end |
#access_token_secret ⇒ String
The ACCESS TOKEN SECRET to access Sakura Cloud API.
14 15 16 |
# File 'lib/vagrant-sakura/config.rb', line 14 def access_token_secret @access_token_secret end |
#disk_id ⇒ Fixnum
The ID of the disk to be connected to the server.
19 20 21 |
# File 'lib/vagrant-sakura/config.rb', line 19 def disk_id @disk_id end |
#disk_plan ⇒ Fixnum
The plan ID of the disk to be connected to the server.
24 25 26 |
# File 'lib/vagrant-sakura/config.rb', line 24 def disk_plan @disk_plan end |
#disk_source_archive ⇒ String
The source archive of the disk image to be copied to the instance.
29 30 31 |
# File 'lib/vagrant-sakura/config.rb', line 29 def disk_source_archive @disk_source_archive end |
#public_key_path ⇒ String
The pathname of the SSH public key to register on the server.
34 35 36 |
# File 'lib/vagrant-sakura/config.rb', line 34 def public_key_path @public_key_path end |
#server_name ⇒ String
The name of the server.
39 40 41 |
# File 'lib/vagrant-sakura/config.rb', line 39 def server_name @server_name end |
#server_plan ⇒ Fixnum
The Plan ID of the server.
44 45 46 |
# File 'lib/vagrant-sakura/config.rb', line 44 def server_plan @server_plan end |
#sshkey_id ⇒ String
The resource ID of the SSH public key to login the server.
49 50 51 |
# File 'lib/vagrant-sakura/config.rb', line 49 def sshkey_id @sshkey_id end |
#use_insecure_key ⇒ Boolean
Use insecure default key to login the server.
54 55 56 |
# File 'lib/vagrant-sakura/config.rb', line 54 def use_insecure_key @use_insecure_key end |
#zone_id ⇒ Object
The ID of the zone.
57 58 59 |
# File 'lib/vagrant-sakura/config.rb', line 57 def zone_id @zone_id end |
Instance Method Details
#finalize! ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/vagrant-sakura/config.rb', line 73 def finalize! if @access_token == UNSET_VALUE @access_token = ENV['SAKURA_ACCESS_TOKEN'] end if @access_token_secret == UNSET_VALUE @access_token_secret = ENV['SAKURA_ACCESS_TOKEN_SECRET'] end if @disk_id == UNSET_VALUE @disk_id = nil # create a new disk end if @disk_plan == UNSET_VALUE @disk_plan = 4 # SSD end if @disk_source_archive == UNSET_VALUE @disk_source_archive = 112800438454 end @public_key_path = nil if @public_key_path == UNSET_VALUE if @server_name == UNSET_VALUE @server_name = nil end if @server_plan == UNSET_VALUE @server_plan = 1001 # 1Core-1GB - cheapest end @sshkey_id = nil if @sshkey_id == UNSET_VALUE @use_insecure_key = false if @use_insecure_key == UNSET_VALUE if @zone_id == UNSET_VALUE @zone_id = "is1a" # the first zone end end |
#validate(machine) ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/vagrant-sakura/config.rb', line 113 def validate(machine) errors = _detected_errors if @access_token.nil? errors << I18n.t("vagrant_sakura.config.access_token_required") end if @access_token_secret.nil? errors << I18n.t("vagrant_sakura.config.access_token_secret_required") end if not (@sshkey_id or @public_key_path or @use_insecure_key) errors << I18n.t("vagrant_sakura.config.need_ssh_key_config") end { "Sakura Provider" => errors } end |