static function initThisList($parent, $class) { $parent->setUpdateSubaction('getBeancounter'); $res = rl_exec_set($parent->__masterserver, $parent->syncserver, $parent); $parent->dbaction = 'clean'; if ($res) { foreach ($res as &$__rt) { $__rt['syncserver'] = $parent->syncserver; $__rt['parent_clname'] = createParentName("vps", $parent->nname); } } dprint($res); return $res; }
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"; }
function syncToSystem() { // Special for pserver... Since the whole idea of remote syncing is handled here, it makes sense to have the special case of pserver when it is added here itself. global $gbl, $sgbl, $login, $ghtml; if ($this->dbaction === 'add') { dprint("This is ssytem not syncing anymore\n"); return false; } if (!$this->isSync()) { return; } if ($this->dbaction === 'delete') { $gbl->pserver_password = $this->realpass; } rl_exec_set($this->__masterserver, $this->syncserver, $this); }
function simpleRestoreMeUpThere() { $this->setUpdateSubaction('top_level_simple_restore'); $this->createExtraVariables(); $res = rl_exec_set(null, $this->syncserver, $this); }
function __ac_desc_graph($object) { global $gbl, $sgbl, $login, $ghtml; $subaction = $ghtml->frm_subaction; $selflist = $object->getSelfList(); if (!$ghtml->frm_c_graph_time) { $ghtml->frm_c_graph_time = '1d'; } $object->createShowPropertyList($alist); $object->createShowAlist($alist, $subaction); $nalist = null; if (!isset($alist['property'])) { $alist['property'] = array(); } $nalist = lx_merge_good($nalist, $alist['property']); remove_if_older_than_a_minute_dir("__path_program_htmlbase/tmp/"); $ghtml->print_tab_block($nalist); if ($selflist) { $ghtml->printShowSelectBox($selflist); } if (cse($ghtml->frm_subaction, 'base')) { $core = strtil($ghtml->frm_subaction, "base"); $ghtml->__http_vars['frm_subaction'] = "{$core}traffic"; $subaction = "{$core}traffic"; } $galist = $object->createGraphList(); $ghtml->print_tab_block($galist); $graphtlist = array('1h' => '1h', '12h' => '12h', '1d' => '1d', '2d' => '2d', '1week' => '1week', '1month' => '1month'); $gtlistsec = array('1h' => 3600, '12h' => 12 * 3600, '1d' => 24 * 3600, '2d' => 2 * 24 * 3600, '1week' => 7 * 24 * 3600, '1month' => 30 * 24 * 3600, '1year' => 365 * 24 * 3600); $ghtml->printGraphSelect($graphtlist); lxfile_mkdir("__path_program_htmlbase/tmp"); $tmpgraph = ltempnam("__path_program_htmlbase/tmp/", "graph"); $object->setUpdateSubaction("graph_{$subaction}"); $time = $ghtml->frm_c_graph_time; $object->rrdtime = $gtlistsec[$time]; try { $object->createExtraVariables(); $file = rl_exec_set(null, $object->syncserver, $object); } catch (lxException $e) { $ghtml->print_curvy_table_start(); print "Graph Failed due to {$e->getMessage()} {$e->value}"; $ghtml->print_curvy_table_end(); $object->dbaction = 'clean'; return; } $object->dbaction = 'clean'; lfile_put_contents($tmpgraph, $file); $tmpgraph = basename($tmpgraph); print "<img src=/tmp/{$tmpgraph}>"; }
function backup_one_vps($l) { if (!$l->priv->isOn('centralbackup_flag')) { print "Central Backup flag is off for vps {$l->nname}... skipping...\n"; return; } $l->truehostname = getInternalNetworkIp($l->syncserver); $bserver = $l->getBackupServer(); if ($l->isWindows()) { print "Windows Cannot be backed up...\n"; return; } if (is_disabled_or_null($bserver)) { $msg = "Backup server for {$l->syncserver} is disabled.. Skipping {$l->nname}\n"; print $msg; log_log("centralbackup_error", $msg); return; } if (!isset($this->bserver_l[$bserver])) { print "The backup server {$bserver} doesn't exist\n"; return; } $bs = $this->bserver_l[$bserver]; if (!isset($this->global_list[$l->syncserver])) { try { $res = rl_exec_get(null, $l->syncserver, 'setup_scpid', array($bs->backupiddsa)); } catch (Exception $e) { $msg = "Could not connect to {$l->syncserver} Skipping {$l->nname}: {$e->getMessage()}\n"; log_log("centralbackup_error", $msg); print $msg; return; } $this->addknownHost($bs, "{$l->truehostname} {$res}"); $this->global_list[$l->syncserver] = $l->truehostname; } else { } $msg = "Backing Up {$l->nname} on {$l->truehostname} to {$bs->nname}({$bs->ssh_port}):{$bs->snapshotdir} \n"; log_log("centralbackup", $msg); print $msg; $l->setUpdateSubaction('top_level_central_back'); $l->__var_bc_backupextra_stopvpsflag = $this->stopvps ? 'on' : 'off'; try { $res = rl_exec_set(null, $l->syncserver, $l); } catch (Exception $e) { $msg = "Failed Preparing... Skipping {$l->nname} on {$l->syncserver}: {$e->getMessage()}\n"; log_log("centralbackup_error", $msg); print $msg; return; } $l->subaction = null; if ($res['savelist']) { foreach ($res['savelist'] as $k => $v) { $l->{$k} = $v; } } $l->__save_bc = $res['back']; if ($l->isXen()) { $localdir = $l->nname; } else { $localdir = "{$l->vpsid}-{$l->nname}"; } $ssh_port_for_slave = db_get_value("sshconfig", $l->syncserver, "ssh_port"); if (!$ssh_port_for_slave) { $ssh_port_for_slave = "22"; } $l->__var_remotedir = $res['back'][0]; $l->__var_ssh_port_for_slave = $ssh_port_for_slave; $this->run_rsnapshot($bs, $l); $l->setUpdateSubaction('top_level_central_back_clean'); $res = rl_exec_set(null, $l->syncserver, $l); }