class SyncWrap::Qpid

Qpid AMQP broker provisioning. Currently this is RHEL (CentoOS, Amazon Linux) centric; it has not been ported to Debian.

Host component dependencies: RHEL

Attributes

boost_pkg[RW]

Distro package base name for boost. On Amazon Linux you may want to set this to “boost141”, depending on the qpid version. (Default: “boost”)

corosync_repo[RW]

Base HTTP url to corosync source repo.

corosync_version[RW]

Corosync version to build, isntall (Default: '1.4.4')

qpid_distro[RW]

Output package naming modifier, i.e. “amzn1”

qpid_repo[RW]

Base HTTP url to qpid source repo.

qpid_src_root[RW]

Root directory for src and build (Default: /tmp/src)

qpid_version[RW]

The qpidd version to build, install

Public Class Methods

new( opt = {} ) click to toggle source
Calls superclass method SyncWrap::Component.new
# File lib/syncwrap/components/qpid.rb, line 53
def initialize( opt = {} )
  @qpid_src_root = '/tmp/src'

  @qpid_version = '0.24'
  @qpid_repo = 'http://archive.us.apache.org/dist/qpid'
  # FIXME: Usable only for the newest builds
  # @qpid_repo = 'http://apache.osuosl.org/qpid'
  @qpid_distro = 'amzn1'

  @boost_pkg = 'boost'

  @corosync_version = '1.4.4'
  @corosync_repo = 'http://corosync.org/download'
  super
end

Public Instance Methods

corosync_install( opts = {} ) click to toggle source
# File lib/syncwrap/components/qpid.rb, line 126
def corosync_install( opts = {} )
  unless exist?( "/usr/sbin/corosync" )
    corosync_install!( opts )
  end
end
corosync_install!( opts = {} ) click to toggle source
# File lib/syncwrap/components/qpid.rb, line 132
def corosync_install!( opts = {} )
  corosync_build
  dist_install( "#{corosync_src}/x86_64/*.rpm" )
end
install() click to toggle source
# File lib/syncwrap/components/qpid.rb, line 69
def install
  unless distro.kind_of?( RHEL )
    raise ContextError, "#{distro.class} unsupported"
  end
  qpid_install
end
qpid_install() click to toggle source
# File lib/syncwrap/components/qpid.rb, line 76
def qpid_install
  unless test_qpidd_version
    qpid_install!
    qpid_install_init!
  end
  qpid_tools_install
  rput( 'usr/local/etc/qpidd.conf', user: :root )
end
qpid_install!() click to toggle source
# File lib/syncwrap/components/qpid.rb, line 121
def qpid_install!
  corosync_install!( devel: true )
  qpid_build
end
qpid_install_init!() click to toggle source
# File lib/syncwrap/components/qpid.rb, line 100
def qpid_install_init!
  sudo <<-SH
    if ! id qpidd >/dev/null 2>&1; then
      useradd -r qpidd
    fi
    mkdir -p /var/local/qpidd
    chown qpidd:qpidd /var/local/qpidd
  SH

  rput( 'etc/init.d/qpidd', user: :root )

  # Add to init.d
  dist_install_init_service( 'qpidd' )
end
qpid_tools_install() click to toggle source
# File lib/syncwrap/components/qpid.rb, line 115
def qpid_tools_install
  unless exist?( "/usr/bin/qpid-config" )
    qpid_tools_install!
  end
end
qpid_tools_install!() click to toggle source
# File lib/syncwrap/components/qpid.rb, line 137
def qpid_tools_install!
  dist_install( 'python-setuptools' )
  qpid_src = "#{qpid_src_root}/qpid-#{qpid_version}"

  sh <<-SH
    mkdir -p #{qpid_src_root}
    rm -rf #{qpid_src}
    cd #{qpid_src_root}
    curl -sSL #{qpid_tools_tarball} | tar -zxf -
  SH

  sudo <<-SH
    cd #{qpid_src}
    easy_install ./python ./tools ./extras/qmf
  SH
