vagrant-openshift 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
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,38 @@
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
+
17
+ module Vagrant
18
+ module Openshift
19
+ module Action
20
+ class SetupBindDnsKey
21
+ include CommandHelper
22
+
23
+ def initialize(app, env)
24
+ @app = app
25
+ @env = env
26
+ end
27
+
28
+ def call(env)
29
+ domain = env[:machine].config.openshift.cloud_domain
30
+
31
+ sudo(env[:machine], "rm -rf /var/named/K*.*.*")
32
+ sudo(env[:machine], "/usr/sbin/dnssec-keygen -a HMAC-MD5 -b 512 -n USER -r /dev/urandom -K /var/named #{domain}")
33
+ @app.call(env)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,141 @@
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
+
17
+ module Vagrant
18
+ module Openshift
19
+ module Action
20
+ class SetupBindHost
21
+ include CommandHelper
22
+
23
+ def initialize(app, env)
24
+ @app = app
25
+ @env = env
26
+ end
27
+
28
+ def call(env)
29
+ domain = env[:machine].config.openshift.cloud_domain
30
+ sudo(env[:machine], %{
31
+ yum install -y bind bind-utils
32
+ NAMESERVERS=$(cat /etc/resolv.conf | grep -w nameserver | cut -d' ' -f 2 )
33
+ FORWARDERS=$(echo $NAMESERVERS | sed 's/ /; /g')
34
+ pushd /var/named
35
+ rm -rf K*.*.*
36
+ /usr/sbin/dnssec-keygen -a HMAC-MD5 -b 512 -n USER -r /dev/urandom -K /var/named #{domain}
37
+ KEYSTRING=$(grep Key: K#{domain}.*.private | cut -d' ' -f 2)
38
+ echo 'forwarders { '$FORWARDERS'; };' > forwarders.conf
39
+ echo $'key #{domain} {\n algorithm HMAC-MD5;\n secret "'$KEYSTRING$'";\n};' > #{domain}.key
40
+ cat <<EOF> #{domain}.zones
41
+ zone "#{domain}" IN {
42
+ type master;
43
+ file "dynamic/#{domain}.db";
44
+ allow-update { key #{domain}; };
45
+ };
46
+ EOF
47
+ touch dynamic/#{domain}.db
48
+ cat <<EOF> dynamic/#{domain}.db
49
+ \\$ORIGIN .
50
+ \\$TTL 1 ; 1 seconds (for testing only)
51
+ #{domain} IN SOA ns1.#{domain}. hostmaster.#{domain}. (
52
+ 2011112904 ; serial
53
+ 60 ; refresh (1 minute)
54
+ 15 ; retry (15 seconds)
55
+ 1800 ; expire (30 minutes)
56
+ 10 ; minimum (10 seconds)
57
+ )
58
+ NS ns1.#{domain}.
59
+ MX 10 mail.#{domain}.
60
+ \\$ORIGIN #{domain}.
61
+ mail A 127.0.0.1
62
+ master A 192.168.1.1
63
+ ns1 A 127.0.0.1
64
+ node A 192.168.1.10
65
+ ; test records
66
+ testns1 TXT "reserved namespace testns1"
67
+ ;testns2 TXT "to be added by tests"
68
+ testns3 TXT "reserved to add apps"
69
+ testns4 TXT "reserved to delete apps"
70
+ testapp4-testns4 CNAME node.#{domain}.com.
71
+ EOF
72
+ popd
73
+ pushd /etc/
74
+ mv named.conf named.conf.old
75
+ cat <<EOF> named.conf
76
+ options {
77
+ listen-on port 53 { 127.0.0.1; 172.17.42.1; };
78
+ listen-on-v6 port 53 { ::1; };
79
+ directory "/var/named";
80
+ dump-file "/var/named/data/cache_dump.db";
81
+ statistics-file "/var/named/data/named_stats.txt";
82
+ memstatistics-file "/var/named/data/named_mem_stats.txt";
83
+ allow-query { any; };
84
+ recursion yes;
85
+ dnssec-enable yes;
86
+ dnssec-validation no;
87
+ dnssec-lookaside auto;
88
+ bindkeys-file "/etc/named.iscdlv.key";
89
+ managed-keys-directory "/var/named/dynamic";
90
+ pid-file "/run/named/named.pid";
91
+ session-keyfile "/run/named/session.key";
92
+ forward only;
93
+ include "forwarders.conf";
94
+ };
95
+ logging {
96
+ channel default_debug {
97
+ file "data/named.run";
98
+ severity dynamic;
99
+ };
100
+ };
101
+ include "/etc/named.rfc1912.zones";
102
+ include "/etc/named.root.key";
103
+ include "/var/named/#{domain}.zones";
104
+ include "#{domain}.key";
105
+ EOF
106
+ if ! cat /etc/dhcp/dhclient.conf | grep 'prepend domain-name-servers 172.17.42.1;' 2>&1 > /dev/null ; then
107
+ echo "$(cat /etc/dhcp/dhclient.conf)\nprepend domain-name-servers 172.17.42.1;" > /etc/dhcp/dhclient.conf;
108
+ fi
109
+ systemctl enable named
110
+ systemctl restart named
111
+ service network restart
112
+ systemctl restart docker
113
+ BIND_CONF=#{Vagrant::Openshift::Constants.plugins_conf_dir}/dns/bind/conf
114
+ mkdir -p $BIND_CONF
115
+ pushd $BIND_CONF
116
+ cat <<EOF> openshift-origin-dns-bind.conf
117
+ # Settings related to the bind variant of an OpenShift DNS plugin
118
+
119
+ # The DNS server
120
+ BIND_SERVER="172.17.42.1"
121
+
122
+ # The DNS server's port
123
+ BIND_PORT=53
124
+
125
+ # The key name for your zone
126
+ BIND_KEYNAME="#{domain}"
127
+
128
+ # base64-encoded key, most likely from /var/named/example.com.key.
129
+ BIND_KEYVALUE="$KEYSTRING"
130
+
131
+ # The base zone for the DNS server
132
+ BIND_ZONE="#{domain}"
133
+ EOF
134
+ popd
135
+ })
136
+ @app.call(env)
137
+ end
138
+ end
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,57 @@
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 'yaml'
17
+
18
+ module Vagrant
19
+ module Openshift
20
+ module Action
21
+ class SetupBuilderFiles
22
+ include CommandHelper
23
+
24
+ def initialize(app, env)
25
+ @app = app
26
+ @env = env
27
+ end
28
+
29
+ def call(env)
30
+ ssh_user = env[:machine].ssh_info[:username]
31
+ sudo(env[:machine], "yum clean all")
32
+ sudo(env[:machine], "rm -rf #{Constants.build_dir}")
33
+ sudo(env[:machine], "mkdir -p #{Constants.build_dir}")
34
+ sudo(env[:machine], "mkdir -p #{Constants.build_dir + "builder"}; chown #{ssh_user}:#{ssh_user} #{Constants.build_dir + "builder"};")
35
+ env[:machine].communicate.upload(File.expand_path("#{__FILE__}/../../templates/builder"), Constants.build_dir.to_s )
36
+ env[:machine].communicate.upload(File.expand_path("#{__FILE__}/../../constants.rb"), (Constants.build_dir + "builder/lib/constants.rb").to_s )
37
+ sudo(env[:machine], "chmod +x #{Constants.build_dir + "builder/yum-listbuilddep"}; chown #{ssh_user}:#{ssh_user} -R #{Constants.build_dir}")
38
+ remote_write(env[:machine], Constants.build_dir + "builder/lib/options.rb") do
39
+ %{
40
+ require 'yaml'
41
+ OPTIONS = YAML.load(
42
+ "#{
43
+ {
44
+ :ignore_packages => env[:machine].config.openshift.ignore_packages,
45
+ :cloud_domain => env[:machine].config.openshift.cloud_domain,
46
+ :additional_services => env[:machine].config.openshift.additional_services,
47
+ }.to_yaml}"
48
+ )
49
+ }
50
+ end
51
+
52
+ @app.call(env)
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,71 @@
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
+
17
+ module Vagrant
18
+ module Openshift
19
+ module Action
20
+ class SetupGeardBroker
21
+ include CommandHelper
22
+
23
+ def initialize(app, env)
24
+ @app = app
25
+ @env = env
26
+ end
27
+
28
+ def call(env)
29
+ sudo(env[:machine], %{
30
+ #{bash_systemd_polling_functions}
31
+ #
32
+ gear list-units
33
+
34
+ echo "Waiting for origin-db and origin-broker to become available..."
35
+
36
+ if ! wait_for_activate origin-db; then
37
+ echo "WARNING: The 'origin-db' container is not ACTIVE. Trying restart..."
38
+ gear restart origin-db-1
39
+ if ! wait_for_activate origin-db; then
40
+ echo "ERROR: Unable to activate the origin-db container."
41
+ gear status origin-db-1
42
+ exit 1
43
+ fi
44
+ fi
45
+
46
+ if ! wait_for_activate origin-broker; then
47
+ echo "WARNING: The 'origin-broker' container is not ACTIVE. Trying restart..."
48
+ gear restart origin-broker-1
49
+ if ! wait_for_activate origin-broker; then
50
+ echo "ERROR: Unable to activate the origin-broker container."
51
+ gear status origin-broker-1
52
+ exit 1
53
+ fi
54
+ fi
55
+
56
+ echo "Install cartridges into broker"
57
+
58
+ retries=1
59
+ until [ $retries -ge 5 ]; do
60
+ switchns --container="origin-broker-1" -- /bin/bash --login -c '$HOME/src/docker/openshift_init'
61
+ [ $? == 0 ] && break
62
+ echo "Installing cartridges failed ($?). Retry \#$retries" && sleep 1
63
+ retries=$[$retries+1]
64
+ done
65
+ })
66
+ @app.call(env)
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,115 @@
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
+
17
+ module Vagrant
18
+ module Openshift
19
+ module Action
20
+ class SyncLocalRepository
21
+ include CommandHelper
22
+
23
+ def initialize(app, env)
24
+ @app = app
25
+ @env = env
26
+ end
27
+
28
+ def call(env)
29
+ env[:machine].env.ui.info("Sync'ing local sources")
30
+
31
+ pids = []
32
+ Constants.repos.each do |repo_name, url|
33
+ local_repo = Pathname.new(File.expand_path(env[:machine].env.root_path + repo_name))
34
+ unless local_repo.exist?
35
+ env[:machine].ui.warn "Missing local clone of repository #{local_repo}"
36
+ next
37
+ end
38
+
39
+ pids << fork {
40
+ Dir.chdir(local_repo) { sync_repo(env[:machine], repo_name) }
41
+ }
42
+ end
43
+ Process.waitall
44
+
45
+ @app.call(env)
46
+ end
47
+
48
+ private
49
+
50
+ def sync_repo(machine, repo_name)
51
+ begin
52
+ temp_commit
53
+
54
+ # Get the current branch
55
+ branch = get_branch
56
+
57
+ puts "Synchronizing [#{repo_name}@#{branch}] from #{File.basename(FileUtils.pwd)}..."
58
+
59
+ command = ""
60
+ unless Constants.git_ssh.nil? or Constants.git_ssh.empty?
61
+ command += "export GIT_SSH=#{Constants.git_ssh};\n"
62
+ end
63
+ if branch == 'origin/master'
64
+ command += "git push -q verifier:#{Constants.build_dir + repo_name}-bare master:master --tags --force;\n"
65
+ end
66
+ command += "git push -q verifier:#{Constants.build_dir + repo_name }-bare #{branch}:master --tags --force"
67
+ system(command)
68
+ ensure
69
+ reset_temp_commit
70
+ end
71
+ end
72
+
73
+ def temp_commit
74
+ # Warn on uncommitted changes
75
+ %x[git diff-index --quiet HEAD]
76
+
77
+ if $?.exitstatus != 0
78
+ # Perform a temporary commit
79
+ puts "Creating temporary commit to build"
80
+
81
+ begin
82
+ %x[git commit -m "Temporary commit #1 - index changes"]
83
+ ensure
84
+ (@temp_commit ||= []).push("git reset --soft HEAD^") if $?.exitstatus == 0
85
+ end
86
+
87
+ begin
88
+ `git commit -a -m "Temporary commit #2 - non-index changes"`
89
+ ensure
90
+ (@temp_commit ||= []).push("git reset --mixed HEAD^") if $?.exitstatus == 0
91
+ end
92
+
93
+ puts @temp_commit ? "No-op" : "Done"
94
+ end
95
+ end
96
+
97
+ def reset_temp_commit
98
+ if @temp_commit
99
+ puts "Undoing temporary commit..."
100
+ while undo = @temp_commit.pop
101
+ %x[#{undo}]
102
+ end
103
+ @temp_commit = nil
104
+ puts "Done."
105
+ end
106
+ end
107
+
108
+ def get_branch
109
+ (%x[git status | head -n1].chomp =~ /.*branch (.*)/) ? $1 : 'origin/master'
110
+ end
111
+
112
+ end
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,71 @@
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
+
17
+ module Vagrant
18
+ module Openshift
19
+ module Action
20
+ class SyncUpstreamRepository
21
+ include CommandHelper
22
+
23
+ def initialize(app, env)
24
+ @app = app
25
+ @env = env
26
+ end
27
+
28
+ def call(env)
29
+ env[:machine].env.ui.info("Sync'ing upstream sources\n")
30
+ command = ""
31
+
32
+ Constants.repos.each do |repo_name, url|
33
+
34
+ branch="master"
35
+
36
+ bare_repo_name = repo_name + "-bare"
37
+ bare_repo_wc_name = repo_name + "-bare-working_copy"
38
+ bare_repo_path = Constants.build_dir + bare_repo_name
39
+ bare_repo_wc_path = Constants.build_dir + bare_repo_wc_name
40
+
41
+ command += "export GIT_SSH=#{Constants.git_ssh};\n" unless Constants.git_ssh.nil? or Constants.git_ssh.empty?
42
+ command += %{
43
+ (
44
+ if [ ! -d #{bare_repo_wc_path} ]; then
45
+ echo 'Cloning #{repo_name} ...'
46
+ git clone -l --quiet #{bare_repo_path} #{bare_repo_wc_path}
47
+ fi
48
+
49
+ cd #{bare_repo_wc_path}
50
+ git remote add upstream #{url}
51
+ git fetch upstream
52
+ git checkout master
53
+ git reset --hard upstream/#{branch}
54
+ git push origin master -f
55
+ ) &
56
+ PIDS+=$!\" \";
57
+ }
58
+ end
59
+
60
+ command += "[ -n \"$PIDS\" ] && wait $PIDS\n"
61
+
62
+ do_execute(env[:machine], command)
63
+
64
+ env[:machine].env.ui.info("Done")
65
+ @app.call(env)
66
+ end
67
+
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,36 @@
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
+
17
+ module Vagrant
18
+ module Openshift
19
+ module Action
20
+ class TestExitCode
21
+ include CommandHelper
22
+
23
+ def initialize(app, env)
24
+ @app = app
25
+ @env = env
26
+ end
27
+
28
+ def call(env)
29
+ exit(env[:test_exit_code]) if env.has_key? :test_exit_code
30
+
31
+ @app.call(env)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,37 @@
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
+
17
+ module Vagrant
18
+ module Openshift
19
+ module Action
20
+ class UninstallOpenShiftRpms
21
+ include CommandHelper
22
+
23
+ def initialize(app, env)
24
+ @app = app
25
+ @env = env
26
+ end
27
+
28
+ def call(env)
29
+ is_fedora = env[:machine].communicate.test("test -e /etc/fedora-release")
30
+ sudo env[:machine], "cd #{Constants.build_dir + "builder; #{scl_wrapper(is_fedora,'rake clean_rpms')}"}"
31
+ sudo env[:machine], "rm -rf #{Constants.build_dir + "origin-rpms"} #{Constants.build_dir + "origin-srpms"} #{Constants.build_dir + ".built_packages"} #{Constants.build_dir + ".spec_cache"}"
32
+ @app.call(env)
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,67 @@
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
+
17
+ module Vagrant
18
+ module Openshift
19
+ module Action
20
+ class YumUpdate
21
+ include CommandHelper
22
+
23
+ def initialize(app, env)
24
+ @app = app
25
+ @env = env
26
+ end
27
+
28
+ def call(env)
29
+ sudo env[:machine], "rm -rf /etc/yum.repos.d/openshift-origin.repo"
30
+ sudo env[:machine], "yum clean all;"
31
+ sudo env[:machine], "yum -y update --exclude=kernel*", {retries: 3, fail_on_error: false}
32
+
33
+ env[:machine].ui.warn "Increasing YUM cache timeout to 9999999. You will need manually clear cache to get additional updates."
34
+ remote_write(env[:machine], "/etc/yum.conf") {
35
+ %{
36
+ [main]
37
+ cachedir=/var/cache/yum/$basearch/$releasever
38
+ keepcache=0
39
+ debuglevel=2
40
+ logfile=/var/log/yum.log
41
+ exactarch=1
42
+ obsoletes=1
43
+ gpgcheck=0
44
+ plugins=1
45
+ installonly_limit=3
46
+
47
+ # This is the default, if you make this bigger yum won't see if the metadata
48
+ # is newer on the remote and so you'll "gain" the bandwidth of not having to
49
+ # download the new metadata and "pay" for it by yum not having correct
50
+ # information.
51
+ # It is esp. important, to have correct metadata, for distributions like
52
+ # Fedora which don't keep old packages around. If you don't like this checking
53
+ # interrupting your command line usage, it's much better to have something
54
+ # manually check the metadata once an hour (yum-updatesd will do this).
55
+ metadata_expire=9999999
56
+
57
+ # PUT YOUR REPOS HERE OR IN separate files named file.repo
58
+ # in /etc/yum.repos.d
59
+ }
60
+ }
61
+
62
+ @app.call(env)
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end