示例#1
0
 function updateImportVPs($param)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $gen = $login->getObject('general');
     $sq = new Sqlite(null, 'vps');
     $driverapp = $gbl->getSyncClass('localhost', $this->nname, 'vps');
     if ($driverapp === 'xen') {
         if (!$gen->generalmisc_b->xenimportdriver) {
             throw new lxexception('need_to_set_xenimportdriver', '');
         }
         $this->__var_xenimportdriver = $gen->generalmisc_b->xenimportdriver;
     }
     $this->__var_vps_driver = $driverapp;
     $this->setUpdateSubaction('importvps');
     $res = rl_exec_set($this->__masterserver, $this->syncserver, $this);
     $this->dbaction = 'clean';
     if (!$res) {
         throw new lxexception('could_not_find_any_vms_to_import', '');
     }
     foreach ($res as $k => $r) {
         $r->__parent_o = $login;
         if ($driverapp === 'openvz') {
             if ($this->checkOpenvzVpsid($r)) {
                 unset($res[$k]);
             }
         } else {
             if ($this->checkXenVpsName($r)) {
                 unset($res[$k]);
             }
         }
     }
     if ($res) {
         foreach ($res as $k => $r) {
             $r->metadbaction = 'writeonly';
             $r->dbaction = 'add';
             $r->write();
         }
     }
     if ($driverapp === 'xen') {
         foreach ($res as $k => $r) {
             $r->makeSureVifExists();
             $r->makeSureTheMacAddressExists();
             $r->createSyncClass();
             $r->createExtraVariables();
             $r->dbaction = 'update';
             $r->metadbaction = 'all';
             //if ($this->__var_xenimportdriver !== 'hypervm') {
             $r->setUpdateSubaction('createconfig');
             //}
             $r->was();
         }
     }
     exec_justdb_collectquota();
     $gbl->__this_redirect = $ghtml->getFullUrl('a=list&c=vps') . "&frm_smessage=import_succeeded";
 }
示例#2
0
function checkRestart()
{
    if (if_demo()) {
        return;
    }
    $res = lscandir_without_dot("__path_program_etc/.restart");
    if ($res === false) {
        dprint(".restart does not exist... Creating\n");
        lxfile_mkdir("__path_program_etc/.restart");
        lxfile_generic_chown("__path_program_etc/.restart", "lxlabs");
    }
    foreach ((array) $res as $r) {
        if (csb($r, "._restart_")) {
            $cmd = strfrom($r, "._restart_");
        }
        lunlink("__path_program_etc/.restart/{$r}");
        dprint("Restarting {$cmd}\n");
        // THe 3,4 etc are the tcp ports of this program, and it should be closed, else some programs will grab it.
        //exec("/etc/init.d/$cmd restart  </dev/null >/dev/null 2>&1 3</dev/null 4</dev/null 5</dev/null 6</dev/null &");
        switch ($cmd) {
            case 'lxcollectquota':
                exec_justdb_collectquota();
                break;
            case 'openvz_tc':
                exec_openvz_tc();
                break;
            default:
                exec_with_all_closed("/etc/init.d/{$cmd} restart");
                break;
        }
    }
}
示例#3
0
function checkRestart()
{
    if (if_demo()) {
        return;
    }
    log_log("cron_exec", "Check service restarts...\n");
    $res = lscandir_without_dot("__path_program_etc/.restart");
    if ($res === false) {
        dprint(".restart does not exist... Creating\n");
        lxfile_mkdir("__path_program_etc/.restart");
        lxfile_generic_chown("__path_program_etc/.restart", "lxlabs");
    }
    foreach ((array) $res as $r) {
        if (csb($r, "._restart_")) {
            $cmd = strfrom($r, "._restart_");
        }
        lunlink("__path_program_etc/.restart/{$r}");
        dprint("Restarting {$cmd}\n");
        switch ($cmd) {
            case 'lxcollectquota':
                log_log("cron_exec", "Start collecting Quota's\n");
                exec_justdb_collectquota();
                break;
            case 'openvz_tc':
                log_log("cron_exec", "Start openvz_tc script\n");
                exec_openvz_tc();
                break;
            default:
                log_log("cron_exec", "Restarting {$cmd}\n");
                exec_with_all_closed("/etc/init.d/{$cmd} restart");
                break;
        }
    }
}