Sha256: 038c8a0c9a613901ae587669b7955699786e8d06489e55abe9a66cd6486e1898

Contents?: true

Size: 1.83 KB

Versions: 9

Compression:

Stored size: 1.83 KB

Contents

module Pvcglue
  class Packages
    def self.apply(package, context, nodes, user = 'deploy', package_filter = nil)
      # puts nodes.inspect
      orca_suite = OrcaSuite.init(package_filter)
      nodes.each do |node, data|
        orca_node = ::Orca::Node.new(node, data[:public_ip], {user: user, port: Pvcglue.cloud.port_in_context(context)})
        ::Pvcglue.cloud.current_node = {node => data}
        tries = 3
        begin
          begin
            orca_suite.run(orca_node.name, package.to_s, :apply)
          ensure
            ::Pvcglue.cloud.current_node = nil
            ::Pvcglue.cloud.current_hostname = nil
          end
        rescue
          tries -= 1
          if tries > 0
            retry
          else
            puts "\n"*10
            puts "*"*80
            puts "ERROR, retrying..."
            puts "*"*80
          end
        end
      end
    end
  end

  class OrcaSuite

    def self.init(package_filter)
      ::Orca.verbose(package_filter != 'manager') # show details for all packages except manager, for now

      # Load orca extensions
      orca_file = File.join(File.dirname(__FILE__), 'all_the_things.rb')
      ENV['ORCA_FILE'] = orca_file
      suite = ::Orca::Suite.new
      suite.load_file(orca_file)
      packages_loaded = []

      Dir[File.join(Pvcglue::gem_dir, 'lib', 'pvcglue', 'packages', '*.rb')].each do |file|
        # package filter is used to load the manager package by itself when stage is not specified
        next if package_filter && package_filter != File.basename(file, ".rb")
        begin
          suite.load_file(file)
        rescue Exception => e
          puts "Error loading #{file}:  #{e.message}"
          raise
        end
        packages_loaded << File.basename(file, ".rb")
      end
      puts "Packages loaded: #{packages_loaded.sort.join(' ')}."
      suite
    end
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
pvcglue-0.1.35 lib/pvcglue/packages.rb
pvcglue-0.1.34 lib/pvcglue/packages.rb
pvcglue-0.1.33 lib/pvcglue/packages.rb
pvcglue-0.1.32 lib/pvcglue/packages.rb
pvcglue-0.1.31 lib/pvcglue/packages.rb
pvcglue-0.1.30 lib/pvcglue/packages.rb
pvcglue-0.1.29 lib/pvcglue/packages.rb
pvcglue-0.1.28 lib/pvcglue/packages.rb
pvcglue-0.1.27 lib/pvcglue/packages.rb