Skip to content

Commit

Permalink
v1.2.0: Client Area & Actions now OK
Browse files Browse the repository at this point in the history
  • Loading branch information
lsthompson committed Jun 18, 2023
1 parent 512d2eb commit 644f606
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 40 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Changelog
All notable changes to Proxmox VE for WHMCS will be documented in this file.

## [1.2.0b] - Not yet released
## [1.2.0b] - 2013-06-18

### Added
- Link off to GitHub Issues for Support from the Module page in WHMCS
Expand All @@ -21,15 +21,18 @@ All notable changes to Proxmox VE for WHMCS will be documented in this file.
- Updated noVNC, TigerVNC, Ubuntu, Debian and CentOS interface images
- Improved error handling and pass-back from Proxmox to Class to WHMCS
- Updated the PVE2 API Class and improved its logging (prefix/exception)
- Method to fire API Calls updated due to reduction in WHMCS param scope

### Fixed
- Regression in v1.1 with missing semicolon breaking activation (#14)
- Edit Icon not rendering on IP/Pool edit page, missing asset (#13)
- Relative link to PVE2 API Class file broken, use ROOTDIR (#13/15)
- IPv4 Address functions, update file to use float not real (#13)
- Container (CT/LXC) Swap reporting in Client Area now working
- RRD (Usage) measurements: params attached to requests
- RRD (Usage) measurements: params attached to requests OK
- API Requests for Creation now functional (fixes #17)
- Client Area pages/actions now fixed (fixes #19)
- Font Awesome icons fixed in the Client Area

## [1.1b] - 2023-06-06

Expand Down
2 changes: 1 addition & 1 deletion modules/addons/pvewhmcs/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ function pvewhmcs_hook_logout($vars) {
}

// Define Client Logout Hook Call
add_hook("ClientLogout",1,"pvewhmcs_hook_logout");
add_hook("ClientLogout",1,"pvewhmcs_hook_logout");
4 changes: 2 additions & 2 deletions modules/addons/pvewhmcs/pvewhmcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ function pvewhmcs_config() {
$configarray = array(
"name" => "Proxmox VE for WHMCS",
"description" => "Proxmox Virtual Environment + WHMCS",
"version" => "1.1",
"version" => "1.2.0",
"author" => "The Network Crew Pty Ltd",
'language' => 'English'
);
return $configarray;
}

function pvewhmcs_version(){
return "1.1";
return "1.2.0";
}

function pvewhmcs_activate() {
Expand Down
11 changes: 6 additions & 5 deletions modules/servers/pvewhmcs/clientarea.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
</div>
<div class="col col-md-2">
<img src="/modules/servers/pvewhmcs/img/{$vm_status['status']}.png"/><br/>
{$vm_status['status']}<br/>
Uptime:&nbsp;{$vm_status['uptime']}
<span style="text-transform: uppercase"><strong>{$vm_status['status']}</strong></span><br/>
Up:&nbsp;{$vm_status['uptime']}

</div>
<div class="col col-md-7">
Expand Down Expand Up @@ -57,7 +57,7 @@

<table class="table table-bordered table-striped">
<tr>
<td>Assigned IPv4 Address</td><td>{$vm_config['ipv4']}&nbsp;Subnet Mask:&nbsp;{$vm_config['netmask4']}&nbsp;Gateway:&nbsp;{$vm_config['gateway4']}</td>
<td>Network Addressing</td><td>{$vm_config['ipv4']}&nbsp;Subnet Mask:&nbsp;{$vm_config['netmask4']}&nbsp;Gateway:&nbsp;{$vm_config['gateway4']}</td>
</tr>
<tr>
<td>OS (Type)</td>
Expand Down Expand Up @@ -86,8 +86,9 @@
{$disk=(","|explode:$vm_config['ide0'])}
{$disk[1]}
{$rootfs[1]}

<br/>{$vm_config['scsci0']}</td>
{$vm_config['scsi0']}
{$vm_config['virtio0']}
</td>
</tr>
</table>
{if ($smarty.get.a eq 'vmStat')}
Expand Down
Binary file added modules/servers/pvewhmcs/img/os/l24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added modules/servers/pvewhmcs/img/os/l26.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
103 changes: 73 additions & 30 deletions modules/servers/pvewhmcs/pvewhmcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -522,22 +522,32 @@ function get_server_pass_from_whmcs($enc_pass){
function pvewhmcs_ClientAreaCustomButtonArray() {
$buttonarray = array(
"<img src='./modules/servers/pvewhmcs/img/tigervnc.png'/> TigerVNC (Java)" => "javaVNC",
"<img src='./modules/servers/pvewhmcs/img/novnc.png'/> NoVNC (HTML5)" => "noVNC",
"<i class='fa fa-2x fa-plug'></i> Start" => "vmStart",
"<i class='fa fa-2x fa-power-off'></i> Shutdown" => "vmShutdown",
"<i class='fa fa-2x fa-stop'></i> Stop" => "vmStop",
"<i class='fa fa-2x fa fa-line-chart'></i> Statistics" => "vmStat",
"<img src='./modules/servers/pvewhmcs/img/novnc.png'/> noVNC (HTML5)" => "noVNC",
"<i class='fa fa-2x fa-flag-checkered'></i> Start VM/CT" => "vmStart",
"<i class='fa fa-2x fa-power-off'></i> Shut Down" => "vmShutdown",
"<i class='fa fa-2x fa-stop'></i> Stop VM/CT" => "vmStop",
"<i class='fa fa-2x fa-chart-bar'></i> Statistics" => "vmStat",
);
return $buttonarray;
}

function pvewhmcs_ClientArea($params) {
//reterive virtual machine info from table mod_pvewhmcs_vms
// Retrieve virtual machine info from table mod_pvewhmcs_vms
$guest=Capsule::table('mod_pvewhmcs_vms')->where('id','=',$params['serviceid'])->get()[0] ;
$serverip = $params["serverip"];
$serverusername = $params["serverusername"];
$serverpassword = $params["serverpassword"];
$proxmox=new PVE2_API($serverip, $serverusername, "pam", $serverpassword);

// Gather access credentials for PVE, as these are no longer passed for Client Area
$pveservice=Capsule::table('tblhosting')->find($params['serviceid']) ;
$pveserver=Capsule::table('tblservers')->where('id','=',$pveservice->server)->get()[0] ;

$serverip = $pveserver->ipaddress;
$serverusername = $pveserver->username;

$api_data = array(
'password2' => $pveserver->password,
);
$serverpassword = localAPI('DecryptPassword', $api_data);

$proxmox=new PVE2_API($serverip, $serverusername, "pam", $serverpassword['password']);
if ($proxmox->login()) {
//$proxmox->setCookie();
# Get first node name.
Expand Down Expand Up @@ -568,7 +578,7 @@ function pvewhmcs_ClientArea($params) {

if ($guest->vtype == 'lxc') {
$ct_specific=$proxmox->get('/nodes/'.$first_node.'/lxc/'.$params['serviceid'] .'/status/current') ;
$vm_status['swapusepercent'] = intval($ct_specific['swap'] * 100 / $ct_specific['maxswap']);
$vm_status['swapusepercent'] = intval($ct_specific['swap'] * 100 / $ct_specific['maxswap']);
}
} else {
// Handle the VM not found in the cluster resources (Optional)
Expand Down Expand Up @@ -678,19 +688,21 @@ function pvewhmcs_ClientArea($params) {
$vm_config['netmask4']=$guest->subnetmask ;
$vm_config['gateway4']=$guest->gateway ;
$vm_config['created']=$guest->created ;

}
else echo '<center><strong>Unable to contact Hypervisor - aborting!<br>Please contact Tech Support.</strong></center>' ; die;
else {
echo '<center><strong>Unable to contact Hypervisor - aborting!<br>Please contact Tech Support.</strong></center>';
die;
}

return array(
'templatefile' => 'clientarea',
'templateVariables' =>array(
'vars' => array(
'params' => $params,
'vm_config'=>$vm_config,
'vm_status'=>$vm_status,
'vm_statistics'=>$vm_statistics,
'vm_vncproxy'=>$vm_vncproxy,
)
),
);
}

Expand Down Expand Up @@ -752,56 +764,87 @@ function pvewhmcs_javaVNC($params){
}

function pvewhmcs_vmStart($params) {
$serverip = $params["serverip"];
$serverusername = $params["serverusername"];
$serverpassword = $params["serverpassword"];
$proxmox=new PVE2_API($serverip, $serverusername, "pam", $serverpassword);
// Gather access credentials for PVE, as these are no longer passed for Client Area
$pveservice=Capsule::table('tblhosting')->find($params['serviceid']) ;
$pveserver=Capsule::table('tblservers')->where('id','=',$pveservice->server)->get()[0] ;

$serverip = $pveserver->ipaddress;
$serverusername = $pveserver->username;

$api_data = array(
'password2' => $pveserver->password,
);
$serverpassword = localAPI('DecryptPassword', $api_data);
$proxmox=new PVE2_API($serverip, $serverusername, "pam", $serverpassword['password']);
if ($proxmox->login()) {
//$proxmox->setCookie();
# Get first node name.
$nodes = $proxmox->get_node_list();
$first_node = $nodes[0];
unset($nodes);
$guest=Capsule::table('mod_pvewhmcs_vms')->where('id','=',$params['serviceid'])->get()[0] ;
$pve_cmdparam = array();
$pve_cmdparam['timeout'] = '60';

if ($proxmox->post('/nodes/'.$first_node.'/'.$guest->vtype.'/'.$params['serviceid'].'/status/start'))
if ($proxmox->post('/nodes/' . $first_node . '/' . $guest->vtype . '/' . $params['serviceid'] . '/status/start' , $pve_cmdparam))
return true ;
}
return false;
}

function pvewhmcs_vmShutdown($params) {
$serverip = $params["serverip"];
$serverusername = $params["serverusername"];
$serverpassword = $params["serverpassword"];
$proxmox=new PVE2_API($serverip, $serverusername, "pam", $serverpassword);
// Gather access credentials for PVE, as these are no longer passed for Client Area
$pveservice=Capsule::table('tblhosting')->find($params['serviceid']) ;
$pveserver=Capsule::table('tblservers')->where('id','=',$pveservice->server)->get()[0] ;

$serverip = $pveserver->ipaddress;
$serverusername = $pveserver->username;

$api_data = array(
'password2' => $pveserver->password,
);
$serverpassword = localAPI('DecryptPassword', $api_data);
$proxmox=new PVE2_API($serverip, $serverusername, "pam", $serverpassword['password']);
if ($proxmox->login()) {
//$proxmox->setCookie();
# Get first node name.
$nodes = $proxmox->get_node_list();
$first_node = $nodes[0];
unset($nodes);
$guest=Capsule::table('mod_pvewhmcs_vms')->where('id','=',$params['serviceid'])->get()[0] ;
$pve_cmdparam = array();
$pve_cmdparam['timeout'] = '60';

if ($proxmox->post('/nodes/'.$first_node.'/'.$guest->vtype.'/'.$params['serviceid'].'/status/shutdown'))
if ($proxmox->post('/nodes/' . $first_node . '/' . $guest->vtype . '/' . $params['serviceid'] . '/status/shutdown' , $pve_cmdparam))
return true ;
}
return false;
}

function pvewhmcs_vmStop($params) {
$serverip = $params["serverip"];
$serverusername = $params["serverusername"];
$serverpassword = $params["serverpassword"];
$proxmox=new PVE2_API($serverip, $serverusername, "pam", $serverpassword);
// Gather access credentials for PVE, as these are no longer passed for Client Area
$pveservice=Capsule::table('tblhosting')->find($params['serviceid']) ;
$pveserver=Capsule::table('tblservers')->where('id','=',$pveservice->server)->get()[0] ;

$serverip = $pveserver->ipaddress;
$serverusername = $pveserver->username;

$api_data = array(
'password2' => $pveserver->password,
);
$serverpassword = localAPI('DecryptPassword', $api_data);
$proxmox=new PVE2_API($serverip, $serverusername, "pam", $serverpassword['password']);
if ($proxmox->login()) {
//$proxmox->setCookie();
# Get first node name.
$nodes = $proxmox->get_node_list();
$first_node = $nodes[0];
unset($nodes);
$guest=Capsule::table('mod_pvewhmcs_vms')->where('id','=',$params['serviceid'])->get()[0] ;
if ($proxmox->post('/nodes/'.$first_node.'/'.$guest->vtype.'/'.$params['serviceid'].'/status/stop'))
$pve_cmdparam = array();
$pve_cmdparam['timeout'] = '60';

if ($proxmox->post('/nodes/' . $first_node . '/' . $guest->vtype . '/' . $params['serviceid'] . '/status/stop' , $pve_cmdparam))
return true ;
}
return false;
Expand Down

0 comments on commit 644f606

Please sign in to comment.