class DiscoveryDAO:
    __db = None

    def __init__(self):
        self.__db = DbHelper()

    def getAll(self):
        return self.__db.query("SELECT * FROM container_discovery",
                               None).fetchall()

    def getAvailableContainer(self, workload, host):
        return self.__db.query(
            """
          SELECT * FROM container_discovery 
          WHERE status = %s AND workload = %s AND host = %s
          """, ("stopped", workload, host))

    def updateContainerStatus(self, status, containerId):
        self.__db.query(
            """
         UPDATE container_discovery 
         SET status=%s
         WHERE id=%s
         """, (status, containerId))

        self.__db.commit()
Beispiel #2
0
class HostDAO:
   __db = None;

   def __init__(self):
       self.__db = DbHelper()

   def getAll(self):
       return self.__db.query("SELECT * FROM host", None).fetchall();
Beispiel #3
0
class CpuStatusDAO:
    __db = None

    def __init__(self):
        self.__db = DbHelper()

    def getAll(self):
        return self.__db.query("SELECT * FROM cpu_status", None).fetchall()

    def getAvailableCpu(self):
        return self.__db.query(
            "SELECT * FROM cpu_status WHERE status = 'idle'", None)

    def updateCpuStatus(self, status, host, cpuNumber):
        self.__db.query(
            """
         UPDATE cpu_status 
         SET status=%s
         WHERE host=%s AND cpu=%s
         """, (status, host, cpuNumber))

        self.__db.commit()