end
test_qpidd_version() click to toggle source
# File lib/syncwrap/components/qpid.rb, line 85
    def test_qpidd_version
      bin = "/usr/local/sbin/qpidd"
      code,_ = capture( "        if [ -x #{bin} ]; then
          ver=`#{bin} --version | grep -o -E '[0-9]+(\.[0-9]+)+$'`
          if [ "$ver" = "#{qpid_version}" ]; then
             exit 0
          fi
          exit 92
        fi
        exit 91
", accept[[0,91,92] )
      (code == 0)
    end

Protected Instance Methods

corosync_build() click to toggle source
# File lib/syncwrap/components/qpid.rb, line 206
def corosync_build
  qpid_install_build_deps
  corosync_install_build_deps

  sh <<-SH
    mkdir -p #{qpid_src_root}
    rm -rf #{corosync_src}
    cd #{qpid_src_root}
    curl -sSL #{corosync_repo}/corosync-#{corosync_version}.tar.gz | tar -zxf -
    cd #{corosync_src}
    ./autogen.sh #{redirect?}
    ./configure #{redirect?}
    make rpm #{redirect?}
  SH

end
corosync_install_build_deps() click to toggle source
# File lib/syncwrap/components/qpid.rb, line 230
def corosync_install_build_deps
  dist_install( %w[ nss-devel libibverbs-devel librdmacm-devel ] )
end
corosync_packages( include_devel = false ) click to toggle source
# File lib/syncwrap/components/qpid.rb, line 223
def corosync_packages( include_devel = false )
  packs = [ "corosync-#{corosync_version}-1.#{qpid_distro}.x86_64.rpm",
            "corosynclib-#{corosync_version}-1.#{qpid_distro}.x86_64.rpm" ]
  packs <<  "corosynclib-devel-#{corosync_version}-1.#{qpid_distro}.x86_64.rpm" if include_devel
  packs
end
corosync_src() click to toggle source
# File lib/syncwrap/components/qpid.rb, line 234
def corosync_src
  "#{qpid_src_root}/corosync-#{corosync_version}"
end
exist?( file ) click to toggle source
# File lib/syncwrap/components/qpid.rb, line 238
def exist?( file )
  code,_ = capture( "test -e #{file}", accept[[0,1] )
  (code == 0)
end
qpid_build() click to toggle source
# File lib/syncwrap/components/qpid.rb, line 156
def qpid_build
  qpid_install_build_deps
  qpid_install_deps

  qpid_src = "#{qpid_src_root}/qpidc-#{qpid_version}"

  sh <<-SH
    mkdir -p #{qpid_src_root}
    rm -rf #{qpid_src}
    cd #{qpid_src_root}
    curl -sSL #{qpid_src_tarball} | tar -zxf -
    cd #{qpid_src}
    ./configure --enable-deprecated-autotools #{redirect?}
    make #{redirect?}
  SH

  sudo <<-SH
    cd #{qpid_src}
    make install #{redirect?}
    make check #{redirect?}
    cd /usr/local
    rm -f /tmp/qpidc-#{qpid_version}-1-#{qpid_distro}-x64.tar.gz
    tar -zc \
         --exclude games --exclude lib64/perl5 --exclude src \
         --exclude share/man --exclude share/perl5 --exclude share/info \
         --exclude share/applications \
         -f /tmp/qpidc-#{qpid_version}-1-#{qpid_distro}-x64.tar.gz .
  SH
end
qpid_install_build_deps() click to toggle source
# File lib/syncwrap/components/qpid.rb, line 194
def qpid_install_build_deps
  dist_install( %w[ gcc gcc-c++ make autogen autoconf
                    help2man libtool pkgconfig rpm-build ] )
end
qpid_install_deps() click to toggle source
# File lib/syncwrap/components/qpid.rb, line 199
def qpid_install_deps
  dist_install( [ "#{boost_pkg}-devel" ] +
                %w[ nss-devel libuuid-devel swig
                    ruby-devel python-devel
                    cyrus-sasl-devel cyrus-sasl-plain cyrus-sasl-md5 ] )
end
qpid_src_tarball() click to toggle source
# File lib/syncwrap/components/qpid.rb, line 186
def qpid_src_tarball
  "#{qpid_repo}/#{qpid_version}/qpid-cpp-#{qpid_version}.tar.gz"
end
qpid_tools_tarball() click to toggle source
# File lib/syncwrap/components/qpid.rb, line 190
def qpid_tools_tarball
  "#{qpid_repo}/#{qpid_version}/qpid-#{qpid_version}.tar.gz"
end
redirect?() click to toggle source
# File lib/syncwrap/components/qpid.rb, line 243
def redirect?
  verbose? ? "" : ">/dev/null"
end