vagrant-openstack-provider 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. checksums.yaml +13 -5
  2. data/.rubocop.yml +28 -0
  3. data/Appraisals +3 -3
  4. data/CHANGELOG.md +4 -0
  5. data/Gemfile +3 -0
  6. data/Rakefile +6 -2
  7. data/Vagrantfile +4 -15
  8. data/gemfiles/latest_stable.gemfile +2 -0
  9. data/gemfiles/oldest_current.gemfile +2 -0
  10. data/gemfiles/previous_release.gemfile +2 -0
  11. data/lib/vagrant-openstack-provider.rb +18 -13
  12. data/lib/vagrant-openstack-provider/action.rb +112 -46
  13. data/lib/vagrant-openstack-provider/action/connect_openstack.rb +9 -10
  14. data/lib/vagrant-openstack-provider/action/create_server.rb +86 -57
  15. data/lib/vagrant-openstack-provider/action/delete_server.rb +5 -6
  16. data/lib/vagrant-openstack-provider/action/{is_created.rb → message.rb} +4 -3
  17. data/lib/vagrant-openstack-provider/action/read_ssh_info.rb +7 -27
  18. data/lib/vagrant-openstack-provider/action/read_state.rb +7 -9
  19. data/lib/vagrant-openstack-provider/action/resume.rb +20 -0
  20. data/lib/vagrant-openstack-provider/action/start_server.rb +22 -0
  21. data/lib/vagrant-openstack-provider/action/stop_server.rb +22 -0
  22. data/lib/vagrant-openstack-provider/action/suspend.rb +20 -0
  23. data/lib/vagrant-openstack-provider/action/sync_folders.rb +27 -38
  24. data/lib/vagrant-openstack-provider/action/wait_stop.rb +29 -0
  25. data/lib/vagrant-openstack-provider/client/keystone.rb +76 -0
  26. data/lib/vagrant-openstack-provider/client/neutron.rb +32 -0
  27. data/lib/vagrant-openstack-provider/client/nova.rb +166 -0
  28. data/lib/vagrant-openstack-provider/client/openstack.rb +41 -0
  29. data/lib/vagrant-openstack-provider/client/utils.rb +38 -0
  30. data/lib/vagrant-openstack-provider/config.rb +38 -110
  31. data/lib/vagrant-openstack-provider/errors.rb +7 -3
  32. data/lib/vagrant-openstack-provider/plugin.rb +8 -8
  33. data/lib/vagrant-openstack-provider/provider.rb +6 -6
  34. data/lib/vagrant-openstack-provider/version.rb +1 -1
  35. data/locales/en.yml +83 -5
  36. data/numergyrc +22 -0
  37. data/spec/vagrant-openstack-provider/action/create_server_spec.rb +89 -0
  38. data/spec/vagrant-openstack-provider/client/keystone_spec.rb +140 -0
  39. data/spec/vagrant-openstack-provider/client/neutron_spec.rb +53 -0
  40. data/spec/vagrant-openstack-provider/client/nova_spec.rb +373 -0
  41. data/spec/vagrant-openstack-provider/client/utils_spec.rb +125 -0
  42. data/spec/vagrant-openstack-provider/config_spec.rb +117 -0
  43. data/spec/vagrant-openstack-provider/provider_spec.rb +13 -0
  44. data/spec/vagrant-openstack-provider/spec_helper.rb +23 -0
  45. data/vagrant-openstack-provider.gemspec +13 -14
  46. metadata +40 -30
  47. data/features/provision.feature +0 -35
  48. data/features/steps/sdk_steps.rb +0 -13
  49. data/features/steps/server_steps.rb +0 -25
  50. data/features/support/env.rb +0 -37
  51. data/features/support/fog_mock.rb +0 -19
  52. data/features/vagrant-openstack-provider.feature +0 -70
  53. data/lib/vagrant-openstack-provider/action/message_already_created.rb +0 -16
  54. data/lib/vagrant-openstack-provider/action/message_not_created.rb +0 -16
  55. data/lib/vagrant-openstack-provider/openstack_client.rb +0 -98
  56. data/spec/vagrant-openstack/config_spec.rb +0 -184
  57. data/stackrc +0 -31
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6f67721a60001e4be971af684ea45cde415f0a3d
4
- data.tar.gz: afcfda525e9e92210a028de2fd6a0507a8ba8ede
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NjA4MjM1MzJiZGI0MWJlNWMzMTQxNDI5M2NmZmY3MTA3YzE0MWU0Mw==
5
+ data.tar.gz: !binary |-
6
+ M2U3ZDFiNzA0YWRhMWU4OTA1ZTJjYmUwZWQxMDNkMzQ4NGNhYTUyMQ==
5
7
  SHA512:
