diff --git a/lib/vagrant-openshift/action.rb b/lib/vagrant-openshift/action.rb index 153b403d..e20a9119 100644 --- a/lib/vagrant-openshift/action.rb +++ b/lib/vagrant-openshift/action.rb @@ -51,9 +51,14 @@ def self.repo_sync(options) end end - b.use SyncLocalRepository if options[:local_source] + if options[:local_source] + b.use SyncLocalRepository + else + b.use SyncUpstreamRepository + end b.use CheckoutRepositories b.use InstallOpenShiftDependencies if options[:deps] + b.use UninstallOpenShiftRpms if options[:clean] b.use BuildSources unless options[:no_build] end end @@ -76,6 +81,7 @@ def self.run_tests(options) action_root = Pathname.new(File.expand_path("../action", __FILE__)) autoload :Clean, action_root.join("clean") + autoload :UninstallOpenShiftRpms, action_root.join("uninstall_openshift_rpms") autoload :CloneUpstreamRepositories, action_root.join("clone_upstream_repositories") autoload :CreateYumRepositories, action_root.join("create_yum_repositories") autoload :CreatePuppetFile, action_root.join("create_puppet_file") @@ -88,6 +94,7 @@ def self.run_tests(options) autoload :InstallBuildDependencies, action_root.join("install_build_dependencies") autoload :PrepareSshConfig, action_root.join("prepare_ssh_config") autoload :SyncLocalRepository, action_root.join("sync_local_repository") + autoload :SyncUpstreamRepository, action_root.join("sync_upstream_repository") autoload :BuildSources, action_root.join("build_sources") autoload :LocalRepoCheckout, action_root.join("local_repo_checkout") autoload :CreateBareRepoPlaceholders, action_root.join("create_bare_repo_placeholders") diff --git a/lib/vagrant-openshift/action/build_sources.rb b/lib/vagrant-openshift/action/build_sources.rb index ba448697..2e682259 100644 --- a/lib/vagrant-openshift/action/build_sources.rb +++ b/lib/vagrant-openshift/action/build_sources.rb @@ -27,6 +27,8 @@ def initialize(app, env) def call(env) is_fedora = env[:machine].communicate.test("test -e /etc/fedora-release") + hostname = env[:machine].config.vm.hostname + sudo(env[:machine],"echo #{hostname} > /proc/sys/kernel/hostname") sudo(env[:machine], "cd #{Constants.build_dir + "builder"}; #{scl_wrapper(is_fedora,'rake update_packages')}", {timeout: 60*30}) @app.call(env) diff --git a/lib/vagrant-openshift/action/clean.rb b/lib/vagrant-openshift/action/clean.rb index bf2b5494..f9e21004 100644 --- a/lib/vagrant-openshift/action/clean.rb +++ b/lib/vagrant-openshift/action/clean.rb @@ -31,15 +31,17 @@ def call(env) git_clone_commands = "" Constants.repos.each do |repo_name, url| bare_repo_name = repo_name + "-bare" + wc_repo_name = repo_name + "-bare-working_copy" bare_repo_path = Constants.build_dir + bare_repo_name + repo_path = Constants.build_dir + repo_name + wc_repo_path = Constants.build_dir + wc_repo_name + git_clone_commands += "rm -rf #{bare_repo_path}; \n" end do_execute env[:machine], git_clone_commands sudo env[:machine], "rm -rf /etc/yum.repos.d/openshift-origin.repo" sudo env[:machine], "rm -rf /var/cache/yum/x86_64/19/openshift-origin" #clear openshift package cache - sudo env[:machine], "cd #{Constants.build_dir + "builder; #{scl_wrapper(is_fedora,'rake clean_rpms')}"}" - sudo env[:machine], "rm -rf #{Constants.build_dir + "origin-rpms"} #{Constants.build_dir + ".built_packages"} #{Constants.build_dir + ".spec_cache"}" @app.call(env) end end diff --git a/lib/vagrant-openshift/action/create_yum_repositories.rb b/lib/vagrant-openshift/action/create_yum_repositories.rb index f0a7a111..5dbbb1b7 100644 --- a/lib/vagrant-openshift/action/create_yum_repositories.rb +++ b/lib/vagrant-openshift/action/create_yum_repositories.rb @@ -29,13 +29,14 @@ def call(env) is_fedora = env[:machine].communicate.test("test -e /etc/fedora-release") unless is_fedora - sudo env[:machine], "yum install -y http://mirror.pnl.gov/epel/6/i386/epel-release-6-8.noarch.rpm" - remote_write(env[:machine], "/etc/yum.repos.d/epel.repo") { - %{ + unless env[:machine].communicate.test("rpm -q epel-release") + sudo env[:machine], "yum install -y http://mirror.pnl.gov/epel/6/i386/epel-release-6-8.noarch.rpm" + remote_write(env[:machine], "/etc/yum.repos.d/epel.repo") { + %{ [epel] name=Extra Packages for Enterprise Linux 6 - $basearch #baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch -mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch +mirrorlist=http://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch exclude=*passenger* nodejs* failovermethod=priority enabled=1 @@ -61,8 +62,9 @@ def call(env) enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 gpgcheck=1 - } - } + } + } + end remote_write(env[:machine], "/etc/yum.repos.d/puppet.repo") { %{[puppet] diff --git a/lib/vagrant-openshift/action/preserve_mcollective_logs.rb b/lib/vagrant-openshift/action/preserve_mcollective_logs.rb index 32b3cb0e..a8a109f7 100644 --- a/lib/vagrant-openshift/action/preserve_mcollective_logs.rb +++ b/lib/vagrant-openshift/action/preserve_mcollective_logs.rb @@ -29,7 +29,12 @@ def call(env) unless env[:machine].communicate.test("grep 'keeplogs=9999' /etc/mcollective/server.cfg") env[:machine].ui.info "Keep all mcollective logs on remote instance" sudo(env[:machine], "echo keeplogs=9999 >> /etc/mcollective/server.cfg") - sudo(env[:machine], "/sbin/service mcollective restart") + is_fedora = env[:machine].communicate.test("test -e /etc/fedora-release") + if is_fedora + sudo(env[:machine], "/sbin/service mcollective restart") + else + sudo(env[:machine], "/sbin/service ruby193-mcollective restart") + end end @app.call(env) diff --git a/lib/vagrant-openshift/action/sync_upstream_repository.rb b/lib/vagrant-openshift/action/sync_upstream_repository.rb new file mode 100644 index 00000000..a21249bb --- /dev/null +++ b/lib/vagrant-openshift/action/sync_upstream_repository.rb @@ -0,0 +1,67 @@ +#-- +# 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. +#++ + +module Vagrant + module Openshift + module Action + class SyncUpstreamRepository + include CommandHelper + + def initialize(app, env) + @app = app + @env = env + end + + def call(env) + env[:machine].env.ui.info("Sync'ing upstream sources\n") + + Constants.repos.each do |repo_name, url| + sync_repo(env[:machine], repo_name, url) + end + env[:machine].env.ui.info("Done") + + @app.call(env) + end + + private + + def sync_repo(machine, repo_name, url, branch="master") + bare_repo_name = repo_name + "-bare" + bare_repo_wc_name = repo_name + "-bare-working_copy" + bare_repo_path = Constants.build_dir + bare_repo_name + bare_repo_wc_path = Constants.build_dir + bare_repo_wc_name + + command = "" + command += "export GIT_SSH=#{Constants.git_ssh};\n" unless Constants.git_ssh.nil? or Constants.git_ssh.empty? + command += %{ + +if [ ! -d #{bare_repo_wc_path} ]; then + git clone -l #{bare_repo_path} #{bare_repo_wc_path}; +fi; + +cd #{bare_repo_wc_path}; +git remote add upstream #{url}; +git fetch upstream; +git checkout master; +git reset --hard upstream/#{branch}; +git push origin master -f; +} + do_execute(machine, command) + end + end + end + end +end \ No newline at end of file diff --git a/lib/vagrant-openshift/action/uninstall_openshift_rpms.rb b/lib/vagrant-openshift/action/uninstall_openshift_rpms.rb new file mode 100644 index 00000000..7b83a9f9 --- /dev/null +++ b/lib/vagrant-openshift/action/uninstall_openshift_rpms.rb @@ -0,0 +1,37 @@ +#-- +# 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. +#++ + +module Vagrant + module Openshift + module Action + class UninstallOpenShiftRpms + include CommandHelper + + def initialize(app, env) + @app = app + @env = env + end + + def call(env) + is_fedora = env[:machine].communicate.test("test -e /etc/fedora-release") + sudo env[:machine], "cd #{Constants.build_dir + "builder; #{scl_wrapper(is_fedora,'rake clean_rpms')}"}" + sudo env[:machine], "rm -rf #{Constants.build_dir + "origin-rpms"} #{Constants.build_dir + ".built_packages"} #{Constants.build_dir + ".spec_cache"}" + @app.call(env) + end + end + end + end +end \ No newline at end of file diff --git a/lib/vagrant-openshift/constants.rb b/lib/vagrant-openshift/constants.rb index 7843655d..670e94d1 100644 --- a/lib/vagrant-openshift/constants.rb +++ b/lib/vagrant-openshift/constants.rb @@ -38,10 +38,17 @@ def self.git_ssh "" end - def self.restart_services_cmd - services = [ 'mongod', 'mcollective', 'activemq', 'cgconfig', 'cgred', 'named', + def self.restart_services_cmd(is_fedora) + services = [ 'mongod', 'activemq', 'cgconfig', 'cgred', 'named', 'openshift-broker', 'openshift-console', 'openshift-node-web-proxy', 'sshd', 'httpd' ] + + if(is_fedora) + services << 'mcollective' + else + services << 'ruby193-mcollective' + end + cmd = [] cmd += services.map do |service| "/sbin/service #{service} stop;" @@ -51,7 +58,7 @@ def self.restart_services_cmd end cmd << "rm -rf /var/www/openshift/broker/tmp/cache/*;" cmd << "/etc/cron.minutely/openshift-facts;" - cmd << "/sbin/service openshift-tc reload;" + cmd << "/sbin/service openshift-tc start || /sbin/service openshift-tc reload;" cmd << "/sbin/service network restart || /sbin/service network reload;" cmd << "/sbin/service messagebus restart;" cmd << "/sbin/service oddjobd restart;" diff --git a/lib/vagrant-openshift/helper/command_helper.rb b/lib/vagrant-openshift/helper/command_helper.rb index c5b32b0e..b7bfb144 100644 --- a/lib/vagrant-openshift/helper/command_helper.rb +++ b/lib/vagrant-openshift/helper/command_helper.rb @@ -63,6 +63,7 @@ def do_execute(machine, command) stderr = [] rc = -1 + machine.env.ui.info "Running command '#{command}'" rc = machine.communicate.execute(command) do |type, data| if [:stderr, :stdout].include?(type) if type == :stdout diff --git a/lib/vagrant-openshift/provisioner.rb b/lib/vagrant-openshift/provisioner.rb index 69f63f54..0cf75a29 100644 --- a/lib/vagrant-openshift/provisioner.rb +++ b/lib/vagrant-openshift/provisioner.rb @@ -43,8 +43,12 @@ def provision #reapply puppet configuration so that IPs and ifcfg-* file is correct if @machine.communicate.test("test -d /etc/openshift") @machine.ui.info("Reapplying puppet script to update changed IP values") + hostname = @machine.config.vm.hostname + sudo(machine,"echo #{hostname} > /proc/sys/kernel/hostname") sudo(machine,"puppet apply --verbose #{Vagrant::Openshift::Constants.build_dir + 'configure_origin.pp'}") - sudo(machine,Constants.restart_services_cmd.join("\n")) + is_fedora = @machine.communicate.test("test -e /etc/fedora-release") + + sudo(machine,Constants.restart_services_cmd(is_fedora).join("\n")) if @machine.config.openshift.additional_services.size > 0 cmd = "" @machine.config.openshift.additional_services.each do |service| @@ -63,4 +67,4 @@ def provision end end end -end \ No newline at end of file +end diff --git a/lib/vagrant-openshift/templates/builder/Rakefile b/lib/vagrant-openshift/templates/builder/Rakefile index 8ddd0ac5..b833a291 100644 --- a/lib/vagrant-openshift/templates/builder/Rakefile +++ b/lib/vagrant-openshift/templates/builder/Rakefile @@ -90,7 +90,8 @@ task :update_packages do end task :restart_services do - system(Vagrant::Openshift::Constants.restart_services_cmd.join("\n")) + is_fedora=File.exists?("/etc/fedora-release") + system(Vagrant::Openshift::Constants.restart_services_cmd(is_fedora).join("\n")) cmd = "" OPTIONS[:additional_services].each do |service| cmd += "service #{service} restart;" diff --git a/lib/vagrant-openshift/templates/builder/lib/test.rb b/lib/vagrant-openshift/templates/builder/lib/test.rb index 9d4369d0..44a6190e 100644 --- a/lib/vagrant-openshift/templates/builder/lib/test.rb +++ b/lib/vagrant-openshift/templates/builder/lib/test.rb @@ -352,12 +352,19 @@ def idle_all_gears is_fedora = system("test -e /etc/fedora-release") print "Idling all gears on remote instance\n" - system('/sbin/service mcollective stop; /sbin/service mcollective start; /sbin/service openshift-port-proxy restart;') + + if is_fedora + system('/sbin/service mcollective stop; /sbin/service mcollective start; /sbin/service openshift-port-proxy restart;') + else + system('/sbin/service ruby193-mcollective stop; /sbin/service ruby193-mcollective start; /sbin/service openshift-port-proxy restart;') + end + system(%{ for gear in `oo-admin-ctl-gears list`; do oo-admin-ctl-gears idlegear $gear; done; }) + if is_fedora system('/sbin/service httpd reload') else diff --git a/lib/vagrant-openshift/templates/command/init-openshift/Vagrantfile.erb b/lib/vagrant-openshift/templates/command/init-openshift/Vagrantfile.erb index 5ba0f2b1..b37feba2 100644 --- a/lib/vagrant-openshift/templates/command/init-openshift/Vagrantfile.erb +++ b/lib/vagrant-openshift/templates/command/init-openshift/Vagrantfile.erb @@ -115,6 +115,7 @@ runcmd: 'rubygem-openshift-origin-container-libvirt', 'openshift-origin-cartridge-jbosseap', 'openshift-origin-cartridge-jbossews', + 'openshift-origin-cartridge-jbossas', 'avahi-cname-manager', 'rubygem-openshift-origin-dns-avahi', diff --git a/lib/vagrant-openshift/version.rb b/lib/vagrant-openshift/version.rb index 31017ca4..d545a4df 100644 --- a/lib/vagrant-openshift/version.rb +++ b/lib/vagrant-openshift/version.rb @@ -16,6 +16,6 @@ module Vagrant module Openshift - VERSION = "0.0.2" + VERSION = "0.0.3" end end