def run_distribute_file(dist_file):
    p_file = home_dir + "/" + key_nam + ".pem"
    s_text = ['root@cds1', 'root@cds2']
    d_text = hosts_dns1_name
    inpu_file = home_dir + dist_file
    for no in range(2):
        stext = s_text[no]
        dtext = d_text[no]
        rhui_lib.answers_replace(stext, dtext, inpu_file)  
        
    s_text = ['root@rhua']
    d_text = hosts_dns2_name
    inpu_file = home_dir + dist_file
    for no in range(1):
        stext = s_text[no]
        dtext = d_text[no]
        rhui_lib.answers_replace(stext, dtext, inpu_file)  
       
    stext = "cloud_key"
    dtext = "/root/" + key_nam + ".pem"
    rhui_lib.answers_replace(stext, dtext, inpu_file)
        
    print "\n\nWorking again with RHUA instance to upload the updated", inpu_file, " file"   
    for instance in reservation_rhua.instances:
        host_auto = instance.dns_name
        command = 'mkdir -p /root/rhui20'
        print "\nInstalling various rpms: \n", command
        rhui_lib.remote_exe(host_auto, p_file, command)
        l_path = home_dir + dist_file
        f_path = "/root" + dist_file
        rhui_lib.putfile(host_auto, p_file, l_path, f_path)
def call_remote (PUB, KNAM, SRC, DES, CMD):
    if args.put_files:
        rhui_lib.putfile(PUB, KNAM, SRC, DES)
    if args.get_files:
        rhui_lib.getfile(PUB, KNAM, SRC, DES)
    if args.execute:
        rhui_lib.remote_exe(PUB, KNAM, CMD)
for instance in reservation_rhua.instances:
    host_auto = instance.dns_name
    l_path = home_dir + "/rhui20/pulp_setup.tar"
    f_path = "/root/pulp_setup.tar"
    rhui_lib.putfile(host_auto, p_file, l_path, f_path)
    l_path = home_dir + "/rhui20/qpid_cert_gen.sh"
    f_path = "/root/qpid_cert_gen.sh"
    rhui_lib.putfile(host_auto, p_file, l_path, f_path)
#For security reasons avoid transfering your private key to the host, 
#if transfered for any reasons **DO NOT** enable password authentication.
    l_path = p_file
    f_path = "/root/" + key_nam + ".pem"
    rhui_lib.putfile(host_auto, p_file, l_path, f_path)
    command = "chmod 600 /root/" + key_nam + ".pem"
    print "\nChange key Permissions : \n", command
    rhui_lib.remote_exe(host_auto, p_file, command)

    l_path = home_dir + "/rhui20/hostname.sh"
    f_path = "/root/hostname.sh"
    rhui_lib.putfile(host_auto, p_file, l_path, f_path)      
    l_path = home_dir + "/rhui20/gen_certs.tar"
    f_path = "/root/gen_certs.tar"
    rhui_lib.putfile(host_auto, p_file, l_path, f_path)  
    l_path = home_dir + "/rhui20/rhui20-iso.tar"
    f_path = "/root/rhui20-iso.tar"
    rhui_lib.putfile(host_auto, p_file, l_path, f_path)  
    #Connecting to the rhua instance and formatting the devices (e.g : /dev/sdf)
    command = 'tar -xvf /root/pulp_setup.tar ; tar -xvf /root/gen_certs.tar ; tar -xvf /root/rhui20-iso.tar ; iptables -F'
    print "\nUntaring the Pulp tar files : \n", command
    rhui_lib.remote_exe(host_auto, p_file, command)
#    command = '/bin/rpm -Uvh http://download.fedora.redhat.com/pub/epel/beta/6/i386/epel-release-6-5.noarch.rpm'