def fill_vnc_data(self, vnc_session): results = exec_pg_select_rb(kcd_db_conn, "select port from kcd_kws_vnc_session \ where kws_id=%s AND session_id = %s" % \ ( ntos(vnc_session.workspace_id), ntos(vnc_session.session_id))) if len(results) > 0: row = results[0] port = row[0] vnc_session.port = port else: vnc_session.port = 9999 #invalid port
def get_kws_id_list(last_id, max_kws_id): query = "SELECT kws_id, bool(flags & %i) as deleted FROM kcd_kws_list WHERE kws_id > %s" % \ (KANP_KWS_FLAG_DELETE, ntos(last_id)) if max_kws_id != None: query += " AND kws_id <= %s" % ( ntos(max_kws_id) ) results = exec_pg_select_rb(kcd_db_conn, query) s = [] for row in results: kws_id = row[0] deleted = row[1] logger.info("Adding workspace %i to the list." % ( kws_id ) ) s.append((kws_id, deleted)) return s
def get_kws_id_list(last_id, max_kws_id): query = "SELECT kws_id, bool(flags & %i) as deleted FROM kcd_kws_list WHERE kws_id > %s" % \ (KANP_KWS_FLAG_DELETE, ntos(last_id)) if max_kws_id != None: query += " AND kws_id <= %s" % (ntos(max_kws_id)) results = exec_pg_select_rb(kcd_db_conn, query) s = [] for row in results: kws_id = row[0] deleted = row[1] logger.info("Adding workspace %i to the list." % (kws_id)) s.append((kws_id, deleted)) return s
def check_delete(self): # Get workspace deleted flag from the KCD database. logger.debug("Checking workspace %i deleted flag." % ( self.ws.id ) ) results = exec_pg_select_rb(kcd_db_conn, "select flags from kcd_kws_list where kws_id = %s" % ( ntos(self.ws.id) ) ) row = results[0] kcd_deleted = bool(row[0] & KANP_KWS_FLAG_DELETE) if kcd_deleted and not self.ws.deleted: # Workspace is deleted but local database doesn't know that yet. # Stop listening for this workspace. self.stop_listening() # Delete workspace. logger.debug("Deleting workspace %i." % ( self.ws.id ) ) Workspace.delete_workspace(self.ws.id) # Commit change in sql alchemy session. SASession.commit() logger.info("Deleted workspace %i." % ( self.ws.id ) ) # Delete workspace from the list. global kws_delete_list kws_delete_list += [self.ws.id]
def check_delete(self): # Get workspace deleted flag from the KCD database. logger.debug("Checking workspace %i deleted flag." % (self.ws.id)) results = exec_pg_select_rb( kcd_db_conn, "select flags from kcd_kws_list where kws_id = %s" % (ntos(self.ws.id))) row = results[0] kcd_deleted = bool(row[0] & KANP_KWS_FLAG_DELETE) if kcd_deleted and not self.ws.deleted: # Workspace is deleted but local database doesn't know that yet. # Stop listening for this workspace. self.stop_listening() # Delete workspace. logger.debug("Deleting workspace %i." % (self.ws.id)) Workspace.delete_workspace(self.ws.id) # Commit change in sql alchemy session. SASession.commit() logger.info("Deleted workspace %i." % (self.ws.id)) # Delete workspace from the list. global kws_delete_list kws_delete_list += [self.ws.id]
def poll(self): while 1: # Fetch the events by groups. limit = 100 # Receive the events. results = exec_pg_select_rb(kcd_db_conn, "select evt_id, major, minor, type, event \ from kcd_kws_event_log \ where kws_id=%s AND evt_id > %s order by evt_id limit %s" % \ ( ntos(self.ws.id), ntos(self.ws.last_event_id), ntos(limit))) if len(results) == 0: break for row in results: evt = WSEvent(self.ws.id, row[0], row[1], row[2], row[3], row[4]) self.handle_event(evt)
def get_general_infos(self): logger.debug("Fetching workspace %i additionnal infos from kcd db." % (self.ws.id)) results = exec_pg_select_rb( kcd_db_conn, "select creation_date, name, flags from kcd_kws_list where kws_id = %s" % (ntos(self.ws.id))) row = results[0] self.ws.creation_date = row[0] self.ws.name = row[1] flags = row[2] self.ws.public = False if flags & KANP_KWS_FLAG_PUBLIC: self.ws.public = True if flags & KANP_KWS_FLAG_COMPAT_V2: self.ws.compat_v2 = True if self.ws.public: self.ws.secured = False else: self.ws.secured = True else: self.ws.compat_v2 = False self.ws.secured = ((flags & KANP_KWS_FLAG_SECURE) > 0)
def get_general_infos(self): logger.debug("Fetching workspace %i additionnal infos from kcd db." % ( self.ws.id ) ) results = exec_pg_select_rb(kcd_db_conn, "select creation_date, name, flags from kcd_kws_list where kws_id = %s" % ( ntos(self.ws.id) ) ) row = results[0] self.ws.creation_date = row[0] self.ws.name = row[1] flags = row[2] self.ws.public = False if flags & KANP_KWS_FLAG_PUBLIC: self.ws.public = True if flags & KANP_KWS_FLAG_COMPAT_V2: self.ws.compat_v2 = True if self.ws.public: self.ws.secured = False else: self.ws.secured = True else: self.ws.compat_v2 = False self.ws.secured = ((flags & KANP_KWS_FLAG_SECURE ) > 0)