vagrant-google 0.1.5 → 0.2.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -3
  3. data/.rubocop.yml +7 -0
  4. data/.rubocop_todo.yml +201 -0
  5. data/CHANGELOG.md +14 -0
  6. data/README.md +45 -22
  7. data/example_boxes/gce/Vagrantfile +23 -0
  8. data/example_boxes/gce-test/Vagrantfile +30 -0
  9. data/lib/vagrant-google/action/connect_google.rb +10 -14
  10. data/lib/vagrant-google/action/is_terminated.rb +31 -0
  11. data/lib/vagrant-google/action/run_instance.rb +58 -35
  12. data/lib/vagrant-google/action/start_instance.rb +90 -0
  13. data/lib/vagrant-google/action/stop_instance.rb +48 -0
  14. data/lib/vagrant-google/action/warn_networks.rb +2 -1
  15. data/lib/vagrant-google/action.rb +62 -12
  16. data/lib/vagrant-google/config.rb +56 -11
  17. data/lib/vagrant-google/errors.rb +13 -5
  18. data/lib/vagrant-google/version.rb +1 -1
  19. data/lib/vagrant-google.rb +3 -3
  20. data/locales/en.yml +33 -4
  21. data/tasks/acceptance.rake +20 -1
  22. data/tasks/lint.rake +3 -0
  23. data/tasks/test.rake +1 -0
  24. data/test/acceptance/provider/multi_instance_spec.rb +31 -0
  25. data/test/acceptance/provider/preemptible_spec.rb +26 -0
  26. data/test/acceptance/provider/scopes_spec.rb +29 -0
  27. data/test/acceptance/skeletons/multi_instance/Vagrantfile +29 -0
  28. data/test/acceptance/skeletons/preemptible/Vagrantfile +17 -0
  29. data/test/acceptance/skeletons/scopes/Vagrantfile +18 -0
  30. data/test/unit/base.rb +1 -1
  31. data/test/unit/common/config_test.rb +62 -13
  32. data/vagrant-google.gemspec +4 -3
  33. data/vagrant-spec.config.rb +2 -2
  34. data/vagrantfile_examples/Vagrantfile.multiple_machines +93 -0
  35. data/vagrantfile_examples/Vagrantfile.provision_single +48 -0
  36. data/vagrantfile_examples/Vagrantfile.simple +29 -0
  37. data/vagrantfile_examples/Vagrantfile.zone_config +40 -0
  38. metadata +39 -8
  39. data/lib/vagrant-google/action/sync_folders.rb +0 -104
@@ -1,104 +0,0 @@
1
- # Copyright 2013 Google Inc. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- require "log4r"
15
- require "vagrant/util/subprocess"
16
- require "vagrant/util/scoped_hash_override"
17
- require "vagrant/util/which"
18
-
19
- module VagrantPlugins
20
- module Google
21
- module Action
22
- # This middleware uses `rsync` to sync the folders over to the
23
- # Google instance.
24
- class SyncFolders
25
- include Vagrant::Util::ScopedHashOverride
26
-
27
- def initialize(app, env)
28
- @app = app
29
- @logger = Log4r::Logger.new("vagrant_google::action::sync_folders")
30
- end
31
-
32
- def call(env)
33
- @app.call(env)
34
-
35
- ssh_info = env[:machine].ssh_info
36
-
37
- env[:machine].config.vm.synced_folders.each do |id, data|
38
- data = scoped_hash_override(data, :google)
39
-
40
- # Ignore disabled shared folders
41
- next if data[:disabled]
42
-
43
- unless Vagrant::Util::Which.which('rsync')
44
- env[:ui].warn(I18n.t('vagrant_aws.rsync_not_found_warning'))
45
- break
46
- end
47
-
48
- hostpath = File.expand_path(data[:hostpath], env[:root_path])
49
- guestpath = data[:guestpath]
50
-
51
- # Make sure there is a trailing slash on the host path to
52
- # avoid creating an additional directory with rsync
53
- hostpath = "#{hostpath}/" if hostpath !~ /\/$/
54
-
55
- # on windows rsync.exe requires cygdrive-style paths
56
- if Vagrant::Util::Platform.windows?
57
- hostpath = hostpath.gsub(/^(\w):/) { "/cygdrive/#{$1}" }
58
- end
59
-
60
- env[:ui].info(I18n.t("vagrant_google.rsync_folder",
61
- :hostpath => hostpath,
62
- :guestpath => guestpath))
63
-
64
- # Create the guest path
65
- env[:machine].communicate.sudo("mkdir -p '#{guestpath}'")
66
- env[:machine].communicate.sudo(
67
- "chown #{ssh_info[:username]} '#{guestpath}'")
68
-
69
- # patch from https://github.com/tmatilai/vagrant-aws/commit/4a043a96076c332220ec4ec19470c4af5597dd51
70
- def ssh_key_options(ssh_info)
71
- # Ensure that `private_key_path` is an Array (for Vagrant < 1.4)
72
- Array(ssh_info[:private_key_path]).map { |path| "-i '#{path}' " }.join
73
- end
74
-
75
- #collect rsync excludes specified :rsync__excludes=>['path1',...] in synced_folder options
76
- excludes = ['.vagrant/', *Array(data[:rsync__excludes])]
77
-
78
- # Rsync over to the guest path using the SSH info
79
- command = [
80
- "rsync", "--verbose", "--archive", "-z",
81
- *excludes.map{|e|['--exclude', e]}.flatten,
82
- "-e", "ssh -p #{ssh_info[:port]} -o StrictHostKeyChecking=no #{ssh_key_options(ssh_info)}",
83
- hostpath,
84
- "#{ssh_info[:username]}@#{ssh_info[:host]}:#{guestpath}"]
85
-
86
- # we need to fix permissions when using rsync.exe on windows, see
87
- # http://stackoverflow.com/questions/5798807/rsync-permission-denied-created-directories-have-no-permissions
88
- if Vagrant::Util::Platform.windows?
89
- command.insert(1, "--chmod", "ugo=rwX")
90
- end
91
-
92
- r = Vagrant::Util::Subprocess.execute(*command)
93
- if r.exit_code != 0
94
- raise Errors::RsyncError,
95
- :guestpath => guestpath,
96
- :hostpath => hostpath,
97
- :stderr => r.stderr
98
- end
99
- end
100
- end
101
- end
102
- end
103
- end
104
- end