Example #1
0
 def download_remote(self):
     self.append_log("Download remote results initiated")        
     try:
         ServerInterface().download_results_simjob(self)
     except Exception as e:
         self.append_log("Couldn't download the files: " + e)
     return
Example #2
0
 def update(self, nsg_job_list=None, ssh_connection=None):
     if self.status == ServerInterface.ssh_status[0] or self.status == ServerInterface.nsg_status[0]:
         
         ServerInterface().update_for_completion(self,nsg_job_list=nsg_job_list,ssh_connection=ssh_connection)
         ServerInterface().download_status_simjob(self,nsg_job_list=nsg_job_list,ssh_connection=ssh_connection)
         self.sim_last_update_time = time.time()
         self.write_properties()
         
     if self.status == ServerInterface.ssh_status[1] or self.status == ServerInterface.nsg_status[1]:
         ServerInterface().download_results_simjob(self,nsg_job_list=nsg_job_list,ssh_connection=ssh_connection)
         #ServerInterface().download_status_simjob(self,nsg_job_list=nsg_job_list,ssh_connection=ssh_connection)#We would have just called download status before previous call
         self.sim_last_update_time = time.time()
         self.write_properties()
     
     
     return
Example #3
0
 def run(self):
     self.append_log("Run initiated")
     self.append_log("Creating directory snapshot")
     self.create_snapshot()
     self.append_log(self.file_snapshotzip + " created")
             
     ServerInterface().start_simjob(self)
     return
Example #4
0
 def update(self, nsg_job_list=None, ssh_connection=None, update_server_output=True):
     if self.status == ServerInterface.ssh_status[0] or self.status == ServerInterface.nsg_status[0]: 
         ServerInterface().update_for_completion(self,nsg_job_list=nsg_job_list,ssh_connection=ssh_connection)
         if update_server_output:
             ServerInterface().download_status_simjob(self,nsg_job_list=nsg_job_list,ssh_connection=ssh_connection)
         self.sim_last_update_time = time.time()
         self.write_properties()
         
     if self.status == ServerInterface.ssh_status[1] or self.status == ServerInterface.nsg_status[1]:
         ServerInterface().download_results_simjob(self,nsg_job_list=nsg_job_list,ssh_connection=ssh_connection)
         if self.status==ServerInterface.ssh_status[1] and not update_server_output:#We always want to download the status regardless
             ServerInterface().download_status_simjob(self,nsg_job_list=nsg_job_list,ssh_connection=ssh_connection)
         if self.sim_delete_remote_on_finish:
             ServerInterface().delete_remote_results(self,nsg_job_list=nsg_job_list, ssh_connection=ssh_connection)   
         if self.sim_delete_duplicates_on_finish:
             self.delete_dups()
         self.sim_last_update_time = time.time()
         self.write_properties()
     
     
     return
Example #5
0
    def update_all_jobs(self, update_server_output=False):

        nsg_job_lists = {}
        ssh_conns = {}
        _update_server_output = self.update_server_output
        if update_server_output:
            _update_server_output = True

        for job in self.sim_jobs:
            if (job.status == ServerInterface.ssh_status[0]):

                ssh_conn = ssh_conns.get(job.server_connector)
                if not ssh_conn:
                    server = job.get_server()
                    try:
                        ssh_conn = ServerInterface().connect_ssh(server, job)
                        ssh_conns[job.server_connector] = ssh_conn
                    except Exception as e:
                        job.append_log(
                            'SimDirectory.update_all_jobs() Caught exception: %s: %s'
                            % (e.__class__, e))
                        #traceback.print_exc()
                        try:
                            ssh_conn.close()
                        except:
                            pass

                job.update(ssh_connection=ssh_conn,
                           update_server_output=_update_server_output)
                job.read_properties()

            if (job.status == ServerInterface.nsg_status[0]):

                nsg_list = nsg_job_lists.get(job.server_connector)
                if not nsg_list:
                    server = job.get_server()
                    nsg = Client(server.nsg_api_appname, server.nsg_api_appid,
                                 server.user, server.password,
                                 server.nsg_api_url)
                    nsg_job_lists[job.server_connector] = nsg.listJobs()

                job.update(nsg_job_list=nsg_list,
                           update_server_output=_update_server_output)
                job.read_properties()

        for key, ssh_conn in ssh_conns.items():  #clean up ssh connections
            try:
                ssh_conn.close()
            except Exception as e:
                print(
                    'SimDirectory.update_all_jobs() Caught exception while attempting to close connections: %s: %s'
                    % (e.__class__, e))
                pass

        return
Example #6
0
 def download_server_output(self):
     ServerInterface.download_status_simjob(self)
     return
Example #7
0
 def stop(self):
     if self.status == ServerInterface.ssh_status[0] or self.status == ServerInterface.nsg_status[0]:
         self.append_log("Attempting to stop")
         ServerInterface().stop_simjob(self)
     
     return
Example #8
0
 def delete_remote(self):
     self.append_log("Delete remote initiated")        
     ServerInterface().delete_remote_results(self)
     return
