Fixes and reinstall

feature/node-rewrite
Sven Slootweg 13 years ago
parent 25b951dfd0
commit 5f8d9f8332

@ -249,6 +249,8 @@ class Container extends CPHPDatabaseRecordClass
$this->uRootPassword = $sRootPassword; $this->uRootPassword = $sRootPassword;
$this->InsertIntoDatabase(); $this->InsertIntoDatabase();
var_dump($this->sTemplate->sTemplateName);
$command = shrink_command("vzctl create {$this->sInternalId} $command = shrink_command("vzctl create {$this->sInternalId}
--ostemplate {$this->sTemplate->sTemplateName} --ostemplate {$this->sTemplate->sTemplateName}
"); ");
@ -376,7 +378,7 @@ class Container extends CPHPDatabaseRecordClass
public function Destroy() public function Destroy()
{ {
if($this->sCurrentStatus == CVM_STATUS_RUNNING) if($this->sCurrentStatus == CVM_STATUS_STARTED)
{ {
$this->Stop(); $this->Stop();
} }
@ -423,7 +425,7 @@ class Container extends CPHPDatabaseRecordClass
} }
elseif($this->sStatus == CVM_STATUS_TERMINATED) elseif($this->sStatus == CVM_STATUS_TERMINATED)
{ {
throw new ContainerSuspendedException("The container cannot be started as it is terminated.", 1, $this->sInternalId); throw new ContainerTerminatedException("The container cannot be started as it is terminated.", 1, $this->sInternalId);
} }
else else
{ {

@ -13,6 +13,70 @@
if(!isset($_CVM)) { die("Unauthorized."); } if(!isset($_CVM)) { die("Unauthorized."); }
$display_form = true;
if(isset($_POST['submit']))
{
if(!empty($_POST['template']))
{
try
{
$sTemplate = new Template($_POST['template']);
if($sTemplate->sIsAvailable === true)
{
if(isset($_POST['confirm']))
{
if($sContainer->sStatus != CVM_STATUS_SUSPENDED)
{
try
{
$sContainer->uTemplateId = $sTemplate->sId;
$sContainer->InsertIntoDatabase();
$sContainer->Reinstall();
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_SUCCESS, "Reinstallation succeeded!", "Your VPS was successfully reinstalled.");
$sPageContents .= $err->Render();
}
catch (ContainerReinstallException $e)
{
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, "Reinstallation failed", "Something went wrong during the reinstallation of your VPS. Please try again. If the reinstallation fails again, please contact support.");
$sPageContents .= $err->Render();
}
}
else
{
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, "Reinstallation aborted", "You can not reinstall this VPS, because it is suspended. If you believe this is in error, please contact support.");
$sPageContents .= $err->Render();
}
}
else
{
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, "Reinstallation aborted", "You did not tick the checkbox at the bottom of the page. Please carefully read the warning, tick the checkbox, and try again.");
$sPageContents .= $err->Render();
}
}
else
{
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, "Reinstallation aborted", "The template you selected is not available. Please select a different template.");
$sPageContents .= $err->Render();
}
}
catch (NotFoundException $e)
{
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, "Reinstallation aborted", "The template you selected does not exist (anymore). Please select a different template.");
$sPageContents .= $err->Render();
}
}
else
{
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, "No template selected", "You did not select a template from the list. Please select a template and try again.");
$sPageContents .= $err->Render();
}
}
if($display_form === true)
{
$result = mysql_query_cached("SELECT * FROM templates WHERE `Available` = '1'"); $result = mysql_query_cached("SELECT * FROM templates WHERE `Available` = '1'");
$sTemplateList = array(); $sTemplateList = array();
@ -27,8 +91,8 @@ foreach($result->data as $row)
); );
} }
$sPageContents = Templater::InlineRender("vps.reinstall", $locale->strings, array( $sPageContents .= Templater::InlineRender("vps.reinstall", $locale->strings, array(
'templates' => $sTemplateList 'templates' => $sTemplateList
)); ));
}
?> ?>

Loading…
Cancel
Save