6
- metadata.gz: cb94233253f0602739ece3d40f9224d10a9f210f00c343ba535fd3e79a7b6322f7215a5651b159d249b395568abeac591c15215d51166b6f1563291d6e828ae2
7
- data.tar.gz: 97b7d686f7be2b2cc4623ba8250e06c6096d5c218db9b7e2e42d01399b79a21091230e267e1298f7e30e8b7cd100bb2eb33d7ff1601b5933260d4b7072015d49
8
+ metadata.gz: !binary |-
9
+ ODJkZGMzYzNiNzA0ZTdlMDAxNzA1ODIzYTQ0YTQ4Mjc2MDJmMmY1ZjY3ZDJh
10
+ NzM2YWM5MzgzODQ4ODZkMzU2NzVmZTcwMzc1N2VmOGQxYjRiZmE2NzBkZTMy
11
+ NWZlYTNjYzZiZWVhYWZjMjQwYTgyMDdjMjQwOTNkMmE3Y2NmOWM=
12
+ data.tar.gz: !binary |-
13
+ MThiZjUyYjU1NmY2M2JkYjAxOTcwYzczM2I1YTAzYTAyNjYwODQ1Njg0ZWYw
14
+ ZGY3M2I0YmE0ZmEwODBlZTdlOGEzYjkxNDAwNjY3MzIzMjY3ZTIxZWRkNmEz
15
+ OTJiYmVmNzY3ZWM2ZWQwZTMyM2MxYjEzYTI0YzliMGJkMGE1OTE=
@@ -0,0 +1,28 @@
1
+ AllCops:
2
+ Exclude:
3
+ - 'out/**/*'
4
+
5
+ Style/FileName:
6
+ Enabled: false
7
+
8
+ Style/Encoding:
9
+ Enabled: false
10
+
11
+ Style/Documentation:
12
+ Enabled: false
13
+
14
+ Style/ClassLength:
15
+ Max: 300
16
+
17
+ Style/CyclomaticComplexity:
18
+ Severity: warning
19
+ Max: 10
20
+
21
+ Style/MethodLength:
22
+ Max: 50
23
+
24
+ Style/LineLength:
25
+ Max: 150
26
+
27
+ Style/ParameterLists:
28
+ Max: 6
data/Appraisals CHANGED
@@ -1,13 +1,13 @@
1
1
  appraise "latest-stable" do
2
- gem "vagrant", :git => 'git://github.com/mitchellh/vagrant.git', :branch => 'v1.4.2'
2
+ gem "vagrant", :git => 'git://github.com/mitchellh/vagrant.git', :tag => 'v1.6.3'
3
3
  end
4
4
 
5
5
  # Oldest (current release)
6
6
  appraise "oldest-current" do
7
- gem "vagrant", :git => 'git://github.com/mitchellh/vagrant.git', :branch => 'v1.4.0'
7
+ gem "vagrant", :git => 'git://github.com/mitchellh/vagrant.git', :tag => 'v1.5.4'
8
8
  end
9
9
 
10
10
  # Latest patch (previous release)
11
11
  appraise "previous-release" do
12
- gem "vagrant", :git => 'git://github.com/mitchellh/vagrant.git', :branch => 'v1.3.5'
12
+ gem "vagrant", :git => 'git://github.com/mitchellh/vagrant.git', :tag => 'v1.4.3'
13
13
  end
