class Object

Public Instance Methods

check_cpath(opts) click to toggle source

Support funcs

# File lib/rhc-common.rb, line 803
def check_cpath(opts)
  if !opts["config"].nil?
    @opts_config_path = opts["config"]
    if !File.readable?(File.expand_path(@opts_config_path))
      puts "Could not open config file: #{@opts_config_path}"
      exit 253
    else
      begin
        @opts_config = ParseConfig.new(File.expand_path(@opts_config_path))
      rescue Errno::EACCES => e
        puts "Could not open config file (#{@opts_config_path}): #{e.message}"
        exit 253
      end
    end
  end
end
config() click to toggle source
# File lib/rhc-common.rb, line 824
def config
  return @opts_config ? @opts_config : @local_config
end
config_path() click to toggle source
# File lib/rhc-common.rb, line 820
def config_path
  return @opts_config_path ? @opts_config_path : @local_config_path
end
get_kfile(check_exists=true) click to toggle source
# File lib/rhc-common.rb, line 859
def get_kfile(check_exists=true)
  ssh_key_file = get_var('ssh_key_file')
  if ssh_key_file
    if (File.basename(ssh_key_file) == ssh_key_file)
      kfile = "#{ENV['HOME']}/.ssh/#{ssh_key_file}"
    else
      kfile = File.expand_path(ssh_key_file)
    end
  else
    kfile = "#{ENV['HOME']}/.ssh/libra_id_rsa"
  end
  if check_exists && !File.exists?(kfile)
    if ssh_key_file
      puts "WARNING: Unable to find '#{kfile}' referenced in express.conf."
      kfile_not_found
    else
      kfile = "#{ENV['HOME']}/.ssh/id_rsa"
      if !File.exists?(kfile)
        puts "WARNING: Unable to find ssh key file."
        kfile_not_found
      end
    end
  end
  return kfile
end
get_kpfile(kfile, check_exists=true) click to toggle source
# File lib/rhc-common.rb, line 885
def get_kpfile(kfile, check_exists=true)
  kpfile = kfile + '.pub'
  if check_exists && !File.exists?(kpfile)
    puts "WARNING: Unable to find '#{kpfile}'"
    kfile_not_found
  end
  return kpfile
end
get_var(var) click to toggle source

Check for local var in

0) --config path file
1) ~/.openshift/express.conf
2) /etc/openshift/express.conf
3) $GEM/../conf/express.conf
# File lib/rhc-common.rb, line 835
def get_var(var)
  v = nil
  if !@opts_config.nil? && @opts_config.get_value(var)
    v = @opts_config.get_value(var)
  else
    v = @local_config.get_value(var) ? @local_config.get_value(var) : @global_config.get_value(var)
  end
  v
end
kfile_not_found() click to toggle source
# File lib/rhc-common.rb, line 845
def kfile_not_found
  puts "Your SSH keys are created either by running ssh-keygen (password optional)
or by having the rhc-create-domain command do it for you.  If you created
them on your own (or want to use an existing keypair), be sure to paste
your public key into the express console at http://www.openshift.com.
The client tools use the value of 'ssh_key_file' in express.conf to find
your key followed by the defaults of libra_id_rsa[.pub] and then
id_rsa[.pub].
"

#exit 212
end