function getResourceOstemplate(&$vlist, $ttype = 'all') { $olist = vps::getVpsOsimage(null, "openvz"); $olist = array_keys($olist); $xlist = vps::getVpsOsimage(null, "xen"); $xlist = array_keys($xlist); if ($ttype === 'openvz' || $ttype === 'all') { $vlist['openvzostemplate_list'] = array('U', $olist); } if ($ttype === 'xen' || $ttype === 'all') { $vlist['xenostemplate_list'] = array('U', $xlist); } }
function getCommandResource($resource) { global $gbl, $sgbl, $login, $ghtml; $ret = null; switch ($resource) { case "ostemplate_xen": return vps::getVpsOsimage($login, "xen"); case "ostemplate_openvz": return vps::getVpsOsimage($login, "openvz"); case "vpspserver": $lx = $this->getVpsServers('xen'); $lo = $this->getVpsServers('openvz'); $ret = lx_merge_good($lx, $lo); $ret = convert_to_associate($ret); break; case "vpspserver_xen": $ret = $this->getVpsServers("xen"); $ret = convert_to_associate($ret); break; case "vpspserver_openvz": $ret = $this->getVpsServers("openvz"); $ret = convert_to_associate($ret); break; case "dnstemplate": $ret = domainBase::getDnsTemplateList($this); $ret = convert_to_associate($ret); break; case "resourceplan": $list = $this->getList('resourceplan'); $ret = get_namelist_from_objectlist($list, 'nname', 'realname'); break; } return $ret; }
function updateform($subaction, $param) { global $gbl, $sgbl, $login, $ghtml; $parent = $this->getParentO(); $gen = $login->getObject('general')->generalmisc_b; switch ($subaction) { case "recovervps": /* if (!lxfile_exists("{$this->getOstemplatePath()}/{$this->ostemplate}.tar.gz")) { $list = exec_class_method("vps__{$this->ttype}", "getOsTemplatelist"); $vlist['recover_ostemplate'] = array('A', $list); } */ $vlist['recover_confirm_f'] = null; return $vlist; case "mount": $vlist['confirm_f'] = array('M', "confirm"); return $vlist; case "macaddress": $vlist['macaddress'] = null; return $vlist; case "ostemplatelist": getResourceOstemplate($vlist, $this->ttype); $vlist['__v_updateall_button'] = array(); return $vlist; case "hardpoweroff": $vlist['confirm_f'] = array("M", "Confirm"); return $vlist; case "reboot": $vlist['reboot_confirm_f'] = null; // array("f", "Confirm"); $vlist['__v_button'] = 'Reboot'; return $vlist; case "shutdown": $vlist['poweroff_confirm_f'] = null; // array("f", "Confirm"); $vlist['__v_button'] = 'Power OFF'; return $vlist; case "mainipaddress": $vlist['mainipaddress'] = array('s', get_namelist_from_objectlist($this->vmipaddress_a)); return $vlist; case "livemigrate": $serverlist = $login->getServerList($this->get__table()); $rs = null; foreach ($serverlist as $l) { $driverapp = $gbl->getSyncClass(null, $l, 'vps'); if ($driverapp === 'openvz') { $rs[] = $l; } } $serverlist = $rs; if (!$this->checkIfLockedForAction('livemigrate')) { if ($this->olddeleteflag === 'doing') { $this->olddeleteflag = 'program_interrupted'; $this->setUpdateSubaction(); } } $vlist['olddeleteflag'] = array('M', null); $vlist['server_detail_f'] = array('M', pserver::createServerInfo($serverlist, $this->get__table())); $vlist['syncserver'] = array('s', $serverlist); return $vlist; case "append_inittab": $vlist['text_inittab'] = array('t', $this->text_inittab); return $vlist; case "append_xen_config": $vlist['text_xen_config'] = array('t', $this->text_xen_config); return $vlist; case "changelocation": if ($this->isXen()) { return $this->formChangeLocationXen(); } else { return $this->formChangeLocationOpenvz(); } break; case "createuser": $this->username = str_replace(".", "", $this->nname); $vlist['username'] = array('M', null); return $vlist; case "changeosimagename": $vlist['ostemplate'] = null; return $vlist; case "clonevps": $vlist['__v_button'] = array(); return $vlist; case "createtemplate": $stem = explode("-", $this->ostemplate); if ($this->isWindows()) { $name = "{$stem[0]}-"; } else { $name = "{$stem[0]}-{$stem[1]}-{$stem[2]}-"; } $vlist['newostemplate_name_f'] = array("m", array("pretext" => $name)); $vlist['__v_button'] = 'Create'; return $vlist; case "rebuild": if ($this->isWindows()) { $type = "img"; } else { $type = "tar.gz"; } $ostlist = vps::getVpsOsimage($this, $this->ttype, $type); $vlist['ostemplate'] = array('A', $ostlist); if ($this->isNotWindows() && $this->priv->isOn('backup_flag')) { //$vlist['rebuild_backup_f'] = null; } $vlist['rebuild_confirm_f'] = null; return $vlist; /* case "installkloxo": $this->kloxo_type = 'master'; $vlist['rebuild_confirm_f'] = null; $vlist['__v_button'] = 'Install'; return $vlist; */ /* case "installkloxo": $this->kloxo_type = 'master'; $vlist['rebuild_confirm_f'] = null; $vlist['__v_button'] = 'Install'; return $vlist; */ case "commandcenter": return $this->commandCenter($param); case "fixdev": $vlist['fixdev_confirm_f'] = null; return $vlist; case "rootpassword": if ($this->isXen()) { $vlist['__m_message_pre'] = 'xen_restart_message'; } $vlist['rootpassword'] = null; return $vlist; //ONly for Template... //ONly for Template... case "description": $vlist['description'] = null; //$vlist['share_status'] = null; if (!$this->isRightParent()) { $this->convertToUnmodifiable($vlist); } return $vlist; case "timezone": $vlist['timezone'] = array('s', pserver::getTimeZoneList()); return $vlist; case "information": $vlist['nname'] = array('M', $this->nname); $vlist['corerootdir'] = array('M', $this->corerootdir); $vlist['ddate'] = array('M', @date('d-m-Y', $this->ddate)); // $vlist['kloxo_flag'] = null; if ($login->isAdmin() && $this->isXen()) { $vlist['nosaveconfig_flag'] = null; } if (!$this->isXen()) { $vlist['vpsid'] = array('M', $this->vpsid); } if ($this->isXen() && $login->isAdmin()) { $vlist['vcpu_number'] = array('s', range(1, 10)); } if ($login->isAdmin()) { $use_slaves = "__use-slaves-backup-server__"; if (!$this->centralbackup_server) { $this->centralbackup_server = $use_slaves; } $sq = new Sqlite(null, "centralbackupserver"); $list = get_namelist_from_arraylist($sq->getTable(array('nname'))); $list = lx_merge_good(array($use_slaves), $list); //$vlist['centralbackup_flag'] = null; $vlist['centralbackup_server'] = array('s', $list); } $vlist['ostemplate'] = array('M', null); $vlist['parent_name_f'] = array('M', $this->getParentName()); //$vlist['dbtype_list'] = array('M', $this->listpriv->dbtype_list); $vlist['contactemail'] = ""; if (!$this->isLogin()) { $vlist['text_comment'] = null; } return $vlist; // Only for template. For the main guy, it comes as 'rebuild' // Only for template. For the main guy, it comes as 'rebuild' case "network": if ($this->isXen()) { $vlist['__m_message_pre'] = 'xen_restart_message'; } if (!$this->isLogin() || !$gen->isOn('disable_hostname_change')) { $vlist['hostname'] = null; } if ($this->isXen()) { if (!$this->networknetmask) { $this->networknetmask = "255.255.255.0"; } $vlist['networkgateway'] = null; $vlist['networknetmask'] = null; if ($login->priv->isOn('ip_manage_flag') || $login->isAdmin()) { $vlist['networkbridge'] = array('s', array("__automatic__", "xenbr0", "xenbr1", "xenbr2", "xenbr3", "xenbr4")); } } $iplist = $this->vmipaddress_a; $iplist = implode(", ", get_namelist_from_objectlist($iplist, 'nname')); $vlist['one_ipaddress_f'] = array('M', $iplist); $vlist['nameserver'] = null; return $vlist; case "ostemplate": $driverapp = $gbl->getSyncClass($this->__masterserver, $this->listpriv->vpspserver_sing, 'vps'); $ostlist = rl_exec_get(null, $this->listpriv->vpspserver_sing, array("vps__{$driverapp}", "getOsTemplatelist")); $ostlist = lx_merge_good(array('--defer-osimage--' => '--defer-osimage--'), $ostlist); $vlist['ostemplate'] = array('A', $ostlist); return $vlist; case "changesyncserver": $sq = new Sqlite(null, 'pserver'); $list = $sq->getTable(array('nname')); $list = get_namelist_from_arraylist($list); $vlist['syncserver'] = array('s', $list); $gbl->__ajax_refresh = true; return $vlist; // Only for template... // Only for template... case "vpspserver_s": $listpriv = $parent->listpriv; $vlist['server_detail_f'] = array('M', pserver::createServerInfo($listpriv->vpspserver_list, "vps")); $parent = $this->getParentO(); $vlist['vpspserver_sing'] = null; if (!$this->isRightParent()) { $this->convertToUnmodifiable($vlist); } return $vlist; } return parent::updateform($subaction, $param); }
static function addform($parent, $class, $typetd = null) { global $gbl, $sgbl, $login, $ghtml; $vlist['nname'] = array('m', array("posttext" => ".vm")); $nclist = $parent->getResourcePlanList('resourceplan'); $vlist['__v_button'] = $login->getKeywordUc('add'); $vlist['password'] = null; $vlist['num_ipaddress_f'] = array('s', range(0, 8)); $vlist['one_ipaddress_f'] = null; $vlist['contactemail'] = ""; $vlist['send_welcome_f'] = ""; $vlist['__c_subtitle_info'] = "Info"; $vlist['hostname'] = ""; if ($typetd['val'] === 'xen') { $vlist['networkgateway'] = null; } $vlist['nameserver'] = ""; $vlist['resourceplan_f'] = array('A', $nclist); $vlist['__c_subtitle_server'] = "Server"; //var_dump($typetd['val']); // $typetd['val'] openvz or xen in clientlib.php $serverlist = $parent->getVpsServers($typetd['val']); if (!$serverlist) { throw new lxexception('Server no configured for driver ' . $typetd['val'] . '. You can use setdriver.php for configure a driver. For example: cd /usr/local/lxlabs/hypervm/httpdocs; lphp.exe ../bin/common/setdriver.php --server=localhost --class=vps --driver=' . $typetd['val'] . '', '', ''); } $sinfo = pserver::createServerInfo($serverlist, "vps"); $sinfo = get_warning_for_server_info($parent, $sinfo); $vlist['server_detail_f'] = array('M', $sinfo); $vlist['syncserver'] = array('s', $serverlist); $vlist['ostemplate'] = array('A', vps::getVpsOsimage($parent, $typetd['val'])); $ret['variable'] = $vlist; $ret['action'] = "continue"; $ret['continueaction'] = "server"; return $ret; }
static function addform($parent, $class, $typetd = null) { global $gbl, $sgbl, $login, $ghtml; $vlist['nname'] = array('m', array("posttext" => ".vm")); $nclist = $parent->getResourcePlanList('resourceplan'); $vlist['__v_button'] = $login->getKeywordUc('add'); $vlist['password'] = null; $vlist['num_ipaddress_f'] = array('s', range(0, 8)); $vlist['num_ipv6address_f'] = array('s', range(0, 8)); $vlist['one_ipaddress_f'] = null; $vlist['contactemail'] = ""; $vlist['send_welcome_f'] = ""; $vlist['__c_subtitle_info'] = "Info"; $vlist['hostname'] = ""; if ($typetd['val'] === 'xen') { $vlist['networkgateway'] = null; } $vlist['nameserver'] = ""; $vlist['resourceplan_f'] = array('A', $nclist); $vlist['__c_subtitle_server'] = "Server"; $serverlist = $parent->getVpsServers($typetd['val']); if (!$serverlist) { // be more ModSecurity with OWASP_CRS friendly... throw new lxexception('not_configured_for_driver'); } $sinfo = pserver::createServerInfo($serverlist, "vps"); $sinfo = get_warning_for_server_info($parent, $sinfo); $vlist['server_detail_f'] = array('M', $sinfo); $vlist['syncserver'] = array('s', $serverlist); $vlist['ostemplate'] = array('A', vps::getVpsOsimage($parent, $typetd['val'])); $ret['variable'] = $vlist; $ret['action'] = "continue"; $ret['continueaction'] = "server"; return $ret; }