def test_getAWSMachines(): print("\n---test_getAWSMachines---") machines = util.getAWSMachines(machine_type='t2.micro') print(f"Current t2.micro Machines:") print(json.dumps(machines, indent=4, default=str)) machines = util.getAWSMachines(machine_type='*', location='us-east-1') print(f"All Current Machines:") print(json.dumps(machines, indent=4, default=str)) machines = util.getAWSMachines(machine_type='p2.xlarge', location='us-east-1') print(f"p2.xlarge Current Machines:") print(json.dumps(machines, indent=4, default=str))
def runTasks(self): global task_files_full_path # Determine the DNS for all the machine that we have, default to us-east-1 and p2.xlarge self.available_machines = util.getAWSMachines() self.log.info(f"Machines available {self.available_machines}") # Get all the tasks files task_files_full_path = [ path.abspath(join(TASK_FILE_PATH, f)) for f in listdir(TASK_FILE_PATH) if isfile(join(TASK_FILE_PATH, f)) ] self.log.info(f"Number of tasks: {len(task_files_full_path)}") # Create a thread for each machine threads = [] for machine in self.available_machines: processThread = threading.Thread(target=self.runThreadOnEC2Machine, args=(machine, )) processThread.start() threads.append(processThread) # Wait for them all to finish for thread in threads: thread.join() self.log.info("Ending runtasks")
def runCheckXorg(self): self.available_machines = util.getAWSMachines() self.log.info(f"Machines available {self.available_machines}") for machine in self.available_machines: bs = BaselineCheckXorg(machine, self.log) bs.process()
def getFirstMachine(): machines = util.getAWSMachines(machine_type='*', location='*') machines.sort() if len(machines) > 0: return machines[0]