Example #9
0
 def display(self):            
     top = self.top
     top.geometry('375x435')
     top.resizable(0,0)
     top.title(self.window_title)
    
     
     def on_server_type_change(type_):
         if(type_ == "nsg"):
             conn_option_frame.grid_forget()
             nsgconn_option_frame.grid(column=0,row=14,sticky='news',padx=10,pady=5,columnspan=3)
         elif(type_ == "ssh"):
             nsgconn_option_frame.grid_forget()
             conn_option_frame.grid(column=0,row=15,sticky='news',padx=10,pady=5,columnspan=3)
         else:
             conn_option_frame.grid_forget()
             nsgconn_option_frame.grid_forget()
             
         return
     
     def select_batch():
         self.batch_file.set(os.path.basename(filedialog.askopenfilename(initialdir=self.sim_directory.sim_directory)))
         self.top.lift()
         return
     
     def new_batch(*args):
         Create_Batch_File(self.top)
         return
 
 
     def new_server():
         ServerEntryBox(self.top, confirm_callback=set_server_choices)
         #Refresh options
         
         # on change dropdown value
     def change_dropdown(*args):
         server_name = self.server_connector.get()
         
         if(server_name==""):
             on_server_type_change("")
             return
         servers = ServersFile()
         s = servers.get_server_byname(server_name)
         #get the connection and check if it's a ssh / nsg
         if s:
             on_server_type_change(s.type)
         
     def change_dropdown_nsg_tool(*args):
         return
     
     def change_dropdown_ssh_tool(*args):
         return
     
     
     def validate(action, index, value_if_allowed,
                prior_value, text, validation_type, trigger_type, widget_name):
         if text in ' ':
             return False
         else:
             return True
         
     self.server_choicedrop = None
     def set_server_choices():
         self.server_choices = self.get_connections()
         if self.server_choicedrop is not None:
             self.server_choicedrop.grid_forget()
         self.server_choicedrop = OptionMenu(general_option_frame, self.server_connector, *self.server_choices)
         self.server_choicedrop.grid(row = 5, column =1)
         
     
     vcmd = (top.register(validate),'%d', '%i', '%P', '%s', '%S', '%v', '%V', '%W')
     
     toptext = "New Remote Job"
     if self.edit_job:
         toptext = "Edit Job"
     if self.clone_mode:
         toptext = "Clone Job"
     
     tk.Label(top, text=toptext).grid(row=0,column=0,sticky="WE",pady=15, columnspan=3)
     
     general_option_frame = tk.LabelFrame(top, text="General")
     
     tk.Label(general_option_frame, text='Sim Job Name',width=15, background='light gray', relief=tk.GROOVE).grid(row=1,column=0,pady=5,padx=5,columnspan=1)
     self.name_e = tk.Entry(general_option_frame,width=25,textvariable=self.name,validate='key', validatecommand=vcmd)
     self.name_e.grid(row=1,column=1,padx=5,columnspan=1)
     
     if self.edit_job:
         self.name_e.config(state=tk.DISABLED)
     if self.clone_mode:
         self.name_e.config(state=tk.NORMAL)
     
     tk.Label(general_option_frame, text='Server Connection',width=15, background='light gray',relief=tk.GROOVE).grid(row=5,column=0,pady=5,padx=5,columnspan=1)
     set_server_choices()
     
     self.server_connector.trace('w', change_dropdown)
     b = tk.Button(general_option_frame, text="New", command=new_server)
     b.grid(pady=5, padx=5, column=2, row=5, sticky="WE",columnspan=1)
     
     general_option_frame.grid(column=0,row=2,sticky='news',padx=10,pady=5,columnspan=3)
     
     conn_option_frame = tk.LabelFrame(top, text="SSH Connection Parameters")
     nsgconn_option_frame = tk.LabelFrame(top, text="NSG Connection Parameters")
     
     if self.edit_job:
         change_dropdown()#In case we're editing
     ###SSH###
     
     tk.Label(conn_option_frame, text='Tool',width=15, background='light gray',relief=tk.GROOVE).grid(row=1,column=0,pady=5,padx=5)
     self.ssh_tool_choices = ServerInterface().get_ssh_tools()
     popupMenu = OptionMenu(conn_option_frame, self.server_ssh_tool, *self.ssh_tool_choices)
     popupMenu.grid(row = 1, column =1)
     self.server_ssh_tool.trace('w', change_dropdown_ssh_tool)
             
     tk.Label(conn_option_frame, text='Batch File',width=15, background='light gray',relief=tk.GROOVE).grid(row=2,column=0,pady=5,padx=5,columnspan=1)
     self.name_e = tk.Entry(conn_option_frame,width=25,textvariable=self.batch_file,state=tk.DISABLED)
     self.name_e.grid(row=2,column=1,padx=5,columnspan=1)
     b = tk.Button(conn_option_frame, text="Select", command=select_batch).grid(pady=5, padx=5, column=2, row=2, sticky="WE",columnspan=1)
     self.batch_file.trace('w', self.change_batch)
     #b = tk.Button(conn_option_frame, text="New", command=new_batch).grid(pady=5, padx=5, column=3, row=2, sticky="WE",columnspan=1)
     
     
     tk.Label(conn_option_frame, text='Partition',width=15, background='light gray',relief=tk.GROOVE).grid(row=3,column=0,pady=5,padx=5)
     self.host_e = tk.Entry(conn_option_frame,width=25,textvariable=self.server_mpi_partition)
     self.host_e.grid(row=3,column=1,padx=5)
     
     tk.Label(conn_option_frame, text='Nodes',width=15, background='light gray',relief=tk.GROOVE).grid(row=4,column=0,pady=5,padx=5,columnspan=1)
     self.name_e = tk.Entry(conn_option_frame,width=25,textvariable=self.server_nodes)
     self.name_e.grid(row=4,column=1,padx=5,columnspan=1)
     
     tk.Label(conn_option_frame, text='Cores',width=15, background='light gray',relief=tk.GROOVE).grid(row=5,column=0,pady=5,padx=5,columnspan=1)
     self.name_e = tk.Entry(conn_option_frame,width=25,textvariable=self.server_cores)
     self.name_e.grid(row=5,column=1,padx=5,columnspan=1)
     
     tk.Label(conn_option_frame, text='Max Run (hours)',width=15, background='light gray',relief=tk.GROOVE).grid(row=6,column=0,pady=5,padx=5,columnspan=1)
     self.name_e = tk.Entry(conn_option_frame,width=25,textvariable=self.server_max_runtime)
     self.name_e.grid(row=6,column=1,padx=5,columnspan=1)
     
                 
     ####NSG###
     
     tk.Label(nsgconn_option_frame, text='Tool',width=15, background='light gray',relief=tk.GROOVE).grid(row=2,column=0,pady=5,padx=5)
     self.nsg_tool_choices = self.get_nsg_tools()
     popupMenu = OptionMenu(nsgconn_option_frame, self.server_nsg_tool, *self.nsg_tool_choices)
     popupMenu.grid(row = 2, column =1)
     self.server_nsg_tool.trace('w', change_dropdown_nsg_tool)
     
     tk.Label(nsgconn_option_frame, text='Main Run File',width=15, background='light gray',relief=tk.GROOVE).grid(row=3,column=0,pady=5,padx=5,columnspan=1)
     self.name_e = tk.Entry(nsgconn_option_frame,width=25,textvariable=self.batch_file,state=tk.DISABLED)
     self.name_e.grid(row=3,column=1,padx=5,columnspan=1)
     b = tk.Button(nsgconn_option_frame, text="Select", command=select_batch).grid(pady=5, padx=5, column=2, row=3, sticky="WE",columnspan=1)
     
     tk.Label(nsgconn_option_frame, text='Nodes',width=15, background='light gray',relief=tk.GROOVE).grid(row=4,column=0,pady=5,padx=5,columnspan=1)
     self.name_e = tk.Entry(nsgconn_option_frame,width=25,textvariable=self.server_nodes)
     self.name_e.grid(row=4,column=1,padx=5,columnspan=1)
     
     tk.Label(nsgconn_option_frame, text='Cores',width=15, background='light gray',relief=tk.GROOVE).grid(row=5,column=0,pady=5,padx=5,columnspan=1)
     self.name_e = tk.Entry(nsgconn_option_frame,width=25,textvariable=self.server_cores)
     self.name_e.grid(row=5,column=1,padx=5,columnspan=1)
     
     tk.Label(nsgconn_option_frame, text='Max Run (hours)',width=15, background='light gray',relief=tk.GROOVE).grid(row=6,column=0,pady=5,padx=5,columnspan=1)
     self.name_e = tk.Entry(nsgconn_option_frame,width=25,textvariable=self.server_max_runtime)
     self.name_e.grid(row=6,column=1,padx=5,columnspan=1)
                 
     tk.Label(nsgconn_option_frame, text='Uses Python',width=15, background='light gray',relief=tk.GROOVE).grid(row=7,column=0,pady=5,padx=5)
     tk.Checkbutton(nsgconn_option_frame, text="", variable=self.server_nsg_python).grid(row=7,column=1,padx=5, sticky='W')
     
     tk.Label(nsgconn_option_frame, text='Send Status Emails',width=15, background='light gray',relief=tk.GROOVE).grid(row=8,column=0,pady=5,padx=5)
     tk.Checkbutton(nsgconn_option_frame, text="", variable=self.server_status_email).grid(row=8,column=1,padx=5, sticky='W')
      
     #Return
                 
     button_frame = tk.Frame(top)
     button_frame.grid(row=20,column=0,columnspan=3)
     
     b = tk.Button(button_frame, text="Ok", command=self.ok)
     b.grid(pady=5, padx=5, column=0, row=0, sticky="WE")
     
     b = tk.Button(button_frame, text="Cancel", command=self.cancel)
     b.grid(pady=5, padx=5, column=1, row=0, sticky="WE")
Example #10
0
 def get_nsg_tools(self):
     return ServerInterface().get_nsg_tools()