vagrant-openstack-provider 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +8 -8
  2. data/Appraisals +6 -6
  3. data/CHANGELOG.md +44 -1
  4. data/Gemfile +10 -6
  5. data/Vagrantfile +7 -15
  6. data/functional_tests/Vagrantfile +58 -0
  7. data/functional_tests/keys/vagrant-openstack +27 -0
  8. data/functional_tests/keys/vagrant-openstack.pub +1 -0
  9. data/functional_tests/run_tests.sh +142 -0
  10. data/gemfiles/latest_stable.gemfile +5 -0
  11. data/gemfiles/oldest_current.gemfile +5 -0
  12. data/gemfiles/previous_release.gemfile +5 -0
  13. data/lib/vagrant-openstack-provider/action.rb +17 -2
  14. data/lib/vagrant-openstack-provider/action/connect_openstack.rb +60 -8
  15. data/lib/vagrant-openstack-provider/action/create_server.rb +131 -43
  16. data/lib/vagrant-openstack-provider/action/delete_server.rb +2 -0
  17. data/lib/vagrant-openstack-provider/action/read_ssh_info.rb +22 -3
  18. data/lib/vagrant-openstack-provider/action/resume.rb +2 -0
  19. data/lib/vagrant-openstack-provider/action/stop_server.rb +1 -0
  20. data/lib/vagrant-openstack-provider/action/suspend.rb +2 -0
  21. data/lib/vagrant-openstack-provider/action/sync_folders.rb +3 -2
  22. data/lib/vagrant-openstack-provider/action/wait_active.rb +29 -0
  23. data/lib/vagrant-openstack-provider/action/wait_stop.rb +1 -1
  24. data/lib/vagrant-openstack-provider/client/domain.rb +26 -0
  25. data/lib/vagrant-openstack-provider/client/http_utils.rb +96 -0
  26. data/lib/vagrant-openstack-provider/client/keystone.rb +30 -41
  27. data/lib/vagrant-openstack-provider/client/neutron.rb +24 -11
  28. data/lib/vagrant-openstack-provider/client/nova.rb +99 -104
  29. data/lib/vagrant-openstack-provider/client/openstack.rb +4 -0
  30. data/lib/vagrant-openstack-provider/client/request_logger.rb +24 -0
  31. data/lib/vagrant-openstack-provider/command/abstract_command.rb +31 -0
  32. data/lib/vagrant-openstack-provider/command/flavor_list.rb +21 -0
  33. data/lib/vagrant-openstack-provider/command/floatingip_list.rb +34 -0
  34. data/lib/vagrant-openstack-provider/command/image_list.rb +21 -0
  35. data/lib/vagrant-openstack-provider/command/main.rb +51 -0
  36. data/lib/vagrant-openstack-provider/command/network_list.rb +21 -0
  37. data/lib/vagrant-openstack-provider/command/utils.rb +22 -0
  38. data/lib/vagrant-openstack-provider/config.rb +31 -3
  39. data/lib/vagrant-openstack-provider/errors.rb +28 -0
  40. data/lib/vagrant-openstack-provider/plugin.rb +5 -0
  41. data/lib/vagrant-openstack-provider/version.rb +1 -1
  42. data/locales/en.yml +45 -1
  43. data/spec/vagrant-openstack-provider/action/connect_openstack_spec.rb +190 -0
  44. data/spec/vagrant-openstack-provider/action/create_server_spec.rb +166 -1
  45. data/spec/vagrant-openstack-provider/action/read_ssh_info_spec.rb +109 -0
  46. data/spec/vagrant-openstack-provider/client/keystone_spec.rb +32 -48
  47. data/spec/vagrant-openstack-provider/client/neutron_spec.rb +42 -4
  48. data/spec/vagrant-openstack-provider/client/nova_spec.rb +247 -6
  49. data/spec/vagrant-openstack-provider/client/utils_spec.rb +58 -5
  50. data/spec/vagrant-openstack-provider/command/floatingip_list_spec.rb +67 -0
  51. data/spec/vagrant-openstack-provider/config_spec.rb +21 -6
  52. data/spec/vagrant-openstack-provider/spec_helper.rb +7 -0
  53. data/{numergyrc → stackrc} +4 -1
  54. metadata +24 -4
  55. data/lib/vagrant-openstack-provider/client/utils.rb +0 -38
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjA4MjM1MzJiZGI0MWJlNWMzMTQxNDI5M2NmZmY3MTA3YzE0MWU0Mw==
4
+ MzI3NjM4NTQwZWQwODg5OGRiMjFhNDU5MGViNmY5ZjVlMjAzOTc0NA==
5
5
  data.tar.gz: !binary |-