@@ -1,3 +1,7 @@
1
+ # 0.2.0 (June 26, 2014)
2
+
3
+ https://github.com/ggiamarchi/vagrant-openstack-provider/releases/tag/v0.2.0
4
+
1
5
  # 0.1.2 (April 25, 2014)
2
6
 
3
7
  IMPROVEMENTS:
data/Gemfile CHANGED
@@ -4,8 +4,11 @@ gemspec
4
4
 
5
5
  gem "appraisal", "1.0.0"
6
6
  gem "restclient", "0.10.0"
7
+ gem 'webmock', '~> 1.18.0', :group => [:test]
8
+ gem "rubocop", '0.23.0', require: false
7
9
  gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :tag => "v1.4.3"
8
10
 
11
+
9
12
  group :development do
10
13
  # We depend on Vagrant for development, but we don't add it as a
11
14
  # gem dependency because we expect to be installed within the
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'bundler/setup'
3
3
  require 'rspec/core/rake_task'
4
+ require 'rubocop/rake_task'
4
5
 
5
6
  # Immediately sync all stdout so that tools like buildbot can
6
7
  # immediately load in the output.
@@ -8,7 +9,7 @@ $stdout.sync = true
8
9
  $stderr.sync = true
9
10
 
10
11
  # Change to the directory of this file.
11
- Dir.chdir(File.expand_path("../", __FILE__))
12
+ Dir.chdir(File.expand_path('../', __FILE__))
12
13
 
13
14
  # This installs the tasks that help with gem creation and
14
15
  # publishing.
@@ -17,5 +18,8 @@ Bundler::GemHelper.install_tasks
17
18
  # Install the `spec` task so that we can run tests.
18
19
  RSpec::Core::RakeTask.new
19
20
 
21
+ # Install the `rubocop` task
22
+ RuboCop::RakeTask.new
23
+
20
24
  # Default task is to run the unit tests
21
- task :default => "spec"
25
+ task default: %w(rubocop spec)
@@ -12,26 +12,15 @@ Vagrant.configure("2") do |config|
12
12
 
13
13
  os.server_name = "vagrant-os-plugin-test"
14
14
  os.username = ENV['OS_USERNAME']
15
- os.floating_ip = "185.39.216.118"
16
- os.api_key = ENV['OS_PASSWORD']
17
- #os.network = "private"
18
- os.flavor = /Linux-XL.2plus-4vCpu-32G/
15
+ os.floating_ip = "185.39.216.244"
16
+ os.password = ENV['OS_PASSWORD']
17
+ os.flavor = /Linux-L-2vCpu-4G/
19
18
  os.image = /ubuntu-12.04_x86_64_LVM/
20
19
  os.openstack_auth_url = ENV['OS_AUTH_URL']
21
20
  os.openstack_compute_url = ENV['OS_COMPUTE_URL']
22
- os.availability_zone = "nova"
21
+ os.openstack_network_url = ENV['OS_NETWORK_URL']
23
22
  os.tenant_name = ENV['OS_TENANT_NAME']
24
23
  os.keypair_name = "julien-vagrant"
25
24
  os.ssh_username = "stack"
26
-
27
- # os.metadata = {"key" => "value"} # optional
28
- # os.user_data = "#cloud-config\nmanage_etc_hosts: True" # optional
29
- # os.networks = [ "internal", "external" ] # optional, overrides os.network
30
- # os.address_id = "YOUR ADDRESS ID" # optional (`network` above has higher precedence)
31
- # os.scheduler_hints = {
32
- # :cell => 'australia'
33
- # } # optional
34
- # os.security_groups = ['ssh', 'http'] # optional
35
-
36
25
  end
37
26
  end
@@ -4,6 +4,8 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal", "1.0.0"
6
6
  gem "restclient", "0.10.0"
7
+ gem "webmock", "~> 1.18.0", :group => [:test]
8
+ gem "rubocop", "0.23.0", :require => false
7
9
  gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :tag => "v1.4.3"
