module Pvcglue

TODO: Set up a maintenance mode page and command to allow the message to be changed without a redeploy, like if Amazon S3 goes down…

TODO: Refactor this, it's kinda messy :(

Example for '~/.pvcglue.toml':

cloud_manager = "nnn.nnn.nnn.nnn"

Constants

VERSION

Public Class Methods

cloud() click to toggle source
# File lib/pvcglue/cloud.rb, line 598
def self.cloud
  @cloud ||= Cloud.new
end
cloud=(config) click to toggle source
# File lib/pvcglue/cloud.rb, line 602
def self.cloud=(config)
  @cloud = config
end
configuration() click to toggle source

# File lib/pvcglue/configuration.rb, line 248
def self.configuration
  @configuration ||= Configuration.new
end
configuration=(config) click to toggle source
# File lib/pvcglue/configuration.rb, line 252
def self.configuration=(config)
  @configuration = config
end
configure() { |configuration| ... } click to toggle source
# File lib/pvcglue/configuration.rb, line 256
def self.configure
  yield configuration
end
filter_verbose() { || ... } click to toggle source
# File lib/pvcglue.rb, line 174
def self.filter_verbose
  @filtering_verbose = true
  begin
    yield
  ensure
    @filtering_verbose = false
  end
end
gem_dir() click to toggle source
# File lib/pvcglue.rb, line 187
def self.gem_dir
  Gem::Specification.find_by_name('pvcglue').gem_dir
end
render_template(template, file_name = nil) click to toggle source
# File lib/pvcglue.rb, line 197
def self.render_template(template, file_name = nil)
  # puts '-'*80
  # puts "---> render_template(template=#{template}, file_name=#{file_name}"
  # Pvcglue.logger.debug { "render_template(template=#{template}, file_name=#{file_name}" }
  Pvcglue.logger.debug { "render_template(template_file_name=#{Pvcglue.template_file_name(template)}" }
  data = Tilt.new(Pvcglue.template_file_name(template)).render
  if file_name
    File.write(file_name, data)
  end
  data
end
reset_minion_state?() click to toggle source
# File lib/pvcglue.rb, line 183
def self.reset_minion_state?
  !!Pvcglue.command_line_options[:rebuild]
end
run_remote(host, port, user, cmd) click to toggle source
# File lib/pvcglue.rb, line 209
def self.run_remote(host, port, user, cmd)
  cmd = "ssh -p #{port} #{user}@#{host} '#{cmd}'"
  # puts "Running `#{cmd}`"

  unless system cmd
    raise("Error:  #{$?}")
  end
  true
end
system_get_stdout(cmd, raise_error = false) click to toggle source
# File lib/pvcglue.rb, line 219
def self.system_get_stdout(cmd, raise_error = false)
  Pvcglue.logger.debug { cmd }
  result = `#{cmd}`
  Pvcglue.verbose? { result }
  Pvcglue.logger.debug { "exit_code=#{$?.to_i}" }
  raise($?.inspect) if raise_error && $?.to_i != 0
  result
end
template_file_name(template) click to toggle source
# File lib/pvcglue.rb, line 191
def self.template_file_name(template)
  override = File.join(Pvcglue.configuration.template_override_dir, template)
  return override if File.exists?(override)
  File.join(Pvcglue::gem_dir, 'lib', 'pvcglue', 'templates', template)
end
verbose?() { || ... } click to toggle source
# File lib/pvcglue.rb, line 167
def self.verbose?
  return if @filtering_verbose
  if Pvcglue.command_line_options[:verbose]
    puts yield
  end
end