vagrant-flow 1.0.19 → 1.0.21

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dad0bbfd73f2794bc4e74120594f1f2580dcd4c6
4
- data.tar.gz: cb21b1de1422202b3a57abe2ca9553f3d2044ab4
3
+ metadata.gz: 00d213603722e753a64dc6d017f1a3411deffef2
4
+ data.tar.gz: 8b4f6e26f222c8fe0e508ec771889bb33ffabe53
5
5
  SHA512:
6
- metadata.gz: 6f7af27a757eac04d532a118ed0dd8b6e18d02d76296f234941a8eaf3fc69a05ccb9c79001b0d5231d56aa837616a4375d116942508a93bb42acac2a74370641
7
- data.tar.gz: a63b7a3d408b54a37872c0482002900a5c1da0a2fa3b1a39373daabd4de15bbbde77313c1d168c61ee82e49c1f1613bb71b45b0328fc309e7ea5b625d1707626
6
+ metadata.gz: 8e6232bbd26f61b63b1fc22848ab2e52bc3b8be29404962affee91464075e683ef08f28699c03b07c4af43a05faf01b270a2c41805c7122bb49ae68f14c36998
7
+ data.tar.gz: 2d552ee70774fee88632a1f177cad5eb811661dd8041339a064a67a71d4095f4c6bd41e6238b2e1b9a1b22ea6935b880705b41494f5aedf69cee8eb24431e35c
data/README.md CHANGED
@@ -15,6 +15,7 @@ Vagrant-Flow is a [vagrant] (http://www.vagrantup.com/) plugin which allows for
15
15
  echo "StrictHostKeyChecking no" >> ~/.ssh/config
16
16
 
17
17
  #If you're on OSX
18
+ #This step may no longer be necessary as vagrant-digitalocean shouldn't require it anymore
18
19
  brew install curl-ca-bundle
19
20
 
20
21
 
@@ -141,17 +142,18 @@ machines:
141
142
 
142
143
  ```
143
144
 
144
- Example multiinitconfig.yml file for use with virtualbox and digitalocean providers. All the extra parameters are required to make digitalocean work.
145
+ Example multiinitconfig.yml file for use with virtualbox and digitalocean providers. All the extra parameters are required to make digitalocean work. Get your digitalOcean token by logging in and generating a new token under "Apps & API"
145
146
  ```
146
147
  ---
147
148
  #Where your ssh private key lives (for use with digital ocean)
148
149
  #~/.ssh/id_rsa is the default, so you can omit this value if you want
149
150
  :sshPrivateKeyPath: ~/.ssh/id_rsa
150
151
 
151
- #These two keys (digitalOceanApiKey and digitalOceanClientId) must be set for digitalocean to work
152
- #Omit them if you don't want digitalocean as a provider option in your vagrantfile
153
- :digitalOceanApiKey: 782a1d830f62e57d985eb7b1c938f94f
154
- :digitalOceanClientId: ae856c82c79398598838f3f93b7a7d5e
152
+
153
+ #The digitalOceanToken must be set for digitalocean to work. You can generate one at https://cloud.digitalocean.com/settings/applications
154
+ #Omit it if you don't want digitalocean as a provider option in your vagrantfile
155
+ :digitalOceanToken: xxxxxxxxxxxxxxyyyyyyyzzzzz988765445678765
156
+
155
157
 
156
158
  :intnetName: neverwinterDP
157
159
  machines:
@@ -1,41 +1,60 @@
1
1
  require "net/http"
2
2
  require "uri"
3
3
  require "json"
4
- require "uri"
5
4
 
6
5
  class DigitalOcean_Api
7
6
 
8
- def initialize(digitaloceanurl= 'https://api.digitalocean.com/droplets/?')
7
+ def initialize(digitaloceanurl= 'https://api.digitalocean.com', digitaloceanpath="/v2/droplets")
9
8
  @DIGITALOCEAN_URL=digitaloceanurl
9
+ @DIGITALOCEAN_PATH=digitaloceanpath
10
10
  end
11
11
 
12
- #getparams should be a hash that will get turned into a url
13
- def makeApiCall(getparams)
14
- url = @DIGITALOCEAN_URL + URI.encode_www_form(getparams)
15
-
16
- response = Net::HTTP.get_response(URI.parse(url))
17
-
12
+ #params should be a hash that will be in the form of
13
+ #{"Authorization"=>"Bearer ~~DIGITALOCEANTOKEN~~"}
14
+ def makeApiCall(params)
15
+
16
+ uri = URI.parse(@DIGITALOCEAN_URL)
17
+ http = Net::HTTP.new(uri.host,uri.port)
18
+ http.use_ssl = true
19
+ request = Net::HTTP::Get.new(@DIGITALOCEAN_PATH)
20
+
21
+ request.initialize_http_header(params)
22
+ response = http.request(request)
18
23
  return JSON.parse(response.body)
19
24
  end
20
25
 
21
- #https://api.digitalocean.com/droplets/?client_id=xxxxxxx&api_key=yyyyyyyyyy
26
+
22
27
  #returns parsed hash object from returned json
23
- def showAllActiveDroplets(clientId,apiKey)
28
+ def showAllActiveDroplets(token)
24
29
  x = {
25
- "client_id" => clientId,
26
- "api_key" => apiKey,
30
+ "Authorization" => "Bearer "+token
27
31
  }
28
32
  return makeApiCall(x)
29
33
  end
30
34
 
31
35
  #Calls showAllActiveDroplets and then parses the info for just hostname and ip
32
- def getHostNamesAndIps(clientId,apiKey)
33
- hash = showAllActiveDroplets(clientId,apiKey)
36
+ def getHostNamesAndIps(token)
37
+ hash = showAllActiveDroplets(token)
34
38
  returnHash = []
39
+
35
40
  hash["droplets"].each {|droplet|
41
+ #Grab the IP information for each droplet
42
+ #Each IP is contained in an array, so extract that
43
+ ip = []
44
+ droplet["networks"]["v4"].each do |x|
45
+ ip.push(x["ip_address"])
46
+ end
47
+
48
+ #Usually there's only the one IP address per machine,
49
+ #this will help with backwards compatibility
50
+ if ip.length == 1
51
+ ip = ip[0]
52
+ end
53
+
54
+
36
55
  returnHash.push({
37
56
  :hostname => droplet["name"],
38
- :ip => droplet["ip_address"]
57
+ :ip => ip
39
58
  })
40
59
  }
41
60
  return returnHash
@@ -30,7 +30,7 @@ module VagrantPlugins
30
30
  options[:nowrite] = false
31
31
  options[:quiet] = false
32
32
  options[:digitalocean] = false
33
- options[:digitalocean_file] = "hostfile_do.yml"
33
+ options[:digitalocean_file] = "multiinitconfig.yml"
34
34
 
35
35
  #Parse option, look up OptionParser documentation
36
36
  opts = OptionParser.new do |o|
@@ -48,11 +48,11 @@ module VagrantPlugins
48
48
  options[:nowrite] = true
49
49
  end
50
50
 
51
- o.on("-d", "--digitalocean", "(Optional) Writes your digital ocean's hostnames and IP addresses to hosts file. Default file is hostfile_do.yml") do |f|
51
+ o.on("-d", "--digitalocean", "(Optional) Writes your digital ocean's hostnames and IP addresses to the host files of your machines. Default file is multiinitconfig.yml") do |f|
52
52
  options[:digitalocean] = true
53
53
  end
54
54
 
55
- o.on("-o", "--digitaloceanfile FILE", "(Optional) File to read in for -d option instead of hostfile_do.yml") do |f|
55
+ o.on("-o", "--digitaloceanfile FILE", "(Optional) File to read in for -d option instead of multiinitconfig.yml") do |f|
56
56
  options[:digitalocean_file] = f
57
57
  end
58
58
  end
@@ -67,7 +67,7 @@ module VagrantPlugins
67
67
  if options[:digitalocean]
68
68
  config = YAML.load_file(options[:digitalocean_file])
69
69
  digitalocean = DigitalOcean_Api.new()
70
- hostinfo = digitalocean.getHostNamesAndIps(config[:client_id],config[:api_key])
70
+ hostinfo = digitalocean.getHostNamesAndIps(config[:digitalOceanToken])
71
71
  else
72
72
  with_target_vms(argv, :provider => options[:provider]) do |machine|
73
73
  return unless machine.communicate.ready?
@@ -8,7 +8,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
8
8
 
9
9
  Vagrant.require_version ">= 1.4.3"
10
10
 
11
-
11
+ <% if @sshPrivateKeyPath %>
12
+ config.ssh.private_key_path = '<%= @sshPrivateKeyPath %>'
13
+ <% end %>
12
14
 
13
15
  <% for machine in @machines %>
14
16
 
@@ -21,22 +23,21 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
21
23
  <%= machine["name"]%>.vm.network :private_network, ip: "<%= machine["ip"]%>", virtualbox__intnet: "<%= @intnetName %>"
22
24
  <%= machine["name"]%>.vm.hostname = "<%= machine["name"]%>"
23
25
 
24
- <% if machine.has_key?("digitalOceanImage") and machine.has_key?("digitalOceanRegion") and @digitalOceanApiKey and @digitalOceanClientId and @sshPrivateKeyPath %>
25
- #digitalOcean provider
26
26
  <%= machine["name"]%>.vm.synced_folder ".", "/vagrant", disabled: true
27
- config.vm.provider :digital_ocean do |provider, override|
28
- override.ssh.private_key_path = '<%= @sshPrivateKeyPath %>'
29
- provider.client_id = '<%= @digitalOceanClientId %>'
30
- provider.api_key = '<%= @digitalOceanApiKey %>'
27
+
28
+ <% if machine.has_key?("digitalOceanImage") and machine.has_key?("digitalOceanRegion") and @digitalOceanToken and @sshPrivateKeyPath %>
29
+ #digitalOcean provider
30
+ <%= machine["name"]%>.vm.provider :digital_ocean do |provider, override|
31
+ provider.token = '<%= @digitalOceanToken %>'
31
32
  provider.region = '<%=machine["digitalOceanRegion"] %>'
32
- provider.image = '<%= machine["digitalOceanImage"] %>'
33
- provider.size = '<%= machine["ram"] %>'
33
+ provider.image = '<%= machine["digitalOceanImage"] %>'
34
+ provider.size = '<%= machine["ram"] %>'
34
35
  end
35
36
  <% end %>
36
37
 
37
38
  <% if machine.has_key?("name") and machine.has_key?("url") %>
38
39
  #VirtualBox provider
39
- config.vm.provider :virtualbox do |vb|
40
+ <%= machine["name"]%>.vm.provider :virtualbox do |vb|
40
41
  vb.name = "<%= machine["name"]%>"
41
42
  vb.customize ["modifyvm", :id, "--memory", "<%= machine["vagrantram"] %>"]
42
43
  # vb.customize ["modifyvm", :id, "--cpus", "2"]
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module VagrantFlow
3
- VERSION = "1.0.19"
3
+ VERSION = "1.0.21"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.19
4
+ version: 1.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Morin