8
10
 
9
11
  group :development do
@@ -4,6 +4,8 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal", "1.0.0"
6
6
  gem "restclient", "0.10.0"
7
+ gem "webmock", "~> 1.18.0", :group => [:test]
8
+ gem "rubocop", "0.23.0", :require => false
7
9
  gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :tag => "v1.4.3"
8
10
 
9
11
  group :development do
@@ -4,6 +4,8 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal", "1.0.0"
6
6
  gem "restclient", "0.10.0"
7
+ gem "webmock", "~> 1.18.0", :group => [:test]
8
+ gem "rubocop", "0.23.0", :require => false
7
9
  gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :tag => "v1.4.3"
8
10
 
9
11
  group :development do
@@ -1,16 +1,16 @@
1
- require "pathname"
1
+ require 'pathname'
2
2
 
3
- require "vagrant-openstack-provider/plugin"
3
+ require 'vagrant-openstack-provider/plugin'
4
4
 
5
5
  module VagrantPlugins
6
6
  module Openstack
7
- lib_path = Pathname.new(File.expand_path("../vagrant-openstack-provider", __FILE__))
8
- autoload :Errors, lib_path.join("errors")
7
+ lib_path = Pathname.new(File.expand_path('../vagrant-openstack-provider', __FILE__))
8
+ autoload :Errors, lib_path.join('errors')
9
9
 
10
10
  # This initializes the i18n load path so that the plugin-specific
11
11
  # translations work.
12
12
  def self.init_i18n
13
- I18n.load_path << File.expand_path("locales/en.yml", source_root)
13
+ I18n.load_path << File.expand_path('locales/en.yml', source_root)
14
14
  I18n.reload!
15
15
  end
16
16
 
@@ -20,26 +20,31 @@ module VagrantPlugins
20
20
  # Initialize logging
21
21
  level = nil
22
22
  begin
23
- level = Log4r.const_get(ENV["VAGRANT_LOG"].upcase)
23
+ level = Log4r.const_get(ENV['VAGRANT_LOG'].upcase)
24
24
  rescue NameError
25
25
  # This means that the logging constant wasn't found,
26
26
  # which is fine. We just keep `level` as `nil`. But
27
27
  # we tell the user.
28
- level = nil
28
+ begin
29
+ level = Log4r.const_get(ENV['VAGRANT_OPENSTACK_LOG'].upcase)
30
+ rescue NameError
31
+ level = nil
32
+ end
29
33
  end
30
34
 
31
35
  # Some constants, such as "true" resolve to booleans, so the
32
36
  # above error checking doesn't catch it. This will check to make
33
37
  # sure that the log level is an integer, as Log4r requires.
34
- level = nil if !level.is_a?(Integer)
38
+ level = nil unless level.is_a?(Integer)
35
39
 
36
- # Set the logging level on all "vagrant" namespaced
40
+ # Set the logging level
37
41
  # logs as long as we have a valid level.
38
42
  if level
39
- logger = Log4r::Logger.new("vagrant_openstack")
40
- logger.outputters = Log4r::Outputter.stderr
43
+ logger = Log4r::Logger.new('vagrant_openstack')
44
+ out = Log4r::Outputter.stdout
45
+ out.formatter = Log4r::PatternFormatter.new(pattern: '%d | %5l | %m', date_pattern: '%Y-%m-%d %H:%M')
46
+ logger.outputters = out
41
47
  logger.level = level
42
- logger = nil
43
48
  end
44
49
  end
45
50
 
@@ -47,7 +52,7 @@ module VagrantPlugins
47
52
  #
48
53
  # @return [Pathname]
49
54
  def self.source_root
50
- @source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
55
+ @source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
51
56
  end
52
57
  end
53
58
  end
@@ -1,6 +1,6 @@
1
- require "pathname"
1
+ require 'pathname'
2
2
 
3
- require "vagrant/action/builder"
3
+ require 'vagrant/action/builder'
4
4
 
5
5
  module VagrantPlugins
