import subprocess from utils import CommandRunner cr = CommandRunner() print """#####################install ceilometer##################""" if cr.ask_run_section("run install ceilometer? (delete existing, reclone, switch, branch, and python setup): "): #delete ceilometer cr.run_command("Delete the /opt/stack/ceilometer folder? ([y]/n): ", "Deleting ceilometer folder...", "sudo rm -rf ceilometer", "/opt/stack/", "Done removing ceilometer folder") #clone ceilometer cr.run_command("clone ceilometer for github eric's repo? ([y]/n): ", "Start clone:", "git clone https://github.com/jyericlin/ceilometer.git", "/opt/stack", "Done clone" ) cr.run_command("Change ceilo branch: ", "Changing", "git checkout devel", "/opt/stack/ceilometer", "Done changing branch") cr.run_command("Install ceilometer: ", "Start install", "sudo python setup.py install", "/opt/stack/ceilometer", "Done install") cr.run_command("Install ceilometer devel: ", "Start install devel", "sudo python setup.py develop", "/opt/stack/ceilometer", "Done install") print """##################install ceilometer client#######################""" if cr.ask_run_section('run install ceilometer client? (delete existing, reclone, switch branch, and python setup)'): cr.run_command("Delete the /opt/stack/python-ceilometerclient folder? ([y]/n): ", "Deleting ceilometer client folder...", "sudo rm -rf python-ceilometerclient", "/opt/stack/", "Done removing ceilometer client folder") cr.run_command("clone ceilometer client for github eric's repo? ([y]/n): ", "Start clone:", "git clone https://github.com/jyericlin/python-ceilometerclient.git", "/opt/stack", "Done clone" ) cr.run_command("Change ceilo client branch: ", "Changing", "git checkout s-havana", "/opt/stack/python-ceilometerclient", "Done changing branch") cr.run_command("Install ceilometer client: ", "Start install", "sudo python setup.py install", "/opt/stack/python-ceilometerclient", "Done install")
def check_file_exist(path, filename): cm = CommandRunner() file_exist, err = cm.run_shell_command_return('ls -l ' + os.path.join(path, filename), "checking if " + filename + " exist") if not file_exist: raise Exception(filename + " does not exist!")
def exerciser1and2(machines): # Exerciser 1 print("") print(SEPARATOR) print("Exerciser 1: This is a basic exercise that checks if your programs starts properly and run with no failure") print(SEPARATOR) if len(machines)<1: raise Exception(GENERAL_ERROR + "At least one execution machine should be provided for exerciser 1") exe_machine = machines[0] cm = CommandRunner() p_zk = cm.run_shell_command('~/myzk/bin/zkServer.sh start') p_fs = cm.run_shell_command('./start_fileserver.sh ' + exe_machine + ' ' + str(ZOOKEEPER_PORT)) p_jb = cm.run_shell_command('./start_jobtracker.sh ' + exe_machine + ' ' + str(ZOOKEEPER_PORT)) p_w1 = cm.run_shell_command('./start_worker.sh ' + exe_machine + ' ' + str(ZOOKEEPER_PORT)) p_w2 = cm.run_shell_command('./start_worker.sh ' + exe_machine + ' ' + str(ZOOKEEPER_PORT)) print("File server running on process number: " + str(p_fs.pid)) print("Job tracker running on process number: " + str(p_jb.pid)) print("Worker 1 running on process number: " + str(p_w1.pid)) print("Worker 2 running on process number: " + str(p_w2.pid)) p_zk.wait() print("Zookeeper started running on port: " + str(ZOOKEEPER_PORT)) time.sleep(2) check_process_running(p_fs, "File Server") check_process_running(p_jb, "Job Tracker") check_process_running(p_w1, "Worker 1") check_process_running(p_w2, "Worker 2") print("Exerciser 1: PASS") # Exerciser 2 print("") print(SEPARATOR) print("Exerciser 2: This exerciser submits a job to your cluster and check the result") print(SEPARATOR) in_progress_pattern = re.compile('In progress') success_pattern = re.compile('Password found:.*') failure_pattern = re.compile('Failed:.*') hashcode = '755f85c2723bb39381c7379a604160d8' password = '******' print("Submitting job to find password for hashcode: " + hashcode) submit_result, submit_error = cm.run_shell_command_return('./submit_job.sh ' + exe_machine + ' ' + str(ZOOKEEPER_PORT) + ' ' + hashcode) print("submit result: " + submit_result) print("Getting status of the submitted job...") while (True): status_result, status_error = cm.run_shell_command_return('./check_job_status.sh ' + exe_machine + ' ' + str(ZOOKEEPER_PORT) + ' ' + hashcode) print("Current Status is: " + status_result) if in_progress_pattern.match(status_result): print('Job running in progress') elif success_pattern.match(status_result): password_found = status_result.split(':') if len(password_found)<2: raise('Incorrect format for message when password found. Expecting: "Password found: {password here}" ' 'without the braces') else: password_found = password_found[1].strip(' \t\n') if password_found != password: raise Exception('Incorrect password found: The password you found is ' + password_found + ', the expected password is ' + password) else: print("successfully found password") break elif failure_pattern.match(status_result): reason = status_result.split(':') if len(reason < 2): raise Exception('Incorrect format for message when failed to find password. Expecting: "Failed: ' + FAIL_PASSWORD_NO_FOUND + '"') else: reason = reason[1].strip() if reason == FAIL_PASSWORD_NO_FOUND: raise Exception("Failed to find password: hash code" + hashcode + " is corresponding to password " + password) break else: raise Exception("Message with incorrect format printed by client driver. Please refer to the handout for format.") time.sleep(1) print("End of exerciser 2")
import subprocess import datetime from utils import CommandRunner import re import time import smtplib import os from random import randrange from utils import CommandRunner #subprocess.Popen("env > /tmp/env.output"+str(randrange(500)), shell=True) cr = CommandRunner() #check = cr.run_command("env | grep OS_REGION_NAME","done check") #print "check['output'] is: %s"% check['output'] #subprocess.Popen(str(check['output'])+" > /tmp/env.output"+str(randrange(500)), shell=True) region_name = os.environ['OS_REGION_NAME'].rstrip() print "Performing Ceilometed Tests for Region: "+str(region_name) #subprocess.Popen("echo "+region_name+" > /tmp/env.output"+str(randrange(500)), shell=True) start_time = time.time() """ ************************* Ceilometer Metering API commands ************************************ """