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

Commit

Permalink
add setup-mirrors command
Browse files Browse the repository at this point in the history
  • Loading branch information
mfojtik committed Oct 13, 2016
1 parent 19fc161 commit b205367
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/vagrant-openshift/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ def self.build_origin(options)
end
end

def self.setup_openshift_mirrors(options)
Vagrant::Action::Builder.new.tap do |b|
b.use SetupOpenShiftMirrors, options
end
end

def self.push_openshift_images(options)
Vagrant::Action::Builder.new.tap do |b|
b.use PushOpenshiftImages, options
Expand Down Expand Up @@ -374,6 +380,7 @@ def self.install_rhc(options)
autoload :BuildOriginRpmTest, action_root.join("build_origin_rpm_test")
autoload :CreateLocalYumRepo, action_root.join("create_local_yum_repo")
autoload :BuildOriginImages, action_root.join("build_origin_images")
autoload :SetupOpenShiftMirrors, action_root.join("setup_openshift_mirrors")
end
end
end
47 changes: 47 additions & 0 deletions lib/vagrant-openshift/action/setup_openshift_mirrors.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#--
# Copyright 2014 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#++

module Vagrant
module Openshift
module Action
class SetupOpenShiftMirrors
include CommandHelper

def initialize(app, env, options)
@app = app
@env = env
@options = options
end

def call(env)
do_execute(env[:machine], %{
echo "Setting up 'mirror.openshift.com' for EPEL ..."
set -e
rm -f /tmp/epel-mirror.repo /tmp/set-build-image-args.sh
curl -s https://mirror.openshift.com/mirror/epel/epel7.repo | sed "s/^\\[epel/[epel-openshift/" > /tmp/epel-mirror.repo
echo 'export OS_BUILD_IMAGE_ARGS="--mount /etc/yum.repos.d/epel-mirror.repo:/etc/yum.repos.d/epel.repo"' > /tmp/set-build-image-args.sh
sudo mv /tmp/epel-mirror.repo /etc/yum.repos.d/epel-mirror.repo
sudo mv /tmp/set-build-image-args.sh /etc/profile.d/set-build-image-args.sh
},
{ :timeout => 60*60*2, :verbose => false })
@app.call(env)
end

end
end
end
end
50 changes: 50 additions & 0 deletions lib/vagrant-openshift/command/setup_mirrors.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#--
# Copyright 2013 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#++
require_relative "../action"

module Vagrant
module Openshift
module Commands
class SetupMirrors < Vagrant.plugin(2, :command)
include CommandHelper

def self.synopsis
"setup OpenShift repository mirrors"
end

def execute
options = {}
options[:clean] = false

opts = OptionParser.new do |o|
o.banner = "Usage: vagrant setup-mirrors [vm-name]"
o.separator ""
end

# Parse the options
argv = parse_options(opts)
return if !argv

with_target_vms(argv, :reverse => true) do |machine|
actions = Vagrant::Openshift::Action.setup_openshift_mirrors(options)
@env.action_runner.run actions, {:machine => machine}
0
end
end
end
end
end
end
5 changes: 5 additions & 0 deletions lib/vagrant-openshift/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ class Plugin < Vagrant.plugin("2")
Commands::RepoSyncOriginMetrics
end

command "setup-openshift-mirrors" do
require_relative "command/setup_mirrors"
Commands::SetupMirrors
end

provisioner(:openshift) do
require_relative "provisioner"
Provisioner
Expand Down

0 comments on commit b205367

Please sign in to comment.