Commit b2ca7c03 authored by RemyD's avatar RemyD

2.4.5

parents
# ISPCONFIG Module hosted
## Code repositery
[GIT Server](https://git.csti.ch)
[CSTI SA ](https://www.csti.ch)
## Contacts
* [Facebook Company Page](https://www.facebook.com/CSTI.SA.CH)
* [LinkedIn Company Page](https://www.linkedin.com/company/csti-sa)
* [Twitter Company Page](https://www.twitter.com/CSTI_SA)
## Application details
This application is an Add-ons for ISPConfig used for VPS management (Vmware)
There is 2 level of security :
* Admin
* Users
## Requirements
* ISPConfig 3.0.5
* mysql database (it's also a requirement for ISPConfig)
* Vmware SDK
## Contribute
You can create an account on our git server.
## License
Copyright (c) 2013, CSTI SA
All rights reserved.
You are free to ditribute this module, but all changes without our consent is prohibited.
Please also note that any update will erase all files.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
RELEASE NOTES :
==============
Version 2.4.2 :
Latest supported version in production.
Manage your VPS :
- Start
- Shutdown
- Restart
- Hard Reboot (unplug the power)
Display :
- Power Status
- VPS Status
- Last Boot Time
- Installed Memory
- Commsumed Memory
- Installed CPU
- Consummed CPU
- Disk Space (Total, available, usage)
- Disk Partition details
- Operating System Type
- Operating System Details
- Events logs for VPS
- Events logs for this module (traking action)
Admin Function
- Snapshot Init (make a snapshot before go live a VPS)
- Remove All Snpashots
Admin Display
- vCenter Server
- GUID
- CPU details information (consummed, max used)
- Type
- Runing Task
- Configuration Date
- Last Service Update date
- Linked to Client
- All Events
- All Snapshots
- All Template
- Setup , configuration and update
<?php
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
require_once('../hosted/lib/class.csti.php');
/******************************************
* Begin Form configuration
******************************************/
$list_def_file = "list/config.list.php";
/******************************************
* End Form configuration
******************************************/
//* Check permissions for module
$app->auth->check_module_permissions('hosted');
$app->uses('listform_actions');
class list_action extends listform_actions {
}
$list = new list_action;
$list->SQLExtWhere = 'id=1';
$list->onLoad();
// $app->listform_actions->onLoad();
?>
\ No newline at end of file
<?php
$tform_def_file = "form/config.tform.php";
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
require_once('../hosted/lib/class.csti.php');
//* Check permissions for module
$app->auth->check_module_permissions('hosted');
// Loading classes
$app->uses('tpl,tform,tform_actions');
$app->load('tform_actions');
//* load language file
$lng_file = 'lib/lang/'.$_SESSION['s']['language'].'.lng';
include($lng_file);
class page_action extends tform_actions {
function onShowNew() {
global $app, $conf, $wb;
$app->tpl->setVar($wb);
parent::onShowNew();
}
function onShowEnd() {
global $app, $conf, $wb;
$app->tpl->setVar($wb);
parent::onShowEnd();
}
function onSubmit() {
global $app, $conf, $wb;
$app->tpl->setVar($wb);
parent::onSubmit();
}
}
$page = new page_action;
$page->onLoad();
?>
\ No newline at end of file
<?php
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
require_once('../hosted/lib/class.csti.php');
/******************************************
* Begin Form configuration
******************************************/
$list_def_file = "list/events.list.php";
/******************************************
* End Form configuration
******************************************/
//* Check permissions for module
$app->auth->check_module_permissions('hosted');
$app->uses('listform_actions');
class list_action extends listform_actions {
}
$list = new list_action;
if (isset($_REQUEST['vmid'])) {
$_SESSION["s"]["user"]["vmid"] =$_REQUEST['vmid'];
} else {
if ($_SESSION["s"]["user"]["typ"]=='admin'){
unset($_SESSION["s"]["user"]["vmid"]);
}
}
if (isset($_SESSION["s"]["user"]["vmid"])){
$SQLExtWhere = 'vmname=(select vmname from hosted where vmid="'.$_SESSION["s"]["user"]["vmid"].'")';
$list->SQLExtWhere= $SQLExtWhere;
}
$list->SQLOrderBy = 'ORDER BY start_time desc';
$list->onLoad();
?>
\ No newline at end of file
<?php
$form["title"] = "Config";
$form["description"] = "";
$form["name"] = "Config";
$form["action"] = "config_edit.php";
$form["db_table"] = "hosted_Setup";
$form["db_table_idx"] = "id";
$form["db_history"] = "yes";
$form["tab_default"] = "details";
$form["list_default"] = "config.php";
$form["auth"] = 'yes'; // yes / no
$form["auth_preset"]["userid"] = 0; // 0 = id of the user, > 0 id must match with id of current user
//$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
$form["tabs"]['details'] = array (
'title' => "Config VMware",
'width' => 100,
'template' => "templates/config_edit.htm",
'fields' => array (
'username' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'width' => '30',
'maxlength' => '50'
),
'password' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'width' => '30',
'maxlength' => '50'
),
'server' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'width' => '30',
'maxlength' => '55'
),
'loglevel' => array (
'datatype' => 'INTEGER',
'formtype' => 'SELECT',
'default' => '',
'value' => array ( 0 =>'0',1 =>'1', 2 => '2', 3 => '3' , 4 =>'4', 5 =>'5'),
'width' => '30',
'maxlength' => '10'
),
)
);
?>
\ No newline at end of file
<?php
$form["title"] = "Details";
$form["description"] = "";
$form["name"] = "snapshots";
$form["action"] = "snapshots_details.php";
$form["db_table"] = "hosted_snapshots";
$form["db_table_idx"] = "id";
$form["db_history"] = "yes";
$form["tab_default"] = "details";
$form["list_default"] = "snapshots_list.php";
$form["auth"] = 'yes'; // yes / no
$form["auth_preset"]["userid"] = 0; // 0 = id of the user, > 0 id must match with id of current user
//$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
$form["tabs"]['details'] = array (
'title' => "snapshots",
'width' => 100,
'readonly' => true,
'template' => "templates/snapshots_details.htm",
'fields' => array (
'vmid' => array (
'datatype' => 'VARCHAR',
'formtype' => 'SELECT',
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'select vmid,vmname from hosted',
'keyfield'=> 'vmid',
'valuefield'=> 'vmname'
),
'default' => '',
'value' => '',
'width' => '30',
'maxlength' => '255'
),
'snap_name' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'width' => '30',
'maxlength' => '255'
),
'snap_desc' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'width' => '30',
'maxlength' => '255'
),
'snap_level' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'width' => '30',
'maxlength' => '255'
),
'update_date' => array (
'datatype' => 'DATETIME',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'width' => '30',
'maxlength' => '255'
),
'isInit' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '',
'value' => array ( 1 =>'Yes', 0 =>'No', 2 => '???'),
'width' => '30',
'maxlength' => '255'
),
)
##################################
# ENDE Datatable fields
##################################
);
?>
\ No newline at end of file
<?php
$form["title"] = "Details";
$form["description"] = "";
$form["name"] = "hosted";
$form["action"] = "vps_details.php";
$form["db_table"] = "hosted";
$form["db_table_idx"] = "id";
$form["db_history"] = "yes";
$form["tab_default"] = "hosted";
$form["list_default"] = "vps_list.php";
$form["auth"] = 'yes'; // yes / no
$form["auth_preset"]["userid"] = 0; // 0 = id of the user, > 0 id must match with id of current user
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
$form["tabs"]['hosted'] = array (
'title' => "Details",
'width' => 100,
'readonly' => true,
'template' => "templates/vps_details.htm",
'fields' => array (
'datacenter_server' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'width' => '30',
'maxlength' => '255'
),
'vmid' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'width' => '30',
'maxlength' => '255'
),
'task_run' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'width' => '30',
'maxlength' => '255'
),
// vm_disk_freespace_GB task_run
##################################
# ENDE Datatable fields
##################################
)
);
if($_SESSION["s"]["user"]["typ"] == 'admin') {
$form["tabs"]['client'] = array (
'title' => "client",
'width' => 100,
'template' => "templates/vps_edit.htm",
'fields' => array (
'sys_groupid' => array (
'datatype' => 'INTEGER',
'formtype' => 'SELECT',
'datasource' => array ( 'type' => 'SQL',
'querystring' => "SELECT sys_group.groupid, CONCAT(client.company_name,' :: ',client.contact_name) as name FROM sys_group, client WHERE sys_group.client_id = client.client_id AND sys_group.client_id > 0 ORDER BY sys_group.name",
'keyfield'=> 'groupid',
'valuefield'=> 'name'
),
'default' => '',
'value' => '',
'width' => '30',
'maxlength' => '255'
),
)
);
}
?>
\ No newline at end of file
function sendCmd( act, vmid, vmname ){
// Definition du message prompt
switch (act) {
case "Info" :
sendAction( act, vmid, false );
break
case "Init" :
var promptStr = "This will restore "+vmname+" to the factory state !";
securityAndAction( act, vmid, true, true, vmname, promptStr );
break
case "Reboot" :
var promptStr = ucFirst(vmname)+" will be restarted.";
securityAndAction( act, vmid, true, true, vmname, promptStr );
break
case "Reset" :
var promptStr = ucFirst(vmname)+" will be restarted.";
securityAndAction( act, vmid, true, true, vmname, promptStr );
break
case "Shutdown" :
var promptStr = ucFirst(vmname)+" will be stopped.";
securityAndAction( act, vmid, true, true, vmname, promptStr );
break
case "Startup" :
var promptStr = ucFirst(vmname)+" will be started.";
securityAndAction( act, vmid, true, false, vmname, promptStr );
break
case "Snapshot" :
var promptStr = ucFirst(vmname)+" will do snapshot.";
securityAndAction( act, vmid, true, false, vmname, promptStr );
break
default :
securityAndAction( act, vmid, true, false, vmname, promptStr );
}
}
function securityAndAction( act, vmid, reload, isPrompt, vmname, promptCustom ){
if( isPrompt ){
var promptText = promptCustom+"\r\nWrite the VPS name as shown in the list to launch this action (case sensitive).";
var response = promptDisplay( promptText );
if ( response.toLowerCase()==vmname.toLowerCase() ) {
alert( "This operation can take a while. Please refresh the page to see the VPS's status.");
sendAction( act, vmid, reload );
}else if ( response==null ){
// alert( "Cancelled." );
}else{
alert( "The VPS name is not the correct one. Please verifiy." );
}
}else{
var response = confirm( promptCustom );
if( response ){
sendAction( act, vmid, reload );
}
}
}
function sendAction ( act, vmid, reload ) {
var phpScript = "hosted/actions/action.php?act="+act+"&vmid="+vmid;
$.ajax({
type:"GET",
url: phpScript,
success: function(retour){
if( reload ){ location.reload(); }
}
});
return false;
}
function promptDisplay( message ){
var retVal = prompt( message, "" );
return( retVal );
}
function showHistory( vmid ){
var act="log";
$.get("hosted/actions/action.php?act="+act+"&vmid="+vmid, function( resultJson ) {
var logHtml = '<table><tr><th>Description</th><th>Status</th><th>Start</th><th>End</th></tr>';
var logJson = jQuery.parseJSON( resultJson );
$.each( logJson, function(index, value){
var desc = value.task_description;
if( value.end_date == "0000-00-00 00:00:00" ){
var end = "";
}else{
var end = value.end_date+" GMT";
}
logHtml += '<tr>'+'<td><b>'+desc+'</b></td>'+'<td>'+value.task_status+'</td>'+'<td>'+value.start_time+' GMT</td>'+'<td>'+end+'</td>'+'</tr>';
});
logHtml += '</table>';
// Affichage du html dans le TR crée
$( "#"+vmid ).closest( "tr" ).after( $( "<tr id='info_"+vmid+"' class='tableLog'><td colspan='5'>"+showInfo(vmid)+logHtml+"</td></tr>" ).show( 300 ) );
});
}
function showInfo( vmid ){
var infoHtml = '<div class="stateview" id="info_'+vmid+'"><div class="systemmonitor-state state-info"><div class="systemmonitor-content icons32 ico-info">';
var resultJson = (function(){
var val = null;
$.ajax({
'async': false,
'global': false,
'url': "hosted/actions/action.php?act=info&vmid="+vmid,
'success': function (data) {
val = data;
}
});
return val;
})();
var infoJson = jQuery.parseJSON( resultJson );
$.each( infoJson, function( index, value ){
infoHtml += "<b>Boot time</b> : "+value.vmbootTime+"<br/>";
infoHtml += "<b>Disk usage</b> : "+value.vm_disk_freespace_GB+" GB free of "+value.vm_disk_capacity_GB+" GB<br/>";
infoHtml += "<b>Memory configured</b> : "+value.vm_mem_MB+" MB<br/>";
infoHtml += "<b>CPU number</b> : "+value.vm_cpu;
});
infoHtml += "</div></div></div>";
return( infoHtml );
}
function ucFirst( string ) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
function toggleLog( vmid ){
if ( $("#info_"+vmid).length > 0 ){
$("#info_"+vmid).remove();
}else{
showHistory( vmid );
}
}
function linkClientVps( clientId, vpsId ){
if( (clientId!=null) && (vpsId!=null) ){
$.ajax({
url: 'hosted/actions/linkVpsUser.php',
data: 'clientId='+clientId+'&vpsId='+vpsId,
success: function(data) {
alert(data);
}
});
}else{
alert( "Please select a client and a virtual machine.");
}
}
function unlinkClientVps( clientId, vpsId ){
if( vpsId!=null ){
$.ajax({
url: 'hosted/actions/unlinkVpsUser.php',
data: 'vpsId='+vpsId,
success: function(data) {
alert(data);
}
});
}else{
alert( "Please select a client and a virtual machine.");
}
}
This diff is collapsed.
<?php
?>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
<?php
$wb["list_head_txt"] = 'Virtual Private Server';
$wb["vmname_txt"] = 'Name';
$wb["status_pwr_txt"] = 'Power';
$wb["status_vmw_txt"] = 'Status';
$wb["vmtype_txt"] = 'Type ';
$wb['vm_disk_capacity_GB_txt'] =' Total';
$wb['vm_disk_freespace_GB_txt'] ='Free Space';
$wb['ipAddress_txt'] ='Ip Address';
$wb['vm_OS_txt'] ='Operating System';
$wb['vm_config_date_txt'] ='Configuration Date';
$wb['client_id_txt'] ='Client Name';
$wb['datacenter_server_txt'] ='Datacenter Server';
$wb['vmid_txt'] ='Virtual ID';
$wb['updateDate_txt'] ='Last update date';
$wb['vmbootTime_txt'] ='Last Boot Time';
$wb['vm_mem_MB_txt'] ='Installed Memory';
$wb['vm_mem_consume_txt'] ='Memory Usage';
$wb['vm_cpu_txt'] ='Installed CPU';
$wb['task_run_txt'] ='Running Task';
$wb['action_list_txt'] = 'Possible Actions';
$wb['cpu_img_usage_txt'] ="CPU Usage";
?>
\ No newline at end of file
<?php
$wb["username_txt"] = 'username';
$wb["password_txt"] = 'password';
$wb["server_txt"] = 'server';
$wb["loglevel_txt"] = 'Log level for services (1 to 5 )';
?>
\ No newline at end of file
<?php
$wb["list_head_txt"] = 'Configuration';
$wb["username_txt"] = 'username';
$wb["password_txt"] = 'password';
$wb["server_txt"] = 'server';
?>
\ No newline at end of file
<?php
$wb["list_head_txt"] = "Liste d'événements";
$wb["vmname_txt"] = 'Nom';
$wb["task_id_txt"] = 'Identifiant';
$wb["task_status_txt"] = 'Status';
$wb["task_description_txt"] = 'Description';
$wb["start_time_txt"] = 'Date de départ';
$wb["end_date_txt"] = 'Date de fin';
?>
\ No newline at end of file
<?php
$wb["client_id_txt"] = 'client_id';
$wb["datacenter_server_txt"] = 'datacenter_server';
$wb["vmname_txt"] = 'vmname';
$wb["vmid_txt"] = 'vmid';
$wb["status_pwr_txt"] = 'status_pwr';
$wb["status_vmw_txt"] = 'status_vmw';
$wb["0_txt"] = '0';
$wb["vmtype_txt"] = 'vmtype';
$wb["updateDate_txt"] = 'updateDate';
$wb["vmbootTime_txt"] = 'vmbootTime';
$wb["vm_mem_MB_txt"] = 'vm_mem_MB';
$wb["vm_cpu_txt"] = 'vm_cpu';
$wb["vm_config_date_txt"] = 'vm_config_date';
$wb["vm_disk_capacity_GB_txt"] = 'vm_disk_capacity_GB';
$wb["vm_OS_txt"] = 'vm_OS';
$wb["vm_disk_freespace_GB_txt"] = 'vm_disk_freespace_GB';
$wb["task_run_txt"] = 'task_run';
?>
\ No newline at end of file