tao.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. class zanodeTao extends zanodeModel
  3. {
  4. /**
  5. * 通过主机ID获取此主机下所有的子主机。
  6. * Get all sub hosts by host ID.
  7. *
  8. * @param int $hostID
  9. * @param string $orderBy
  10. * @access protected
  11. * @return array
  12. */
  13. protected function getSubZahostListByID($hostID, $orderBy)
  14. {
  15. return $this->dao->select('id, name, vnc, cpuCores, memory, diskSize, osName, status, heartbeat')->from(TABLE_ZAHOST)
  16. ->where('deleted')->eq(0)
  17. ->andWhere('parent')->eq($hostID)
  18. ->orderBy($orderBy)
  19. ->fetchAll();
  20. }
  21. /**
  22. * 通过查询条件获取执行节点列表。
  23. * Get host list by query.
  24. *
  25. * @param string $query
  26. * @param string $orderBy
  27. * @param object $pager
  28. * @access protected
  29. * @return array
  30. */
  31. protected function getZaNodeListByQuery($query, $orderBy, $pager)
  32. {
  33. return $this->dao->select("t1.*, t2.name as hostName, if(t1.hostType='', t2.extranet, t1.extranet) extranet,if(t1.hostType='', t3.osName, t1.osName) osName")->from(TABLE_ZAHOST)->alias('t1')
  34. ->leftJoin(TABLE_ZAHOST)->alias('t2')->on('t1.parent = t2.id')
  35. ->leftJoin(TABLE_IMAGE)->alias('t3')->on('t3.id = t1.image')
  36. ->where('t1.deleted')->eq(0)
  37. ->andWhere("t1.type = 'node'")
  38. ->beginIF($query)->andWhere($query)->fi()
  39. ->orderBy($orderBy)
  40. ->page($pager)
  41. ->fetchAll();
  42. }
  43. /**
  44. * 通过主机ID列表获取主机列表。
  45. * Get host list by host ID list.
  46. *
  47. * @param array $hostIDList
  48. * @access protected
  49. * @return array
  50. */
  51. protected function getHostsByIDList($hostIDList)
  52. {
  53. return $this->dao->select('id,status,heartbeat')->from(TABLE_ZAHOST)
  54. ->where('id')->in($hostIDList)
  55. ->fetchAll('id');
  56. }
  57. }