6
- M2U3ZDFiNzA0YWRhMWU4OTA1ZTJjYmUwZWQxMDNkMzQ4NGNhYTUyMQ==
6
+ N2UwODBjOGE5ZTgwOGEwYjQ4ZjE3YmMwZjA4ZWVlOGUyYmYyMTI4Zg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ODJkZGMzYzNiNzA0ZTdlMDAxNzA1ODIzYTQ0YTQ4Mjc2MDJmMmY1ZjY3ZDJh
10
- NzM2YWM5MzgzODQ4ODZkMzU2NzVmZTcwMzc1N2VmOGQxYjRiZmE2NzBkZTMy
11
- NWZlYTNjYzZiZWVhYWZjMjQwYTgyMDdjMjQwOTNkMmE3Y2NmOWM=
9
+ MGQ4NzZmYTg3YjNhYzUyMWJhZjQ2YTE3MjA2OTEyNGRhY2FkMmQ5MjgwZjQy
10
+ NWJlMDk0NGViOTU3MDA0ZDEwMmY3YzY1ZmU0OWQ4NjZiZWRhNzExZmIzNGU5
11
+ ZGU4OWE0NTFkYWY2MTM2NTcwZWU0MjMzYzA2ZTUxNmM4NTI4OWY=
12
12
  data.tar.gz: !binary |-
13
- MThiZjUyYjU1NmY2M2JkYjAxOTcwYzczM2I1YTAzYTAyNjYwODQ1Njg0ZWYw
14
- ZGY3M2I0YmE0ZmEwODBlZTdlOGEzYjkxNDAwNjY3MzIzMjY3ZTIxZWRkNmEz
15
- OTJiYmVmNzY3ZWM2ZWQwZTMyM2MxYjEzYTI0YzliMGJkMGE1OTE=
13
+ NDY3YmZmOTA2OWJkMGRlOTE0ODdkYmEwNmM1YzNlZmE5ODlkMjViZWNjMjUx
14
+ OWY1NTgxZWQwMDBjMmQ1MDllMWE4MGU1MzM0YjZhNTVjM2ZiMDE1ZmE4MzJk
15
+ ZGE2Y2NhNjFmZjE5NmU1YTBlMWYxYjUzNWM2ZDIzMGQ2MjIyN2Q=
data/Appraisals CHANGED
@@ -1,13 +1,13 @@
1
- appraise "latest-stable" do
2
- gem "vagrant", :git => 'git://github.com/mitchellh/vagrant.git', :tag => 'v1.6.3'
1
+ appraise 'latest-stable' do
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
- appraise "oldest-current" do
7
- gem "vagrant", :git => 'git://github.com/mitchellh/vagrant.git', :tag => 'v1.5.4'
6
+ appraise 'oldest-current' do
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
- appraise "previous-release" do
12
- gem "vagrant", :git => 'git://github.com/mitchellh/vagrant.git', :tag => 'v1.4.3'
11
+ appraise 'previous-release' do
12
+ gem 'vagrant', git: 'git://github.com/mitchellh/vagrant.git', tag: 'v1.4.3'
13
13
  end
