rhc-common.rb

Path: lib/rhc-common.rb
Last Update: Mon Sep 10 18:15:31 -0400 2012

Required files

rubygems   fileutils   getoptlong   net/http   net/https   net/ssh   rhc/vendor/sshkey   resolv   uri   highline/import   rhc   rhc/rest   rhc/helpers   rhc/config   rhc/wizard   rhc/targz   rhc/json  

Methods

Public Class methods

Add a new namespace to configs

Public Instance methods

Public: Add or upload an ssh key

type - The String type RSA or DSS. command - The String value ‘add’ or ‘update’ identifier - The String value to identify the key pub_key_file_path - The String file path of the public key rhlogin - The String login to the broker password- The String password for the user

Examples

 generate_ssh_key_ruby('add', 'newkeyname', '~/.ssh/id_rsa',
                       'mylogin', 'mypass')
 # => /home/user/.ssh/id_rsa.pub

Returns nil on success or HTTP object on failure

Public: Generate an SSH key and store it in ~/.ssh/id_rsa

type - The String type RSA or DSS. bits - The Integer value for number of bits. comment - The String comment for the key

Examples

 generate_ssh_key_ruby()
 # => /home/user/.ssh/id_rsa.pub

Returns nil on failure or public key location as a String on success

Public: legacy convinience function for getting config keys

Public: Handle response message when updating keys

url - The Object URI::HTTPS data - The Hash representation of the data response password - The String password for the user

Examples

 handle_key_mgmt_response(
                 URI.parse('https://openshift.redhat.com/broker/ssh_keys'),
                 {
                   :rhlogin=>"rhnlogin@example.com",
                   :key_name=>"default",
                   :action=>"update-key",
                   :ssh=>"AAAAB3NzaC1yc2EAAAADAQABAAAAgQCrXG5c.....",
                   :key_type=>"ssh-rsa"},
                 'mypass')
 # => nil

Returns nil on Success and RHC::http object on failure

Public: Run ssh command on remote host

host - The String of the remote hostname to ssh to. username - The String username of the remote user to ssh as. command - The String command to run on the remote host.

Examples

 ssh_ruby('myapp-t.rhcloud.com',
           '109745632b514e9590aa802ec015b074',
           'rhcsh tail -f $OPENSHIFT_LOG_DIR/*"')
 # => true

Returns true on success

[Validate]