94 Commits

Author SHA1 Message Date
Luke S Thompson
22d19b4ad4 v1.2.3: New CPUs; Conn. Test OK; Debug Log polish 2023-12-31 17:40:05 +10:00
Luke S Thompson
69e5a830ce Change to stacked logo 2023-12-23 22:45:49 +10:00
Luke S Thompson
a6ed7d001a Delete zLOGO.png 2023-12-23 22:45:27 +10:00
Luke S Thompson
66c1058970 Updated logo variant 2023-12-23 22:44:57 +10:00
Luke S Thompson
8a21e011f9 De-emoji a little bit (only) 2023-12-23 22:43:53 +10:00
Luke S Thompson
57c39489f8 Merge branch 'master' of https://github.com/The-Network-Crew/Proxmox-VE-for-WHMCS 2023-12-18 11:21:36 +10:00
Luke S Thompson
bc9e4554fa Explicit GPLv3 in each PHP file 2023-12-18 11:21:32 +10:00
Luke S Thompson
7d76126bdf Add dependency licenses 2023-12-18 07:49:30 +10:00
Luke S Thompson
b497a0e928 Add release year for IPv4 val. 2023-12-18 07:40:13 +10:00
Luke S Thompson
38463dd97d Add IPv4 input validator to deps 2023-12-18 07:39:30 +10:00
Luke S Thompson
448aadfffd Minor tweaks 2023-12-18 07:30:51 +10:00
Luke S Thompson
f822293c80 GH Issues links in, so add Code Design info etc 2023-12-18 07:29:24 +10:00
Luke S Thompson
a01da7cbb4 Update Proxmox web page URL (site update) 2023-12-12 09:43:16 +10:00
Luke S Thompson
b38079947e PVE support to 8.x only, remove 7.x
Now that 8.1 is released, remove 7.x
2023-12-06 12:53:57 +10:00
Luke S Thompson
e8f659ad22 Client Area debug (add SID/CID to log) 2023-12-06 10:12:08 +10:00
Luke S Thompson
f50f52ae77 Client Area GUI tweaks; Cluster/Guest to debug log 2023-12-06 10:06:18 +10:00
Luke S Thompson
163b967301 Add Issue numbers to C'LOG 2023-12-05 18:16:26 +10:00
Luke S Thompson
fd345b674c Debug Logging enhancements; SPICE prep; C'LOG 2023-12-05 17:48:21 +10:00
Luke S Thompson
ea458af9e5 SQL tidy; Add new CPU models; #32 post-clone WIP 2023-12-05 15:03:31 +10:00
Luke S Thompson
d415eb0b8b Clarify psABI pre-reqs + onwards 2023-12-05 13:43:35 +10:00
Luke S Thompson
be3e050ffa Merge branch 'master' of https://github.com/The-Network-Crew/Proxmox-VE-for-WHMCS 2023-12-05 13:40:59 +10:00
Luke S Thompson
3ab4574789 psABI change prefix (visual only) 2023-12-05 13:40:55 +10:00
Luke S Thompson
9b1e53a05d SPICE and Xterm.JS links out 2023-12-05 13:15:56 +10:00
Luke S Thompson
4a455b6203 Adjust TestConnection; error routing (#29) 2023-12-05 13:09:16 +10:00
Luke S Thompson
a3a8543b1c Create SECURITY.md 2023-12-05 12:54:32 +10:00
Luke S Thompson
be0cc40386 2nd fix for #36; Conn Test #29 potential fix; typos 2023-12-05 12:32:06 +10:00
Luke S Thompson
d45d0bb80b Slight tidying up (OCD) 2023-12-03 17:19:32 +10:00
Luke S Thompson
416069e4f1 WIP v1.2.3 into C'LOG; Issue link 2023-12-03 17:17:41 +10:00
Luke S Thompson
a0f5612994 x86-64-ABI; README: IPv4/v6, Features, etc. 2023-12-03 17:09:55 +10:00
Luke S Thompson
e5a35c7492 Add thanks to psyborg® (logo design) 2023-12-03 16:27:10 +10:00
Luke S Thompson
e822540455 Re-order logo and salvation line 2023-12-03 15:37:32 +10:00
Luke S Thompson
6fec30628b Add module logo to repo (Proxmox ref 5435074) 2023-12-03 15:36:51 +10:00
Luke S Thompson
7d7b5be4bf Wrap service/file names; more tidying 2023-11-28 11:06:05 +10:00
Luke S Thompson
dcea0c267c More specific Support requirements 2023-11-28 10:59:31 +10:00
Luke S Thompson
5c66ea3c94 More explicit mentions of GPLv3 2023-11-18 10:18:15 +10:00
Luke S Thompson
529d065690 H4 to H3 2023-11-17 20:39:15 +10:00
Luke S Thompson
435ccf272a Include VM/CT steps from Manual PDF 2023-11-17 20:26:51 +10:00
Luke S Thompson
1772bf85d2 Reflect 2x to 1x old PDF 2023-11-16 19:42:22 +10:00
Luke S Thompson
f7455f10a1 Manual PDF tidy; etc. 2023-11-16 19:34:51 +10:00
Luke S Thompson
81483ee853 Soften headings; helps ToC formatting 2023-11-16 12:12:50 +10:00
Luke S Thompson
32f2d7a7b6 More minor tweaks 2023-11-16 08:32:21 +10:00
Luke S Thompson
bb14aec611 Update README.md 2023-11-16 08:24:01 +10:00
Luke S Thompson
730f9d1e85 Move initial points to top 2023-11-16 08:23:33 +10:00
Luke S Thompson
db2cca1c94 Improvements to README 2023-11-16 08:22:54 +10:00
Luke S Thompson
bb2179ef2f Thank @cybercoder in C'LOG 2023-10-22 08:48:17 +10:00
Luke S Thompson
4376798c0d Improve README.md slightly 2023-10-18 13:59:33 +10:00
Luke S Thompson
ea5f67cfa9 Suspend/Unsuspend: into c'log 2023-09-18 15:58:41 +10:00
Luke S Thompson
a0decccb50 Version bump from v1.2.1 to v1.2.2 2023-09-15 09:48:22 +10:00
Luke S Thompson
eb7c0914f8 v1.2.2 into CHANGELOG, final check 2023-09-15 09:46:57 +10:00
Luke S Thompson
2d2755bb81 New GUI Tabs ahead of v1.2.3 2023-09-15 09:44:14 +10:00
Luke S Thompson
201d7f6f29 Adjust method: un/suspend/term; 30 sec term. sleep 2023-09-14 20:37:02 +10:00
Luke S Thompson
1951b5dbb2 Suspend/Unsuspend now Stop/Start 2023-09-14 15:05:09 +10:00
Luke S Thompson
13fce0651b Update SQL statement formatting (MariaDB) 2023-09-14 13:03:52 +10:00
Luke S Thompson
6e6f2a5e86 Same missing bracket (#40) as with noVNC 2023-09-14 13:01:19 +10:00
Luke S Thompson
5fa8fbe00f Change c'log to point out to SQL.md 2023-09-14 10:29:26 +10:00
Luke S Thompson
0e040aff44 Add SQL.md file for Update Changes 2023-09-14 10:26:16 +10:00
Luke S Thompson
dd2ec07d6b Missing bracket when verifying vnc_secret (#40) 2023-09-14 10:10:24 +10:00
Luke S Thompson
98fa2c32d8 Add issue templates - bug/feature 2023-09-14 08:51:43 +10:00
Luke S Thompson
6a96263dee Test and tweak Debug Mode, resolves #38 2023-09-14 08:37:12 +10:00
Luke S Thompson
88720b5f56 GUI Option for #38 (Debug); Try fix #40 (Error)
Plus more respectful re-arrange of SQL, so we can look to supply update script/function to add missing columns.
2023-09-14 08:27:20 +10:00
Luke S Thompson
aca15eb2d3 1st pass at Debug Mode (#38) 2023-09-14 08:11:47 +10:00
Luke S Thompson
d5ab11b03e Pointless file_put; Prep for debug_mode; etc. 2023-09-14 07:58:56 +10:00
Luke S Thompson
d9ef54e25a Minor tweaks to GUI language 2023-09-13 14:38:44 +10:00
Luke S Thompson
6f969a618e Missing bracket; VLAN ID null default; SERVER_NAME 2023-09-13 14:28:08 +10:00
Luke S Thompson
a016784d20 Slight tweaks to README and C'LOG 2023-09-13 14:14:31 +10:00
Luke S Thompson
4e7cb78aad Set on-boot for CTs in PVE Creation (#34) 2023-09-13 13:27:52 +10:00
Luke S Thompson
0b794ebd96 feat: Ability to assign VLAN ID to Plans (#35) 2023-09-13 13:12:56 +10:00
Luke S Thompson
f017bcd1f0 + Update Checker (#21), more code comments 2023-09-13 12:39:35 +10:00
Luke S Thompson
a220eea9fa Add WHMCS Service config save to README 2023-09-13 09:59:04 +10:00
Luke S Thompson
b8da683746 IP SQL Error (#36), VNC check conf (#27), GUI tune 2023-09-13 08:24:05 +10:00
Luke S Thompson
25ea01effb Module Config/GUI: Text improvements 2023-09-11 15:38:01 +10:00
Luke S Thompson
3ee12c4231 \n 2023-08-22 10:57:31 +10:00
Luke S Thompson
8ef4b8cb4f Clean-up README a little 2023-08-22 10:56:20 +10:00
Luke S Thompson
616ccda1f9 Improve comments in noVNC router 2023-08-07 17:25:37 +10:00
Luke S Thompson
d8d8644775 Minor heading tweaks 2023-07-05 20:41:18 +10:00
Luke S Thompson
0b39af76b8 Headings: Emoji book-ending 2023-07-04 21:54:09 +10:00
Luke S Thompson
7dc3ebce92 Larger headings 2023-07-04 21:52:24 +10:00
Luke S Thompson
484bb1f79c Remove line break 2023-07-04 21:51:41 +10:00
Luke S Thompson
3854fd86fe Overhaul completed 2023-07-04 21:50:48 +10:00
Luke S Thompson
c9d14506c4 Add Installation section 2023-06-28 23:12:40 +10:00
Luke S Thompson
799500bbf0 Add Wiki links; Explanation for vnc cred field 2023-06-21 19:45:27 +10:00
Luke S Thompson
b7ee090b4d Admin Area: Remove noVNC (no HTML) 2023-06-19 18:53:12 +10:00
Luke S Thompson
7f6171efbf Change action return to new; Actions in Admin GUI 2023-06-19 18:51:29 +10:00
Luke S Thompson
f44647c170 v1.2.1: noVNC OK, Tidy-up GUI 2023-06-19 16:55:22 +10:00
Luke S Thompson
bac101e6d8 noVNC working OK via dual-auth 2023-06-19 15:58:21 +10:00
Luke S Thompson
1c0fe39e28 VM Reboot action; noVNC next steps 2023-06-19 15:51:06 +10:00
Luke S Thompson
d1e6694b3c Client Area: Improve VM/CT spec display/language 2023-06-19 13:27:28 +10:00
Luke S Thompson
2d1a9a8461 Pre-removal: Demote TigerVNC from root to vnc 2023-06-19 13:14:57 +10:00
Luke S Thompson
9acf5ea188 noVNC: More ground-work on dual-ticket 2023-06-19 12:04:58 +10:00
Luke S Thompson
cb263ce100 v1.2.1 partial: noVNC overhaul beginnings; etc. 2023-06-19 10:47:13 +10:00
Luke S Thompson
1edc89a1e3 noVNC: Change backend proxy params 2023-06-18 20:34:43 +10:00
Luke S Thompson
0ea7243a69 v1.2.1: Fix VNC errors; minor tweaks 2023-06-18 20:16:53 +10:00
Luke S Thompson
98ec70eae6 noVNC: Attempt at resolving out-of-order data 2023-06-18 19:50:54 +10:00
Luke S Thompson
4030c94762 Client menu re-arrange; Admin health tweak 2023-06-18 17:54:36 +10:00
34 changed files with 1207 additions and 243 deletions

View File

@@ -0,0 +1,37 @@
---
name: "\U0001F41B Bug Report"
about: Create a report to help us improve the module!
title: ''
labels: bug
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behaviour:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behaviour**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem to us.
**Module > Support/Health tab (remove IP and paste here):**
- Version of module
- Web Server info
- PHP version
- etc.
**WHMCS Information (please complete the following):**
- WHMCS Version (must be supported):
- Using HTTPS: Yes or No
**Confirm that you have MORE THAN 100 services (all statuses) in WHMCS?**
Otherwise you will receive a "value does not look like a valid VM ID" error. Check the error!

View File

@@ -0,0 +1,20 @@
---
name: "\U0001F680 Feature Request"
about: How can we improve Proxmox VE for WHMCS?
title: ''
labels: enhancement
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

View File

@@ -1,9 +1,69 @@
# Changelog
All notable changes to Proxmox VE for WHMCS will be documented in this file.
## [1.2.0b] - 2013-06-18
## [1.2.3] - 2023-12-31 - _"NY Tidy-up 123"_
### Added
### 🚀 Feature
- x86-64-ABI: Add options; Emulation default now `x86-64-v2-AES` (#58)
- Intel/AMD: Add new CPU Emulation options (8~ Intel, 2x EPYC) (#58)
### 💅 Polish
- Debug Logs: Improved quality & scope of logged info (#59)
- SECURITY.md: Add file to repository, clarifying process (#61)
- README.md: Add VM/CT creation explanations from old Manual (#57)
- Logo: Per request from Proxmox Server Solutions, we got a logo (#56)
- SPICE: Ground-work for future potential addition of 2nd HTML5/etc VNC
### 🐛 Bug Fix
- PHP v8.1: Verified no problems operating on v8 old-stable ver.
- Connection Test: Fixed, so it reports OK/Green or an error (#29)
- Admin, Edit Service: Should now populate existing config OK (#36)
## [1.2.2] - 2023-09-15 - _"Nice refinements"_
### 🚀 Feature
- Debugging Mode: Allow admin to turn on/off Module Log feed (#38)*
- VLAN ID: Set the required Virtual LAN ID against VM/CT Plan (#35)*
- Version: Report in-use & latest versions in Health; ver alert (#21)
- Power Actions: Now available in Admin Area as well as Client Area
- (Note: Suspend/Unsuspend/Terminate remain admin-only functions)
### 💅 Polish
- Suspend/Unsuspend: Functions changed to Stop/Start (fixes #34)
- Client Area: Power Action wording amended (Soft Stop, Hard Stop)
- Admin, Module Config: Explain what the VNC Secret field is about
- Admin, Module Config: House-keeping to design, Support/Health tab
### 🐛 Bug Fix
- Admin, Create Service: Fails if Plan/Pool not assigned in WHMCS (#36)
- Client, VNC: Fails early if VNC Secret is not set or adequate (#27)
- On-boot Status: Enabled/Disabled now properly applied for CTs (#34)
(\*): SQL Note: There are new columns in 2 of the module tables, see [SQL.md](https://github.com/The-Network-Crew/Proxmox-VE-for-WHMCS/blob/master/SQL.md)
## [1.2.1b] - 2023-06-19 - _"Working, including VNC!"_
### 🚀 Feature
- Module Config tab, allowing for configuration of the VNC Secret
- Reboot command/action added to Client Area (ie. on/off/hard-off)
- Link from Health tab of Admin GUI to WHMCS Marketplace re: reviews
- Images for all supported Operating Systems & Kernel types (some fixed)
- noVNC overhauled, to send PVE Cookie (ticket) and VNC Access Ticket also
### 💅 Polish
- Stop VM/CT (Client Area) renamed to Hard Stop, compared to Shut Down
- Modify the PHP API2 class, adding getTicket() so we can dual-auth (VNC)
- Move VNC Clients from root-level to vnc-only-level access to Proxmox VE
### 🐛 Bug Fix
- noVNC render method updated to stop out-of-order data flow problem
- noVNC back-end vncproxy and vncwebsocket methods updated re: spec
- Client Area actions (Power Off/On, etc) fixed for LXC (QEMU OK)
- Error with both VNC methods. We are going to remove TigerVNC
## [1.2.0b] - 2023-06-18 - _"Loads of key fixes"_
### 🚀 Feature
- Link off to GitHub Issues for Support from the Module page in WHMCS
- CHANGELOG.md file added to repository to track in recommended format
- Try-catch around the Creation API Call, routing OK/error into WHMCS
@@ -14,7 +74,7 @@ All notable changes to Proxmox VE for WHMCS will be documented in this file.
- Warning in README.md re: WHMCS Service ID being > 100
- Zero Tolerance Abuse Policy added to README file
### Changed
### 💅 Polish
- Module versioning changed to semver (semantic versioning) 1.2.0
- Change rel. path to ROOTDIR in IPv4 file, in case of other issues
- Use /cluster/resources via API, not /node/, to get stats (ex. swap)
@@ -23,7 +83,7 @@ All notable changes to Proxmox VE for WHMCS will be documented in this file.
- 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
### 🐛 Bug Fix
- 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)
@@ -34,33 +94,35 @@ All notable changes to Proxmox VE for WHMCS will be documented in this file.
- Client Area pages/actions now fixed (fixes #19)
- Font Awesome icons fixed in the Client Area
## [1.1b] - 2023-06-06
## [1.1b] - 2023-06-06 - _"The overhaul begins!"_
### Added
### 🚀 Feature
- Swap space editing for plans; back-end existed but not GUI editing
- Modern-day language to GUI according to changes in the 6 years
- README now links out to all Dependencies and Documentation
### Changed
### 💅 Polish
- Module Name from "PRVE" to "pvewhmcs" (ie. Proxmox VE for WHMCS)
- Default storage/disk type changed from IDE to Virtio (fastest)
- Updated 3 dependencies to latest: PVE2-PHP, noVNC, TigerVNC
- Removed all code segments relating to Software Licensing
- DNS defaults changed from Google DNS to Cloudflare DNS
### Fixed
### 🐛 Bug Fix
- Module can now be installed onto WHMCS 8.x installations
- OpenVZ changed to LXC, to support PVE 4.x installs & up
- Removed I/O Priority setting, to re-do via Throttling
- Catch exception in Client Area if can't reach Proxmox
## [1.0] - 2017-01-26
## [1.0] - 2017-01-26 - _"FOSS Foundations"_
### Added
**_Thank you @cybercoder for open-sourcing your code!_**
### 🚀 Feature
- Open-sourced the previously commercial plugin
### Changed
### 💅 Polish
- Commented out the licensing code segments
### Fixed
- Removed old database schema import file
### 🐛 Bug Fix
- Removed old database schema import file

240
README.md
View File

@@ -1,68 +1,246 @@
# Proxmox VE for WHMCS (Module) Provision & Manage
We're overhauling the Module to suit our internal needs at [LEOPARD.host](https://leopard.host).
**Salvation, a free and open-source solution for beloved PVE!** If you love it, REVIEW & SHARE IT! ❤️
- Automatically Provision VMs & CTs in [Proxmox VE](https://proxmox.com/en/proxmox-ve/features) from [WHMCS](https://www.whmcs.com/tour/)
- Allow clients to view/manage VMs using WHMCS Client Area
<img alt="Logo for the Proxmox VE for WHMCS module" src="zLOGO.png">
The original module was written in 2 months by @cybercoder for sale online in 2016, though didn't sell any copies so they kindly open-sourced it and removed the licensing requirement. _The manual PDF files are due to be updated (these still mention licensing - ignore this)_
- Configure VM/CT plans with custom CPU/RAM/VLAN/On-boot/Bandwidth/etc
- Automatically Provision VMs & CTs in [Proxmox VE](https://proxmox.com/en/proxmox-virtual-environment/features) from [WHMCS](https://www.whmcs.com/tour/) easily
- Allow clients to view/manage VMs using the WHMCS Client Area
- Create/Suspend/Unsuspend/Terminate via WHMCS Admin Area
- Statistics/Graphing is available in the Client Area for services :)
https://marketplace.whmcs.com/product/6935-proxmox-ve-for-whmcs
## ❤️ RTFM: Read the Manual & Review the Module!
### 🛠️ SYSTEM REQUIREMENTS:
**Please read the entire README.md file before getting started with Proxmox VE for WHMCS.** Thanks!
We're pretty much done overhauling the Module to suit our needs at [The Network Crew Pty Ltd (TNC)](https://thenetworkcrew.com.au).
> **Please review the module!** https://marketplace.whmcs.com/product/6935-proxmox-ve-for-whmcs
>
> If you want it to remain free and fabulous, it could use a moment of your time in reviewing it. Thanks!
## 🎯 MODULE: System Requirements (PVE/WHMCS)
New Biz: Fresh Installations/Businesses using WHMCS need to take note of the Service ID < 100 case.
**SID >100:** The WHMCS Service ID requirement is CRITICAL, as Proxmox reserves VMIDs <100 (system).
- (WHMCS) v8.x.x stable (HTTPS)
- (WHMCS) Service ID >100
- (PHP) v8.x.x stable
- (Proxmox) VE v7/8
- (WHMCS) **Service ID above 100**
- (PHP) v8.x (stable version)
- (Proxmox) VE v8.x (current)
- (Proxmox) 2 users (API/VNC)
**SID >100:** The WHMCS Service ID requirement is critical, as Proxmox reserves VMIDs <100.
_If you don't have enough services (of any status) in WHMCS (DB: tblhosting.id), create enough dummy/test entries to reach Service ID 101+._ **Else you're likely to see an error which explains this:** `HTTP/1.1 400 Parameter verification failed. (invalid format - value does not look like a valid VM ID)`
_If you don't have enough services (any status) in WHMCS, create services until you reach SID 101._
## ✅ MODULE: Installation & Configuration
**PROXMOX 8.x:** As this major release is in beta (as of June 2023), support is experimental.
**DON'T SKIP ANY PART OF THIS README.md - please don't raise pointless Issues - thank you!**
### 🤬 ABUSE - ZERO TOLERANCE:
Firstly, you need to upload, activate and make the WHMCS Module available to Administrators.
**NOTE:** This module is being overhauled and is in beta. Your support is welcomed.
Once you've done all of that, in order to get the module working properly, you need to:
If you cannot accept this, do not download nor use the code. Complaints, nasty reviews, and similar behaviour is against the spirit of FOSS and will not be tolerated. Be grateful & considerate - thank you!
0. Proxmox VE > Create an additional VNC-only user, per instructions below
1. WHMCS Admin > Config > Servers > Add your PVE host/s (user: root; IP: PVE's)
2. WHMCS Admin > Addons > Proxmox VE for WHMCS > Module Config > VNC Secret (see below)
3. WHMCS Admin > Addons > Proxmox VE for WHMCS > Add KVM/LXC Plan/s
4. WHMCS Admin > Addons > Proxmox VE for WHMCS > Add an IP Pool
5. WHMCS Admin > Config > Products/Services > New Service (create offering)
6. " " > Newly-added Service > Tab 3 > **SAVE** (links Module Plan to WHMCS Service type)
### 🆘 TECHNICAL SUPPORT:
## 🥽 noVNC: Console Tunnel (Client Area)
Including logs, details, steps to reproduce, etc, please raise an [Issue](https://github.com/The-Network-Crew/Proxmox-VE-for-WHMCS/issues).
After forking the module, we considered how to improve security of Console Tunneling via WHMCS. We decided to implement a routing method which uses a secondary user in Proxmox VE with very restrictive permissions. This requires more work to make it function, however improves security.
Information we will need, at a minimum:
### To offer VNC via WHMCS Client Area
- (PHP) error_log contents
- (WHMCS) Module Debug Log contents
1. Install & configure the module properly
2. Follow the PVE User Requirement info below
3. Public IPv4 for PVE (or proxy to private)
4. PVE and WHMCS on the same Domain Name*
5. Have valid PTR/rDNS for the PVE Address
noVNC has been overhauled. It isn't guaranteed, nor the project at all. :-)
- Note #1 = You must use different Subdomains on the same Domain Name, for the cookie (anti-CSRF).
- Note #2 = If your Domain Name has a 2-part TLD (ie. co.uk) then you will need to fork & amend `novnc_router.php` - ideally we/someone will optimise this to better cater to all formats.
## 👥 PVE: User Requirements (API & VNC)
**You must have a root account to use the Module at all.** Configured via WHMCS > Servers.
Additionally, to improve security, for VNC you must also have a Restricted User. Configured in the _Module_.
### Creating the VNC user within PVE
1. Create User Group "VNC" via PVE > Datacenter / Permissions / Group
2. Create new User "vnc" > Datacenter / Permissions / Users - select Group: "VNC", Realm: pve
3. Create new Role -> Datacenter / Permissions / Roles - select Name: "VNC", Privileges: VM.Console (only)
4. Add permission to access VNC -> Datacenter / Node / VM / Permissions / Add Group Permissions - select Group: "VNC", Role: "VNC"
5. Configure the WHMCS > Modules > Proxmox VE for WHMCS > Module Config > VNC Secret with 'vnc' password.
> Do NOT set less restrictive permissions. The above is designed for hypervisor security.
## ⚙️ VM/CT PLANS: Setting everything up
These steps explain the unique requirements per-option.
Custom Fields: Values need to go in Name & Select Options.
> **Unsure?** Consult the zMANUAL-PVE4.pdf _legacy_ manual file.
### VM Option 1: KVM, using PVE Template VM
Firstly, create the Template in PVE. You need its unique PVE ID.
Use that ID in the Custom Field `KVMTemplate`, as in `ID|Name`.
> Note: `Name` is what's displayed in the WHMCS Client Area.
### VM Option 2: KVM, WHMCS Plan + PVE ISO
Firstly, create the Plan in WHMCS Module. Then, WHMCS Config > Services.
Under the Service, you need to add a Custom Field `ISO` with the full location.
### CT Option: LXC, using PVE Template File
Firstly, store the Template in PVE. You need its unique File Name.
Use that full file name in the Custom Field `Template`, as in:
`ubuntu-99.99-standard_amd64.tar.gz|Ubuntu 99`
Then make a 2nd Custom Field `Password` for the CT's root user.
## 🌐 IPv4/v6: Networking (IP Pools)
Please make sure you create an IP Pool with sufficient scope/size to be able to deploy addresses within it to your guest VMs and CTs. Else it won't be able to create a Service for you.
**Private IPs for PVE Hosts:** Note that VNC may be problematic without work due to the strict requirements introduced in Proxmox v8.0 (strict same-site attribute).
### IPv6: Not yet functional! 😐
Per The-Network-Crew/Proxmox-VE-for-WHMCS#33 there is not yet functional IPv6 in this module.
You can of course add this via PVE/`pvesh` manually, however it isn't module-supported as of late 2023.
## 💅 FEATURES: PVE v8.0/8.1 bling
There are new features deployed into Proxmox VE upstream in the v8 branch which are exciting and should be added to this module.
### Proxmox v8.0
1. Create, manage and assign resource mappings for PCI and USB devices for use in virtual machines (VMs) via API and web UI.
2. (DONE) Add virtual machine CPU models based on the x86-64 psABI Micro-Architecture Levels and use the widely supported x86-64-v2-AES as default for new VMs created via the web UI.
### Proxmox v8.1
1. Secure Boot support.
2. Software Defined Networking (SDN).
3. New flexible notification system (SMTP & Gotify).
4. MAC Organizationally Unique Identifier (OUI) BC:24:11: prefix!
Reference: https://pve.proxmox.com/wiki/Roadmap
## 🤬 ABUSE: Zero Tolerance (ZT)
This module has been overhauled and remains functionally-OK but not thoroughly tested nor reviewed.
Your support and assistance is always welcomed per the spirit of FOSS (Free Open-source Software)!
If you cannot accept this, do not download nor use the code. Complaints, nasty reviews, and similar behaviour is against the spirit of FOSS and will not be tolerated.
**Be grateful & considerate - thank you!**
## 🆘 HELP: Best-effort Support
**Before raising a [GitHub Issue](https://github.com/The-Network-Crew/Proxmox-VE-for-WHMCS/issues), please check:**
1. The [Wiki](https://github.com/The-Network-Crew/Proxmox-VE-for-WHMCS/wiki)
2. The [README.md](https://github.com/The-Network-Crew/Proxmox-VE-for-WHMCS/tree/master)
3. Open [GitHub Issues](https://github.com/The-Network-Crew/Proxmox-VE-for-WHMCS/issues)
4. HTTP, PHP, WHMCS & debug logs (see below).
5. PVE logs; best practices; network; etc.
6. Read the errors. Do they explain it?
> Help: Including logs, details, steps to reproduce, etc, please raise a [GitHub Issue](https://github.com/The-Network-Crew/Proxmox-VE-for-WHMCS/issues).
>
> Logs: We work to ensure that Proxmox VE for WHMCS passes through error details to you.
### Issues/etc raised must include:
#### Logging & Debug Logging
- (Logs: PHP) `error_log` contents
- (Logs: WHMCS) Module Debug Logging*
- (Logs: Config) WHMCS Display/Log Errors = ON
- (Logs: PVE) Logs from Proxmox Host (`pveproxy` etc)
#### Other Support Requirements
- (Visibility) Screenshots of the issue
- (Configs) WHMCS/PHP/Module/Proxmox/etc
- (PVE) Logs from Proxmox Host (pveproxy etc)
- (Reproduction) pvesh/etc variants of failing calls
- (Reproduction) `pvesh` etc variants of failing calls
- (Network) Proof WHMCS Server can talk to PVE OK
- (PEBKAC) _PROOF THAT YOU'VE FOLLOWED THIS README!_
Please note that this is FOSS and Support is not guaranteed.
The more info/context you provide up-front, the quicker & easier it will be!
This module is licensed via the GNU General Public License v3.0.
\* Debug: Make sure you enable Debug Logging in the Module Settings, as needed.
### 🖥️ LIBRARIES & DEPENDENCIES:
**Please note that this is FOSS and Support is not guaranteed at all.**
- [PHP Client for PVE2 API](https://github.com/CpuID/pve2-api-php-client) (Dec 5th, 2022)
- [TigerVNC VncViewer.jar](https://sourceforge.net/projects/tigervnc/files/stable/) (v1.13.1 in repo)
- [noVNC HTML5 Viewer](https://github.com/novnc/noVNC) (v1.4.0 in repo)
**If you don't read, listen or actively try, no help given.**
### 📄 DOCUMENTATION & RESOURCES:
## 🔄 UPDATING: Patching the Module
WHMCS Admin > Addon Modules > Proxmox VE for WHMCS > Support/Health shows updates.
You can download the new version and upload it over the top, then run any needed SQL ops.
Please consult the [UPDATE-SQL.md](https://github.com/The-Network-Crew/Proxmox-VE-for-WHMCS/blob/master/UPDATE-SQL.md) file, open your WHMCS DB & run the statements. Then you're done.
## 🖥️ INC: Libraries & Dependencies
- (MIT) [PHP Client for PVE2 API](https://github.com/CpuID/pve2-api-php-client) (Dec 5th, 2022)
- (GPLv2) [TigerVNC VncViewer.jar](https://sourceforge.net/projects/tigervnc/files/stable/) (v1.13.1 in repo)
- (MPLv2) [noVNC HTML5 Viewer](https://github.com/novnc/noVNC) (v1.4.0 in repo)
- (GPLv3) [SPICE HTML5 Viewer](https://gitlab.freedesktop.org/spice/spice-html5) (v0.3 in repo)
- (MIT) [IPv4/SN Validation](https://github.com/tapmodo/php-ipv4/) (August 2012)
## 📄 DIY: Documentation & Resources
- Proxmox API: https://pve.proxmox.com/pve-docs/api-viewer/
- TigerVNC: https://github.com/TigerVNC/tigervnc/wiki
- noVNC: https://github.com/novnc/noVNC/wiki
- WHMCS: https://developers.whmcs.com/
- x86-64-ABI: [latest PDF download](https://gitlab.com/x86-psABIs/x86-64-ABI/-/jobs/artifacts/master/raw/x86-64-ABI/abi.pdf?job=build)
### 🙌 CONTRIBUTING TO THE MODULE:
## 🎉 FOSS: Contributions & Open-source
If you'd like to contribute to the Module, please open a [PR](https://github.com/The-Network-Crew/Proxmox-VE-for-WHMCS/pulls).
We would like to thank [@cybercoder](https://github.com/cybercoder/) and [@WaldperlachFabi](https://github.com/WaldperlachFabi) for their original contributions and troubleshooting assistance respectively. FOSS is only possible thanks to dedicated individuals!
The original module was written in 2 months by @cybercoder for sale online in 2016, though didn't sell any copies so they kindly open-sourced it and removed the licensing requirement.
We would like to thank [@cybercoder](https://github.com/cybercoder/) and [@WaldperlachFabi](https://github.com/WaldperlachFabi) for their original contributions and troubleshooting assistance respectively.
Thank you to [psyborg®](https://www.psyborg.com.au/graphic-design-services-newcastle/logo-design/) for the module's logo design! We love it.
FOSS is only possible thanks to dedicated individuals!
## Usage License (GPLv3) & Links to TNC & Co.
_**This module is licensed under the GNU General Public License (GPL) v3.0.**_
GPLv3: https://www.gnu.org/licenses/gpl-3.0.txt (by the Free Software Foundation)
**[The Network Crew Pty Ltd](https://thenetworkcrew.com.au)**
**[LEOPARD.host](https://leopard.host)**
### Support: Best-effort via GitHub Issues
Browse issues, raise a new one: **[GitHub Issues](https://github.com/The-Network-Crew/Proxmox-VE-for-WHMCS/issues)**

57
SECURITY.md Normal file
View File

@@ -0,0 +1,57 @@
# Security Policy
## 🏥 Supported Versions
The single latest available release is the only release supported by this Security Policy.
| Version | Supported |
| ------- | ------------------ |
| 1.x.x latest | :white_check_mark: |
| 1.2.x | :x: |
| 1.1.x | :x: |
| 1.0.x | :x: |
> \* Note: Latest version - if it is v1.2.3 then that is supported, if latest is v1.4.1 then that is supported, etc.
## 🔒 Secure Code Contributions
Please refrain from depending on any external source - for instance, noVNC-latest is bundled into the Module.
Best practices should be followed during Software Engineering which is especially hard when only patching.
### For instance, work to implement:
- Principle of Least Privilege
- Input Validation & Sanitisation
- Secure Communication (HTTPS etc)
- Compatibility with core/updates
- Thorough inline comments/specs
- Robust error handling/logging
- Secure configs by default
### References:
- https://owasp.org/
- [CERT Secure Coding](https://wiki.sei.cmu.edu/confluence/display/seccode/SEI+CERT+Coding+Standards)
- [NIST Secure SW Dev](https://csrc.nist.gov/Projects/ssdf)
- [MIT Open Security](https://ocw.mit.edu/courses/6-858-computer-systems-security-fall-2014/)
## 🐛 Reporting a Vulnerability
GitHub "Private vulnerability reporting" is enabled for The-Network-Crew/Proxmox-VE-for-WHMCS repository.
Or, use a publicly-available email address for The Network Crew Pty Ltd to submit it via email instead.
DO NOT raise a public issue where there is threat to users of the module. Raise it properly.
### No bounties offered
As a company, we do not believe in paying security bounties, rather in writing good code.
We appreciate your input and work to address issues as quickly as possible, security first and foremost.
Updates can be provided as promptly as days apart, however this depends on severity/scope, and is always reasonable.
## ❤️ Thank you for responsibly disclosing
We & the entire FOSS community thank you for reviewing this file & being aware of how to improve the project.

8
UPDATE-SQL.md Normal file
View File

@@ -0,0 +1,8 @@
# SQL Statements for Updates (nav to DB first)
### v1.2.1 to v1.2.2
```
ALTER TABLE mod_pvewhmcs ADD COLUMN `debug_mode` tinyint(1) unsigned DEFAULT '0';
ALTER TABLE mod_pvewhmcs_plans ADD COLUMN `vlanid` varchar(10) DEFAULT NULL;
```

View File

@@ -1,9 +1,11 @@
CREATE TABLE IF NOT EXISTS `mod_pvewhmcs` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`config` text,
`config` varchar(255),
`vnc_secret` varchar(255),
`debug_mode` tinyint(1) unsigned DEFAULT '0',
PRIMARY KEY (`id`)
);
INSERT INTO `mod_pvewhmcs` (`id`, `config`) VALUES (1, NULL);
INSERT INTO `mod_pvewhmcs` (`id`, `config`, `vnc_secret`) VALUES (1, NULL, NULL);
CREATE TABLE IF NOT EXISTS `mod_pvewhmcs_ip_addresses` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`pool_id` int(11) NOT NULL DEFAULT '0',
@@ -20,13 +22,13 @@ CREATE TABLE IF NOT EXISTS `mod_pvewhmcs_ip_pools` (
);
CREATE TABLE IF NOT EXISTS `mod_pvewhmcs_plans` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(255) CHARACTER SET utf8 NOT NULL COMMENT 'Plan - Name',
`vmtype` varchar(8) NOT NULL COMMENT 'Guest Type - KVM or LXC',
`ostype` varchar(8) DEFAULT NULL COMMENT 'OS - Type',
`title` varchar(255) CHARACTER SET utf8 NOT NULL,
`vmtype` varchar(8) NOT NULL,
`ostype` varchar(8) DEFAULT NULL,
`cpus` tinyint(2) unsigned DEFAULT NULL,
`cpuemu` varchar(30) CHARACTER SET utf8 DEFAULT NULL COMMENT 'Emulated CPU Type eg. coreduo | core2duo | kvm32 | kvm64 | qemu32 | qemu64 | phenom | host',
`cores` tinyint(2) unsigned DEFAULT NULL COMMENT 'Cores per Socket',
`cpulimit` smallint(5) unsigned DEFAULT NULL COMMENT 'Limit vs Host CPU (max)',
`cpuemu` varchar(30) CHARACTER SET utf8 DEFAULT NULL,
`cores` tinyint(2) unsigned DEFAULT NULL,
`cpulimit` smallint(5) unsigned DEFAULT NULL,
`cpuunits` smallint(5) unsigned DEFAULT NULL,
`memory` smallint(5) unsigned NOT NULL,
`swap` smallint(5) unsigned DEFAULT NULL,
@@ -45,6 +47,7 @@ CREATE TABLE IF NOT EXISTS `mod_pvewhmcs_plans` (
`bw` int(6) unsigned DEFAULT '0',
`kvm` tinyint(1) unsigned DEFAULT '0',
`onboot` tinyint(1) unsigned DEFAULT '0',
`vlanid` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
);
CREATE TABLE IF NOT EXISTS `mod_pvewhmcs_vms` (

View File

@@ -1,5 +1,26 @@
<?php
/*
Proxmox VE for WHMCS - Addon/Server Modules for WHMCS (& PVE)
https://github.com/The-Network-Crew/Proxmox-VE-for-WHMCS/
File: /modules/addons/pvewhmcs/hooks.php (WHMCS Hooks)
Copyright (C) The Network Crew Pty Ltd (TNC) & Co.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (!defined("WHMCS"))
die("This file cannot be accessed directly");

View File

@@ -133,6 +133,15 @@ class PVE2_API {
setrawcookie("PVEAuthCookie", $this->login_ticket['ticket'], 0, "/");
}
# Gets the PVE Access Ticket
public function getTicket() {
if ($this->login_ticket['ticket']) {
return $this->login_ticket['ticket'];
} else {
return false;
}
}
/*
* bool check_login_ticket ()
* Checks if the login ticket is valid still, returns false if not.

View File

@@ -1,62 +1,117 @@
<?php
/*
Proxmox VE for WHMCS - Addon/Server Modules for WHMCS (& PVE)
https://github.com/The-Network-Crew/Proxmox-VE-for-WHMCS/
File: /modules/addons/pvewhmcs/pvewhmcs.php (GUI Work)
Copyright (C) The Network Crew Pty Ltd (TNC) & Co.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// Pull in the WHMCS database handler Capsule for SQL
use Illuminate\Database\Capsule\Manager as Capsule;
// Define where the module operates in the Admin GUI
define( 'pvewhmcs_BASEURL', 'addonmodules.php?module=pvewhmcs' );
// DEP: Require the PHP API Class to interact with Proxmox VE
require_once('proxmox.php');
// CONFIG: Declare key options to the WHMCS Addon Module framework.
function pvewhmcs_config() {
$configarray = array(
"name" => "Proxmox VE for WHMCS",
"description" => "Proxmox Virtual Environment + WHMCS",
"version" => "1.2.0",
"description" => "Proxmox VE (Virtual Environment) & WHMCS, integrated & open-source! Provisioning & Management of VMs/CTs.".is_pvewhmcs_outdated(),
"version" => "1.2.3",
"author" => "The Network Crew Pty Ltd",
'language' => 'English'
);
return $configarray;
}
// VERSION: also stored in repo/version (for update-available checker)
function pvewhmcs_version(){
return "1.2.0";
return "1.2.3";
}
// WHMCS MODULE: ACTIVATION of the ADDON MODULE
// This consists of importing the SQL structure, and then crudely returning yay or nay (needs improving)
function pvewhmcs_activate() {
// Pull in the SQL structure (includes VNC/etc tweaks)
$sql = file_get_contents(ROOTDIR.'/modules/addons/pvewhmcs/db.sql');
if (!$sql) {
return array('status'=>'error','description'=>'The db.sql file not found.');
}
// SQL file is good, let's proceed with pulling it in
$err=false;
$i=0;
$query_array=explode(';',$sql) ;
$query_count=count($query_array) ;
// Iterate through the SQL commands to finalise init.
foreach ( $query_array as $query) {
if ($i<$query_count-1)
if (!Capsule::statement($query.';'))
$err=true;
$i++ ;
}
// Return success or error.
if (!$err)
return array('status'=>'success','description'=>'PVE for WHMCS installed successfuly.');
return array('status'=>'success','description'=>'Proxmox VE for WHMCS was installed successfully.');
return array('status'=>'error','description'=>'PVE for WHMCS was not activated properly.');
return array('status'=>'error','description'=>'Proxmox VE for WHMCS was not activated properly.');
}
// WHMCS MODULE: DEACTIVATION
function pvewhmcs_deactivate() {
// Drop all module-related tables
Capsule::statement('drop table mod_pvewhmcs_ip_addresses,mod_pvewhmcs_ip_pools,mod_pvewhmcs_plans,mod_pvewhmcs_vms,mod_pvewhmcs');
# Return Result
return array('status'=>'success','description'=>'PVE for WHMCS successfuly deactivated and all related tables deleted.');
return array('status'=>'error','description'=>'If an error occurs you can return an error
message for display here');
return array('status'=>'info','description'=>'If you want to give an info message to a user
you can return it here');
// Return the assumed result (change?)
return array('status'=>'success','description'=>'Proxmox VE for WHMCS successfully deactivated and all related tables deleted.');
}
function pvewhmcs_output($vars) {
// UPDATE CHECKER: live vs repo
function is_pvewhmcs_outdated(){
if(get_pvewhmcs_latest_version() > pvewhmcs_version()){
return "<br><span style='float:right;'><b>Proxmox VE for WHMCS is outdated: <a style='color:red' href='https://github.com/The-Network-Crew/Proxmox-VE-for-WHMCS/releases'>Download the new version!</a></span>";
}
}
// UPDATE CHECKER: return latest ver
function get_pvewhmcs_latest_version(){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://raw.githubusercontent.com/The-Network-Crew/Proxmox-VE-for-WHMCS/master/version");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close ($ch);
return str_replace("\n", "", $result);
}
// ADMIN MODULE GUI: output (HTML etc)
function pvewhmcs_output($vars) {
$modulelink = $vars['modulelink'];
// Messages
// Check for update and report if available
if (!empty(is_pvewhmcs_outdated())) {
$_SESSION['pvewhmcs']['infomsg']['title']='Proxmox VE for WHMCS: New version available!' ;
$_SESSION['pvewhmcs']['infomsg']['message']='Please visit the GitHub repository > Releases page. https://github.com/The-Network-Crew/Proxmox-VE-for-WHMCS/releases' ;
}
// Print Messages to GUI before anything else
if (isset($_SESSION['pvewhmcs']['infomsg'])) {
echo '
<div class="infobox">
@@ -74,7 +129,10 @@ function pvewhmcs_output($vars) {
<ul class="nav nav-tabs admin-tabs">
<li class="'.($_GET['tab']=="vmplans" ? "active" : "").'"><a id="tabLink1" data-toggle="tab" role="tab" href="#plans">VM Plans</a></li>
<li class="'.($_GET['tab']=="ippools" ? "active" : "").'"><a id="tabLink2" data-toggle="tab" role="tab" href="#ippools">IP Pools</a></li>
<li class="'.($_GET['tab']=="health" ? "active" : "").'"><a id="tabLink3" data-toggle="tab" role="tab" href="#health">Support / Health</a></li>
<li class="'.($_GET['tab']=="nodes" ? "active" : "").'"><a id="tabLink3" data-toggle="tab" role="tab" href="#nodes">Nodes / Cluster</a></li>
<li class="'.($_GET['tab']=="actions" ? "active" : "").'"><a id="tabLink4" data-toggle="tab" role="tab" href="#actions">Actions / Logs</a></li>
<li class="'.($_GET['tab']=="health" ? "active" : "").'"><a id="tabLink5" data-toggle="tab" role="tab" href="#health">Support / Health</a></li>
<li class="'.($_GET['tab']=="config" ? "active" : "").'"><a id="tabLink6" data-toggle="tab" role="tab" href="#config">Module Config</a></li>
</ul>
</div>
<div class="tab-content admin-tabs">
@@ -102,15 +160,15 @@ function pvewhmcs_output($vars) {
echo '
<div id="plans" class="tab-pane '.($_GET['tab']=="vmplans" ? "active" : "").'">
<div class="btn-group btn-group-lg" role="group" aria-label="...">
<div class="btn-group" role="group" aria-label="...">
<a class="btn btn-default" href="'. pvewhmcs_BASEURL .'&amp;tab=vmplans&amp;action=planlist">
<i class="fa fa-list"></i>&nbsp; Plans List
<i class="fa fa-list"></i>&nbsp; List: VM Plans
</a>
<a class="btn btn-default" href="'. pvewhmcs_BASEURL .'&amp;tab=vmplans&amp;action=add_kvm_plan">
<i class="fa fa-plus-square"></i>&nbsp; Add new KVM plan
<i class="fa fa-plus-square"></i>&nbsp; Add: KVM Plan
</a>
<a class="btn btn-default" href="'. pvewhmcs_BASEURL .'&amp;tab=vmplans&amp;action=add_lxc_plan">
<i class="fa fa-plus-square"></i>&nbsp; Add new LXC plan
<i class="fa fa-plus-square"></i>&nbsp; Add: LXC Plan
</a>
</div>
';
@@ -186,6 +244,9 @@ function pvewhmcs_output($vars) {
NIC Model
</th>
<th>
VLAN ID
</th>
<th>
Rate
</th>
<th>
@@ -213,6 +274,7 @@ function pvewhmcs_output($vars) {
echo '<td>'.$vm->netmode . PHP_EOL .'</td>';
echo '<td>'.$vm->bridge.$vm->vmbr . PHP_EOL .'</td>';
echo '<td>'.$vm->netmodel . PHP_EOL .'</td>';
echo '<td>'.$vm->vlanid . PHP_EOL .'</td>';
echo '<td>'.$vm->netrate . PHP_EOL .'</td>';
echo '<td>'.$vm->bw . PHP_EOL .'</td>';
echo '<td>
@@ -236,10 +298,10 @@ function pvewhmcs_output($vars) {
<div id="ippools" class="tab-pane '.($_GET['tab']=="ippools" ? "active" : "").'" >
<div class="btn-group">
<a class="btn btn-default" href="'. pvewhmcs_BASEURL .'&amp;tab=ippools&amp;action=list_ip_pools">
<i class="fa fa-list"></i>&nbsp; List IP Pools
<i class="fa fa-list"></i>&nbsp; List: IP Pools
</a>
<a class="btn btn-default" href="'. pvewhmcs_BASEURL .'&amp;tab=ippools&amp;action=newip">
<i class="fa fa-plus"></i>&nbsp; Add IP to Pool
<i class="fa fa-plus"></i>&nbsp; Add: IP to Pool
</a>
</div>
';
@@ -267,17 +329,96 @@ function pvewhmcs_output($vars) {
echo'
</div>
';
// Health Tab
// NODES / CLUSTER tab in ADMIN GUI
echo '<div id="nodes" class="tab-pane '.($_GET['tab']=="nodes" ? "active" : "").'" >' ;
echo ('<strong><h2>PVE: /cluster/resources</h2></strong>');
echo ('Coming in v1.3.x');
echo ('<strong><h2>PVE: Cluster Action Viewer</h2></strong>');
echo ('Coming in v1.3.x');
echo ('<strong><h2>PVE: Failed Actions (emailed)</h2></strong>');
echo ('Coming in v1.3.x<br><br>');
echo ('<strong><a href=\'https://github.com/The-Network-Crew/Proxmox-VE-for-WHMCS/milestones\' target=\'_blank\'>View the milestones/versions on GitHub</a></strong>');
echo '</div>';
// ACTIONS / LOGS tab in ADMIN GUI
echo '<div id="actions" class="tab-pane '.($_GET['tab']=="actions" ? "active" : "").'" >' ;
echo ('<strong><h2>Module: Action History</h2></strong>');
echo ('Coming in v1.3.x');
echo ('<strong><h2>Module: Failed Actions</h2></strong>');
echo ('Coming in v1.3.x');
echo ('<strong><h2>WHMCS: Module Logging</h2></strong>');
echo ('<u><a href=\'/admin/index.php?rp=/admin/logs/module-log\'>Click here</a></u> (Module Config > Debug Mode = ON)<br><br>');
echo ('<strong><a href=\'https://github.com/The-Network-Crew/Proxmox-VE-for-WHMCS/milestones\' target=\'_blank\'>View the milestones/versions on GitHub</a></strong>');
echo '</div>';
// SUPPORT / HEALTH tab in ADMIN GUI
echo '<div id="health" class="tab-pane '.($_GET['tab']=="health" ? "active" : "").'" >' ;
echo ('<h2>Technical Support:</h2>Please raise an <a href="https://github.com/The-Network-Crew/Proxmox-VE-for-WHMCS/issues/new" target="_blank"><u>Issue</u></a> on GitHub - include logs, steps to reproduce, etc. Thank you.<br><br>');
echo ('<h2>Updates & Codebase:</h2><b>Proxmox for WHMCS is open-source and free to use & improve on!</b><br><a href="https://github.com/The-Network-Crew/Proxmox-VE-for-WHMCS/" target="_blank">https://github.com/The-Network-Crew/Proxmox-VE-for-WHMCS/</a><br><br>');
echo ('<h2>System Environment:</h2>Proxmox VE for WHMCS v' . pvewhmcs_version() . ' on PHP v' . phpversion() . ' (' . $_SERVER['SERVER_SOFTWARE'] . ')');
echo ('<strong><h2>System Environment</h2></strong><b>Proxmox VE for WHMCS</b> v' . pvewhmcs_version() . ' (GitHub reports latest as <b>v' . get_pvewhmcs_latest_version() . '</b>)' . '<br><b>PHP</b> v' . phpversion() . ' running on <b>' . $_SERVER['SERVER_SOFTWARE'] . '</b> Web Server (' . $_SERVER['SERVER_NAME'] . ')<br><br>');
echo ('<strong><h2>Updates & Codebase</h2></strong><b>Proxmox for WHMCS is open-source and free to use & improve on! ❤️</b><br>Repo: <a href="https://github.com/The-Network-Crew/Proxmox-VE-for-WHMCS/" target="_blank">https://github.com/The-Network-Crew/Proxmox-VE-for-WHMCS/</a><br><br>');
echo ('<strong><h2>Product & Reviewing</h2></strong><b style="color:darkgreen;">Your 5-star review on WHMCS Marketplace will help the module grow!</b><br>*****: <a href="https://marketplace.whmcs.com/product/6935-proxmox-ve-for-whmcs" target="_blank">https://marketplace.whmcs.com/product/6935-proxmox-ve-for-whmcs</a><br><br>');
echo ('<strong><h2>Issues: Common Causes</h2></strong>1. <b>WHMCS needs to have >100 Services, else it is an illegal Proxmox VMID.</b><br>2. Save your Package (Plan/Pool)! (configproducts.php?action=edit&id=...#tab=3)<br>3. Where possible, we pass-through the exact error to WHMCS Admin. Check it for info!<br><br>');
echo ('<strong><h2>Module Technical Support</h2></strong>Please raise an <a href="https://github.com/The-Network-Crew/Proxmox-VE-for-WHMCS/issues/new" target="_blank"><u>Issue</u></a> on GitHub - include logs, steps to reproduce, etc.<br>Help is not guaranteed (FOSS). We will need your assistance. <b>Thank you.</b><br><br>');
echo '</div>';
// Config Tab
$config= Capsule::table('mod_pvewhmcs')->where('id', '=', '1')->get()[0];
echo '<div id="config" class="tab-pane '.($_GET['tab']=="config" ? "active" : "").'" >' ;
echo '
<form method="post">
<table class="form" border="0" cellpadding="3" cellspacing="1" width="100%">
<tr>
<td class="fieldlabel">VNC Secret</td>
<td class="fieldarea">
<input type="text" size="35" name="vnc_secret" id="vnc_secret" value="'.$config->vnc_secret.'"> Password of "vnc"@"pve" user. Mandatory for VNC proxying. See the <a href="https://github.com/The-Network-Crew/Proxmox-VE-for-WHMCS/wiki" target="_blank">Wiki</a> for more info.
</td>
</tr>
<tr>
<td class="fieldlabel">Debug Mode</td>
<td class="fieldarea">
<label class="checkbox-inline">
<input type="checkbox" name="debug_mode" value="1" '. ($config->debug_mode=="1" ? "checked" : "").'> Whether or not you want Debug Logging enabled (WHMCS Module Log for Debugging >> /admin/logs/module-log)
</label>
</td>
</tr>
</table>
<div class="btn-container">
<input type="submit" class="btn btn-primary" value="Save Changes" name="save_config" id="save_config">
<input type="reset" class="btn btn-default" value="Cancel Changes">
</div>
</form>
';
echo '</div>';
echo '</div>'; // end of tab-content
if (isset($_POST['save_config'])) {
save_config() ;
}
}
/* adding a KVM plan */
// MODULE CONFIG: Commit changes to the database
function save_config() {
try {
Capsule::connection()->transaction(
function ($connectionManager)
{
/** @var \Illuminate\Database\Connection $connectionManager */
$connectionManager->table('mod_pvewhmcs')->update(
[
'vnc_secret' => $_POST['vnc_secret'],
'debug_mode' => $_POST['debug_mode'],
]
);
}
);
$_SESSION['pvewhmcs']['infomsg']['title']='Module Config saved.' ;
$_SESSION['pvewhmcs']['infomsg']['message']='New options have been successfully saved.' ;
header("Location: ".pvewhmcs_BASEURL."&tab=config");
} catch (\Exception $e) {
echo "Uh oh! That didn't work, but I was able to rollback. {$e->getMessage()}";
}
}
// MODULE FORM: Add new KVM Plan
function kvm_plan_add() {
echo '
<form method="post">
@@ -313,10 +454,14 @@ function kvm_plan_add() {
<select class="form-control select-inline" name="cpuemu">
<option value="host">(Host) Host</option>
<option value="kvm32">(QEMU) kvm32</option>
<option value="kvm64" selected="">(QEMU) kvm64</option>
<option value="kvm64">(QEMU) kvm64</option>
<option value="max">(QEMU) Max</option>
<option value="qemu32">(QEMU) qemu32</option>
<option value="qemu64">(QEMU) qemu64</option>
<option value="x86-64-v2">(x86-64 psABI) v2 (Nehalem/Opteron_G3 on)</option>
<option value="x86-64-v2-AES" selected="">(x86-64 psABI) v2-AES (Westmere/Opteron_G4 on)</option>
<option value="x86-64-v3">(x86-64 psABI) v3 (Broadwell/EPYC on)</option>
<option value="x86-64-v4">(x86-64 psABI) v4 (Skylake/EPYCv4 on)</option>
<option value="486">(Intel) 486</option>
<option value="Broadwell">(Intel) Broadwell</option>
<option value="Broadwell-IBRS">(Intel) Broadwell-IBRS</option>
@@ -324,7 +469,12 @@ function kvm_plan_add() {
<option value="Broadwell-noTSX-IBRS">(Intel) Broadwell-noTSX-IBRS</option>
<option value="Cascadelake-Server">(Intel) Cascadelake-Server</option>
<option value="Cascadelake-Server-noTSX">(Intel) Cascadelake-Server-noTSX</option>
<option value="Cascadelake-Server-v2">(Intel) Cascadelake-Server-v2</option>
<option value="Cascadelake-Server-v4">(Intel) Cascadelake-Server-v4</option>
<option value="Cascadelake-Server-v5">(Intel) Cascadelake-Server-v5</option>
<option value="Conroe">(Intel) Conroe</option>
<option value="Cooperlake">(Intel) Cooperlake</option>
<option value="Cooperlake-v2">(Intel) Cooperlake-v2</option>
<option value="Haswell">(Intel) Haswell</option>
<option value="Haswell-IBRS">(Intel) Haswell-IBRS</option>
<option value="Haswell-noTSX">(Intel) Haswell-noTSX</option>
@@ -333,6 +483,10 @@ function kvm_plan_add() {
<option value="Icelake-Client-noTSX">(Intel) Icelake-Client-noTSX</option>
<option value="Icelake-Server">(Intel) Icelake-Server</option>
<option value="Icelake-Server-noTSX">(Intel) Icelake-Server-noTSX</option>
<option value="Icelake-Server-v3">(Intel) Icelake-Server-v3</option>
<option value="Icelake-Server-v4">(Intel) Icelake-Server-v4</option>
<option value="Icelake-Server-v5">(Intel) Icelake-Server-v5</option>
<option value="Icelake-Server-v6">(Intel) Icelake-Server-v6</option>
<option value="IvyBridge">(Intel) IvyBridge</option>
<option value="IvyBridge-IBRS">(Intel) IvyBridge-IBRS</option>
<option value="KnightsMill">(Intel) KnightsMill</option>
@@ -341,12 +495,16 @@ function kvm_plan_add() {
<option value="Penryn">(Intel) Penryn</option>
<option value="SandyBridge">(Intel) SandyBridge</option>
<option value="SandyBridge-IBRS">(Intel) SandyBridge-IBRS</option>
<option value="SapphireRapids">(Intel) SapphireRapids</option>
<option value="Skylake-Client">(Intel) Skylake-Client</option>
<option value="Skylake-Client-IBRS">(Intel) Skylake-Client-IBRS</option>
<option value="Skylake-Client-noTSX-IBRS">(Intel) Skylake-Client-noTSX-IBRS</option>
<option value="Skylake-Client-v4">(Intel) Skylake-Client-v4</option>
<option value="Skylake-Server">(Intel) Skylake-Server</option>
<option value="Skylake-Server-IBRS">(Intel) Skylake-Server-IBRS</option>
<option value="Skylake-Server-noTSX-IBRS">(Intel) Skylake-Server-noTSX-IBRS</option>
<option value="Skylake-Server-v4">(Intel) Skylake-Server-v4</option>
<option value="Skylake-Server-v5">(Intel) Skylake-Server-v5</option>
<option value="Westmere">(Intel) Westmere</option>
<option value="Westmere-IBRS">(Intel) Westmere-IBRS</option>
<option value="pentium">(Intel) Pentium I</option>
@@ -360,13 +518,15 @@ function kvm_plan_add() {
<option value="EPYC-IBPB">(AMD) EPYC-IBPB</option>
<option value="EPYC-Milan">(AMD) EPYC-Milan</option>
<option value="EPYC-Rome">(AMD) EPYC-Rome</option>
<option value="EPYC-Rome-v2">(AMD) EPYC-Rome-v2</option>
<option value="EPYC-v3">(AMD) EPYC-v3</option>
<option value="Opteron_G1">(AMD) Opteron_G1</option>
<option value="Opteron_G2">(AMD) Opteron_G2</option>
<option value="Opteron_G3">(AMD) Opteron_G3</option>
<option value="Opteron_G4">(AMD) Opteron_G4</option>
<option value="Opteron_G5">(AMD) Opteron_G5</option>
</select>
CPU emulation type. Default is KVM64
CPU emulation type. Default is x86-64 psABI v2-AES
</td>
</tr>
@@ -449,7 +609,7 @@ function kvm_plan_add() {
</td>
</tr>
<tr>
<td class="fieldlabel">PVE Storage - Name</td>
<td class="fieldlabel">PVE Store - Name</td>
<td class="fieldarea">
<input type="text" size="8" name="storage" id="storage" value="local" required>
Name of VM/CT Storage on Proxmox VE hypervisor. local/local-lvm/etc.
@@ -512,12 +672,19 @@ function kvm_plan_add() {
</td>
</tr>
<tr>
<td class="fieldlabel">Trunk - VLAN ID</td>
<td class="fieldarea">
<input type="text" size="8" name="vlanid" id="vlanid">
VLAN ID for Plan Services. Default forgoes tagging (VLAN ID), leave blank for untagged.
</td>
</tr>
<tr>
<td class="fieldlabel">
Hardware Virt?
</td>
<td class="fieldarea">
<label class="checkbox-inline">
<input type="checkbox" name="kvm" value="1" checked> Enable KVM hardware virtualisation. (Recommended)
<input type="checkbox" name="kvm" value="1" checked> Enable KVM hardware virtualisation. Requires support/enablement in BIOS. (Recommended)
</label>
</td>
</tr>
@@ -541,7 +708,7 @@ function kvm_plan_add() {
';
}
/* editing a KVM plan */
// MODULE FORM: Edit a KVM Plan
function kvm_plan_edit($id) {
$plan= Capsule::table('mod_pvewhmcs_plans')->where('id', '=', $id)->get()[0];
if (empty($plan)) {
@@ -589,6 +756,10 @@ function kvm_plan_edit($id) {
<option value="max" ' . ($plan->cpuemu == "max" ? "selected" : "") . '>(QEMU) Max</option>
<option value="qemu32" ' . ($plan->cpuemu == "qemu32" ? "selected" : "") . '>(QEMU) qemu32</option>
<option value="qemu64" ' . ($plan->cpuemu == "qemu64" ? "selected" : "") . '>(QEMU) qemu64</option>
<option value="x86-64-v2" ' . ($plan->cpuemu == "x86-64-v2" ? "selected" : "") . '>(x86-64 psABI) v2 (Nehalem/Opteron_G3 on)</option>
<option value="x86-64-v2-AES" ' . ($plan->cpuemu == "x86-64-v2-AES" ? "selected" : "") . '>(x86-64 psABI) v2-AES (Westmere/Opteron_G4 on)</option>
<option value="x86-64-v3" ' . ($plan->cpuemu == "x86-64-v3" ? "selected" : "") . '>(x86-64 psABI) v3 (Broadwell/EPYC on)</option>
<option value="x86-64-v4" ' . ($plan->cpuemu == "x86-64-v4" ? "selected" : "") . '>(x86-64 psABI) v4 (Skylake/EPYCv4 on)</option>
<option value="486" ' . ($plan->cpuemu == "486" ? "selected" : "") . '>(Intel) 486</option>
<option value="Broadwell" ' . ($plan->cpuemu == "Broadwell" ? "selected" : "") . '>(Intel) Broadwell</option>
<option value="Broadwell-IBRS" ' . ($plan->cpuemu == "Broadwell-IBRS" ? "selected" : "") . '>(Intel) Broadwell-IBRS</option>
@@ -596,7 +767,12 @@ function kvm_plan_edit($id) {
<option value="Broadwell-noTSX-IBRS" ' . ($plan->cpuemu == "Broadwell-noTSX-IBRS" ? "selected" : "") . '>(Intel) Broadwell-noTSX-IBRS</option>
<option value="Cascadelake-Server" ' . ($plan->cpuemu == "Cascadelake-Server" ? "selected" : "") . '>(Intel) Cascadelake-Server</option>
<option value="Cascadelake-Server-noTSX" ' . ($plan->cpuemu == "Cascadelake-Server-noTSX" ? "selected" : "") . '>(Intel) Cascadelake-Server-noTSX</option>
<option value="Cascadelake-Server-v2" ' . ($plan->cpuemu == "Cascadelake-Server-v2" ? "selected" : "") . '>(Intel) Cascadelake-Server V2</option>
<option value="Cascadelake-Server-v4" ' . ($plan->cpuemu == "Cascadelake-Server-v4" ? "selected" : "") . '>(Intel) Cascadelake-Server V4</option>
<option value="Cascadelake-Server-v5" ' . ($plan->cpuemu == "Cascadelake-Server-v5" ? "selected" : "") . '>(Intel) Cascadelake-Server V5</option>
<option value="Conroe" ' . ($plan->cpuemu == "Conroe" ? "selected" : "") . '>(Intel) Conroe</option>
<option value="Cooperlake" ' . ($plan->cpuemu == "Cooperlake" ? "selected" : "") . '>(Intel) Cooperlake</option>
<option value="Cooperlake-v2" ' . ($plan->cpuemu == "Cooperlake-v2" ? "selected" : "") . '>(Intel) Cooperlake V2</option>
<option value="Haswell" ' . ($plan->cpuemu == "Haswell" ? "selected" : "") . '>(Intel) Haswell</option>
<option value="Haswell-IBRS" ' . ($plan->cpuemu == "Haswell-IBRS" ? "selected" : "") . '>(Intel) Haswell-IBRS</option>
<option value="Haswell-noTSX" ' . ($plan->cpuemu == "Haswell-noTSX" ? "selected" : "") . '>(Intel) Haswell-noTSX</option>
@@ -605,6 +781,10 @@ function kvm_plan_edit($id) {
<option value="Icelake-Client-noTSX" ' . ($plan->cpuemu == "Icelake-Client-noTSX" ? "selected" : "") . '>(Intel) Icelake-Client-noTSX</option>
<option value="Icelake-Server" ' . ($plan->cpuemu == "Icelake-Server" ? "selected" : "") . '>(Intel) Icelake-Server</option>
<option value="Icelake-Server-noTSX" ' . ($plan->cpuemu == "Icelake-Server-noTSX" ? "selected" : "") . '>(Intel) Icelake-Server-noTSX</option>
<option value="Icelake-Server-v3" ' . ($plan->cpuemu == "Icelake-Server-v3" ? "selected" : "") . '>(Intel) Icelake-Server V3</option>
<option value="Icelake-Server-v4" ' . ($plan->cpuemu == "Icelake-Server-v4" ? "selected" : "") . '>(Intel) Icelake-Server V4</option>
<option value="Icelake-Server-v5" ' . ($plan->cpuemu == "Icelake-Server-v5" ? "selected" : "") . '>(Intel) Icelake-Server V5</option>
<option value="Icelake-Server-v6" ' . ($plan->cpuemu == "Icelake-Server-v6" ? "selected" : "") . '>(Intel) Icelake-Server V6</option>
<option value="IvyBridge" ' . ($plan->cpuemu == "IvyBridge" ? "selected" : "") . '>(Intel) IvyBridge</option>
<option value="IvyBridge-IBRS" ' . ($plan->cpuemu == "IvyBridge-IBRS" ? "selected" : "") . '>(Intel) IvyBridge-IBRS</option>
<option value="KnightsMill" ' . ($plan->cpuemu == "KnightsMill" ? "selected" : "") . '>(Intel) KnightsMill</option>
@@ -613,12 +793,16 @@ function kvm_plan_edit($id) {
<option value="Penryn" ' . ($plan->cpuemu == "Penryn" ? "selected" : "") . '>(Intel) Penryn</option>
<option value="SandyBridge" ' . ($plan->cpuemu == "SandyBridge" ? "selected" : "") . '>(Intel) SandyBridge</option>
<option value="SandyBridge-IBRS" ' . ($plan->cpuemu == "SandyBridge-IBRS" ? "selected" : "") . '>(Intel) SandyBridge-IBRS</option>
<option value="SapphireRapids" ' . ($plan->cpuemu == "SapphireRapids" ? "selected" : "") . '>(Intel) Sapphire Rapids</option>
<option value="Skylake-Client" ' . ($plan->cpuemu == "Skylake-Client" ? "selected" : "") . '>(Intel) Skylake-Client</option>
<option value="Skylake-Client-IBRS" ' . ($plan->cpuemu == "Skylake-Client-IBRS" ? "selected" : "") . '>(Intel) Skylake-Client-IBRS</option>
<option value="Skylake-Client-noTSX-IBRS" ' . ($plan->cpuemu == "Skylake-Client-noTSX-IBRS" ? "selected" : "") . '>(Intel) Skylake-Client-noTSX-IBRS</option>
<option value="Skylake-Client-v4" ' . ($plan->cpuemu == "Skylake-Client-v4" ? "selected" : "") . '>(Intel) Skylake-Client V4</option>
<option value="Skylake-Server" ' . ($plan->cpuemu == "Skylake-Server" ? "selected" : "") . '>(Intel) Skylake-Server</option>
<option value="Skylake-Server-IBRS" ' . ($plan->cpuemu == "Skylake-Server-IBRS" ? "selected" : "") . '>(Intel) Skylake-Server-IBRS</option>
<option value="Skylake-Server-noTSX-IBRS" ' . ($plan->cpuemu == "Skylake-Server-noTSX-IBRS" ? "selected" : "") . '>(Intel) Skylake-Server-noTSX-IBRS</option>
<option value="Skylake-Server-v4" ' . ($plan->cpuemu == "Skylake-Server-v4" ? "selected" : "") . '>(Intel) Skylake-Server V4</option>
<option value="Skylake-Server-v5" ' . ($plan->cpuemu == "Skylake-Server-v5" ? "selected" : "") . '>(Intel) Skylake-Server V5</option>
<option value="Westmere" ' . ($plan->cpuemu == "Westmere" ? "selected" : "") . '>(Intel) Westmere</option>
<option value="Westmere-IBRS" ' . ($plan->cpuemu == "Westmere-IBRS" ? "selected" : "") . '>(Intel) Westmere-IBRS</option>
<option value="pentium" ' . ($plan->cpuemu == "pentium" ? "selected" : "") . '>(Intel) Pentium I</option>
@@ -632,13 +816,15 @@ function kvm_plan_edit($id) {
<option value="EPYC-IBPB" ' . ($plan->cpuemu == "EPYC-IBPB" ? "selected" : "") . '>(AMD) EPYC-IBPB</option>
<option value="EPYC-Milan" ' . ($plan->cpuemu == "EPYC-Milan" ? "selected" : "") . '>(AMD) EPYC-Milan</option>
<option value="EPYC-Rome" ' . ($plan->cpuemu == "EPYC-Rome" ? "selected" : "") . '>(AMD) EPYC-Rome</option>
<option value="EPYC-Rome-v2" ' . ($plan->cpuemu == "EPYC-Rome-v2" ? "selected" : "") . '>(AMD) EPYC-Rome-v2</option>
<option value="EPYC-v3" ' . ($plan->cpuemu == "EPYC-v3" ? "selected" : "") . '>(AMD) EPYC-v3</option>
<option value="Opteron_G1" ' . ($plan->cpuemu == "Opteron_G1" ? "selected" : "") . '>(AMD) Opteron_G1</option>
<option value="Opteron_G2" ' . ($plan->cpuemu == "Opteron_G2" ? "selected" : "") . '>(AMD) Opteron_G2</option>
<option value="Opteron_G3" ' . ($plan->cpuemu == "Opteron_G3" ? "selected" : "") . '>(AMD) Opteron_G3</option>
<option value="Opteron_G4" ' . ($plan->cpuemu == "Opteron_G4" ? "selected" : "") . '>(AMD) Opteron_G4</option>
<option value="Opteron_G5" ' . ($plan->cpuemu == "Opteron_G5" ? "selected" : "") . '>(AMD) Opteron_G5</option>
</select>
CPU emulation type. Default is KVM64
CPU emulation type. Default is x86-64 psABI v2-AES
</td>
</tr>
@@ -667,7 +853,7 @@ function kvm_plan_edit($id) {
<td class="fieldlabel">CPU - Weighting</td>
<td class="fieldarea">
<input type="text" size="8" name="cpuunits" id="cpuunits" value="'.$plan->cpuunits.'" required>
Number is relative to weights of all the other running VMs. 8 - 500000 recommended 1024. NOTE: You can disable fair-scheduler configuration by setting this to 0.
Number is relative to weights of all the other running VMs. 8 - 500000 recommended 1024. NOTE: You can disable fair-scheduler by setting this to 0.
</td>
</tr>
<tr>
@@ -721,7 +907,7 @@ function kvm_plan_edit($id) {
</td>
</tr>
<tr>
<td class="fieldlabel">PVE Storage - Name</td>
<td class="fieldlabel">PVE Store - Name</td>
<td class="fieldarea">
<input type="text" size="8" name="storage" id="storage" required value="'.$plan->storage.'">
Name of VM/CT Storage on Proxmox VE hypervisor. local/local-lvm/etc.
@@ -749,14 +935,14 @@ function kvm_plan_edit($id) {
<td class="fieldlabel">Network - Rate</td>
<td class="fieldarea">
<input type="text" size="8" name="netrate" id="netrate" value="'.$plan->netrate.'">
Network Rate Limit in Megabit, Blank means unlimit.
Network Rate Limit in Megabit, Blank means unlimited.
</td>
</tr>
<tr>
<td class="fieldlabel">Network - BW Limit</td>
<td class="fieldarea">
<input type="text" size="8" name="bw" id="bw" value="'.$plan->bw.'">
Monthly Bandwidth Limit in GigaByte, Blank means unlimit.
Monthly Bandwidth Limit in Gigabyte, Blank means unlimited.
</td>
</tr>
<tr>
@@ -784,12 +970,19 @@ function kvm_plan_edit($id) {
</td>
</tr>
<tr>
<td class="fieldlabel">Trunk - VLAN ID</td>
<td class="fieldarea">
<input type="text" size="8" name="vlanid" id="vlanid">
VLAN ID for Plan Services. Default forgoes tagging (VLAN ID), leave blank for untagged.
</td>
</tr>
<tr>
<td class="fieldlabel">
Hardware Virt?
</td>
<td class="fieldarea">
<label class="checkbox-inline">
<input type="checkbox" name="kvm" value="1" '. ($plan->kvm=="1" ? "checked" : "").'> Enable KVM hardware virtualisation. (Recommended)
<input type="checkbox" name="kvm" value="1" '. ($plan->kvm=="1" ? "checked" : "").'> Enable KVM hardware virtualisation. Requires support/enablement in BIOS. (Recommended)
</label>
</td>
</tr>
@@ -813,8 +1006,7 @@ function kvm_plan_edit($id) {
';
}
/* adding an LXC plan */
// MODULE FORM: Add an LXC Plan
function lxc_plan_add() {
echo '
<form method="post">
@@ -857,11 +1049,11 @@ function lxc_plan_add() {
<td class="fieldlabel">SSD/HDD - Disk</td>
<td class="fieldarea">
<input type="text" size="8" name="disk" id="disk" required>
Disk space in Gigabayte e.g 1024 = 1TB
Disk space in Gigabytes e.g 1024 = 1TB
</td>
</tr>
<tr>
<td class="fieldlabel">PVE Storage - Name</td>
<td class="fieldlabel">PVE Store - Name</td>
<td class="fieldarea">
<input type="text" size="8" name="storage" id="storage" value="local" required>
Name of VM/CT Storage on Proxmox VE hypervisor. local/local-lvm/etc.
@@ -889,6 +1081,13 @@ function lxc_plan_add() {
</td>
</tr>
<tr>
<td class="fieldlabel">Trunk - VLAN ID</td>
<td class="fieldarea">
<input type="text" size="8" name="vlanid" id="vlanid">
VLAN ID for Plan Services. Default forgoes tagging (VLAN ID), leave blank for untagged.
</td>
</tr>
<tr>
<td class="fieldlabel">Network - Rate</td>
<td class="fieldarea">
<input type="text" size="8" name="netrate" id="netrate">
@@ -922,7 +1121,7 @@ function lxc_plan_add() {
';
}
/* editing an LXC plan */
// MODULE FORM: Edit an LXC Plan
function lxc_plan_edit($id) {
$plan= Capsule::table('mod_pvewhmcs_plans')->where('id', '=', $id)->get()[0];
if (empty($plan)) {
@@ -978,7 +1177,7 @@ function lxc_plan_edit($id) {
</td>
</tr>
<tr>
<td class="fieldlabel">PVE Storage - Name</td>
<td class="fieldlabel">PVE Store - Name</td>
<td class="fieldarea">
<input type="text" size="8" name="storage" id="storage" value="'.$plan->storage.'" required>
Name of VM/CT Storage on Proxmox VE hypervisor. local/local-lvm/etc.
@@ -1006,6 +1205,13 @@ function lxc_plan_edit($id) {
</td>
</tr>
<tr>
<td class="fieldlabel">Trunk - VLAN ID</td>
<td class="fieldarea">
<input type="text" size="8" name="vlanid" id="vlanid">
VLAN ID for Plan Services. Default forgoes tagging (VLAN ID), leave blank for untagged.
</td>
</tr>
<tr>
<td class="fieldlabel">Network - Rate</td>
<td class="fieldarea">
<input type="text" size="8" name="netrate" id="netrate" value="'.$plan->netrate.'">
@@ -1039,6 +1245,7 @@ function lxc_plan_edit($id) {
';
}
// MODULE FORM ACTION: Save KVM Plan
function save_kvm_plan() {
try {
Capsule::connection()->transaction(
@@ -1066,6 +1273,7 @@ function save_kvm_plan() {
'bridge' => $_POST['bridge'],
'vmbr' => $_POST['vmbr'],
'netmodel' => $_POST['netmodel'],
'vlanid' => $_POST['vlanid'],
'netrate' => $_POST['netrate'],
'bw' => $_POST['bw'],
'kvm' => $_POST['kvm'],
@@ -1082,6 +1290,7 @@ function save_kvm_plan() {
}
}
// MODULE FORM ACTION: Update KVM Plan
function update_kvm_plan() {
Capsule::table('mod_pvewhmcs_plans')
->where('id', $_GET['id'])
@@ -1106,6 +1315,7 @@ function update_kvm_plan() {
'bridge' => $_POST['bridge'],
'vmbr' => $_POST['vmbr'],
'netmodel' => $_POST['netmodel'],
'vlanid' => $_POST['vlanid'],
'netrate' => $_POST['netrate'],
'bw' => $_POST['bw'],
'kvm' => $_POST['kvm'],
@@ -1117,13 +1327,15 @@ function update_kvm_plan() {
header("Location: ".pvewhmcs_BASEURL."&tab=vmplans&action=planlist");
}
// MODULE FORM ACTION: Remove Plan
function remove_plan($id) {
Capsule::table('mod_pvewhmcs_plans')->where('id', '=', $id)->delete();
header("Location: ".pvewhmcs_BASEURL."&tab=vmplans&action=planlist");
$_SESSION['pvewhmcs']['infomsg']['title']='Plan Deleted.' ;
$_SESSION['pvewhmcs']['infomsg']['message']='Selected Item deleted successfuly.' ;
}
// MODULE FORM ACTION: Save LXC Plan
function save_lxc_plan() {
try {
Capsule::connection()->transaction(
@@ -1145,6 +1357,7 @@ function save_lxc_plan() {
'bridge' => $_POST['bridge'],
'vmbr' => $_POST['vmbr'],
'netmodel' => $_POST['netmodel'],
'vlanid' => $_POST['vlanid'],
'netrate' => $_POST['netrate'],
'bw' => $_POST['bw'],
'onboot' => $_POST['onboot'],
@@ -1160,6 +1373,7 @@ function save_lxc_plan() {
}
}
// MODULE FORM ACTION: Update LXC Plan
function update_lxc_plan() {
Capsule::table('mod_pvewhmcs_plans')
->where('id', $_GET['id'])
@@ -1178,6 +1392,7 @@ function update_lxc_plan() {
'bridge' => $_POST['bridge'],
'vmbr' => $_POST['vmbr'],
'netmodel' => $_POST['netmodel'],
'vlanid' => $_POST['vlanid'],
'netrate' => $_POST['netrate'],
'bw' => $_POST['bw'],
'onboot' => $_POST['onboot'],
@@ -1188,7 +1403,7 @@ function update_lxc_plan() {
header("Location: ".pvewhmcs_BASEURL."&tab=vmplans&action=planlist");
}
// List IP pools in table
// IP POOLS: List all Pools
function list_ip_pools() {
echo '<a class="btn btn-default" href="'. pvewhmcs_BASEURL .'&amp;tab=ippools&amp;action=new_ip_pool"><i class="fa fa-plus-square"></i>&nbsp; New IP Pool</a>';
echo '<table class="datatable"><tr><th>ID</th><th>Pool</th><th>Gateway</th><th>Action</th></tr>';
@@ -1206,7 +1421,7 @@ function list_ip_pools() {
echo '</table>';
}
//create new IP pool
// IP POOL FORM: Add IP Pool
function add_ip_pool() {
echo '
<form method="post">
@@ -1228,6 +1443,7 @@ function add_ip_pool() {
';
}
// IP POOL FORM ACTION: Save Pool
function save_ip_pool() {
try {
Capsule::connection()->transaction(
@@ -1250,6 +1466,7 @@ function save_ip_pool() {
}
}
// IP POOL FORM ACTION: Remove Pool
function removeIpPool($id) {
Capsule::table('mod_pvewhmcs_ip_addresses')->where('pool_id', '=', $id)->delete();
Capsule::table('mod_pvewhmcs_ip_pools')->where('id', '=', $id)->delete();
@@ -1259,7 +1476,7 @@ function removeIpPool($id) {
$_SESSION['pvewhmcs']['infomsg']['message']='Deleted the IP Pool successfully.' ;
}
// add IP address/subnet to Pool
// IP POOL FORM ACTION: Add IP to Pool
function add_ip_2_pool() {
require_once(ROOTDIR.'/modules/addons/pvewhmcs/Ipv4/Subnet.php');
echo '<form method="post">
@@ -1319,7 +1536,7 @@ function add_ip_2_pool() {
}
}
// List IP addresses in pool
// IP POOL FORM: List IPs in Pool
function list_ips() {
//echo '<script>$(function() {$( "#dialog" ).dialog();});</script>' ;
//echo '<div id="dialog">' ;
@@ -1336,7 +1553,7 @@ function list_ips() {
}
// Remove IP Address
// IP POOL FORM ACTION: Remove IP from Pool
function removeip($id,$pool_id) {
Capsule::table('mod_pvewhmcs_ip_addresses')->where('id', '=', $id)->delete();
header("Location: ".pvewhmcs_BASEURL."&tab=ippools&action=list_ips&id=".$pool_id);

View File

@@ -17,7 +17,7 @@
</div>
<div class="col col-md-2">
<img src="/modules/servers/pvewhmcs/img/{$vm_status['status']}.png"/><br/>
<span style="text-transform: uppercase"><strong>{$vm_status['status']}</strong></span><br/>
<span style="text-transform: uppercase"><strong><i>{$vm_status['status']}</i></strong></span><br/>
Up:&nbsp;{$vm_status['uptime']}
</div>
@@ -25,16 +25,16 @@
<div class="row">
<script src="/modules/servers/pvewhmcs/js/CircularLoader.js"></script>
<div class="col col-md-3" style="height:106px;">
<div id="c1" class="circle" data-percent="{$vm_status['cpu']}">CPU</div>
<div id="c1" class="circle" data-percent="{$vm_status['cpu']}"><strong>CPU</strong></div>
</div>
<div class="col col-md-3">
<div id="c2" class="circle" data-percent="{$vm_status['memusepercent']}">RAM</div>
<div id="c2" class="circle" data-percent="{$vm_status['memusepercent']}"><strong>RAM</strong></div>
</div>
<div class="col col-md-3">
<div id="c3" class="circle" data-percent="{$vm_status['diskusepercent']}">Disk</div>
<div id="c3" class="circle" data-percent="{$vm_status['diskusepercent']}"><strong>Disk</strong></div>
</div>
<div class="col col-md-3">
<div id="c4" class="circle" data-percent="{$vm_status['swapusepercent']}">Swap</div>
<div id="c4" class="circle" data-percent="{$vm_status['swapusepercent']}"><strong>Swap</strong></div>
</div>
</div>
<script>
@@ -57,37 +57,38 @@
<table class="table table-bordered table-striped">
<tr>
<td>Network Addressing</td><td>{$vm_config['ipv4']}&nbsp;Subnet Mask:&nbsp;{$vm_config['netmask4']}&nbsp;Gateway:&nbsp;{$vm_config['gateway4']}</td>
<td><strong>IP</strong> (Addressing)</td><td><strong>{$vm_config['ipv4']}</strong><br/>Subnet Mask:&nbsp;{$vm_config['netmask4']}<br/>Gateway:&nbsp;{$vm_config['gateway4']}</td>
</tr>
<tr>
<td>OS (Type)</td>
<td>{$vm_config['ostype']}</td>
<td><strong>OS/etc</strong> (System)</td>
<td>Kernel:&nbsp;{$vm_config['ostype']}</td>
</tr>
<tr>
<td>CPU (Spec)</td>
<td>{$vm_config['sockets']}&nbsp;{$vm_config['cpu']}&nbsp;{$vm_config['cores']}&nbsp;core(s).</td>
<td><strong>Compute</strong> (CPU)</td>
<td>{$vm_config['sockets']}&nbsp;socket/s,&nbsp;{$vm_config['cores']}&nbsp;core/s<br />
Emulation: {$vm_config['cpu']}</td>
</tr>
<tr>
<td>Memory (RAM)</td>
<td>{$vm_config['memory']}&nbsp;MB</td>
<td><strong>Memory</strong> (RAM)</td>
<td>{$vm_config['memory']}MB</td>
</tr>
<tr>
<td>Network Interface #1</td>
<td><strong>NIC</strong> (Interface #1)</td>
<td>{($vm_config['net0']|replace:',':'<br/>')}</td>
</tr>
<tr>
<td>Network Interface #2</td>
<td><strong>NIC</strong> (Interface #2)</td>
<td>{$vm_config['net1']}</td>
</tr>
<tr>
<td>Storage (SSD/HDD)</td>
<td><strong>Storage</strong> (SSD/HDD)</td>
<td>
{$rootfs=(","|explode:$vm_config['rootfs'])}
{$disk=(","|explode:$vm_config['ide0'])}
{$disk[1]}
{$rootfs[1]}
{$vm_config['scsi0']}
{$vm_config['virtio0']}
{($vm_config['scsi0']|replace:',':'<br/>')}
{($vm_config['virtio0']|replace:',':'<br/>')}
</td>
</tr>
</table>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@@ -0,0 +1,50 @@
<?php
/*
Proxmox VE for WHMCS - Addon/Server Modules for WHMCS (& PVE)
https://github.com/The-Network-Crew/Proxmox-VE-for-WHMCS/
File: /modules/servers/pvewhmcs/novnc_router.php (VNC)
Copyright (C) The Network Crew Pty Ltd (TNC) & Co.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (isset($_GET['pveticket']) && isset($_GET['host']) && isset($_GET['path']) && isset($_GET['vncticket'])) {
// Take passed-in variables and re-assign for usage
$pveticket = $_GET['pveticket'];
$vncticket = $_GET['vncticket'];
$host = $_GET['host'];
$path = $_GET['path'];
// Get the requesting hostname/domain from the WHMCS-originated request
$whmcsdomain = parse_url($_SERVER['HTTP_HOST']);
// Now extract just the domain parts we need (FUTURE: capacity/option for multi-part TLDs)
$domainonly = preg_replace("/^(.*?)\.(.*)$/","$2",$whmcsdomain['path']);
// Set the cookie as Proxmox will be expecting it, so it is WHMCS to VNC without further login
setrawcookie('PVEAuthCookie', $pveticket, 0, '/', $domainonly);
// Create the final noVNC URL with the re-encoded vncticket
$hostname = gethostbyaddr($host);
$redirect_url = '/modules/servers/pvewhmcs/novnc/vnc.html?autoconnect=true&encrypt=true&host=' . $hostname . '&port=8006&password=' . urlencode($vncticket) . '&path=' . urlencode($path);
// Redirect the visitor to noVNC & we're done
header('Location: ' . $redirect_url);
exit;
} else {
// Passed in values not present, exit
echo 'Error: Missing required info to route your request. Please try again.';
exit;
}
?>

View File

@@ -1,4 +1,27 @@
<?php
/*
Proxmox VE for WHMCS - Addon/Server Modules for WHMCS (& PVE)
https://github.com/The-Network-Crew/Proxmox-VE-for-WHMCS/
File: /modules/servers/pvewhmcs/pvewhmcs.php (PVE Work)
Copyright (C) The Network Crew Pty Ltd (TNC) & Co.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// DEP: Proxmox API Class - make sure we can access via PVE via API
if (file_exists('../modules/addons/pvewhmcs/proxmox.php'))
require_once('../modules/addons/pvewhmcs/proxmox.php');
else
@@ -8,17 +31,17 @@ use Illuminate\Database\Capsule\Manager as Capsule;
global $guest ;
// WHMCS CONFIG > SERVICES/PRODUCTS > Their Service > Tab #3 (Plan/Pool)
function pvewhmcs_ConfigOptions() {
// Reterive PVE for WHMCS Cluster
$server=Capsule::table('tblservers')->where('type', '=', 'pve-whmcs')->get()[0] ;
// Retrieve PVE for WHMCS Cluster
$server=Capsule::table('tblservers')->where('type', '=', 'pvewhmcs')->get()[0] ;
// Reterive Plans
// Retrieve Plans
foreach (Capsule::table('mod_pvewhmcs_plans')->get() as $plan) {
$plans[$plan->id]=$plan->vmtype.'&nbsp;:&nbsp;'.$plan->title ;
}
// Reterive IP Pools
// Retrieve IP Pools
foreach (Capsule::table('mod_pvewhmcs_ip_pools')->get() as $ippool) {
$ippools[$ippool->id]=$ippool->title ;
}
@@ -39,7 +62,8 @@ function pvewhmcs_ConfigOptions() {
}
}
*/
// Options for the Service
// OPTIONS FOR THE QEMU/LXC PACKAGE; ties WHMCS PRODUCT to MODULE PLAN/POOL
// Ref: https://developers.whmcs.com/provisioning-modules/config-options/
// SQL/Param: configoption1 configoption2
$configarray = array(
"Plan" => array(
@@ -59,7 +83,19 @@ function pvewhmcs_ConfigOptions() {
return $configarray;
}
// PVE API FUNCTION: Create the Service on the Hypervisor
function pvewhmcs_CreateAccount($params) {
// Make sure "WHMCS Admin > Products/Services > Proxmox-based Service -> Plan + Pool" are set. Else, fail early. (Issue #36)
if (!isset($params['configoption1'], $params['configoption2'])) {
throw new Exception("PVEWHMCS Error: Missing Config. Service/Product WHMCS Config not saved (Plan/Pool not assigned to WHMCS Service type). Check Support/Health tab in Module Config for info. Quick and easy fix.");
}
if (empty($params['configoption1'])) {
throw new Exception("PVEWHMCS Error: Missing Config. Service/Product WHMCS Config not saved (Plan/Pool not assigned to WHMCS Service type). Check Support/Health tab in Module Config for info. Quick and easy fix.");
}
if (empty($params['configoption2'])) {
throw new Exception("PVEWHMCS Error: Missing Config. Service/Product WHMCS Config not saved (Plan/Pool not assigned to WHMCS Service type). Check Support/Health tab in Module Config for info. Quick and easy fix.");
}
// Retrieve Plan from table
$plan = Capsule::table('mod_pvewhmcs_plans')->where('id', '=', $params['configoption1'])->get()[0];
@@ -74,7 +110,7 @@ function pvewhmcs_CreateAccount($params) {
// CREATE IF QEMU/KVM
if (!empty($params['customfields']['KVMTemplate'])) {
file_put_contents('d:\log.txt', $params['customfields']['KVMTemplate']);
// file_put_contents('d:\log.txt', $params['customfields']['KVMTemplate']);
$proxmox = new PVE2_API($serverip, $serverusername, "pam", $serverpassword);
if ($proxmox->login()) {
@@ -85,14 +121,18 @@ function pvewhmcs_CreateAccount($params) {
$vm_settings['newid'] = $params["serviceid"];
$vm_settings['name'] = "vps" . $params["serviceid"] . "-cus" . $params['clientsdetails']['userid'];
$vm_settings['full'] = true;
// DEBUG - Log the request parameters before it's fired
logModuleCall(
'pvewhmcs',
__FUNCTION__,
'vm_settings_and_v_1',
['vm_settings' => $vm_settings, 'v' => $v]
);
// KVM TEMPLATE - Conduct the VM CLONE from Template to Machine
$logrequest = '/nodes/' . $first_node . '/qemu/' . $params['customfields']['KVMTemplate'] . '/clone' . $vm_settings;
$response = $proxmox->post('/nodes/' . $first_node . '/qemu/' . $params['customfields']['KVMTemplate'] . '/clone', $vm_settings);
// DEBUG - Log the request parameters before it's fired
if (Capsule::table('mod_pvewhmcs')->where('id', '1')->value('debug_mode') == 1) {
logModuleCall(
'pvewhmcs',
__FUNCTION__,
$logrequest,
json_decode($response)
);
}
if ($response) {
Capsule::table('mod_pvewhmcs_vms')->insert(
[
@@ -105,6 +145,15 @@ function pvewhmcs_CreateAccount($params) {
'created' => date("Y-m-d H:i:s"),
]
);
// ISSUE #32 relates - amend post-clone to ensure excludes-disk amendments are all done, too.
$cloned_tweaks['memory'] = $plan->memory;
$cloned_tweaks['ostype'] = $plan->ostype;
$cloned_tweaks['sockets'] = $plan->cpus;
$cloned_tweaks['cores'] = $plan->cores;
$cloned_tweaks['cpu'] = $plan->cpuemu;
$cloned_tweaks['kvm'] = $plan->kvm;
$cloned_tweaks['onboot'] = $plan->onboot;
$amendment = $proxmox->post('/nodes/' . $first_node . '/qemu/' . $vm_settings['newid'] . '/config'. $cloned_tweaks);
return true;
} else {
if (is_array($response) && isset($response['data']['errors'])) {
@@ -119,7 +168,7 @@ function pvewhmcs_CreateAccount($params) {
} else {
throw new Exception("Proxmox Error: PVE API login failed. Please check your credentials.");
}
// CREATE IF LXC/CONTAINER
// PREPARE SETTINGS FOR QEMU/LXC EVENTUALITIES
} else {
$vm_settings['vmid'] = $params["serviceid"];
if ($plan->vmtype == 'lxc') {
@@ -128,7 +177,11 @@ function pvewhmcs_CreateAccount($params) {
$vm_settings['rootfs'] = $plan->storage . ':' . $plan->disk;
$vm_settings['bwlimit'] = $plan->diskio;
$vm_settings['net0'] = 'name=eth0,bridge=' . $plan->bridge . $plan->vmbr . ',ip=' . $ip->ipaddress . '/' . mask2cidr($ip->mask) . ',gw=' . $ip->gateway;
if(!empty($plan->vlanid)){
$vm_settings['net0'] .= ',trunk=' . $plan->vlanid;
}
$vm_settings['nameserver'] = '1.1.1.1';
$vm_settings['onboot'] = $plan->onboot;
$vm_settings['password'] = $params['customfields']['Password'];
} else {
$vm_settings['ostype'] = $plan->ostype;
@@ -160,6 +213,9 @@ function pvewhmcs_CreateAccount($params) {
if (!empty($plan->netrate)) {
$vm_settings['net0'] .= ',rate=' . $plan->netrate;
}
if (!empty($plan->vlanid)) {
$vm_settings['net0'] .= ',trunk=' . $plan->vlanid;
}
}
/* end of network settings */
}
@@ -168,6 +224,7 @@ function pvewhmcs_CreateAccount($params) {
$vm_settings['cpulimit'] = $plan->cpulimit;
$vm_settings['memory'] = $plan->memory;
// CREATION: Attempt to create the QEMU/LXC instance on Proxmox VE via API
try {
$proxmox = new PVE2_API($serverip, $serverusername, "pam", $serverpassword);
@@ -183,14 +240,18 @@ function pvewhmcs_CreateAccount($params) {
$v = 'lxc';
}
// DEBUG - Log the request parameters before it's fired
logModuleCall(
'pvewhmcs',
__FUNCTION__,
'vm_settings_and_v_2',
['vm_settings' => $vm_settings, 'v' => $v]
);
// ACTION - Fire the attempt to create
$logrequest = '/nodes/' . $first_node . '/' . $v . $vm_settings;
$response = $proxmox->post('/nodes/' . $first_node . '/' . $v, $vm_settings);
// DEBUG - Log the request parameters after it's fired
if (Capsule::table('mod_pvewhmcs')->where('id', '1')->value('debug_mode') == 1) {
logModuleCall(
'pvewhmcs',
__FUNCTION__,
$logrequest,
json_decode($response)
);
}
if ($response) {
unset($vm_settings);
Capsule::table('mod_pvewhmcs_vms')->insert(
@@ -220,85 +281,128 @@ function pvewhmcs_CreateAccount($params) {
}
} catch (PVE2_Exception $e) {
// Record the error in WHMCS's module log.
logModuleCall(
'pvewhmcs',
__FUNCTION__,
$params,
$e->getMessage(),
$e->getTraceAsString()
);
if (Capsule::table('mod_pvewhmcs')->where('id', '1')->value('debug_mode') == 1) {
logModuleCall(
'pvewhmcs',
__FUNCTION__,
$params,
$e->getMessage() . $e->getTraceAsString()
);
}
return $e->getMessage();
}
unset($vm_settings);
}
}
// PVE API FUNCTION, ADMIN: Test Connection with Proxmox node
function pvewhmcs_TestConnection(array $params) {
try {
$success = true; // Assume success by default
try {
// Call the service's connection test function.
$serverip = $params["serverip"];
$serverusername = $params["serverusername"];
$serverpassword = $params["serverpassword"];
$proxmox=new PVE2_API($serverip, $serverusername, "pam", $serverpassword);
if ($proxmox->login())
$success = true;
$errorMsg = '';
} catch (Exception $e) {
// Record the error in WHMCS's module log.
logModuleCall(
'provisioningmodule',
__FUNCTION__,
$params,
$e->getMessage(),
$e->getTraceAsString()
);
$success = false;
$errorMsg = $e->getMessage();
}
return array(
'success' => $success,
'error' => $errorMsg,
);
$serverip = $params["serverip"];
$serverusername = $params["serverusername"];
$serverpassword = $params["serverpassword"];
$proxmox = new PVE2_API($serverip, $serverusername, "pam", $serverpassword);
if (!$proxmox->login()) {
$success = false; // Set success to false if login fails
}
} catch (Exception $e) {
// Record the error in WHMCS's module log, if debug mode is enabled.
if (Capsule::table('mod_pvewhmcs')->where('id', '1')->value('debug_mode') == 1) {
logModuleCall(
'pvewhmcs',
__FUNCTION__,
$params,
$e->getMessage() . $e->getTraceAsString()
);
}
$success = $e->getMessage(); // Set the error message as the success value
}
return array('success' => $success); // Return either true or the error
}
// PVE API FUNCTION, ADMIN: Suspend a Service on the hypervisor
function pvewhmcs_SuspendAccount(array $params) {
$serverip = $params["serverip"]; $serverusername = $params["serverusername"]; $serverpassword = $params["serverpassword"];
$serverip = $params["serverip"];
$serverusername = $params["serverusername"];
$serverpassword = $params["serverpassword"];
$proxmox=new PVE2_API($serverip, $serverusername, "pam", $serverpassword);
if ($proxmox->login()){
if ($proxmox->login()) {
# Get first node name.
$nodes = $proxmox->get_node_list();
$first_node = $nodes[0];
unset($nodes);
// find virtual machine type
$vm=Capsule::table('mod_pvewhmcs_vms')->where('id', '=', $params['serviceid'])->get()[0];
if ($proxmox->post('/nodes/'.$first_node.'/'.$vm->vtype.'/'.$params['serviceid'].'/status/suspend')) {
return true ;
}
$guest=Capsule::table('mod_pvewhmcs_vms')->where('id','=',$params['serviceid'])->get()[0] ;
$pve_cmdparam = array();
$logrequest = '/nodes/' . $first_node . '/' . $guest->vtype . '/' . $params['serviceid'] . '/status/stop';
$response = $proxmox->post('/nodes/' . $first_node . '/' . $guest->vtype . '/' . $params['serviceid'] . '/status/stop' , $pve_cmdparam);
}
// DEBUG - Log the request parameters before it's fired
if (Capsule::table('mod_pvewhmcs')->where('id', '1')->value('debug_mode') == 1) {
logModuleCall(
'pvewhmcs',
__FUNCTION__,
$logrequest,
json_encode($response)
);
}
// Return success only if no errors returned by PVE
if (isset($response) && !isset($response['errors'])) {
return "success";
} else {
// Handle the case where there are errors
$response_message = isset($response['errors']) ? json_encode($response['errors']) : "Unknown Error, consider using Debug Mode.";
return "Error performing action. " . $response_message;
}
return false;
}
// PVE API FUNCTION, ADMIN: Unsuspend a Service on the hypervisor
function pvewhmcs_UnsuspendAccount(array $params) {
$serverip = $params["serverip"]; $serverusername = $params["serverusername"]; $serverpassword = $params["serverpassword"];
$serverip = $params["serverip"];
$serverusername = $params["serverusername"];
$serverpassword = $params["serverpassword"];
$proxmox=new PVE2_API($serverip, $serverusername, "pam", $serverpassword);
if ($proxmox->login()){
if ($proxmox->login()) {
# Get first node name.
$nodes = $proxmox->get_node_list();
$first_node = $nodes[0];
unset($nodes);
// find virtual machine type
$vm=Capsule::table('mod_pvewhmcs_vms')->where('id', '=', $params['serviceid'])->get()[0];
if ($proxmox->post('/nodes/'.$first_node.'/'.$vm->vtype.'/'.$params['serviceid'].'/status/resume')) {
return true ;
}
$guest=Capsule::table('mod_pvewhmcs_vms')->where('id','=',$params['serviceid'])->get()[0] ;
$pve_cmdparam = array();
$logrequest = '/nodes/' . $first_node . '/' . $guest->vtype . '/' . $params['serviceid'] . '/status/start';
$response = $proxmox->post('/nodes/' . $first_node . '/' . $guest->vtype . '/' . $params['serviceid'] . '/status/start');
}
// DEBUG - Log the request parameters before it's fired
if (Capsule::table('mod_pvewhmcs')->where('id', '1')->value('debug_mode') == 1) {
logModuleCall(
'pvewhmcs',
__FUNCTION__,
$logrequest,
json_encode($response)
);
}
// Return success only if no errors returned by PVE
if (isset($response) && !isset($response['errors'])) {
return "success";
} else {
// Handle the case where there are errors
$response_message = isset($response['errors']) ? json_encode($response['errors']) : "Unknown Error, consider using Debug Mode.";
return "Error performing action. " . $response_message;
}
return false;
}
// PVE API FUNCTION, ADMIN: Terminate a Service on the hypervisor
function pvewhmcs_TerminateAccount(array $params) {
$serverip = $params["serverip"]; $serverusername = $params["serverusername"]; $serverpassword = $params["serverpassword"];
$serverip = $params["serverip"];
$serverusername = $params["serverusername"];
$serverpassword = $params["serverpassword"];
$proxmox=new PVE2_API($serverip, $serverusername, "pam", $serverpassword);
if ($proxmox->login()){
# Get first node name.
@@ -306,19 +410,21 @@ function pvewhmcs_TerminateAccount(array $params) {
$first_node = $nodes[0];
unset($nodes);
// find virtual machine type
$vm=Capsule::table('mod_pvewhmcs_vms')->where('id', '=', $params['serviceid'])->get()[0];
$proxmox->post('/nodes/'.$first_node.'/'.$vm->vtype.'/'.$params['serviceid'].'/status/stop') ;
sleep(10) ;
if ($proxmox->delete('/nodes/'.$first_node.'/'.$vm->vtype.'/'.$params['serviceid'],array('skiplock'=>1))) {
$guest=Capsule::table('mod_pvewhmcs_vms')->where('id', '=', $params['serviceid'])->get()[0];
// stop the service before terminating
$proxmox->post('/nodes/'.$first_node.'/'.$guest->vtype.'/'.$params['serviceid'].'/status/stop') ;
sleep(30) ;
if ($proxmox->delete('/nodes/'.$first_node.'/'.$guest->vtype.'/'.$params['serviceid'],array('skiplock'=>1))) {
// delete entry from module table once service terminated in PVE
Capsule::table('mod_pvewhmcs_vms')->where('id', '=', $params['serviceid'])->delete();
return true ;
return "success";
}
}
return false ;
$response_message = json_encode($proxmox['data']['errors']);
return "Error performing action. " . $response_message;
}
// WHMCS Decrypter
// GENERAL CLASS: WHMCS Decrypter
class hash_encryption {
/**
* Hashed value of the user provided encryption key
@@ -508,6 +614,7 @@ class hash_encryption {
}
}
// GENERAL FUNCTION: Server PW from WHMCS DB
function get_server_pass_from_whmcs($enc_pass){
global $cc_encryption_hash;
// Include WHMCS database configuration file
@@ -519,18 +626,32 @@ function get_server_pass_from_whmcs($enc_pass){
return $hasher->decrypt($enc_pass);
}
// MODULE BUTTONS: Admin Interface button regos
function pvewhmcs_AdminCustomButtonArray() {
$buttonarray = array(
"Start" => "vmStart",
"Reboot" => "vmReboot",
"Soft Stop" => "vmShutdown",
"Hard Stop" => "vmStop",
);
return $buttonarray;
}
// MODULE BUTTONS: Client Interface button regos
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-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",
"<img src='./modules/servers/pvewhmcs/img/tigervnc.png'/> TigerVNC (Java)" => "javaVNC",
"<i class='fa fa-2x fa-flag-checkered'></i> Start Machine" => "vmStart",
"<i class='fa fa-2x fa-sync'></i> Reboot Now" => "vmReboot",
"<i class='fa fa-2x fa-power-off'></i> Power Off" => "vmShutdown",
"<i class='fa fa-2x fa-stop'></i> Hard Stop" => "vmStop",
"<i class='fa fa-2x fa-chart-bar'></i> Statistics" => "vmStat",
);
return $buttonarray;
}
// OUTPUT: Module output to the Client Area
function pvewhmcs_ClientArea($params) {
// Retrieve virtual machine info from table mod_pvewhmcs_vms
$guest=Capsule::table('mod_pvewhmcs_vms')->where('id','=',$params['serviceid'])->get()[0] ;
@@ -560,6 +681,18 @@ function pvewhmcs_ClientArea($params) {
$cluster_resources = $proxmox->get('/cluster/resources');
$vm_status = null;
// DEBUG - Log the /cluster/resources and /config for the VM/CT, if enabled
$cluster_encoded = json_encode($cluster_resources);
$vmspecs_encoded = json_encode($vm_config);
if (Capsule::table('mod_pvewhmcs')->where('id', '1')->value('debug_mode') == 1) {
logModuleCall(
'pvewhmcs',
__FUNCTION__,
'CLUSTER INFO: ' . $cluster_encoded,
'GUEST CONFIG (Service #' . $params['serviceid'] . ' / Client #' . $params['clientsdetails']['userid'] . '): ' . $vmspecs_encoded
);
}
# Loop through data, find ID
foreach ($cluster_resources as $vm) {
if ($vm['vmid'] == $params['serviceid'] && $vm['type'] == $guest->vtype) {
@@ -706,17 +839,23 @@ function pvewhmcs_ClientArea($params) {
);
}
// OUTPUT: VM Statistics/Graphs render to Client Area
function pvewhmcs_vmStat($params) {
return true ;
return true;
}
// VNC: Console access to VM/CT via noVNC
function pvewhmcs_noVNC($params) {
// Check if VNC Secret is configured in Module Config, fail early if not. (#27)
if (strlen(Capsule::table('mod_pvewhmcs')->where('id', '1')->value('vnc_secret'))<15) {
throw new Exception("PVEWHMCS Error: VNC Secret in Module Config either not set or not long enough. Recommend 20+ characters for security.");
}
// Get login credentials then make the Proxmox connection attempt.
$serverip = $params["serverip"];
$serverusername = $params["serverusername"];
$serverpassword = $params["serverpassword"];
$proxmox=new PVE2_API($serverip, $serverusername, "pam", $serverpassword);
$serverusername = 'vnc';
$serverpassword = Capsule::table('mod_pvewhmcs')->where('id', '1')->value('vnc_secret');
$proxmox=new PVE2_API($serverip, $serverusername, "pve", $serverpassword);
if ($proxmox->login()) {
//$proxmox->setCookie() ;
# Get first node name.
$nodes = $proxmox->get_node_list();
$first_node = $nodes[0];
@@ -724,23 +863,69 @@ function pvewhmcs_noVNC($params) {
$guest=Capsule::table('mod_pvewhmcs_vms')->where('id','=',$params['serviceid'])->get()[0] ;
$vm_vncproxy=$proxmox->post('/nodes/'.$first_node.'/'.$guest->vtype.'/'.$params['serviceid'] .'/vncproxy', array( 'websocket' => '1' )) ;
$path = 'api2/json/websocket?port=' . $vm_vncproxy['port'] . '&user=' . $serverusername . '@pam' . '&vmid=' . $params['serviceid'] . '&vncticket=' . urlencode($vm_vncproxy['ticket']);
$url='./modules/servers/pvewhmcs/novnc/novnc_pve.php?host='.$serverip.'&port=8006&ticket='.$vm_vncproxy['ticket'].'&path='.urlencode($path) ;
echo '<script>window.open("'.$url.'")</script>';
//echo '<script>window.open("./modules/servers/pvewhmcs/noVNC/vnc.php?node=pve&console=lxc&vmid=136&port='.$vm_vncwebsocket['port'].'&ticket='.$vm_vncproxy['ticket'].'")</script>';
// Get both tickets prepared
$pveticket = $proxmox->getTicket();
$vncticket = $vm_vncproxy['ticket'];
// $path should only contain the actual path without any query parameters
$path = 'api2/json/nodes/' . $first_node . '/' . $guest->vtype . '/' . $params['serviceid'] . '/vncwebsocket?port=' . $vm_vncproxy['port'] . '&vncticket=' . urlencode($vncticket);
// Construct the noVNC Router URL with the path already prepared now
$url = '/modules/servers/pvewhmcs/novnc_router.php?host=' . $serverip . '&pveticket=' . urlencode($pveticket) . '&path=' . urlencode($path) . '&vncticket=' . urlencode($vncticket);
// Build and deliver the noVNC Router hyperlink for access
$vncreply='<center><strong>Console (noVNC) prepared for usage. <a href="'.$url.'" target="_blanK">Click here</a> to open the noVNC window.</strong></center>' ;
return $vncreply;
} else {
$vncreply='Failed to prepare noVNC. Please contact Technical Support.';
return $vncreply;
}
}
function pvewhmcs_javaVNC($params){
// VNC: Console access to VM/CT via SPICE
function pvewhmcs_SPICE($params) {
// Check if VNC Secret is configured in Module Config, fail early if not. (#27)
if (strlen(Capsule::table('mod_pvewhmcs')->where('id', '1')->value('vnc_secret'))<15) {
throw new Exception("PVEWHMCS Error: VNC Secret in Module Config either not set or not long enough. Recommend 20+ characters for security.");
}
// Get login credentials then make the Proxmox connection attempt.
$serverip = $params["serverip"];
$serverusername = $params["serverusername"];
$serverpassword = $params["serverpassword"];
$proxmox=new PVE2_API($serverip, $serverusername, "pam", $serverpassword);
$serverusername = 'vnc';
$serverpassword = Capsule::table('mod_pvewhmcs')->where('id', '1')->value('vnc_secret');
$proxmox=new PVE2_API($serverip, $serverusername, "pve", $serverpassword);
if ($proxmox->login()) {
# 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] ;
$vm_vncproxy=$proxmox->post('/nodes/'.$first_node.'/'.$guest->vtype.'/'.$params['serviceid'] .'/vncproxy', array( 'websocket' => '1' )) ;
// Get both tickets prepared
$pveticket = $proxmox->getTicket();
$vncticket = $vm_vncproxy['ticket'];
// $path should only contain the actual path without any query parameters
$path = 'api2/json/nodes/' . $first_node . '/' . $guest->vtype . '/' . $params['serviceid'] . '/vncwebsocket?port=' . $vm_vncproxy['port'] . '&vncticket=' . urlencode($vncticket);
// Construct the SPICE Router URL with the path already prepared now
$url = '/modules/servers/pvewhmcs/spice_router.php?host=' . $serverip . '&pveticket=' . urlencode($pveticket) . '&path=' . urlencode($path) . '&vncticket=' . urlencode($vncticket);
// Build and deliver the SPICE Router hyperlink for access
$vncreply='<center><strong>Console (SPICE) prepared for usage. <a href="'.$url.'" target="_blanK">Click here</a> to open the noVNC window.</strong></center>' ;
return $vncreply;
} else {
$vncreply='Failed to prepare SPICE. Please contact Technical Support.';
return $vncreply;
}
}
// VNC: Console access to VM/CT via TigerVNC
function pvewhmcs_javaVNC($params){
// Check if VNC Secret is configured in Module Config, fail early if not. (#27)
if (strlen(Capsule::table('mod_pvewhmcs')->where('id', '1')->value('vnc_secret'))<15) {
throw new Exception("PVEWHMCS Error: VNC Secret in Module Config either not set or not long enough. Recommend 20+ characters for security.");
}
// Get login credentials then make the Proxmox connection attempt.
$serverip = $params["serverip"];
$serverusername = 'vnc';
$serverpassword = Capsule::table('mod_pvewhmcs')->where('id', '1')->value('vnc_secret');
$proxmox=new PVE2_API($serverip, $serverusername, "pve", $serverpassword);
if ($proxmox->login()) {
//$proxmox->setCookie();
# Get first node name.
$nodes = $proxmox->get_node_list();
$first_node = $nodes[0];
@@ -748,7 +933,8 @@ function pvewhmcs_javaVNC($params){
$guest=Capsule::table('mod_pvewhmcs_vms')->where('id','=',$params['serviceid'])->get()[0] ;
$vm_vncproxy=$proxmox->post('/nodes/'.$first_node.'/'.$guest->vtype.'/'.$params['serviceid'] .'/vncproxy') ;
$vncparams = array();
$vm_vncproxy=$proxmox->post('/nodes/'.$first_node.'/'.$guest->vtype.'/'.$params['serviceid'] .'/vncproxy', $vncparams) ;
$javaVNCparams=array() ;
$javaVNCparams[0]=$serverip ;
@@ -757,12 +943,17 @@ function pvewhmcs_javaVNC($params){
$javaVNCparams[3]=$vm_vncproxy['user'] ;
$javaVNCparams[4]=$vm_vncproxy['ticket'] ;
echo '<script>window.open("modules/servers/pvewhmcs/tigervnc.php?'.http_build_query($javaVNCparams).'","VNC","location=0,toolbar=0,menubar=0,scrollbars=1,resizable=1,width=802,height=624")</script>';
return true ;
$url='./modules/servers/pvewhmcs/tigervnc.php?'.http_build_query($javaVNCparams).'' ;
$vncreply='<center><strong>Console (TigerVNC) prepared for usage. <a href="'.$url.'" target="_blanK">Click here</a> to open the TigerVNC window.</strong></center>' ;
// echo '<script>window.open("modules/servers/pvewhmcs/tigervnc.php?'.http_build_query($javaVNCparams).'","VNC","location=0,toolbar=0,menubar=0,scrollbars=1,resizable=1,width=802,height=624")</script>';
return $vncreply;
} else {
$vncreply='Failed to prepare TigerVNC. Please contact Technical Support.';
return $vncreply;
}
return false;
}
// PVE API FUNCTION, CLIENT/ADMIN: Start the VM/CT
function pvewhmcs_vmStart($params) {
// Gather access credentials for PVE, as these are no longer passed for Client Area
$pveservice=Capsule::table('tblhosting')->find($params['serviceid']) ;
@@ -777,21 +968,79 @@ function pvewhmcs_vmStart($params) {
$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' , $pve_cmdparam))
return true ;
$logrequest = '/nodes/' . $first_node . '/' . $guest->vtype . '/' . $params['serviceid'] . '/status/start';
$response = $proxmox->post('/nodes/' . $first_node . '/' . $guest->vtype . '/' . $params['serviceid'] . '/status/start' , $pve_cmdparam);
}
// DEBUG - Log the request parameters before it's fired
if (Capsule::table('mod_pvewhmcs')->where('id', '1')->value('debug_mode') == 1) {
logModuleCall(
'pvewhmcs',
__FUNCTION__,
$logrequest,
json_encode($response)
);
}
// Return success only if no errors returned by PVE
if (isset($response) && !isset($response['errors'])) {
return "success";
} else {
// Handle the case where there are errors
$response_message = isset($response['errors']) ? json_encode($response['errors']) : "Unknown Error, consider using Debug Mode.";
return "Error performing action. " . $response_message;
}
return false;
}
// PVE API FUNCTION, CLIENT/ADMIN: Reboot the VM/CT
function pvewhmcs_vmReboot($params) {
// 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()) {
# 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';
$logrequest = '/nodes/' . $first_node . '/' . $guest->vtype . '/' . $params['serviceid'] . '/status/reboot';
$response = $proxmox->post('/nodes/' . $first_node . '/' . $guest->vtype . '/' . $params['serviceid'] . '/status/reboot' , $pve_cmdparam);
}
// DEBUG - Log the request parameters before it's fired
if (Capsule::table('mod_pvewhmcs')->where('id', '1')->value('debug_mode') == 1) {
logModuleCall(
'pvewhmcs',
__FUNCTION__,
$logrequest,
json_encode($response)
);
}
// Return success only if no errors returned by PVE
if (isset($response) && !isset($response['errors'])) {
return "success";
} else {
// Handle the case where there are errors
$response_message = isset($response['errors']) ? json_encode($response['errors']) : "Unknown Error, consider using Debug Mode.";
return "Error performing action. " . $response_message;
}
}
// PVE API FUNCTION, CLIENT/ADMIN: Shutdown the VM/CT
function pvewhmcs_vmShutdown($params) {
// Gather access credentials for PVE, as these are no longer passed for Client Area
$pveservice=Capsule::table('tblhosting')->find($params['serviceid']) ;
@@ -806,21 +1055,36 @@ function pvewhmcs_vmShutdown($params) {
$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' , $pve_cmdparam))
return true ;
// $pve_cmdparam['timeout'] = '60';
$logrequest = '/nodes/' . $first_node . '/' . $guest->vtype . '/' . $params['serviceid'] . '/status/shutdown';
$response = $proxmox->post('/nodes/' . $first_node . '/' . $guest->vtype . '/' . $params['serviceid'] . '/status/shutdown' , $pve_cmdparam);
}
// DEBUG - Log the request parameters before it's fired
if (Capsule::table('mod_pvewhmcs')->where('id', '1')->value('debug_mode') == 1) {
logModuleCall(
'pvewhmcs',
__FUNCTION__,
$logrequest,
json_encode($response)
);
}
// Return success only if no errors returned by PVE
if (isset($response) && !isset($response['errors'])) {
return "success";
} else {
// Handle the case where there are errors
$response_message = isset($response['errors']) ? json_encode($response['errors']) : "Unknown Error, consider using Debug Mode.";
return "Error performing action. " . $response_message;
}
return false;
}
// PVE API FUNCTION, CLIENT/ADMIN: Stop the VM/CT
function pvewhmcs_vmStop($params) {
// Gather access credentials for PVE, as these are no longer passed for Client Area
$pveservice=Capsule::table('tblhosting')->find($params['serviceid']) ;
@@ -835,22 +1099,36 @@ function pvewhmcs_vmStop($params) {
$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/stop' , $pve_cmdparam))
return true ;
// $pve_cmdparam['timeout'] = '60';
$logrequest = '/nodes/' . $first_node . '/' . $guest->vtype . '/' . $params['serviceid'] . '/status/stop';
$response = $proxmox->post('/nodes/' . $first_node . '/' . $guest->vtype . '/' . $params['serviceid'] . '/status/stop' , $pve_cmdparam);
}
// DEBUG - Log the request parameters before it's fired
if (Capsule::table('mod_pvewhmcs')->where('id', '1')->value('debug_mode') == 1) {
logModuleCall(
'pvewhmcs',
__FUNCTION__,
$logrequest,
json_encode($response)
);
}
// Return success only if no errors returned by PVE
if (isset($response) && !isset($response['errors'])) {
return "success";
} else {
// Handle the case where there are errors
$response_message = isset($response['errors']) ? json_encode($response['errors']) : "Unknown Error, consider using Debug Mode.";
return "Error performing action. " . $response_message;
}
return false;
}
// convert subnet mask to CIDR
// NETWORKING FUNCTION: Convert subnet mask to CIDR
function mask2cidr($mask){
$long = ip2long($mask);
$base = ip2long('255.255.255.255');

View File

@@ -1,3 +1,25 @@
/*
Proxmox VE for WHMCS - Addon/Server Modules for WHMCS (& PVE)
https://github.com/The-Network-Crew/Proxmox-VE-for-WHMCS/
File: /modules/servers/pvewhmcs/tigervnc.php (VNC)
Copyright (C) The Network Crew Pty Ltd (TNC) & Co.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses
*/
<html>
<head>
<title>Serial Console</title>

1
version Normal file
View File

@@ -0,0 +1 @@
1.2.3

BIN
zLOGO.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB