vagrant-openshift 1.0.9

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 (96) hide show
  1. checksums.yaml +7 -0
  2. data/.gitattributes +1 -0
  3. data/.gitignore +24 -0
  4. data/Gemfile +11 -0
  5. data/LICENSE.txt +13 -0
  6. data/README.asciidoc +379 -0
  7. data/Rakefile +53 -0
  8. data/lib/vagrant-openshift/action/build_geard.rb +41 -0
  9. data/lib/vagrant-openshift/action/build_geard_broker.rb +59 -0
  10. data/lib/vagrant-openshift/action/build_geard_console.rb +55 -0
  11. data/lib/vagrant-openshift/action/build_geard_images.rb +54 -0
  12. data/lib/vagrant-openshift/action/build_sources.rb +39 -0
  13. data/lib/vagrant-openshift/action/checkout_repositories.rb +72 -0
  14. data/lib/vagrant-openshift/action/checkout_tests.rb +57 -0
  15. data/lib/vagrant-openshift/action/clean.rb +51 -0
  16. data/lib/vagrant-openshift/action/clean_network_setup.rb +52 -0
  17. data/lib/vagrant-openshift/action/clone_upstream_repositories.rb +65 -0
  18. data/lib/vagrant-openshift/action/create_ami.rb +54 -0
  19. data/lib/vagrant-openshift/action/create_bare_repo_placeholders.rb +53 -0
  20. data/lib/vagrant-openshift/action/create_puppet_file.rb +84 -0
  21. data/lib/vagrant-openshift/action/create_test_users.rb +36 -0
  22. data/lib/vagrant-openshift/action/create_yum_repositories.rb +121 -0
  23. data/lib/vagrant-openshift/action/download_artifacts.rb +70 -0
  24. data/lib/vagrant-openshift/action/generate_template.rb +89 -0
  25. data/lib/vagrant-openshift/action/idle_all_gears.rb +36 -0
  26. data/lib/vagrant-openshift/action/install_build_dependencies.rb +48 -0
  27. data/lib/vagrant-openshift/action/install_geard.rb +76 -0
  28. data/lib/vagrant-openshift/action/install_geard_base_dependencies.rb +72 -0
  29. data/lib/vagrant-openshift/action/install_geard_broker.rb +39 -0
  30. data/lib/vagrant-openshift/action/install_geard_images.rb +51 -0
  31. data/lib/vagrant-openshift/action/install_open_shift_dependencies.rb +50 -0
  32. data/lib/vagrant-openshift/action/install_rhc.rb +42 -0
  33. data/lib/vagrant-openshift/action/local_geard_checkout.rb +58 -0
  34. data/lib/vagrant-openshift/action/local_repo_checkout.rb +47 -0
  35. data/lib/vagrant-openshift/action/modify_ami.rb +54 -0
  36. data/lib/vagrant-openshift/action/modify_instance.rb +71 -0
  37. data/lib/vagrant-openshift/action/prepare_ssh_config.rb +89 -0
  38. data/lib/vagrant-openshift/action/preserve_mcollective_logs.rb +48 -0
  39. data/lib/vagrant-openshift/action/restart_geard.rb +39 -0
  40. data/lib/vagrant-openshift/action/restart_geard_broker.rb +43 -0
  41. data/lib/vagrant-openshift/action/restart_geard_console.rb +43 -0
  42. data/lib/vagrant-openshift/action/run_geard_tests.rb +57 -0
  43. data/lib/vagrant-openshift/action/run_tests.rb +47 -0
  44. data/lib/vagrant-openshift/action/set_host_name.rb +43 -0
  45. data/lib/vagrant-openshift/action/setup_bind_dns_key.rb +38 -0
  46. data/lib/vagrant-openshift/action/setup_bind_host.rb +141 -0
  47. data/lib/vagrant-openshift/action/setup_builder_files.rb +57 -0
  48. data/lib/vagrant-openshift/action/setup_geard_broker.rb +71 -0
  49. data/lib/vagrant-openshift/action/sync_local_repository.rb +115 -0
  50. data/lib/vagrant-openshift/action/sync_upstream_repository.rb +71 -0
  51. data/lib/vagrant-openshift/action/test_exit_code.rb +36 -0
  52. data/lib/vagrant-openshift/action/uninstall_openshift_rpms.rb +37 -0
  53. data/lib/vagrant-openshift/action/yum_update.rb +67 -0
  54. data/lib/vagrant-openshift/action.rb +308 -0
  55. data/lib/vagrant-openshift/command/build_geard.rb +51 -0
  56. data/lib/vagrant-openshift/command/build_geard_base.rb +51 -0
  57. data/lib/vagrant-openshift/command/build_geard_broker.rb +59 -0
  58. data/lib/vagrant-openshift/command/build_geard_console.rb +59 -0
  59. data/lib/vagrant-openshift/command/build_geard_images.rb +68 -0
  60. data/lib/vagrant-openshift/command/build_origin_base.rb +51 -0
  61. data/lib/vagrant-openshift/command/checkout_repositories.rb +55 -0
  62. data/lib/vagrant-openshift/command/clone_upstream_repositories.rb +54 -0
  63. data/lib/vagrant-openshift/command/create_ami.rb +49 -0
  64. data/lib/vagrant-openshift/command/install_geard.rb +51 -0
  65. data/lib/vagrant-openshift/command/install_geard_broker.rb +51 -0
  66. data/lib/vagrant-openshift/command/install_rhc.rb +49 -0
  67. data/lib/vagrant-openshift/command/local_geard_setup.rb +62 -0
  68. data/lib/vagrant-openshift/command/local_repo_setup.rb +62 -0
  69. data/lib/vagrant-openshift/command/modify_ami.rb +54 -0
  70. data/lib/vagrant-openshift/command/modify_instance.rb +63 -0
  71. data/lib/vagrant-openshift/command/openshift_init.rb +83 -0
  72. data/lib/vagrant-openshift/command/repo_sync.rb +73 -0
  73. data/lib/vagrant-openshift/command/repo_sync_geard.rb +78 -0
  74. data/lib/vagrant-openshift/command/restart_geard.rb +51 -0
  75. data/lib/vagrant-openshift/command/restart_geard_broker.rb +51 -0
  76. data/lib/vagrant-openshift/command/restart_geard_console.rb +51 -0
  77. data/lib/vagrant-openshift/command/setup_geard_broker.rb +49 -0
  78. data/lib/vagrant-openshift/command/test.rb +108 -0
  79. data/lib/vagrant-openshift/command/test_geard.rb +59 -0
  80. data/lib/vagrant-openshift/command/test_geard_image.rb +147 -0
  81. data/lib/vagrant-openshift/config.rb +56 -0
  82. data/lib/vagrant-openshift/constants.rb +111 -0
  83. data/lib/vagrant-openshift/helper/command_helper.rb +213 -0
  84. data/lib/vagrant-openshift/plugin.rb +171 -0
  85. data/lib/vagrant-openshift/provisioner.rb +82 -0
  86. data/lib/vagrant-openshift/templates/builder/Rakefile +231 -0
  87. data/lib/vagrant-openshift/templates/builder/lib/.gitkeep +0 -0
  88. data/lib/vagrant-openshift/templates/builder/lib/rpm.rb +248 -0
  89. data/lib/vagrant-openshift/templates/builder/lib/test.rb +432 -0
  90. data/lib/vagrant-openshift/templates/builder/yum-listbuilddep +124 -0
  91. data/lib/vagrant-openshift/templates/command/init-openshift/Vagrantfile.erb +175 -0
  92. data/lib/vagrant-openshift/templates/command/init-openshift/box_info.yaml +152 -0
  93. data/lib/vagrant-openshift/version.rb +21 -0
  94. data/lib/vagrant-openshift.rb +34 -0
  95. data/vagrant-openshift.gemspec +43 -0
  96. metadata +234 -0
@@ -0,0 +1,73 @@
1
+ #--
2
+ # Copyright 2013 Red Hat, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #++
16
+ require_relative "../action"
17
+
18
+ module Vagrant
19
+ module Openshift
20
+ module Commands
21
+ class RepoSync < Vagrant.plugin(2, :command)
22
+ include CommandHelper
23
+
24
+ def self.synopsis
25
+ "syncs and installs(by default) your local repos to the current instance"
26
+ end
27
+
28
+ def execute
29
+ options = {}
30
+ options[:clean] = false
31
+ options[:local_source] = true
32
+ options[:no_build] = false
33
+ options[:deps] = false
34
+
35
+ opts = OptionParser.new do |o|
36
+ o.banner = "Usage: vagrant sync [vm-name]"
37
+ o.separator ""
38
+
39
+ o.on("-c", "--clean", "Delete existing repo and uninstall all OpenShift RPMs before syncing") do |f|
40
+ options[:clean] = f
41
+ end
42
+
43
+ o.on("-u", "--upstream", "Build base VM based on local source") do |f|
44
+ options[:local_source] = false
45
+ end
46
+
47
+ o.on("--install-deps", "Install any missing dependencies") do |f|
48
+ options[:deps] = f
49
+ end
50
+
51
+ o.on("--dont-install", "Don't build and install RPMs") do |f|
52
+ options[:no_build] = f
53
+ end
54
+
55
+ o.on("-d","--artifacts", String, "Download logs and rpms") do |f|
56
+ options[:download] = true
57
+ end
58
+ end
59
+
60
+ # Parse the options
61
+ argv = parse_options(opts)
62
+ return if !argv
63
+
64
+ with_target_vms(argv, :reverse => true) do |machine|
65
+ actions = Vagrant::Openshift::Action.repo_sync(options)
66
+ @env.action_runner.run actions, {:machine => machine}
67
+ 0
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,78 @@
1
+ #--
2
+ # Copyright 2013 Red Hat, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #++
16
+ require_relative "../action"
17
+
18
+ module Vagrant
19
+ module Openshift
20
+ module Commands
21
+ class RepoSyncGeard < Vagrant.plugin(2, :command)
22
+ include CommandHelper
23
+
24
+ def self.synopsis
25
+ "syncs your local repos to the current instance"
26
+ end
27
+
28
+ def execute
29
+ options = {}
30
+ options[:geard_images] = []
31
+ options[:no_build] = false
32
+ options[:clean] = false
33
+ options[:source] = false
34
+ options[:include] = [ Vagrant::Openshift::Constants::FILTER_BROKER , Vagrant::Openshift::Constants::FILTER_CONSOLE ,Vagrant::Openshift::Constants::FILTER_GEARD, Vagrant::Openshift::Constants::FILTER_IMAGES, Vagrant::Openshift::Constants::FILTER_RHC]
35
+
36
+ opts = OptionParser.new do |o|
37
+ o.banner = "Usage: vagrant sync-geard [vm-name]"
38
+ o.separator ""
39
+
40
+ o.on("-c", "--clean", "Delete existing repo before syncing") do |f|
41
+ options[:clean] = f
42
+ end
43
+
44
+ o.on("-s", "--source", "Sync the source (not required if using synced folders)") do |f|
45
+ options[:source] = f
46
+ end
47
+
48
+ o.on("--dont-install", "Don't build and install updated source") do |f|
49
+ options[:no_build] = true
50
+ end
51
+
52
+ o.on("-i [comp comp]", "--include", String, "Sync specified components. Default: #{options[:include].join " "}") do |f|
53
+ options[:include] = f.split " "
54
+ end
55
+
56
+ o.on("--geard-images [ #{Vagrant::Openshift::Constants.geard_images.keys.join(' ')} | all ]", "Specify which images should be synced. Default: []") do |f|
57
+ if f.split(" ").include?("all")
58
+ options[:geard_images] = Vagrant::Openshift::Constants.geard_images.keys
59
+ else
60
+ options[:geard_images] = f.split(" ")
61
+ end
62
+ end
63
+ end
64
+
65
+ # Parse the options
66
+ argv = parse_options(opts)
67
+ return if !argv
68
+
69
+ with_target_vms(argv, :reverse => true) do |machine|
70
+ actions = Vagrant::Openshift::Action.repo_sync_geard(options)
71
+ @env.action_runner.run actions, {:machine => machine}
72
+ 0
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,51 @@
1
+ #--
2
+ # Copyright 2013 Red Hat, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #++
16
+ require_relative "../action"
17
+
18
+ module Vagrant
19
+ module Openshift
20
+ module Commands
21
+ class RestartGeard < Vagrant.plugin(2, :command)
22
+ include CommandHelper
23
+
24
+ def self.synopsis
25
+ "restarts geard"
26
+ end
27
+
28
+ def execute
29
+ options = {}
30
+ options[:clean] = false
31
+ options[:local_source] = false
32
+
33
+ opts = OptionParser.new do |o|
34
+ o.banner = "Usage: vagrant restart-geard [vm-name]"
35
+ o.separator ""
36
+ end
37
+
38
+ # Parse the options
39
+ argv = parse_options(opts)
40
+ return if !argv
41
+
42
+ with_target_vms(argv, :reverse => true) do |machine|
43
+ actions = Vagrant::Openshift::Action.restart_geard(options)
44
+ @env.action_runner.run actions, {:machine => machine}
45
+ 0
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,51 @@
1
+ #--
2
+ # Copyright 2013 Red Hat, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #++
16
+ require_relative "../action"
17
+
18
+ module Vagrant
19
+ module Openshift
20
+ module Commands
21
+ class RestartGeardBroker < Vagrant.plugin(2, :command)
22
+ include CommandHelper
23
+
24
+ def self.synopsis
25
+ "restarts geard-based broker"
26
+ end
27
+
28
+ def execute
29
+ options = {}
30
+ options[:clean] = false
31
+ options[:local_source] = false
32
+
33
+ opts = OptionParser.new do |o|
34
+ o.banner = "Usage: vagrant restart-geard-broker [vm-name]"
35
+ o.separator ""
36
+ end
37
+
38
+ # Parse the options
39
+ argv = parse_options(opts)
40
+ return if !argv
41
+
42
+ with_target_vms(argv, :reverse => true) do |machine|
43
+ actions = Vagrant::Openshift::Action.restart_geard_broker(options)
44
+ @env.action_runner.run actions, {:machine => machine}
45
+ 0
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,51 @@
1
+ #--
2
+ # Copyright 2013 Red Hat, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #++
16
+ require_relative "../action"
17
+
18
+ module Vagrant
19
+ module Openshift
20
+ module Commands
21
+ class RestartGeardConsole < Vagrant.plugin(2, :command)
22
+ include CommandHelper
23
+
24
+ def self.synopsis
25
+ "restarts geard-based console"
26
+ end
27
+
28
+ def execute
29
+ options = {}
30
+ options[:clean] = false
31
+ options[:local_source] = false
32
+
33
+ opts = OptionParser.new do |o|
34
+ o.banner = "Usage: vagrant restart-geard-console [vm-name]"
35
+ o.separator ""
36
+ end
37
+
38
+ # Parse the options
39
+ argv = parse_options(opts)
40
+ return if !argv
41
+
42
+ with_target_vms(argv, :reverse => true) do |machine|
43
+ actions = Vagrant::Openshift::Action.restart_geard_console(options)
44
+ @env.action_runner.run actions, {:machine => machine}
45
+ 0
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,49 @@
1
+ #--
2
+ # Copyright 2014 Red Hat, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #++
16
+ require_relative "../action"
17
+
18
+ module Vagrant
19
+ module Openshift
20
+ module Commands
21
+ class SetupGeardBroker < Vagrant.plugin(2, :command)
22
+ include CommandHelper
23
+
24
+ def self.synopsis
25
+ "Populate running broker with required data to interact with geard"
26
+ end
27
+
28
+ def execute
29
+ options = {}
30
+
31
+ opts = OptionParser.new do |o|
32
+ o.banner = "Usage: vagrant setup-geard-broker"
33
+ o.separator ""
34
+ end
35
+
36
+ # Parse the options
37
+ argv = parse_options(opts)
38
+ return if !argv
39
+
40
+ with_target_vms(argv, :reverse => true) do |machine|
41
+ actions = Vagrant::Openshift::Action.setup_geard_broker(options)
42
+ @env.action_runner.run actions, {:machine => machine}
43
+ 0
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,108 @@
1
+ #--
2
+ # Copyright 2013 Red Hat, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #++
16
+ require_relative "../action"
17
+
18
+ module Vagrant
19
+ module Openshift
20
+ module Commands
21
+ class Test < Vagrant.plugin(2, :command)
22
+ include CommandHelper
23
+
24
+ def self.synopsis
25
+ "run the OpenShift tests"
26
+ end
27
+
28
+ def component_list
29
+ [:node,:cart,:gear,:broker,:console,:rhc]
30
+ end
31
+
32
+ def execute
33
+ options = {}
34
+ options[:extended] = false
35
+ options[:download] = false
36
+ component_list.each { |component| options[component] = false }
37
+
38
+ opts = OptionParser.new do |o|
39
+ o.banner = "Usage: vagrant test [machine-name]"
40
+ o.separator ""
41
+
42
+ o.on("-n", "--node", String, "Run node tests") do |f|
43
+ options[:node] = true
44
+ end
45
+
46
+ o.on("-t", "--cart", String, "Run cartridge tests") do |f|
47
+ options[:cart] = true
48
+ end
49
+
50
+ o.on("-g", "--gear", String, "Run gear tests") do |f|
51
+ options[:gear] = true
52
+ end
53
+
54
+ o.on("-b", "--broker", String, "Run broker tests") do |f|
55
+ options[:broker] = true
56
+ end
57
+
58
+ o.on("-r", "--rhc", String, "Run CLI tests") do |f|
59
+ options[:rhc] = true
60
+ end
61
+
62
+ o.on("-c", "--console", String, "Run console/web tests") do |f|
63
+ options[:console] = true
64
+ end
65
+
66
+ o.on("-e", "--extended", String, "Run extended tests") do |f|
67
+ options[:extended] = true
68
+ end
69
+
70
+ o.on("-a", "--all", String, "Run all tests") do |f|
71
+ component_list.each { |component| options[component] = true }
72
+ end
73
+
74
+ o.on("-d","--artifacts", String, "Download logs and rpms") do |f|
75
+ options[:download] = true
76
+ end
77
+
78
+ o.on("--fixme", "Run known broken tests to verify test fixes") do |f|
79
+ options[:fixme] = true
80
+ end
81
+ end
82
+
83
+ # Parse the options
84
+ argv = parse_options(opts)
85
+ return if !argv
86
+
87
+ # Figure out if we are implicitly running all tests
88
+ do_all = true
89
+ component_list.each do |component|
90
+ if options[component]
91
+ do_all = false
92
+ break
93
+ end
94
+ end
95
+ if do_all
96
+ component_list.each { |component| options[component] = true }
97
+ end
98
+
99
+ with_target_vms(argv, :reverse => true) do |machine|
100
+ actions = Vagrant::Openshift::Action.run_tests(options)
101
+ @env.action_runner.run actions, {:machine => machine}
102
+ 0
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,59 @@
1
+ #--
2
+ # Copyright 2013 Red Hat, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #++
16
+ require_relative "../action"
17
+
18
+ module Vagrant
19
+ module Openshift
20
+ module Commands
21
+ class TestGeard < Vagrant.plugin(2, :command)
22
+ include CommandHelper
23
+
24
+ def self.synopsis
25
+ "run the geard tests"
26
+ end
27
+
28
+ def execute
29
+ options = {}
30
+ options[:download] = false
31
+ options[:all] = false
32
+
33
+ opts = OptionParser.new do |o|
34
+ o.banner = "Usage: vagrant test [machine-name]"
35
+ o.separator ""
36
+
37
+ o.on("-a", "--all", String, "Run all tests") do |f|
38
+ options[:all] = true
39
+ end
40
+
41
+ o.on("-d","--artifacts", String, "Download logs and rpms") do |f|
42
+ options[:download] = true
43
+ end
44
+ end
45
+
46
+ # Parse the options
47
+ argv = parse_options(opts)
48
+ return if !argv
49
+
50
+ with_target_vms(argv, :reverse => true) do |machine|
51
+ actions = Vagrant::Openshift::Action.run_geard_tests(options)
52
+ @env.action_runner.run actions, {:machine => machine}
53
+ 0
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,147 @@
1
+ #--
2
+ # Copyright 2013 Red Hat, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #++
16
+ require_relative "../action"
17
+
18
+ module Vagrant
19
+ module Openshift
20
+ module Commands
21
+
22
+ class TestGeardImage < Vagrant.plugin(2, :command)
23
+ include CommandHelper
24
+
25
+ def self.synopsis
26
+ "tests an image"
27
+ end
28
+
29
+ def execute
30
+ options = {}
31
+ options[:image] = nil
32
+ options[:ref] = 'master'
33
+ options[:source] = nil
34
+
35
+ opts = OptionParser.new do |o|
36
+ o.banner = "Usage: vagrant test-geard-image --image IMAGE [vm-name]"
37
+ o.separator ""
38
+
39
+ o.on("-i", "--image IMAGE", String, "image to test") do |o|
40
+ options[:image] = o
41
+ end
42
+
43
+ o.on("-r", "--ref REF", String, "git ref to test") do |o|
44
+ options[:ref] = o
45
+ end
46
+
47
+ o.on("-s", "--source SOURCE", String, "git repo source url") do |o|
48
+ options[:source] = o
49
+ end
50
+ end
51
+
52
+ # Parse the options
53
+ argv = parse_options(opts)
54
+ return if !argv
55
+
56
+ if options[:image].nil? and options[:ref].nil?
57
+ @env.ui.warn "You must specify an image and a git ref"
58
+ exit
59
+ end
60
+
61
+ if options[:source].nil?
62
+ options[:source] = "https://github.com/#{options[:image]}"
63
+ end
64
+
65
+ with_target_vms(argv, :reverse => true) do |machine|
66
+ image = options[:image]
67
+ ref = options[:ref]
68
+ source = options[:source]
69
+
70
+ # image could be centos or openshift/ruby-19-centos
71
+ # just grab the end (centos or ruby-19-centos)
72
+ source_dir = File.basename(image)
73
+ app_name = "test-#{source_dir}"
74
+ rc=1
75
+ begin
76
+ out, err, rc = do_execute(machine, %{
77
+ set -x
78
+
79
+ # so we can call sti
80
+ PATH=/data/bin:$PATH
81
+
82
+ # create a temp dir to play in
83
+ temp_dir=$(mktemp -d /tmp/image_test.XXXXXXX)
84
+
85
+ # set correct SELinux context
86
+ chcon -t docker_share_t $temp_dir
87
+
88
+ cd $temp_dir
89
+
90
+ # clone the image repo
91
+ git clone #{source}
92
+ cd #{source_dir}
93
+
94
+ # switch to the desired ref
95
+ git checkout #{ref}
96
+
97
+ # get git sha1
98
+ git_sha1=`git rev-parse --short #{ref}`
99
+
100
+ # grab the latest image from the index
101
+ docker pull #{image}:latest
102
+
103
+ status=0
104
+
105
+ # build and test the sample app, if it exists
106
+ if [ -d test-app -a -f .sti/bin/test ]; then
107
+ # build
108
+ sti build test-app #{image} #{app_name} --clean
109
+ status=$?
110
+
111
+ if [ $status -eq 0 ]; then
112
+ # run tests
113
+ docker run --rm -v $temp_dir/#{source_dir}/.sti/bin:/tmp/sti #{app_name} /tmp/sti/test
114
+
115
+ status=$?
116
+ fi
117
+ fi
118
+
119
+ if [ $status -eq 0 ]; then
120
+ # get the image id
121
+ image_id=`docker inspect --format="{{ .Id }}" #{image}:latest`
122
+
123
+ # tag it devenv-ready
124
+ docker tag $image_id #{image}:devenv-ready
125
+
126
+ # tag it with the git ref
127
+ docker tag $image_id #{image}:git-$git_sha1
128
+ fi
129
+
130
+ # clean up
131
+ cd /
132
+ rm -rf $temp_dir
133
+ exit $status
134
+ })
135
+ # Vagrant throws an exception if any execute invocation returns non-zero,
136
+ # so catch it so we can return a proper output.
137
+ rescue => e
138
+ @env.ui.info "Exception: #{e}"
139
+ end
140
+ @env.ui.info "RC=#{rc}"
141
+ return rc
142
+ end
143
+ end
144
+ end
145
+ end
146
+ end
147
+ end