Skip to content

Commit

Permalink
rescue mode, usage update functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Gavryliuk committed Feb 26, 2018
1 parent 3c014b3 commit 75fea0b
Show file tree
Hide file tree
Showing 15 changed files with 561 additions and 156 deletions.
2 changes: 1 addition & 1 deletion modules/servers/solusvmpro/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.9-4
4.1.0
5 changes: 5 additions & 0 deletions modules/servers/solusvmpro/get_client_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,9 @@

$cparams = $solusvm->clientAreaCalculations( $r );

if($r['rescuemode'] != 0){
$solusvm->apiCall( 'vserver-rescue', $callArray );
$cparams['rescueData'] = $solusvm->result;
}

echo json_encode( $cparams );
17 changes: 16 additions & 1 deletion modules/servers/solusvmpro/js/get_user_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ $(function () {
$("#controlpanellink").attr("onclick", "window.open('" + data.controlpanellink + "','_blank')");
}

var optionsIds = ["displayreboot", "displayshutdown", "displayboot", "displayconsole", "displayhtml5console", "displayvnc", "displayrootpassword", "displayhostname", "displayvncpassword", "displaypanelbutton", "displayclientkeyauth"];
var optionsIds = ["displayreboot", "displayshutdown", "displayboot", "displayconsole", "displayhtml5console", "displayvnc", "displayrootpassword", "displayhostname", "displayvncpassword", "displayrescuemode", "displaypanelbutton", "displayclientkeyauth"];
var showOptions = false;
optionsIds.forEach(function (v) {
if (data.hasOwnProperty(v)) {
Expand Down Expand Up @@ -94,6 +94,21 @@ $(function () {
$('#hddgraphurlImg').attr('src', data.hddgraphurl);
}

//rescueMode
if (data.rescuemode == 0) {
$('#rescueEnabled').show();
$('#rescueDisabled').remove();
}else if(data.rescueData){
$('#rescueDisabled').show();
$('#rescueEnabled').remove();

$('#rescueip').html(data.rescueData.ip);
$('#rescueport').html(data.rescueData.port);
$('#rescueuser').html(data.rescueData.user);
$('#rescuepassword').html(data.rescueData.password);
}


}).fail(function (jqXHR, textStatus) {
$('#displayState').hide();
$('#displayStateUnavailable').show();
Expand Down
85 changes: 85 additions & 0 deletions modules/servers/solusvmpro/js/rescuemode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
$(function () {
window.solusvmpro_rescuemode = function (vserverid, lang, token, area) {
token = typeof token !== 'undefined' ? token : "";
if (typeof vserverid === 'undefined') {
return false;
}

$('.changerescuemode').on('click', function () {
var button = $(this);
var rescueAction = 'rescueenable';
var rescueValue = $('#rescueImage').val();

if(typeof rescueValue === "undefined"){
rescueValue = true;
rescueAction = 'rescuedisable';
}

var msgSuccess = $('#rescuemodeMsgSuccess');
var msgError = $('#rescuemodedMsgError');
msgSuccess.hide();
msgError.hide();
var showSuccessOrErrorMsg = function (success, msg) {
msgSuccess.hide();
msgError.hide();
if (success) {
msgSuccess.html(msg);
msgSuccess.show();
} else {
msgError.html(msg);
msgError.show();
}
};

button.html('<span class="glyphicon glyphicon-refresh spinning"></span> ' + lang['solusvmpro_processing']);
button.prop('disabled', true);
var ajaxData = {
vserverid: vserverid,
modop: 'custom',
a: 'ChangeRescueMode',
rescueAction: rescueAction,
rescueValue: rescueValue,
ajax: 1,
ac: 'Custom_ChangeRescueMode'
};

$.ajax({
url: document.location.href + token,
data: ajaxData,
cache: false,
dataType: 'json'/*,
timeout: 2000*/
}).done(function (data) {

var dataMsg = '';
if (data.hasOwnProperty("msg")) {
dataMsg = data.msg;
}

var dataSuccess = false;
if (data.hasOwnProperty("success")) {
dataSuccess = data.success;
}

showSuccessOrErrorMsg(dataSuccess, dataMsg);

button.html(lang['solusvmpro_refresh']);
if(area == 'admin'){
button.attr('onclick', 'loadcontrol();');
$('#solusvmpro_collapseSeven .btn').removeClass('changerescuemode');
}else{
button.attr('onclick', 'location.reload();');
$('#solusvmpro_collapseSeven .btn').removeClass('changerescuemode');
}
button.prop('disabled', false);

}).fail(function (jqXHR, textStatus) {
//console.log(jqXHR);
//console.log(textStatus);
});
});

return true;
}
});

11 changes: 10 additions & 1 deletion modules/servers/solusvmpro/lang/arabic.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,13 @@
$_LANG['solusvmpro_shutdown_confirm_label'] = 'تأكيد إيقاف التشغيل';
$_LANG['solusvmpro_cancel'] = 'إلغاء';
$_LANG['solusvmpro_shutdown_confirm'] = 'هل تريد بالتأكيد إيقاف تشغيل هذا الخادم؟';
$_LANG['solusvmpro_reboot_confirm'] = 'هل تريد بالتأكيد إعادة تشغيل هذا الخادم؟';
$_LANG['solusvmpro_reboot_confirm'] = 'هل تريد بالتأكيد إعادة تشغيل هذا الخادم؟';
$_LANG['solusvmpro_rescueMode'] = 'وضع الإنقاذ';
$_LANG['solusvmpro_rescueImage'] = 'الإنقاذ صورة';
$_LANG['solusvmpro_enable'] = 'مكن';
$_LANG['solusvmpro_disable'] = 'تعطيل';
$_LANG['solusvmpro_processing'] = 'معالجة...';
$_LANG['solusvmpro_user'] = 'المستعمل';
$_LANG['solusvmpro_port'] = 'ميناء';
$_LANG['solusvmpro_rescueenabled'] = 'تمكين - وضع الإنقاذ يمكن أن يستغرق عدة دقائق قبل أن يصبح الوصول إليها على الشبكة';
$_LANG['solusvmpro_rescuedisabled'] = 'غير متاحة - يتم الآن إعادة تشغيل الملقم في النظام الأصلي';
12 changes: 11 additions & 1 deletion modules/servers/solusvmpro/lang/english.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,14 @@
$_LANG['solusvmpro_shutdown_confirm_label'] = 'Confirm Shutdown';
$_LANG['solusvmpro_cancel'] = 'Cancel';
$_LANG['solusvmpro_shutdown_confirm'] = 'Are you sure you wish to power off this server?';
$_LANG['solusvmpro_reboot_confirm'] = 'Are you sure you wish to restart this server?';
$_LANG['solusvmpro_reboot_confirm'] = 'Are you sure you wish to restart this server?';
$_LANG['solusvmpro_rescueMode'] = 'Rescue Mode';
$_LANG['solusvmpro_rescueImage'] = 'Rescue Image';
$_LANG['solusvmpro_enable'] = 'Enable';
$_LANG['solusvmpro_disable'] = 'Disable';
$_LANG['solusvmpro_processing'] = 'Processing...';
$_LANG['solusvmpro_user'] = 'User';
$_LANG['solusvmpro_port'] = 'Port';
$_LANG['solusvmpro_rescueenabled'] = 'Enabled - Rescue mode can take several minutes before it becomes accessible on the network';
$_LANG['solusvmpro_rescuedisabled'] = 'Disabled - The server is now rebooting into the original system';

11 changes: 10 additions & 1 deletion modules/servers/solusvmpro/lang/french.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,13 @@
$_LANG['solusvmpro_shutdown_confirm_label'] = 'Confirmer l&#39;arrêt';
$_LANG['solusvmpro_cancel'] = 'Annuler';
$_LANG['solusvmpro_shutdown_confirm'] = 'Êtes-vous sûr de vouloir éteindre ce serveur?';
$_LANG['solusvmpro_reboot_confirm'] = 'Êtes-vous sûr de vouloir redémarrer ce serveur?';
$_LANG['solusvmpro_reboot_confirm'] = 'Êtes-vous sûr de vouloir redémarrer ce serveur?';
$_LANG['solusvmpro_rescueMode'] = 'Mode de sauvetage';
$_LANG['solusvmpro_rescueImage'] = 'Image de sauvetage';
$_LANG['solusvmpro_enable'] = 'Activer';
$_LANG['solusvmpro_disable'] = 'Désactiver';
$_LANG['solusvmpro_processing'] = 'En traitement...';
$_LANG['solusvmpro_user'] = 'Utilisateur';
$_LANG['solusvmpro_port'] = 'Port';
$_LANG['solusvmpro_rescueenabled'] = "Activé - Le mode de secours peut prendre plusieurs minutes avant qu'il ne soit accessible sur le réseau";
$_LANG['solusvmpro_rescuedisabled'] = "Désactivé - Le serveur redémarre maintenant dans le système d'origine";
11 changes: 10 additions & 1 deletion modules/servers/solusvmpro/lang/italian.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,13 @@
$_LANG['solusvmpro_shutdown_confirm_label'] = 'Conferma lo spegnimento';
$_LANG['solusvmpro_cancel'] = 'Annulla';
$_LANG['solusvmpro_shutdown_confirm'] = 'Sei sicuro di voler spegnere questo server?';
$_LANG['solusvmpro_reboot_confirm'] = 'Sei sicuro di voler riavviare questo server?';
$_LANG['solusvmpro_reboot_confirm'] = 'Sei sicuro di voler riavviare questo server?';
$_LANG['solusvmpro_rescueMode'] = 'Modalità di salvataggio';
$_LANG['solusvmpro_rescueImage'] = "Salva l'immagine";
$_LANG['solusvmpro_enable'] = 'Abilitare';
$_LANG['solusvmpro_disable'] = 'disattivare';
$_LANG['solusvmpro_processing'] = 'In lavorazione...';
$_LANG['solusvmpro_user'] = 'Utente';
$_LANG['solusvmpro_port'] = 'Porta';
$_LANG['solusvmpro_rescueenabled'] = 'Abilitato - La modalità Rescue può richiedere diversi minuti prima che diventi accessibile sulla rete';
$_LANG['solusvmpro_rescuedisabled'] = 'Disabilitato: il server si sta riavviando nel sistema originale';
11 changes: 10 additions & 1 deletion modules/servers/solusvmpro/lang/russian.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,13 @@
$_LANG['solusvmpro_shutdown_confirm_label'] = 'Подтвердить завершение работы';
$_LANG['solusvmpro_cancel'] = 'Отмена';
$_LANG['solusvmpro_shutdown_confirm'] = 'Вы действительно хотите отключить этот сервер?';
$_LANG['solusvmpro_reboot_confirm'] = 'Вы действительно хотите перезапустить этот сервер?';
$_LANG['solusvmpro_reboot_confirm'] = 'Вы действительно хотите перезапустить этот сервер?';
$_LANG['solusvmpro_rescueMode'] = 'Режим спасения';
$_LANG['solusvmpro_rescueImage'] = 'Образ диска';
$_LANG['solusvmpro_enable'] = 'Включить';
$_LANG['solusvmpro_disable'] = 'Выключить';
$_LANG['solusvmpro_processing'] = 'Обработка ...';
$_LANG['solusvmpro_user'] = 'Пользователь';
$_LANG['solusvmpro_port'] = 'Порт';
$_LANG['solusvmpro_rescueenabled'] = 'Включено. Режим спасения может занять несколько минут, прежде чем он станет доступен в сети.';
$_LANG['solusvmpro_rescuedisabled'] = 'Отключено. Сервер теперь перезагружается в исходную систему.';
11 changes: 10 additions & 1 deletion modules/servers/solusvmpro/lang/spanish.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,13 @@
$_LANG['solusvmpro_shutdown_confirm_label'] = 'Confirmar apagado';
$_LANG['solusvmpro_cancel'] = 'Cancelar';
$_LANG['solusvmpro_shutdown_confirm'] = 'Está seguro de que desea apagar este servidor?';
$_LANG['solusvmpro_reboot_confirm'] = 'Está seguro de que desea reiniciar este servidor?';
$_LANG['solusvmpro_reboot_confirm'] = 'Está seguro de que desea reiniciar este servidor?';
$_LANG['solusvmpro_rescueMode'] = 'El modo de rescate';
$_LANG['solusvmpro_rescueImage'] = 'Imagen de rescate';
$_LANG['solusvmpro_enable'] = 'Habilitar';
$_LANG['solusvmpro_disable'] = 'Inhabilitar';
$_LANG['solusvmpro_processing'] = 'Tratamiento...';
$_LANG['solusvmpro_user'] = 'Usuario';
$_LANG['solusvmpro_port'] = 'Puerto';
$_LANG['solusvmpro_rescueenabled'] = 'Activado: el modo de rescate puede demorar varios minutos antes de que sea accesible en la red';
$_LANG['solusvmpro_rescuedisabled'] = 'Desactivado: el servidor se está reiniciando en el sistema original';
11 changes: 10 additions & 1 deletion modules/servers/solusvmpro/lang/ukranian.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,13 @@
$_LANG['solusvmpro_shutdown_confirm_label'] = 'Підтвердіть завершення роботи';
$_LANG['solusvmpro_cancel'] = 'скасувати';
$_LANG['solusvmpro_shutdown_confirm'] = 'Ви впевнені, що хочете вимкнути цей сервер?';
$_LANG['solusvmpro_reboot_confirm'] = 'Ви впевнені, що хочете перезапустити цей сервер?';
$_LANG['solusvmpro_reboot_confirm'] = 'Ви впевнені, що хочете перезапустити цей сервер?';
$_LANG['solusvmpro_rescueMode'] = 'Рятувальний режим';
$_LANG['solusvmpro_rescueImage'] = 'Образ Диску';
$_LANG['solusvmpro_enable'] = 'Увімкнути';
$_LANG['solusvmpro_disable'] = 'Відключити';
$_LANG['solusvmpro_processing'] = 'Обробка ...';
$_LANG['solusvmpro_user'] = 'Користувач';
$_LANG['solusvmpro_port'] = 'Порт';
$_LANG['solusvmpro_rescueenabled'] = 'Ввімкнено - режим рятування може тривати кілька хвилин, перш ніж він стане доступним у мережі';
$_LANG['solusvmpro_rescuedisabled'] = 'Відключено - сервер перезавантажується в оригінальній системі';
33 changes: 16 additions & 17 deletions modules/servers/solusvmpro/lib/SolusVM.php
Original file line number Diff line number Diff line change
Expand Up @@ -614,9 +614,9 @@ public function clientAreaCalculations( $result ) {
"displaytrafficgraph" => 0,
"displayloadgraph" => 0,
"displaymemorygraph" => 0,
"displayrescuemode" => 0,
);


$vstatusAr = array(
'online' => array(
'msg' => $_LANG['solusvmpro_online'],
Expand Down Expand Up @@ -744,15 +744,20 @@ public function clientAreaCalculations( $result ) {
$cparams["ipcsv"] = $result["ipaddresses"];
}
$cparams["mainip"] = $result["mainipaddress"];
if ( $result["type"] == "openvz" || $result["type"] == "xen" ) {
if ( $this->getExtData( "html5serialconsole" ) != "disable" ) {
$cparams["displayhtml5console"] = 1;
}
}

if ( $result["type"] == "openvz" || $result["type"] == "xen" ) {
if ( $this->getExtData( "serialconsole" ) != "disable" ) {
$cparams["displayconsole"] = 1;
}
if ( $this->getExtData( "rootpassword" ) != "disable" ) {
$cparams["displayrootpassword"] = 1;
}
if ( $this->getExtData( "hostname" ) != "disable" ) {
$cparams["displayhostname"] = 1;
}
if ( $this->getExtData( "html5serialconsole" ) != "disable" ) {
$cparams["displayhtml5console"] = 1;
}
} else {
if ( $this->getExtData( "vnc" ) != "disable" ) {
$cparams["displayvnc"] = 1;
Expand All @@ -762,22 +767,16 @@ public function clientAreaCalculations( $result ) {
}
}

if ( $result['type'] == 'kvm' ) {
$cparams['displayrescuemode'] = 1;
$cparams['rescuemode'] = $result['rescuemode'];
}

if ( $this->getExtData( "controlpanelbutton" ) != "" ) {
$cparams["displaypanelbutton"] = 1;
$cparams["controlpanellink"] = $this->getExtData( "controlpanelbutton" );
}

if ( $result["type"] == "openvz" || $result["type"] == "xen" ) {
if ( $this->getExtData( "rootpassword" ) != "disable" ) {
$cparams["displayrootpassword"] = 1;
}
}

if ( $this->getExtData( "hostname" ) != "disable" ) {
if ( $result["type"] == "openvz" || $result["type"] == "xen" ) {
$cparams["displayhostname"] = 1;
}
}

if ( $this->getExtData( "reboot" ) != "disable" ) {
$cparams["displayreboot"] = 1;
Expand Down
Loading

0 comments on commit 75fea0b

Please sign in to comment.