Beispiel #1
0
 function delete_all_vpses($lazy)
 {
     global $db;
     if ($this->exists || $this->deleted) {
         while ($row = $db->findByColumn("vps", "m_id", $this->m["m_id"])) {
             $vps = new vps_load($row["vps_id"]);
             $vps->stop();
             $vps->destroy($lazy);
         }
     }
 }
Beispiel #2
0
include WWW_ROOT . 'lib/version.lib.php';
include WWW_ROOT . 'lib/cluster.lib.php';
include WWW_ROOT . 'lib/nas.lib.php';
include WWW_ROOT . 'lib/mail.lib.php';
$db = new sql_db(DB_HOST, DB_USER, DB_PASS, DB_NAME);
// First delete members
$member_timeout = $cluster_cfg->get("general_member_delete_timeout") * 24 * 60 * 60;
$rs = $db->query("SELECT m_id FROM members WHERE m_state = 'deleted' AND m_deleted < " . $db->check(time() - $member_timeout));
while ($row = $db->fetch_array($rs)) {
    $m = new member_load($row["m_id"]);
    $m->delete_all_vpses(false);
    $m->destroy(false);
}
// Mark expired VPSes for lazy deletion
$rs = $db->query("SELECT vps_id FROM vps WHERE vps_expiration IS NOT NULL AND vps_deleted IS NULL AND FROM_UNIXTIME(vps_expiration) < NOW()");
while ($row = $db->fetch_array($rs)) {
    $vps = new vps_load($row["vps_id"]);
    $vps->stop();
    $vps->destroy(true);
}
// Delete lazy deleted VPSes
$vps_timeout = $cluster_cfg->get("general_vps_delete_timeout") * 24 * 60 * 60;
$rs = $db->query("SELECT vps_id FROM vps WHERE vps_deleted IS NOT NULL AND vps_deleted > 0 AND vps_deleted < " . $db->check(time() - $vps_timeout));
while ($row = $db->fetch_array($rs)) {
    $vps = new vps_load($row["vps_id"]);
    if ($vps->ve["vps_backup_export"]) {
        nas_export_delete($vps->ve["vps_backup_export"]);
        $vps->delete_all_backups();
    }
    $vps->destroy(false);
}