6
6
  module Openstack
@@ -12,14 +12,13 @@ module VagrantPlugins
12
12
  def self.action_destroy
13
13
  Vagrant::Action::Builder.new.tap do |b|
14
14
  b.use ConfigValidate
15
- b.use Call, IsCreated do |env, b2|
16
- if !env[:result]
17
- b2.use MessageNotCreated
18
- next
15
+ b.use ConnectOpenstack
16
+ b.use Call, ReadState do |env, b2|
17
+ if env[:machine_state_id] == :not_created
18
+ b2.use Message, I18n.t('vagrant_openstack.not_created')
19
+ else
20
+ b2.use DeleteServer
19
21
  end
20
-
21
- b2.use ConnectOpenstack
22
- b2.use DeleteServer
23
22
  end
24
23
  end
25
24
  end
@@ -28,14 +27,14 @@ module VagrantPlugins
28
27
  def self.action_provision
29
28
  Vagrant::Action::Builder.new.tap do |b|
30
29
  b.use ConfigValidate
31
- b.use Call, IsCreated do |env, b2|
32
- if !env[:result]
33
- b2.use MessageNotCreated
34
- next
30
+ b.use ConnectOpenstack
31
+ b.use Call, ReadState do |env, b2|
32
+ if env[:machine_state_id] == :not_created
33
+ b2.use Message, I18n.t('vagrant_openstack.not_created')
34
+ else
35
+ b2.use Provision
36
+ b2.use SyncFolders
35
37
  end
36
-
37
- b2.use Provision
38
- b2.use SyncFolders
39
38
  end
40
39
  end
41
40
  end
@@ -65,13 +64,13 @@ module VagrantPlugins
65
64
  def self.action_ssh
66
65
  Vagrant::Action::Builder.new.tap do |b|
67
66
  b.use ConfigValidate
68
- b.use Call, IsCreated do |env, b2|
69
- if !env[:result]
70
- b2.use MessageNotCreated
71
- next
67
+ b.use ConnectOpenstack
68
+ b.use Call, ReadState do |env, b2|
69
+ if env[:machine_state_id] == :not_created
70
+ b2.use Message, I18n.t('vagrant_openstack.not_created')
71
+ else
72
+ b2.use SSHExec
72
73
  end
73
-
74
- b2.use SSHExec
75
74
  end
76
75
  end
77
76
  end
@@ -79,13 +78,13 @@ module VagrantPlugins
79
78
  def self.action_ssh_run
80
79
  Vagrant::Action::Builder.new.tap do |b|
81
80
  b.use ConfigValidate
82
- b.use Call, IsCreated do |env, b2|
83
- if !env[:result]
84
- b2.use MessageNotCreated
85
- next
81
+ b.use ConnectOpenstack
82
+ b.use Call, ReadState do |env, b2|
83
+ if env[:machine_state_id] == :not_created
84
+ b2.use Message, I18n.t('vagrant_openstack.not_created')
85
+ else
86
+ b2.use SSHRun
86
87
  end
87
-
88
- b2.use SSHRun
89
88
  end
90
89
  end
91
90
  end
@@ -93,31 +92,98 @@ module VagrantPlugins
93
92
  def self.action_up
94
93
  Vagrant::Action::Builder.new.tap do |b|
95
94
  b.use ConfigValidate
96
- b.use Call, IsCreated do |env, b2|
97
- if env[:result]
98
- b2.use MessageAlreadyCreated
99
- next
95
+ b.use ConnectOpenstack
96
+
97
+ b.use Call, ReadState do |env, b2|
98
+ if env[:machine_state_id] == :not_created
99
+ b2.use Provision
100
+ b2.use SyncFolders
101
+ b2.use CreateServer
102
+ else
103
+ b2.use Message, I18n.t('vagrant_openstack.already_created')
100
104
  end
