vagrant-unbundled 2.2.10.0 → 2.2.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +60 -0
  3. data/Gemfile +1 -1
  4. data/README.md +4 -44
  5. data/RELEASE.md +1 -1
  6. data/contrib/zsh/_vagrant +3 -1
  7. data/contrib/zsh/generate_zsh_completion.rb +2 -3
  8. data/lib/vagrant.rb +0 -4
  9. data/lib/vagrant/action/builder.rb +6 -15
  10. data/lib/vagrant/action/builtin/box_add.rb +5 -1
  11. data/lib/vagrant/action/builtin/cloud_init_setup.rb +10 -15
  12. data/lib/vagrant/action/builtin/synced_folders.rb +8 -2
  13. data/lib/vagrant/action/runner.rb +1 -1
  14. data/lib/vagrant/box.rb +8 -2
  15. data/lib/vagrant/box_collection.rb +1 -1
  16. data/lib/vagrant/bundler.rb +43 -16
  17. data/lib/vagrant/machine.rb +8 -5
  18. data/lib/vagrant/machine_index.rb +1 -0
  19. data/lib/vagrant/plugin/v2/command.rb +2 -1
  20. data/lib/vagrant/shared_helpers.rb +8 -0
  21. data/lib/vagrant/util/downloader.rb +3 -2
  22. data/lib/vagrant/util/is_port_open.rb +1 -1
  23. data/lib/vagrant/util/mime.rb +92 -0
  24. data/lib/vagrant/util/platform.rb +2 -1
  25. data/lib/vagrant/util/template_renderer.rb +2 -2
  26. data/lib/vagrant/util/uploader.rb +7 -4
  27. data/plugins/commands/cap/command.rb +5 -1
  28. data/plugins/commands/cloud/auth/login.rb +20 -23
  29. data/plugins/commands/cloud/auth/logout.rb +2 -10
  30. data/plugins/commands/cloud/auth/middleware/add_downloader_authentication.rb +57 -0
  31. data/plugins/commands/cloud/auth/whoami.rb +18 -20
  32. data/plugins/commands/cloud/box/create.rb +33 -29
  33. data/plugins/commands/cloud/box/delete.rb +30 -24
  34. data/plugins/commands/cloud/box/show.rb +41 -31
  35. data/plugins/commands/cloud/box/update.rb +34 -26
  36. data/plugins/commands/cloud/client/client.rb +50 -81
  37. data/plugins/commands/cloud/list.rb +3 -4
  38. data/plugins/commands/cloud/locales/en.yml +9 -9
  39. data/plugins/commands/cloud/plugin.rb +10 -0
  40. data/plugins/commands/cloud/provider/create.rb +38 -28
  41. data/plugins/commands/cloud/provider/delete.rb +39 -29
  42. data/plugins/commands/cloud/provider/update.rb +37 -28
  43. data/plugins/commands/cloud/provider/upload.rb +44 -34
  44. data/plugins/commands/cloud/publish.rb +185 -108
  45. data/plugins/commands/cloud/search.rb +34 -21
  46. data/plugins/commands/cloud/util.rb +266 -162
  47. data/plugins/commands/cloud/version/create.rb +33 -28
  48. data/plugins/commands/cloud/version/delete.rb +35 -28
  49. data/plugins/commands/cloud/version/release.rb +35 -29
  50. data/plugins/commands/cloud/version/revoke.rb +36 -29
  51. data/plugins/commands/cloud/version/update.rb +29 -25
  52. data/plugins/commands/login/plugin.rb +0 -13
  53. data/plugins/guests/arch/cap/smb.rb +1 -1
  54. data/plugins/guests/darwin/cap/darwin_version.rb +40 -0
  55. data/plugins/guests/darwin/cap/mount_smb_shared_folder.rb +1 -1
  56. data/plugins/guests/darwin/cap/mount_vmware_shared_folder.rb +12 -2
  57. data/plugins/guests/darwin/plugin.rb +10 -0
  58. data/plugins/guests/debian/cap/change_host_name.rb +8 -7
  59. data/plugins/guests/linux/cap/mount_smb_shared_folder.rb +16 -41
  60. data/plugins/guests/linux/cap/mount_virtualbox_shared_folder.rb +6 -0
  61. data/plugins/guests/linux/cap/persist_mount_shared_folder.rb +18 -5
  62. data/plugins/guests/linux/cap/reboot.rb +10 -5
  63. data/plugins/guests/redhat/cap/change_host_name.rb +6 -2
  64. data/plugins/guests/suse/cap/change_host_name.rb +32 -11
  65. data/plugins/guests/windows/cap/reboot.rb +8 -4
  66. data/plugins/kernel_v2/config/cloud_init.rb +7 -0
  67. data/plugins/kernel_v2/config/disk.rb +1 -1
  68. data/plugins/kernel_v2/config/vm.rb +5 -4
  69. data/plugins/providers/hyperv/action.rb +1 -1
  70. data/plugins/providers/virtualbox/cap/mount_options.rb +1 -1
  71. data/plugins/providers/virtualbox/model/storage_controller_array.rb +4 -6
  72. data/plugins/providers/virtualbox/provider.rb +2 -1
  73. data/plugins/synced_folders/smb/cap/mount_options.rb +21 -1
  74. data/plugins/synced_folders/smb/plugin.rb +10 -0
  75. data/scripts/website_push_www.sh +1 -1
  76. data/vagrant.gemspec +5 -6
  77. data/version.txt +1 -1
  78. metadata +1202 -1595
  79. data/plugins/commands/login/client.rb +0 -253
  80. data/plugins/commands/login/command.rb +0 -137
  81. data/plugins/commands/login/errors.rb +0 -24
  82. data/plugins/commands/login/locales/en.yml +0 -49
  83. data/scripts/website_push_docs.sh +0 -40
