Skip to content
This repository was archived by the owner on Aug 29, 2018. It is now read-only.

Commit c6133bb

Browse files
committed
add setup-mirrors command
1 parent 19fc161 commit c6133bb

File tree

4 files changed

+109
-0
lines changed

4 files changed

+109
-0
lines changed

lib/vagrant-openshift/action.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ def self.build_origin(options)
7676
end
7777
end
7878

79+
def self.setup_openshift_mirrors(options)
80+
Vagrant::Action::Builder.new.tap do |b|
81+
b.use SetupOpenShiftMirrors, options
82+
end
83+
end
84+
7985
def self.push_openshift_images(options)
8086
Vagrant::Action::Builder.new.tap do |b|
8187
b.use PushOpenshiftImages, options
@@ -374,6 +380,7 @@ def self.install_rhc(options)
374380
autoload :BuildOriginRpmTest, action_root.join("build_origin_rpm_test")
375381
autoload :CreateLocalYumRepo, action_root.join("create_local_yum_repo")
376382
autoload :BuildOriginImages, action_root.join("build_origin_images")
383+
autoload :SetupOpenShiftMirrors, action_root.join("setup_openshift_mirrors")
377384
end
378385
end
379386
end
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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 SetupOpenShiftMirrors
21+
include CommandHelper
22+
23+
def initialize(app, env, options)
24+
@app = app
25+
@env = env
26+
@options = options
27+
end
28+
29+
def call(env)
30+
do_execute(env[:machine], %{
31+
echo "Setting up 'mirror.openshift.com' for EPEL ..."
32+
set -e
33+
rm -f /tmp/epel-mirror.repo /tmp/set-build-image-args.sh
34+
curl -s https://mirror.openshift.com/mirror/epel/epel7.repo | sed "s/^\\[epel/[epel-openshift/" > /tmp/epel-mirror.repo
35+
echo 'export OS_BUILD_IMAGE_ARGS="--mount /etc/yum.repos.d/epel-mirror.repo:/etc/yum.repos.d/epel-mirror.repo"' > /tmp/set-build-image-args.sh
36+
37+
sudo mv /tmp/epel-mirror.repo /etc/yum.repos.d/epel-mirror.repo
38+
sudo mv /tmp/set-build-image-args.sh /etc/profile.d/set-build-image-args.sh
39+
},
40+
{ :timeout => 60*60*2, :verbose => false })
41+
@app.call(env)
42+
end
43+
44+
end
45+
end
46+
end
47+
end
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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 SetupMirrors < Vagrant.plugin(2, :command)
22+
include CommandHelper
23+
24+
def self.synopsis
25+
"setup OpenShift repository mirrors"
26+
end
27+
28+
def execute
29+
options = {}
30+
options[:clean] = false
31+
32+
opts = OptionParser.new do |o|
33+
o.banner = "Usage: vagrant setup-mirrors [vm-name]"
34+
o.separator ""
35+
end
36+
37+
# Parse the options
38+
argv = parse_options(opts)
39+
return if !argv
40+
41+
with_target_vms(argv, :reverse => true) do |machine|
42+
actions = Vagrant::Openshift::Action.setup_openshift_mirrors(options)
43+
@env.action_runner.run actions, {:machine => machine}
44+
0
45+
end
46+
end
47+
end
48+
end
49+
end
50+
end

lib/vagrant-openshift/plugin.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ class Plugin < Vagrant.plugin("2")
212212
Commands::RepoSyncOriginMetrics
213213
end
214214

215+
command "setup-openshift-mirrors" do
216+
require_relative "command/setup_mirrors"
217+
Commands::SetupMirrors
218+
end
219+
215220
provisioner(:openshift) do
216221
require_relative "provisioner"
217222
Provisioner

0 commit comments

Comments
 (0)