public static function generatePortNumber() { $next_port = self::VNC_DEFAULT_PORT; $criteria = new Criteria(); $criteria->addAscendingOrderByColumn(self::ID); $ports = EtvaVncPortPeer::doSelect($criteria); if (!$ports) { return $next_port; } foreach ($ports as $port) { $port_n = $port->getId(); $in_use = $port->getInUse(); if ($port_n > $next_port) { break; } if ($next_port == $port_n) { if (!$in_use) { $next_port = $port_n; break; } $next_port = $port_n + 1; } } return $next_port; }
public function getVncPort() { $vncPort = null; if ($this->getId()) { $vncPort = EtvaVncPortPeer::getByServer($this->getId()); } if (!$vncPort) { $vncPort = EtvaVncPortPeer::getUnusedPort(); } return $vncPort->getId(); }