105
+ end
106
+ end
107
+ end
108
+
109
+ def self.action_halt
110
+ Vagrant::Action::Builder.new.tap do |b|
111
+ b.use ConfigValidate
112
+ b.use ConnectOpenstack
113
+ b.use Call, ReadState do |env, b2|
114
+ if env[:machine_state_id] == :not_created
115
+ b2.use Message, I18n.t('vagrant_openstack.not_created')
116
+ else
117
+ b2.use StopServer
118
+ end
119
+ end
120
+ end
121
+ end
101
122
 
102
- b2.use ConnectOpenstack
103
- b2.use Provision
104
- b2.use SyncFolders
105
- b2.use CreateServer
123
+ # This is the action that is primarily responsible for suspending
124
+ # the virtual machine.
125
+ def self.action_suspend
126
+ Vagrant::Action::Builder.new.tap do |b|
127
+ b.use ConfigValidate
128
+ b.use ConnectOpenstack
129
+ b.use Call, ReadState do |env, b2|
130
+ if env[:machine_state_id] == :not_created
131
+ b2.use Message, I18n.t('vagrant_openstack.not_created')
132
+ elsif env[:machine_state_id] == :suspended
133
+ b2.use Message, I18n.t('vagrant_openstack.already_suspended')
134
+ else
135
+ b2.use Suspend
136
+ end
137
+ end
138
+ end
139
+ end
140
+
141
+ # This is the action that is primarily responsible for resuming
142
+ # suspended machines.
143
+ def self.action_resume
144
+ Vagrant::Action::Builder.new.tap do |b|
145
+ b.use ConfigValidate
146
+ b.use ConnectOpenstack
147
+ b.use Call, ReadState do |env, b2|
148
+ if env[:machine_state_id] == :not_created
149
+ b2.use Message, I18n.t('vagrant_openstack.not_created')
150
+ else
151
+ b2.use Resume
152
+ end
153
+ end
154
+ end
155
+ end
156
+
157
+ def self.action_reload
158
+ Vagrant::Action::Builder.new.tap do |b|
159
+ b.use ConfigValidate
160
+ b.use ConnectOpenstack
161
+ b.use Call, ReadState do |env, b2|
162
+ if env[:machine_state_id] == :not_created
163
+ b2.use Message, I18n.t('vagrant_openstack.not_created')
164
+ else
165
+ b2.use StopServer
166
+ b2.use WaitForServerToStop
167
+ b2.use StartServer
168
+ end
106
169
  end
107
170
  end
108
171
  end
109
172
 
110
173
  # The autoload farm
111
- action_root = Pathname.new(File.expand_path("../action", __FILE__))
112
- autoload :ConnectOpenstack, action_root.join("connect_openstack")
113
- autoload :CreateServer, action_root.join("create_server")
114
- autoload :DeleteServer, action_root.join("delete_server")
115
- autoload :IsCreated, action_root.join("is_created")
116
- autoload :MessageAlreadyCreated, action_root.join("message_already_created")
117
- autoload :MessageNotCreated, action_root.join("message_not_created")
118
- autoload :ReadSSHInfo, action_root.join("read_ssh_info")
119
- autoload :ReadState, action_root.join("read_state")
120
- autoload :SyncFolders, action_root.join("sync_folders")
174
+ action_root = Pathname.new(File.expand_path('../action', __FILE__))
175
+ autoload :Message, action_root.join('message')
176
+ autoload :ConnectOpenstack, action_root.join('connect_openstack')
177
+ autoload :CreateServer, action_root.join('create_server')
178
+ autoload :DeleteServer, action_root.join('delete_server')
179
+ autoload :StopServer, action_root.join('stop_server')
180
+ autoload :StartServer, action_root.join('start_server')
181
+ autoload :ReadSSHInfo, action_root.join('read_ssh_info')
182
+ autoload :ReadState, action_root.join('read_state')
183
+ autoload :SyncFolders, action_root.join('sync_folders')
184
+ autoload :Suspend, action_root.join('suspend')
185
+ autoload :Resume, action_root.join('resume')
186
+ autoload :WaitForServerToStop, action_root.join('wait_stop')
121
187
  end
122
188
  end
123
189
  end