@@ -1,253 +0,0 @@
1
- require "rest_client"
2
- require "vagrant/util/downloader"
3
- require "vagrant/util/presence"
4
-
5
- module VagrantPlugins
6
- module LoginCommand
7
- class Client
8
- APP = "app".freeze
9
-
10
- include Vagrant::Util::Presence
11
-
12
- attr_accessor :username_or_email
13
- attr_accessor :password
14
- attr_reader :two_factor_default_delivery_method
15
- attr_reader :two_factor_delivery_methods
16
-
17
- # Initializes a login client with the given Vagrant::Environment.
18
- #
19
- # @param [Vagrant::Environment] env
20
- def initialize(env)
21
- @logger = Log4r::Logger.new("vagrant::login::client")
22
- @env = env
23
- end
24
-
25
- # Removes the token, effectively logging the user out.
26
- def clear_token
27
- @logger.info("Clearing token")
28
- token_path.delete if token_path.file?
29
- end
30
-
31
- # Checks if the user is logged in by verifying their authentication
32
- # token.
33
- #
34
- # @return [Boolean]
35
- def logged_in?
36
- token = self.token
37
- return false if !token
38
-
39
- with_error_handling do
40
- url = "#{Vagrant.server_url}/api/v1/authenticate" +
41
- "?access_token=#{token}"
42
- RestClient.get(url, content_type: :json)
43
- true
44
- end
45
- rescue Errors::Unauthorized
46
- false
47
- end
48
-
49
- # Login logs a user in and returns the token for that user. The token
50
- # is _not_ stored unless {#store_token} is called.
51
- #
52
- # @param [String] description
53
- # @param [String] code
54
- # @return [String] token The access token, or nil if auth failed.
55
- def login(description: nil, code: nil)
56
- @logger.info("Logging in '#{username_or_email}'")
57
-
58
- response = post(
59
- "/api/v1/authenticate", {
60
- user: {
61
- login: username_or_email,
62
- password: password
63
- },
64
- token: {
65
- description: description
66
- },
67
- two_factor: {
68
- code: code
69
- }
70
- }
71
- )
72
-
73
- response["token"]
74
- end
75
-
76
- # Requests a 2FA code
77
- # @param [String] delivery_method
78
- def request_code(delivery_method)
79
- @env.ui.warn("Requesting 2FA code via #{delivery_method.upcase}...")
80
-
81
- response = post(
82
- "/api/v1/two-factor/request-code", {
83
- user: {
84
- login: username_or_email,
85
- password: password
86
- },
87
- two_factor: {
88
- delivery_method: delivery_method.downcase
89
- }
90
- }
91
- )
92
-
93
- two_factor = response['two_factor']
94
- obfuscated_destination = two_factor['obfuscated_destination']
95
-
96
- @env.ui.success("2FA code sent to #{obfuscated_destination}.")
97
- end
98
-
99
- # Issues a post to a Vagrant Cloud path with the given payload.
100
- # @param [String] path
101
- # @param [Hash] payload
102
- # @return [Hash] response data
103
- def post(path, payload)
104
- with_error_handling do
105
- url = File.join(Vagrant.server_url, path)
106
-
107
- proxy = nil
108
- proxy ||= ENV["HTTPS_PROXY"] || ENV["https_proxy"]
109
- proxy ||= ENV["HTTP_PROXY"] || ENV["http_proxy"]
110
- RestClient.proxy = proxy
111
-
112
- response = RestClient::Request.execute(
113
- method: :post,
114
- url: url,
115
- payload: JSON.dump(payload),
116
- proxy: proxy,
117
- headers: {
118
- accept: :json,
119
- content_type: :json,
120
- user_agent: Vagrant::Util::Downloader::USER_AGENT,
121
- },
122
- )
123
-
124
- JSON.load(response.to_s)
125
- end
126
- end
127
-
128
- # Stores the given token locally, removing any previous tokens.
129
- #
130
- # @param [String] token
131
- def store_token(token)
132
- @logger.info("Storing token in #{token_path}")
133
-
134
- token_path.open("w") do |f|
135
- f.write(token)
136
- end
137
-
138
- nil
139
- end
140
-
141
- # Reads the access token if there is one. This will first read the
142
- # `VAGRANT_CLOUD_TOKEN` environment variable and then fallback to the stored
143
- # access token on disk.
144
- #
145
- # @return [String]
146
- def token
147
- if present?(ENV["VAGRANT_CLOUD_TOKEN"]) && token_path.exist?
148
- @env.ui.warn <<-EOH.strip
149
- Vagrant detected both the VAGRANT_CLOUD_TOKEN environment variable and a Vagrant login
150
- token are present on this system. The VAGRANT_CLOUD_TOKEN environment variable takes
151
- precedence over the locally stored token. To remove this error, either unset
152
- the VAGRANT_CLOUD_TOKEN environment variable or remove the login token stored on disk:
153
-
154
- ~/.vagrant.d/data/vagrant_login_token
155
-
156
- EOH
157
- end
158
-
159
- if present?(ENV["VAGRANT_CLOUD_TOKEN"])
160
- @logger.debug("Using authentication token from environment variable")
161
- return ENV["VAGRANT_CLOUD_TOKEN"]
162
- end
163
-
164
- if token_path.exist?
165
- @logger.debug("Using authentication token from disk at #{token_path}")
166
- return token_path.read.strip
167
- end
168
-
169
- if present?(ENV["ATLAS_TOKEN"])
170
- @logger.warn("ATLAS_TOKEN detected within environment. Using ATLAS_TOKEN in place of VAGRANT_CLOUD_TOKEN.")
171
- return ENV["ATLAS_TOKEN"]
172
- end
173
-
174
- @logger.debug("No authentication token in environment or #{token_path}")
175
-
176
- nil
177
- end
178
-
179
- protected
180
-
181
- def with_error_handling(&block)
182
- yield
183
- rescue RestClient::Unauthorized
184
- @logger.debug("Unauthorized!")
185
- raise Errors::Unauthorized
186
- rescue RestClient::BadRequest => e
187
- @logger.debug("Bad request:")
188
- @logger.debug(e.message)
189
- @logger.debug(e.backtrace.join("\n"))
190
- parsed_response = JSON.parse(e.response)
191
- errors = parsed_response["errors"].join("\n")
192
- raise Errors::ServerError, errors: errors
193
- rescue RestClient::NotAcceptable => e
194
- @logger.debug("Got unacceptable response:")
195
- @logger.debug(e.message)
196
- @logger.debug(e.backtrace.join("\n"))
197
-
198
- parsed_response = JSON.parse(e.response)
199
-
200
- if two_factor = parsed_response['two_factor']
201
- store_two_factor_information two_factor
202
-
203
- if two_factor_default_delivery_method != APP
204
- request_code two_factor_default_delivery_method
205
- end
206
-
207
- raise Errors::TwoFactorRequired
208
- end
209
-
210
- begin
211
- errors = parsed_response["errors"].join("\n")
212
- raise Errors::ServerError, errors: errors
213
- rescue JSON::ParserError; end
214
-
215
- raise "An unexpected error occurred: #{e.inspect}"
216
- rescue SocketError
217
- @logger.info("Socket error")
218
- raise Errors::ServerUnreachable, url: Vagrant.server_url.to_s
219
- end
220
-
221
- def token_path
222
- @env.data_dir.join("vagrant_login_token")
223
- end
224
-
225
- def store_two_factor_information(two_factor)
226
- @two_factor_default_delivery_method =
227
- two_factor['default_delivery_method']
228
-
229
- @two_factor_delivery_methods =
230
- two_factor['delivery_methods']
231
-
232
- @env.ui.warn "2FA is enabled for your account."
233
- if two_factor_default_delivery_method == APP
234
- @env.ui.info "Enter the code from your authenticator."
235
- else
236
- @env.ui.info "Default method is " \
237
- "'#{two_factor_default_delivery_method}'."
238
- end
239
-
240
- other_delivery_methods =
241
- two_factor_delivery_methods - [APP]
242
-
243
- if other_delivery_methods.any?
244
- other_delivery_methods_sentence = other_delivery_methods
245
- .map { |word| "'#{word}'" }
246
- .join(' or ')
247
- @env.ui.info "You can also type #{other_delivery_methods_sentence} " \
248
- "to request a new code."
249
- end
250
- end
251
- end
252
- end
253
- end
@@ -1,137 +0,0 @@
1
- require 'socket'
2
-
3
- module VagrantPlugins
4
- module LoginCommand
5
- class Command < Vagrant.plugin("2", "command")
6
- def self.synopsis
7
- "log in to HashiCorp's Vagrant Cloud"
8
- end
9
-
10
- def execute
11
- options = {}
12
-
13
- opts = OptionParser.new do |o|
14
- o.banner = "Usage: vagrant login"
15
- o.separator ""
16
- o.on("-c", "--check", "Only checks if you're logged in") do |c|
17
- options[:check] = c
18
- end
19
-
20
- o.on("-d", "--description DESCRIPTION", String, "Description for the Vagrant Cloud token") do |t|
21
- options[:description] = t
22
- end
23
-
24
- o.on("-k", "--logout", "Logs you out if you're logged in") do |k|
25
- options[:logout] = k
26
- end
27
-
28
- o.on("-t", "--token TOKEN", String, "Set the Vagrant Cloud token") do |t|
29
- options[:token] = t
30
- end
31
-
32
- o.on("-u", "--username USERNAME_OR_EMAIL", String, "Specify your Vagrant Cloud username or email address") do |t|
33
- options[:login] = t
34
- end
35
- end
36
-
37
- # Parse the options
38
- argv = parse_options(opts)
39
- return if !argv
40
-
41
- @client = Client.new(@env)
42
- @client.username_or_email = options[:login]
43
-
44
- # Determine what task we're actually taking based on flags
45
- if options[:check]
46
- return execute_check
47
- elsif options[:logout]
48
- return execute_logout
49
- elsif options[:token]
50
- return execute_token(options[:token])
51
- end
52
-
53
- # Let the user know what is going on.
54
- @env.ui.output(I18n.t("login_command.command_header") + "\n")
55
-
56
- # If it is a private cloud installation, show that
57
- if Vagrant.server_url != Vagrant::DEFAULT_SERVER_URL
58
- @env.ui.output("Vagrant Cloud URL: #{Vagrant.server_url}")
59
- end
60
-
61
- # Ask for the username
62
- if @client.username_or_email
63
- @env.ui.output("Vagrant Cloud username or email: #{@client.username_or_email}")
64
- end
65
- until @client.username_or_email
66
- @client.username_or_email = @env.ui.ask("Vagrant Cloud username or email: ")
67
- end
68
-
69
- until @client.password
70
- @client.password = @env.ui.ask("Password (will be hidden): ", echo: false)
71
- end
72
-
73
- description = options[:description]
74
- if description
75
- @env.ui.output("Token description: #{description}")
76
- else
77
- description_default = "Vagrant login from #{Socket.gethostname}"
78
- until description
79
- description =
80
- @env.ui.ask("Token description (Defaults to #{description_default.inspect}): ")
81
- end
82
- description = description_default if description.empty?
83
- end
84
-
85
- code = nil
86
-
87
- begin
88
- token = @client.login(description: description, code: code)
89
- rescue Errors::TwoFactorRequired
90
- until code
91
- code = @env.ui.ask("2FA code: ")
92
-
93
- if @client.two_factor_delivery_methods.include?(code.downcase)
94
- delivery_method, code = code, nil
95
- @client.request_code delivery_method
96
- end
97
- end
98
-
99
- retry
100
- end
101
-
102
- @client.store_token(token)
103
- @env.ui.success(I18n.t("login_command.logged_in"))
104
- 0
105
- end
106
-
107
- def execute_check
108
- if @client.logged_in?
109
- @env.ui.success(I18n.t("login_command.check_logged_in"))
110
- return 0
111
- else
112
- @env.ui.error(I18n.t("login_command.check_not_logged_in"))
113
- return 1
114
- end
115
- end
116
-
117
- def execute_logout
118
- @client.clear_token
119
- @env.ui.success(I18n.t("login_command.logged_out"))
120
- return 0
121
- end
122
-
123
- def execute_token(token)
124
- @client.store_token(token)
125
- @env.ui.success(I18n.t("login_command.token_saved"))
126
-
127
- if @client.logged_in?
128
- @env.ui.success(I18n.t("login_command.check_logged_in"))
129
- return 0
130
- else
131
- @env.ui.error(I18n.t("login_command.invalid_token"))
132
- return 1
133
- end
134
- end
135
- end
136
- end
137
- end
@@ -1,24 +0,0 @@
1
- module VagrantPlugins
2
- module LoginCommand
3
- module Errors
4
- class Error < Vagrant::Errors::VagrantError
5
- error_namespace("login_command.errors")
6
- end
7
-
8
- class ServerError < Error
9
- error_key(:server_error)
10
- end
11
-
12
- class ServerUnreachable < Error
13
- error_key(:server_unreachable)
14
- end
15
-
16
- class Unauthorized < Error
17
- error_key(:unauthorized)
18
- end
19
-
20
- class TwoFactorRequired < Error
21
- end
22
- end
23
- end
24
- end
@@ -1,49 +0,0 @@
1
- en:
2
- login_command:
3
- middleware:
4
- authentication:
5
- different_target: |-
6
- Vagrant has detected a custom Vagrant server in use for downloading
7
- box files. An authentication token is currently set which will be
8
- added to the box request. If the custom Vagrant server should not
9
- be receiving the authentication token, please unset it.
10
-
11
- Known Vagrant server: %{known_host}
12
- Custom Vagrant server: %{custom_host}
13
-
14
- Press ctrl-c to cancel...
15
- errors:
16
- server_error: |-
17
- The Vagrant Cloud server responded with a not-OK response:
18
-
19
- %{errors}
20
- server_unreachable: |-
21
- The Vagrant Cloud server is not currently accepting connections. Please check
22
- your network connection and try again later.
23
-
24
- unauthorized: |-
25
- Invalid username or password. Please try again.
26
-
27
- check_logged_in: |-
28
- You are already logged in.
29
- check_not_logged_in: |-
30
- You are not currently logged in. Please run `vagrant login` and provide
31
- your login information to authenticate.
32
- command_header: |-
33
- In a moment we will ask for your username and password to HashiCorp's
34
- Vagrant Cloud. After authenticating, we will store an access token locally on
35
- disk. Your login details will be transmitted over a secure connection, and
36
- are never stored on disk locally.
37
-
38
- If you do not have an Vagrant Cloud account, sign up at
39
- https://www.vagrantcloud.com
40
- invalid_login: |-
41
- Invalid username or password. Please try again.
42
- invalid_token: |-
43
- Invalid token. Please try again.
44
- logged_in: |-
45
- You are now logged in.
46
- logged_out: |-
47
- You are logged out.
48
- token_saved: |-
49
- The token was successfully saved.