vagrant-vultr 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +6 -0
- data/lib/vagrant-vultr/action/create.rb +15 -0
- data/lib/vagrant-vultr/config.rb +15 -0
- data/lib/vagrant-vultr/helpers/client.rb +15 -5
- data/vagrant-vultr.gemspec +1 -1
- metadata +6 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f031591283dd35a1683006af1dd65ba484f3dbf36da051a79b1f55f085779f3b
|
4
|
+
data.tar.gz: da874ed72a35b7d49e97e6b2772e41bf128b1fe3fbdd7dc9cf2dee2dad85af02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b730e9e7ec7709d135bb5e21edafafb30ef5d8160630e3b82886672eab78967c138bba426ae1715393063ee2fdcb472a13747820e5ccd0d14f99cdecdcb6e67d
|
7
|
+
data.tar.gz: e2f9b4604aa5eead4e9c353895aade2a1c7179d4a0e20708d70e0925d08b25a05b91539ae4c3cd8e608235befdfc5190028f0900806015e31aea1064816c8fbf
|
data/README.md
CHANGED
@@ -31,6 +31,11 @@ Vagrant.configure(2) do |config|
|
|
31
31
|
# Use either OS name or Snapshot identifier
|
32
32
|
vultr.os = 'Ubuntu 14.04 x64'
|
33
33
|
vultr.snapshot = '524557af2439b'
|
34
|
+
|
35
|
+
# Optional parameters
|
36
|
+
vultr.label = 'My Label'
|
37
|
+
vultr.tag = 'My Tag'
|
38
|
+
vultr.hostname = 'myhostname'
|
34
39
|
end
|
35
40
|
end
|
36
41
|
```
|
@@ -46,6 +51,7 @@ Notes
|
|
46
51
|
|
47
52
|
1. You have to specify `override.ssh.private_key_path`. Public key will be uploaded to Vultr as "vagrant" SSH key and will be used when servers are created.
|
48
53
|
2. Currently, servers are created with "root" user.
|
54
|
+
3. If you hit API rate limit, you can set `VULTR_RATE_LIMIT_INTERVAL_MS` environment variable to introduce delay between API requests.
|
49
55
|
|
50
56
|
Testing
|
51
57
|
-------
|
@@ -18,18 +18,33 @@ module VagrantPlugins
|
|
18
18
|
plan = env[:machine].provider_config.plan
|
19
19
|
os = env[:machine].provider_config.os
|
20
20
|
snapshot = env[:machine].provider_config.snapshot
|
21
|
+
enable_ipv6 = env[:machine].provider_config.enable_ipv6
|
22
|
+
enable_private_network = env[:machine].provider_config.enable_private_network
|
23
|
+
label = env[:machine].provider_config.label
|
24
|
+
tag = env[:machine].provider_config.tag
|
25
|
+
hostname = env[:machine].provider_config.hostname
|
21
26
|
|
22
27
|
@logger.info "Creating server with:"
|
23
28
|
@logger.info " -- Region: #{region}"
|
24
29
|
@logger.info " -- OS: #{os}"
|
25
30
|
@logger.info " -- Plan: #{plan}"
|
26
31
|
@logger.info " -- Snapshot: #{snapshot}"
|
32
|
+
@logger.info " -- Enable IPv6: #{enable_ipv6}"
|
33
|
+
@logger.info " -- Enable Private Network: #{enable_private_network}"
|
34
|
+
@logger.info " -- Label: #{label}"
|
35
|
+
@logger.info " -- Tag: #{tag}"
|
36
|
+
@logger.info " -- Hostname: #{hostname}"
|
27
37
|
|
28
38
|
attributes = {
|
29
39
|
region: region,
|
30
40
|
os: os,
|
31
41
|
plan: plan,
|
32
42
|
snapshot: snapshot,
|
43
|
+
enable_ipv6: enable_ipv6,
|
44
|
+
enable_private_network: enable_private_network,
|
45
|
+
label: label,
|
46
|
+
tag: tag,
|
47
|
+
hostname: hostname,
|
33
48
|
ssh_key_name: Action::SetupSSHKey::NAME
|
34
49
|
}
|
35
50
|
@machine.id = @client.create_server(attributes)
|
data/lib/vagrant-vultr/config.rb
CHANGED
@@ -6,6 +6,11 @@ module VagrantPlugins
|
|
6
6
|
attr_accessor :os
|
7
7
|
attr_accessor :snapshot
|
8
8
|
attr_accessor :plan
|
9
|
+
attr_accessor :enable_ipv6
|
10
|
+
attr_accessor :enable_private_network
|
11
|
+
attr_accessor :label
|
12
|
+
attr_accessor :tag
|
13
|
+
attr_accessor :hostname
|
9
14
|
|
10
15
|
# @api private
|
11
16
|
attr_accessor :ssh_key_id
|
@@ -16,6 +21,11 @@ module VagrantPlugins
|
|
16
21
|
@os = UNSET_VALUE
|
17
22
|
@snapshot = UNSET_VALUE
|
18
23
|
@plan = UNSET_VALUE
|
24
|
+
@enable_ipv6 = UNSET_VALUE
|
25
|
+
@enable_private_network = UNSET_VALUE
|
26
|
+
@label = UNSET_VALUE
|
27
|
+
@tag = UNSET_VALUE
|
28
|
+
@hostname = UNSET_VALUE
|
19
29
|
end
|
20
30
|
|
21
31
|
def finalize!
|
@@ -24,6 +34,11 @@ module VagrantPlugins
|
|
24
34
|
@os = 'Ubuntu 14.04 x64' if @os == UNSET_VALUE && @snapshot == UNSET_VALUE
|
25
35
|
@plan = '768 MB RAM,15 GB SSD,1.00 TB BW' if @plan == UNSET_VALUE
|
26
36
|
@snapshot = nil if @snapshot == UNSET_VALUE
|
37
|
+
@enable_ipv6 = 'no' if @enable_ipv6 == UNSET_VALUE
|
38
|
+
@enable_private_network = 'no' if @enable_private_network == UNSET_VALUE
|
39
|
+
@label = '' if @label == UNSET_VALUE
|
40
|
+
@tag = '' if @tag == UNSET_VALUE
|
41
|
+
@hostname = '' if @hostname == UNSET_VALUE
|
27
42
|
end
|
28
43
|
|
29
44
|
def validate(machine)
|
@@ -34,10 +34,16 @@ module VagrantPlugins
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def create_server(attributes)
|
37
|
+
location_id = region_id(attributes[:region])
|
37
38
|
params = {
|
38
|
-
DCID:
|
39
|
-
VPSPLANID: vps_plan_id(attributes[:plan]),
|
40
|
-
SSHKEYID: ssh_key_id(attributes[:ssh_key_name])
|
39
|
+
DCID: location_id,
|
40
|
+
VPSPLANID: vps_plan_id(attributes[:plan], location_id.class.name == "String" ? location_id.to_i : location_id),
|
41
|
+
SSHKEYID: ssh_key_id(attributes[:ssh_key_name]),
|
42
|
+
enable_ipv6: attributes[:enable_ipv6],
|
43
|
+
enable_private_network: attributes[:enable_private_network],
|
44
|
+
label: attributes[:label],
|
45
|
+
tag: attributes[:tag],
|
46
|
+
hostname: attributes[:hostname]
|
41
47
|
}
|
42
48
|
|
43
49
|
if attributes[:snapshot]
|
@@ -81,9 +87,9 @@ module VagrantPlugins
|
|
81
87
|
regions.find { |r| r['name'] == region }['DCID']
|
82
88
|
end
|
83
89
|
|
84
|
-
def vps_plan_id(plan)
|
90
|
+
def vps_plan_id(plan, location_id)
|
85
91
|
plans = request { ::Vultr::Plans.list }
|
86
|
-
plans.values.find { |p| p['name'] == plan }['VPSPLANID']
|
92
|
+
plans.values.find { |p| p['name'] == plan && p['available_locations']&.include?(location_id) }['VPSPLANID']
|
87
93
|
end
|
88
94
|
|
89
95
|
def ssh_keys
|
@@ -134,6 +140,10 @@ module VagrantPlugins
|
|
134
140
|
private
|
135
141
|
|
136
142
|
def request
|
143
|
+
if interval = ENV['VULTR_RATE_LIMIT_INTERVAL_MS']
|
144
|
+
sleep interval.to_f / 1000
|
145
|
+
end
|
146
|
+
|
137
147
|
response = yield
|
138
148
|
if response[:status] != 200
|
139
149
|
raise "API request failed: #{response[:result]}."
|
data/vagrant-vultr.gemspec
CHANGED
@@ -2,7 +2,7 @@ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'vagrant-vultr'
|
5
|
-
spec.version = '0.1.
|
5
|
+
spec.version = '0.1.3'
|
6
6
|
spec.author = 'Alex Rodionov'
|
7
7
|
spec.email = 'p0deje@gmail.com'
|
8
8
|
spec.homepage = 'http://github.com/p0deje/vagrant-vultr'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-vultr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Rodionov
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: vultr
|
@@ -100,7 +100,7 @@ homepage: http://github.com/p0deje/vagrant-vultr
|
|
100
100
|
licenses:
|
101
101
|
- MIT
|
102
102
|
metadata: {}
|
103
|
-
post_install_message:
|
103
|
+
post_install_message:
|
104
104
|
rdoc_options: []
|
105
105
|
require_paths:
|
106
106
|
- lib
|
@@ -115,12 +115,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
117
|
requirements: []
|
118
|
-
|
119
|
-
|
120
|
-
signing_key:
|
118
|
+
rubygems_version: 3.3.25
|
119
|
+
signing_key:
|
121
120
|
specification_version: 4
|
122
121
|
summary: Vultr provider for Vagrant
|
123
122
|
test_files:
|
124
123
|
- features/support/env.rb
|
125
124
|
- features/vagrant-vultr.feature
|
126
|
-
has_rdoc:
|