Esempio n. 1
0
 function getFfileFromVirtualList($name)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $parent = $this->getParentO();
     $bserver = $parent->getBackupServer();
     if (is_disabled_or_null($bserver)) {
         throw new lxException("backup_server_is_not_configured");
     }
     $bs = new CentralBackupServer(null, null, $bserver);
     $bs->get();
     if ($bs->dbaction === 'add') {
         throw new lxException("backup_server_is_not_there");
     }
     $server = $bs->slavename;
     $root = "{$bs->snapshotdir}/vps/{$parent->ttype}/{$parent->nname}/";
     $name = coreFfile::getRealpath($name);
     $name = "/{$name}";
     $ffile = new Ffile(null, $server, $root, $name, "root");
     $ffile->__parent_o = $this;
     $ffile->get();
     $ffile->browsebackup = 'on';
     return $ffile;
 }
Esempio n. 2
0
 function createShowAlist(&$alist, $subaction = null)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $revc = $login->getObject('general')->reversedns_b;
     $hackbutton = $login->getObject('general')->hackbuttonconfig_b;
     static $status;
     static $reason;
     if (isUpdating()) {
         $ghtml->print_redirect_back('system_is_updating_itself', '');
     }
     if ($ghtml->frm_action === 'show') {
     } else {
         $status = $this->status;
     }
     $this->setIId();
     if (!$status) {
         try {
             $status = $this->getStatusForThis();
             dprint($status);
         } catch (Exception $e) {
             if (if_demo()) {
                 $status = 'on';
             } else {
                 print "Could not get Status: Reason: {$e->getMessage()}";
                 exit;
             }
         }
     }
     if (csa($status, ":")) {
         $st = explode(":", $status);
         $status = array_shift($st);
         $reason = implode(" ", $st);
         $reason = str_replace("\n", " ", $reason);
     }
     if ($status !== $this->status) {
         dprint("Status in Db not the same as Status of the system, resetting db");
         $this->status = $status;
         $this->setUpdateSubaction();
     }
     if ($this->status === 'create') {
         $alist['__v_message'] = "<b> VM is being Created... Please Wait.. </b> \n";
         $alist['__v_refresh'] = true;
         return;
     }
     if ($this->status === 'createfailed') {
         $alist['__v_message'] = "<b> VM creation has failed. Reason: {$reason} </b>\n";
         $alist['__v_refresh'] = true;
         return;
     }
     if ($this->checkIfLockedForAction('restore')) {
         $alist['__v_message'] = 'The VM is getting restored, please wait...';
         $alist['__v_refresh'] = true;
         return $alist;
     }
     if ($this->checkIfLockedForAction('rebuild')) {
         $alist['__v_message'] = 'The VM is getting rebuilt, please wait...';
         $alist['__v_refresh'] = true;
         return $alist;
     }
     if ($this->checkIfLockedForAction('switchserver')) {
         $alist['__v_message'] = 'The VM is being migrated, please wait...';
         $alist['__v_refresh'] = true;
         return $alist;
     }
     if ($this->checkIfLockedForAction('livemigrate')) {
         $alist['__v_message'] = 'The VPS is being Migrated Live. The CP is inactive, but your VPS is running Normally.';
         $alist['__v_refresh'] = true;
         return $alist;
     }
     if ($this->status === 'deleted') {
         $alist['__v_message'] = "The VM {$this->getIid}() Doesn't Exist on {$this->syncserver}. If you have migrated the vps, you can manually change the server in the database using the below, Or restore from backup. </b>";
         $alist['__v_refresh'] = true;
         $alist['__title_main'] = $login->getKeywordUc('resource');
         $alist['__v_dialog_csync'] = "a=updateform&sa=changesyncserver";
         $alist['__var_backup_flag'] = "a=show&o=lxbackup";
         $alist[] = "a=updateform&sa=rebuild";
         return null;
     }
     /*
     	if ($this->getObject('lxbackup')->backupstage === 'doing') { 
     		$alist['__v_message'] = 'The VM is getting backed up, please wait...';
     		$alist['__v_refresh'] = true;
     		return $alist;
     	}
     */
     $this->makeSureTheUserExists();
     $this->makeSureTheMacAddressExists();
     $this->makeSureVifExists();
     if ($subaction === 'config') {
         return $this->createShowAlistConfig($alist);
     }
     if ($subaction === 'graph') {
         $alist['__title_graph'] = $login->getKeywordUc('graph');
         return $alist;
     }
     $alist['__title_administer'] = $login->getKeywordUc('administration');
     if ($this->getParentO()->isClass('client')) {
         if (!$this->isLogin()) {
             if ($login->priv->isOn('vps_limit_flag')) {
                 $alist['__v_dialog_limit'] = "a=updateForm&sa=limit";
                 $alist['__v_dialog_plan'] = "a=updateForm&sa=change_plan";
             }
         }
     }
     $alist['__v_dialog_info'] = "a=updateForm&sa=information";
     $alist['__v_dialog_pass'] = "******";
     if (!$this->isWindows()) {
         //$alist[] = "a=show&n=browsebackup&l[class]=ffile&l[nname]=/";
         $bslave = $this->getBackupServer();
         if (!is_disabled_or_null($bslave) && $this->priv->isOn('centralbackup_flag')) {
             $alist[] = "a=show&n=browsebackup";
         }
     }
     if (!$this->isLogin()) {
         $alist[] = "a=update&sa=dologin";
     }
     $alist['__title_console'] = $login->getKeywordUc('console');
     //$alist[] = "a=show&o=sshclient";
     if ($this->isWindows()) {
         $alist[] = "a=show&o=vncviewer";
     } else {
         $alist[] = "a=show&o=consolessh";
         $alist[] = "a=list&c=sshauthorizedkey";
     }
     if (!$this->isXen()) {
         $alist[] = "a=updateform&sa=commandcenter";
     }
     $alist[] = "a=list&c=blockedip";
     $alist['__v_dialog_netw'] = "a=updateform&sa=network";
     $alist[] = "a=list&c=traceroute";
     if (!$this->isWindows()) {
         $alist['__v_dialog_main'] = "a=updateform&sa=mainipaddress";
     }
     if (!$this->isXen()) {
         $alist['__v_dialog_fixdev'] = "a=updateform&sa=fixdev";
     }
     if ($hackbutton && $hackbutton->isOn('nobackup') && !$this->isWindows()) {
         vps::$__desc_backup_num = array("", "", "backup:number_of_backups", "number_of_backups");
     } else {
         if ($this->priv->isOn('backup_flag')) {
             $alist[] = "a=show&o=lxbackup";
         }
     }
     if ($login->isAdmin()) {
         $alist['__title_action'] = $login->getKeywordUc('action');
     }
     if ($login->priv->isOn("rebuildvps_flag")) {
         $alist['__v_dialog_rebuild'] = "a=updateform&sa=rebuild";
     }
     if (!$this->isWindows()) {
         $alist[] = "a=updateform&sa=recovervps";
     }
     if (!$this->isWindows()) {
         if ($login->isAdmin()) {
             $alist['__v_dialog_sw'] = "a=updateform&sa=switchserver";
         }
         if ($login->isAdmin() && !$this->isXen()) {
             $alist['__v_dialog_live'] = "a=updateform&sa=livemigrate";
         }
     }
     if ($login->isAdmin()) {
         $alist['__v_dialog_tem'] = "a=updateform&sa=createtemplate";
         $alist['__v_dialog_clone'] = "a=updateform&sa=clonevps";
     }
     if (!$this->isWindows()) {
         $alist['__title_resource'] = $login->getKeywordUc('resource');
     }
     if (!$this->isLogin() && $login->priv->isOn('ip_manage_flag')) {
         $alist[] = "a=list&c=vmipaddress_a";
     }
     if (!$this->isWindows()) {
         $alist['__v_dialog_root'] = "a=updateform&sa=rootpassword";
         $alist[] = "a=show&l[class]=ffile&l[nname]=/";
         $alist['__v_dialog_time'] = "a=updateform&sa=timezone";
         if ($this->isOn('kloxo_flag') && $login->priv->isOn('rebuildvps_flag')) {
             $alist['__v_dialog_inst'] = "a=updateform&sa=installkloxo";
         }
     }
     $alist['__title_power'] = $login->getKeywordUc('power');
     $alist[] = "a=update&sa=boot";
     $alist[] = "a=update&sa=poweroff";
     $alist[] = "a=update&sa=reboot";
     if ($this->isXen()) {
         $alist[] = "a=updateform&sa=mount";
     }
     if ($this->isXen()) {
         $alist[] = "a=updateform&sa=hardpoweroff";
     }
     $alist[] = "a=list&c=emailalert";
     if (!$this->isXen()) {
         $alist[] = "a=list&c=openvzqos";
     }
     //$this->getLxclientActions($alist);
     /*
     if ($this->priv->isOn('backup_flag')) {
     	$alist[] = "a=show&o=lxbackup";
     }
     */
     $alist['__title_misc'] = "Extra";
     $this->getListActions($alist, 'vpstraffichistory');
     $this->getListActions($alist, 'utmp');
     $this->getTicketMessageUrl($alist);
     if ($hackbutton && $hackbutton->isOn('nomonitor')) {
     } else {
         if (is_unlimited($this->priv->monitorport_num) || $this->priv->monitorport_num) {
             $alist[] = "a=list&c=monitorserver";
         }
     }
     if ($this->priv->isOn('managereversedns_flag')) {
         if ($revc && $revc->isOn('enableflag')) {
             $alist[] = "a=list&c=reversedns";
         }
     }
     if ($this->priv->isOn('managedns_flag')) {
         if ($revc && $revc->isOn('forwardenableflag')) {
             $alist[] = "a=list&c=dns";
         }
     }
     $alist['__title_advanced'] = "Advanced";
     if (!$this->isLogin()) {
         $alist[] = "a=updateform&sa=disable_per";
     }
     if ($login->isAdmin() && !$this->isXen()) {
         $alist[] = "a=updateForm&sa=changenname";
     }
     if (!$this->isLogin()) {
         $alist[] = "a=updateform&sa=resendwelcome";
     }
     if ($login->isAdmin()) {
         $alist[] = "a=updateForm&sa=changelocation";
         $alist[] = "a=updateform&sa=createuser";
     }
     if ($this->isXen() && !$this->isLogin()) {
         $alist[] = "a=updateform&sa=append_xen_config";
     }
     $alist[] = "a=updateform&sa=append_inittab";
     if ($login->isAdmin()) {
         $alist[] = "a=updateform&sa=ostemplatelist";
     }
     //if ($this->isXen() && $this->ostemplate === 'unknown') {
     if ($this->isXen() && $login->isAdmin()) {
         $alist[] = "a=updateForm&sa=changeosimagename";
     }
     if (!$this->isLogin()) {
         if ($login->isNotCustomer()) {
             // Disabling change owner for the present.
             $alist[] = "a=updateForm&sa=changeowner";
         }
     }
     if ($this->isXen()) {
         $alist[] = "a=updateform&sa=macaddress";
     }
     $alist[] = "a=show&o=notification";
     $alist[] = "a=updateform&sa=miscinfo";
     if ($this->isLogin()) {
         $alist[] = "o=sp_specialplay&a=updateform&sa=login_options";
     }
     $this->getCustomButton($alist);
     return $alist;
 }
Esempio n. 3
0
 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);
 }