data/CHANGELOG.md CHANGED
@@ -1,6 +1,49 @@
1
+ # 0.3.0 (August 29, 2014)
2
+
3
+ FEATURES:
4
+
5
+ - Automatic generation of SSH keys [#68](https://github.com/ggiamarchi/vagrant-openstack-provider/issues/68)
6
+ - Make keypair optional in provider's configuration [#54](https://github.com/ggiamarchi/vagrant-openstack-provider/issues/54)
7
+ - Allow setting a floating ip pool rather than a fixed ip [#50](https://github.com/ggiamarchi/vagrant-openstack-provider/issues/50)
8
+ - Implement custom "list" actions [#35](https://github.com/ggiamarchi/vagrant-openstack-provider/issues/35)
9
+ - Enable "availability_zone" configuration [#27](https://github.com/ggiamarchi/vagrant-openstack-provider/issues/27)
10
+
11
+ IMPROVEMENTS:
12
+
13
+ - Log action steps and client calls with requests and responses [#58](https://github.com/ggiamarchi/vagrant-openstack-provider/issues/58)
14
+
15
+ BUG FIXES:
16
+
17
+ - When`vagrant reload` an existing but stoped machine it does not start [#57](https://github.com/ggiamarchi/vagrant-openstack-provider/issues/57)
18
+ - When`vagrant up` an existing but stoped machine it does not start [#56](https://github.com/ggiamarchi/vagrant-openstack-provider/issues/56)
19
+ - Network api URL resolve from keystone catalog is not working [#49](https://github.com/ggiamarchi/vagrant-openstack-provider/issues/49)
20
+
1
21
  # 0.2.0 (June 26, 2014)
2
22
 
3
- https://github.com/ggiamarchi/vagrant-openstack-provider/releases/tag/v0.2.0
23
+ FEATURES:
24
+
25
+ - Enable "networks" configuration [#26](https://github.com/ggiamarchi/vagrant-openstack-provider/issues/26)
26
+ - Implement "suspend" action [#17](https://github.com/ggiamarchi/vagrant-openstack-provider/issues/17)
27
+ - Implement "resume" action [#16](https://github.com/ggiamarchi/vagrant-openstack-provider/issues/16)
28
+ - Implement "reload" action [#9](https://github.com/ggiamarchi/vagrant-openstack-provider/issues/9)
29
+ - Implement "halt" action [#8](https://github.com/ggiamarchi/vagrant-openstack-provider/issues/8)
30
+
31
+ IMPROVEMENTS:
32
+
33
+ - Add sync_method configuration parameter [#12](https://github.com/ggiamarchi/vagrant-openstack-provider/issues/12)
34
+ - Avoid multiple Openstack connection [#37](https://github.com/ggiamarchi/vagrant-openstack-provider/issues/37)
35
+ - Update appraisal configuration for vagrant 1.5 and 1.6 [#32](https://github.com/ggiamarchi/vagrant-openstack-provider/issues/32)
36
+ - In provider's configuration, rename "api_key" to "password" [#30](https://github.com/ggiamarchi/vagrant-openstack-provider/issues/30)
37
+ - Remove default value for "image" and "flavor" configuration parameter [10](https://github.com/ggiamarchi/vagrant-openstack-provider/issues/10) [11](https://github.com/ggiamarchi/vagrant-openstack-provider/issues/11)
38
+
39
+ BUG FIXES:
40
+
41
+ - When a VM is shutoff, the plugin consider it is not created bug [#36](https://github.com/ggiamarchi/vagrant-openstack-provider/issues/36)
42
+ - Hardcoded network name in source code [#34](https://github.com/ggiamarchi/vagrant-openstack-provider/issues/34)
43
+ - Missing translations [#33](https://github.com/ggiamarchi/vagrant-openstack-provider/issues/33)
44
+ - Vagrant steal floating IP of another VM [#23](https://github.com/ggiamarchi/vagrant-openstack-provider/issues/23)
45
+ - Vagrant does not always knows the state of the machine [#21](https://github.com/ggiamarchi/vagrant-openstack-provider/issues/21)
46
+ - Fix "Waiting for ssh to be ready" in create_server [#2](https://github.com/ggiamarchi/vagrant-openstack-provider/issues/2)
4
47
 
5
48
  # 0.1.2 (April 25, 2014)
6
49
 
data/Gemfile CHANGED
@@ -2,16 +2,20 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- gem "appraisal", "1.0.0"
6
- gem "restclient", "0.10.0"
7
- gem 'webmock', '~> 1.18.0', :group => [:test]
8
- gem "rubocop", '0.23.0', require: false
9
- gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :tag => "v1.4.3"
10
-
5
+ gem 'appraisal', '1.0.0'
6
+ gem 'restclient', '0.10.0'
7
+ gem 'terminal-table', '1.4.5'
8
+ gem 'webmock', '~> 1.18.0', group: [:test]
9
+ gem 'rubocop', '0.23.0', require: false
10
+ gem 'vagrant', git: 'git://github.com/mitchellh/vagrant.git', tag: 'v1.4.3'
11
+ gem 'fakefs', '~> 0.5.2', group: [:test]
12
+ gem 'sshkey', '~> 1.6.1'
13
+ gem 'colorize', '~> 0.7.3'
11
14
 
12
15
  group :development do
13
16
  # We depend on Vagrant for development, but we don't add it as a
14
17
  # gem dependency because we expect to be installed within the
15
18
  # Vagrant environment itself using `vagrant plugin`.
16
19
  gem 'coveralls', require: false
20
+ gem 'debugger'
17
21
  end
data/Vagrantfile CHANGED
@@ -1,26 +1,18 @@
1
1
  require 'vagrant-openstack-provider'
2
2
 
3
- Vagrant.configure("2") do |config|
3
+ Vagrant.configure('2') do |config|
4
4
 
5
- config.vm.box = "dummy-openstack"
6
- config.vm.box_url = "https://github.com/ggiamarchi/vagrant-openstack/raw/master/source/dummy.box"
7
-
8
- config.ssh.private_key_path = "/home/vagrant/.ssh/id_rsa"
9
- config.ssh.shell = "sh"
5
+ config.vm.box = 'dummy-openstack'
6
+ config.vm.box_url = 'https://github.com/ggiamarchi/vagrant-openstack/raw/master/source/dummy.box'
10
7
 
11
8
  config.vm.provider :openstack do |os|
12
-
13
- os.server_name = "vagrant-os-plugin-test"
14
9
  os.username = ENV['OS_USERNAME']
15
- os.floating_ip = "185.39.216.244"
10
+ os.floating_ip_pool = ENV['OS_FLOATING_IP_POOL']
16
11
  os.password = ENV['OS_PASSWORD']
17
- os.flavor = /Linux-L-2vCpu-4G/
18
- os.image = /ubuntu-12.04_x86_64_LVM/
12
+ os.flavor = ENV['OS_FLAVOR']
13
+ os.image = ENV['OS_IMAGE']
19
14
  os.openstack_auth_url = ENV['OS_AUTH_URL']
20
- os.openstack_compute_url = ENV['OS_COMPUTE_URL']
21
- os.openstack_network_url = ENV['OS_NETWORK_URL']
22
15
  os.tenant_name = ENV['OS_TENANT_NAME']
23
- os.keypair_name = "julien-vagrant"
24
- os.ssh_username = "stack"
16
+ os.ssh_username = 'stack'
25
17
  end
26
18
  end
@@ -0,0 +1,58 @@
1
+ require 'vagrant-openstack-provider'
2
+
3
+ Vagrant.configure('2') do |config|
4
+
5
+ config.vm.box = 'openstack'
6
+ config.vm.box_url = 'https://github.com/ggiamarchi/vagrant-openstack/raw/master/source/dummy.box'
7
+
8
+ config.ssh.private_key_path = ENV['OS_KEYPAIR_PRIVATE_KEY']
9
+ config.ssh.pty = true
10
+ config.ssh.shell = ENV['OS_SSH_SHELL']
11
+
12
+ config.vm.provider :openstack do |os|
13
+ os.username = ENV['OS_USERNAME']
14
+ os.password = ENV['OS_PASSWORD']
15
+ os.openstack_auth_url = ENV['OS_AUTH_URL']
16
+ os.openstack_compute_url = ENV['OS_COMPUTE_URL']
17
+ os.openstack_network_url = ENV['OS_NETWORK_URL']
18
+ os.tenant_name = ENV['OS_TENANT_NAME']
19
+ os.ssh_timeout = ENV['OS_SSH_TIMEOUT'].to_i
20
+ os.sync_method = ENV['OS_SYNC_METHOD']
21
+ os.flavor = ENV['OS_FLAVOR']
22
+ os.image = ENV['OS_IMAGE']
23
+ os.ssh_username = ENV['OS_SSH_USERNAME']
24
+ os.keypair_name = ENV['OS_KEYPAIR_NAME']
25
+ os.floating_ip_pool = ENV['OS_FLOATING_IP_POOL']
26
+ end
27
+
28
+ config.vm.define 'test-basic' do |test|
29
+ test.vm.provider :openstack do |os|
30
+ os.floating_ip = ENV['OS_FLOATING_IP']
31
+ os.floating_ip_pool = nil
32
+ end
33
+ test.vm.provision 'shell', inline: 'echo "SUCCESS" > /tmp/test_shell_provision'
34
+ end
35
+
36
+ config.vm.define 'test-floating-ip-pool' do |test|
37
+ test.vm.provider :openstack do |os|
38
+ os.floating_ip = nil
39
+ os.floating_ip_pool = ENV['OS_FLOATING_IP_POOL']
40
+ end
41
+ test.vm.provision 'shell', inline: 'echo "SUCCESS" > /tmp/test_shell_provision'
42
+ end
43
+
44
+ config.vm.define 'test-ssh-public-key-path' do |test|
45
+ test.vm.provider :openstack do |os|
46
+ os.keypair_name = nil
47
+ os.public_key_path = ENV['OS_PUBLIC_KEY_PATH']
48
+ end
49
+ test.vm.provision 'shell', inline: 'echo "SUCCESS" > /tmp/test_shell_provision'
50
+ end
51
+
52
+ config.vm.define 'test-availabilty-zone' do |test|
53
+ test.vm.provider :openstack do |os|
54
+ os.availability_zone = ENV['OS_AZ']
55
+ end
56
+ test.vm.provision 'shell', inline: 'echo "SUCCESS" > /tmp/test_shell_provision'
57
+ end
58
+ end
@@ -0,0 +1,27 @@
1
+ -----BEGIN RSA PRIVATE KEY-----
2
+ MIIEowIBAAKCAQEArKPKCXfOr8pjInYeDfGOfKC5JS8jWGgf5OqD0SlvRpdWEKa6
3
+ KR6gDL6rVVFU4z7T5lECzeCp+P4uXwYhqXM4TodEccjPkMLDgR5jt+Fd9ixtlVYR
4
+ Gj5vuAv1a7gk4zVr4M82oOKnTriTqTrFGZL3YG3XyxKftoTZyDWsI4nAbfMoup/e
5
+ d54zHY6gApgDGBg+XlJz5Ai4AJT2YtCwWyu4v/zuDcEtMBDbioI8jpWkKTycFMDw
6
+ W8f5Cwxe3bMCw9sasC6+FUI97ac5itvnE6/LZvcftYjXQF0oakz3ujZ0/gN0rhpe
7
+ pswU2ODSkXWxOMBYS0PXZz9N2r3jzGXa5h1EfwIDAQABAoIBACGaL7TwENa+edU3
8
+ UFo+bhFr5x2Js0N94NdZnhaUDgibZDERgqKGR3izk/2jOvaQQAZQNk+ELxE7yCLO
9
+ uraUqpz+TyAmieAPSKZVF+uufe9wblPm0KVfCbe0/CvfR67BsyGqs2NVOmNkIbmK
10
+ qtpzdJrcRmhMU7He4dTKPZsdMMs1esmWK3+uGgtfQTSaCi7rTxsCMn+Ob+lxvfvG
11
+ QS2Ehb63jyb+8L8PyRqnunK9iBpdhuLHN8tGeDzmrCVz/ziRenslfXq1Ng7pxhUQ
12
+ gyXWjlMoRibt9bcsSt1LcaqZMAeiiRnyUlaqyvtkhSb+yzZyHQZs90DgxRVH40Ya
13
+ ebq9FcECgYEA5eXApNgi2iLDWMIGISO9uPDxzR5i4aDjIyHGv1uos/hWwJiX864K
14
+ N23WLLna2LyIAZaEzUi76cPReFza7lxDtl/OeRDgf7yCPWZdH9OhyAeAtVVOu4eN
15
+ iX5dee/GW5Mmu5xBUXo4z0TETqbey1fWHeJNqaA5W9mWkBKrKnT2aIcCgYEAwD3F
16
+ /yUb8fS/Tj02oh2qb3clIwEIgdh6C38/d2J1OduICVzLoMhq0nZnZ1zMPNtLA/g2
17
+ TjZ70EY1VyDAOWaIo+FGU/HIuLsP2jWKvDSKhJUx/oBBPWpCxqBZefoQhKZLkbmO
18
+ Tw+SrUBQM7r8pL/5ptocW0HDwjL8Sbs4KfSWWkkCgYBSLuPDChDLcgnrPND8H86+
19
+ wkNuVCJ9DgqkkHqABcA1Nd2tU99eGSVF01nw+y+ksyDbkHdA+3NRidLj+C27b/g0
20
+ xeMFnGbkwvq8AE/iBMGcxDHaoPhYSYjrUeUQpgp+ygfaoW0oN0z/q1GR3E1g27GL
21
+ VU72CHT4xLvyHPpbXxyHGQKBgAXO1/iJanq45j664rerJccQVnLkSRmDLMzEH2q/
22
+ 8sK4uzdtMkm9RFzvbthUmWcNSQrpqNpcEwmL1Xi4aJZTXrV0zOckWugZ3rS9AWAG
23
+ RlkTGNuTjGUKnNHbblidEXqwe3//lykUU14gn0uwzok7s5My68BmEEABwlWH7n52
24
+ AUThAoGBANwwj2WKKu6l66fyQPFZu0cJTfjhiZt1WH17mHAAtL2TpLnDJiPZYbzJ
25
+ 8WRqCWrww+IVq1yxBS6LhAGMuHTfxFWZGKSPxf9jOM87RKJbPkiBDHoFXznjkjsn
26
+ tXk6jmn+6bCmwkgfzVypN3GTyEMhVgQPMJNqlMO9Op5ZAAKuyi31
27
+ -----END RSA PRIVATE KEY-----
@@ -0,0 +1 @@
1
+ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCso8oJd86vymMidh4N8Y58oLklLyNYaB/k6oPRKW9Gl1YQpropHqAMvqtVUVTjPtPmUQLN4Kn4/i5fBiGpczhOh0RxyM+QwsOBHmO34V32LG2VVhEaPm+4C/VruCTjNWvgzzag4qdOuJOpOsUZkvdgbdfLEp+2hNnINawjicBt8yi6n953njMdjqACmAMYGD5eUnPkCLgAlPZi0LBbK7i//O4NwS0wENuKgjyOlaQpPJwUwPBbx/kLDF7dswLD2xqwLr4VQj3tpzmK2+cTr8tm9x+1iNdAXShqTPe6NnT+A3SuGl6mzBTY4NKRdbE4wFhLQ9dnP03avePMZdrmHUR/ julienvey@MacBook-Air-de-Julien.local
@@ -0,0 +1,142 @@
1
+ #!/bin/bash
2
+
3
+ export VAGRANT_OPENSTACK_LOG=debug
4
+
5
+ export OS_SSH_TIMEOUT=600
6
+ export OS_SYNC_METHOD=none
7
+ export OS_SSH_SHELL=bash
8
+ export OS_SSH_USERNAME=
9
+ export OS_SERVER_NAME=
10
+ export OS_IMAGE=
11
+
12
+ ERROR_STATE=0
13
+
14
+ cat > /tmp/images_with_ssh_user <<EOL
15
+ ubuntu-12.04_x86_64_HWE;stack
16
+ ubuntu-14.04_x86_64_LVM;stack
17
+ debian7_x86_64_LVM;stack
18
+ centos65_x86_64_LVM;stack
19
+ EOL
20
+
21
+ cat > /tmp/vagrant_machines <<EOL
22
+ test-basic
23
+ test-floating-ip-pool
24
+ test-ssh-public-key-path
25
+ test-availabilty-zone
26
+ EOL
27
+
28
+ #
29
+ # $1 - Log level
30
+ # $2 - Action (e.g. UP, SSH, DESTROY)
31
+ # $* - Text
32
+ #
33
+ function log() {
34
+ [ $# -lt 3 ] && echo "Logger error..." >&2 && exit 1
35
+ level=$1 ; shift
36
+ action=$1 ; shift
37
+ printf "$(date '+%Y-%m-%d %H:%M:%S') | %10s | %10s | %s\n" "${level}" "${action}" "$*" | tee -a test.log
38
+ }
39
+
40
+ #
41
+ # $1 - Action (e.g. UP, SSH, DESTROY)
42
+ # $* - Text
43
+ #
44
+ function logInfo() {
45
+ action=$1
46
+ shift
47
+ log INFO "${action}" "$*"
48
+ }
49
+
50
+ #
51
+ # $1 - Action (e.g. UP, SSH, DESTROY)
52
+ # $* - Text
53
+ #
54
+ function logError() {
55
+ action=$1
56
+ shift
57
+ log ERROR "${action}" "$*"
58
+ ERROR_STATE=1
59
+ }
60
+
61
+ #
62
+ # $1 - Action (e.g. UP, SSH, DESTROY)
63
+ # $* - Text
64
+ #
65
+ function logSuccess() {
66
+ action=$1
67
+ shift
68
+ log SUCCESS "${action}" "$*"
69
+ }
70
+
71
+ runSingleTest() {
72
+ if [ -d ".vagrant" ]; then
73
+ rm -rf .vagrant
74
+ fi
75
+ machine=${1}
76
+
77
+ testSummary="${OS_SERVER_NAME} - ${OS_IMAGE} - ${OS_SSH_USERNAME}"
78
+
79
+ logInfo 'START' "${testSummary}"
80
+
81
+ bundle exec vagrant up "${machine}" --provider openstack 2>&1 | tee -a "${OS_SERVER_NAME}_up.log"
82
+ if [ "${PIPESTATUS[0]}" -ne 0 ] ; then
83
+ logError 'UP' "${testSummary}"
84
+ else
85
+ logSuccess 'UP' "${testSummary}"
86
+ bundle exec vagrant ssh "${machine}" -c "cat /tmp/test_shell_provision" 2>&1 | tee -a "${OS_SERVER_NAME}_ssh.log"
87
+ if [ "${PIPESTATUS[0]}" -ne 0 ] ; then
88
+ logError 'SSH' "${testSummary}"
89
+ else
90
+ logSuccess 'SSH' "${testSummary}"
91
+ fi
92
+ fi
93
+
94
+ bundle exec vagrant destroy "${machine}" 2>&1 | tee -a "${OS_SERVER_NAME}_destroy.log"
95
+ if [ "${PIPESTATUS[0]}" -ne 0 ] ; then
96
+ logError 'DESTROY' "${testSummary}"
97
+ else
98
+ logSuccess 'DESTROY' "${testSummary}"
99
+ fi
100
+
101
+ logInfo 'END' "${testSummary}"
102
+
103
+ }
104
+
105
+ #
106
+ # $1 - Instance name prefix
107
+ # $2 - Floating IP tu use
108
+ #
109
+ function runAllTests() {
110
+ ip=${1}
111
+ i=1
112
+ rm -f test.log "${name}_*.log"
113
+ touch test.log
114
+ nbTests=$(wc -l < /tmp/images_with_ssh_user)
115
+ for (( i=1 ; i<=nbTests ; i++ )) ; do
116
+ #TODO(vagrant status does not support providers, see https://github.com/mitchellh/vagrant/issues/4173)
117
+ #for machine in $(bundle exec vagrant status | tail -n +8 | head -n -4 | awk '{print $1}') ; do
118
+ while IFS= read -r machine
119
+ do
120
+ currentTest=$(head -n ${i} < /tmp/images_with_ssh_user | tail -n 1)
121
+ export OS_SERVER_NAME="${machine}_${i}"
122
+ export OS_IMAGE=$(echo "${currentTest}" | cut -f1 -d";")
123
+ export OS_FLOATING_IP="${ip}"
124
+ export OS_SSH_USERNAME=$(echo "${currentTest}" | cut -f2 -d";")
125
+ runSingleTest "${machine}"
126
+ done < /tmp/vagrant_machines
127
+ done
128
+ }
129
+
130
+ runAllTests "${OS_FLOATING_IP}"
131
+
132
+ echo ''
133
+ echo '################################################################################################'
134
+ echo '# Report summary #'
135
+ echo '################################################################################################'
136
+ echo ''
137
+ cat test.log
138
+ echo ''
139
+ echo '################################################################################################'
140
+ echo ''
141
+
142
+ exit ${ERROR_STATE}
@@ -4,12 +4,17 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal", "1.0.0"
6
6
  gem "restclient", "0.10.0"
7
+ gem "terminal-table", "1.4.5"
7
8
  gem "webmock", "~> 1.18.0", :group => [:test]
8
9
  gem "rubocop", "0.23.0", :require => false
9
10
  gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :tag => "v1.4.3"
11
+ gem "fakefs", "~> 0.5.2", :group => [:test]
12
+ gem "sshkey", "~> 1.6.1"
13
+ gem "colorize", "~> 0.7.3"
10
14
 
11
15
  group :development do
12
16
  gem "coveralls", :require => false
17
+ gem "debugger"
13
18
  end
14
19
 
15
20
  gemspec :path => "../"
@@ -4,12 +4,17 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal", "1.0.0"
6
6
  gem "restclient", "0.10.0"
7
+ gem "terminal-table", "1.4.5"
7
8
  gem "webmock", "~> 1.18.0", :group => [:test]
8
9
  gem "rubocop", "0.23.0", :require => false
9
10
  gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :tag => "v1.4.3"
11
+ gem "fakefs", "~> 0.5.2", :group => [:test]
12
+ gem "sshkey", "~> 1.6.1"
13
+ gem "colorize", "~> 0.7.3"
10
14
 
11
15
  group :development do
12
16
  gem "coveralls", :require => false
17
+ gem "debugger"
13
18
  end
14
19
 
15
20
  gemspec :path => "../"
@@ -4,12 +4,17 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal", "1.0.0"
6
6
  gem "restclient", "0.10.0"
7
+ gem "terminal-table", "1.4.5"
7
8
  gem "webmock", "~> 1.18.0", :group => [:test]
8
9
  gem "rubocop", "0.23.0", :require => false
9
10
  gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :tag => "v1.4.3"
11
+ gem "fakefs", "~> 0.5.2", :group => [:test]
12
+ gem "sshkey", "~> 1.6.1"
13
+ gem "colorize", "~> 0.7.3"
10
14
 
11
15
  group :development do
12
16
  gem "coveralls", :require => false
17
+ gem "debugger"
13
18
  end
14
19
 
15
20
  gemspec :path => "../"