public function dbactionAdd() { global $gbl, $sgbl, $login, $ghtml; self::checkIfXenOK(); $ret = lxshell_return('xm', '--help'); if ($ret == 127) { throw new lxException('no_xen_at_all'); } $main = $this->main; $privilege = isset($main->priv) ? $main->priv : NULL; $diskusage = $privilege->disk_usage; // If unlimited put 3 GB, if not get use the normal disk usage (@todo checks if it's a bug) if ($this->isUnlimited($privilege->disk_usage)) { $diskusage = 3 * 1024; // Put 3 GB (@todo: no byte counted, is bad done on resource backend instead) } if ($main->isWindows() && $diskusage < 2 * 1024) { //throw new lxException("windows_needs_more_than_2GB"); } $freediskspace = $this->getFreeDiskSpace(); if ($freediskspace - $diskusage < 20) { throw new lxException('not_enough_space'); } $user_name = $main->username; $password = $main->password; $virtual_machine_name = $main->nname; if ($main->dbaction === 'syncadd') { $vps_username_created = vps::create_user($user_name, $password, $virtual_machine_name, self::XEN_CONSOLE_BINARY); return NULL; } if (self::getStatus($virtual_machine_name, self::XEN_HOME) !== 'deleted') { throw new lxException('a_virtual_machine_with_the_same_id_exists'); } // Check if the template begins with "windows-lxblank" if ($main->isBlankWindows()) { if (!lxfile_exists('/home/wincd.img')) { throw new lxException('windows_installation_image_missing'); } } /* if (!lxfile_exists("__path_program_home/xen/template/{$main->ostemplate}.tar.gz")) { throw new lxException("could_not_find_the_osimage", '', $main->ostemplate); } */ $vps_username_created = vps::create_user($user_name, $password, $virtual_machine_name, self::XEN_CONSOLE_BINARY); $this->createRootPath(); lxfile_mkdir($main->configrootdir); $this->setMemoryUsage(); $this->setCpuUsage(); $this->setSwapUsage(); $this->setDiskUsage(); if ($sgbl->isDebug()) { $this->doRealCreate(); } else { callObjectInBackground($this, 'doRealCreate'); } $result = array('__syncv_username' => $vps_username_created); return $result; }
function syncCreateUser() { if ($this->ttype === 'xen') { $shell = "/usr/bin/lxxen"; } else { $shell = "/usr/bin/lxopenvz"; } $username = vps::create_user($this->username, $this->password, $this->getIid(), $shell); $ret = array("__syncv_username" => $username); return $ret; }