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)
Example #2
0
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)
def answers_file(ans_file):
    s_text = ['rhua.example.com', 'cds1.example.com', 'cds2.example.com']
    d_text = hosts_dns_name
    inpu_file = home_dir + ans_file
    for no in range(3):
        stext = s_text[no]
        dtext = d_text[no]
        rhui_lib.answers_replace(stext, dtext, inpu_file)  
       
    s_text = ['rhua.crt', 'cds1.crt', 'cds2.crt']
    d_text = ssl_certs
    for no in range(3):
        stext = s_text[no]
        dtext = d_text[no]
        rhui_lib.answers_replace(stext, dtext, inpu_file)
        
    print "\n\nWorking again with RHUA instance to upload the updated answers.sample file"
    p_file = home_dir + "/" + key_nam + ".pem"   
    for instance in reservation_rhua.instances:
        host_auto = instance.dns_name
        l_path = home_dir + ans_file
        f_path = "/root" + ans_file
        rhui_lib.putfile(host_auto, p_file, l_path, f_path)
        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)
        
run_distribute_file("/rhui20/host.sh")


#Putting all the required files in the instances
print "\n\nWorking with RHUA instance"
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)      
Example #5
0
        elif ARCH == 'x86_64':
            for hwp in hwp_x86_64:
                printValues(hwp)
                myConn = getConnection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, REGION)
                this_hostname = startInstance(myConn, hwp["name"], ARCH, RHEL, AMI, SSHKEYNAME)
                map = {"hostname":this_hostname,"hwp":hwp}
                publicDNS.append(map)

        lock = thread.allocate_lock()
#        print "sleep for 130 seconds"
#        time.sleep(130)
        print "Trying to fetch a file to make sure the SSH works, before proceeding ahead."
        f_path = "/tmp/network"
        l_path = "/etc/init.d/network"
        for host in publicDNS:
            keystat = rhui_lib.putfile(host["hostname"], SSHKEY, l_path, f_path)
            if not keystat:
                executeValidScript(SSHKEY, host["hostname"], host["hwp"], BID, ARCH, AMI, REGION, RHEL, SKIPLIST)
            else:
	            print "The Amazon node : "+host["hostname"]+" is not accessible, waited for 210 sec. Skipping and proceeding with the next Profile"
else:
    publicDNS = []
    if ARCH == 'i386':
        for hwp in hwp_i386:
            printValues(hwp)
            myConn = getConnection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, REGION)
            this_hostname = startInstance(myConn, hwp["name"], ARCH, RHEL, AMI, SSHKEYNAME)
            map = {"hostname":this_hostname,"hwp":hwp}
            publicDNS.append(map)
    elif ARCH == 'x86_64':
        for hwp in hwp_x86_64:
Example #6
0
        elif ARCH == 'x86_64':
            for hwp in hwp_x86_64:
                printValues(hwp)
                myConn = getConnection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, REGION)
                this_hostname = startInstance(myConn, hwp["name"], ARCH, RHEL, AMI, SSHKEYNAME)
                map = {"hostname":this_hostname,"hwp":hwp}
                publicDNS.append(map)

        lock = thread.allocate_lock()
#        print "sleep for 130 seconds"
#        time.sleep(130)
        print "Trying to fetch a file to make sure the SSH works, before proceeding ahead."
        f_path = "/tmp/network"
        l_path = "/etc/init.d/network"
        for host in publicDNS:
            keystat = rhui_lib.putfile(host["hostname"], SSHKEY, l_path, f_path)
            if not keystat:
                executeValidScript(SSHKEY, host["hostname"], host["hwp"], BID, ARCH, AMI, REGION, RHEL, SKIPLIST)
            else:
	            print "The Amazon node : "+host["hostname"]+" is not accessible, waited for 210 sec. Skipping and proceeding with the next Profile"
else:
    publicDNS = []
    if ARCH == 'i386':
        for hwp in hwp_i386:
            printValues(hwp)
            myConn = getConnection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, REGION)
            this_hostname = startInstance(myConn, hwp["name"], ARCH, RHEL, AMI, SSHKEYNAME)
            map = {"hostname":this_hostname,"hwp":hwp}
            publicDNS.append(map)
    elif ARCH == 'x86_64':
        for hwp in hwp_x86_64: