Jump to content
timgws

Virtuozzo Module (that works) finally!

Recommended Posts

Hey Guys!

 

I am releasing to you all today on behalf of Digital Pacific (http://www.digitalpacific.com.au) a Virtuozzo module for WHMCS.

 

Finally you will be able to provision containers, change passwords etc.

 

Now; the code is a little bit rough around the edges, so there are a few things that might not always work 100%, but for the most part it should be OK.

 

The code is not Zend'd or IonCube'd, so you will be able to see all of the source code. A proper module for WHMCS is something that we have all wanted for a long time, so if there is anything that can be improved upon, please send your patch to me tim <at> digitalpacific. com.au and I will include it, and throw your name in the author's list.

 

Requirements:

  • JSON Module
  • SimpleXML

 

I have only tested this on WHMCS 4.1.1 and 4.1.2.

 

Download Link:

http://opensource.digitalpacific.com.au/ (click on "download" under "libvz")

 

Install Guide:

  1. Copy the contents of the "module" folder into the "module" folder where your WHMCS installation is.
  2. Run the Create Table statements that are in sql-queries.sql on your MySQL database where WHMCS is installed in.
  3. Utilities->Addon Modules->Virtuozzo and add all the names for the VZ servers that you have. This will allow all the VZ sample configs and OS's to be cached.
  4. In Setup->Products/Services, edit the product that is your VZ product.
  5. Module Settings -> Module Name=Virtuozzo, Package Name=<Sample Config Name as in VZ>
  6. Custom Fields -> Field Name=Environment ID, Field Type=Textbox, Select Options=Admin Only
  7. In Setup->Servers, edit/add your VZ server. Make sure that the hostname is correct (!) and the same as what you entered in the admin module for Virtuozzo.
  8. Server Details->Type=Virtuozzo, Username=root, Password=<shell password>

 

That should work. It did for me :)

Share this post


Link to post
Share on other sites

Hi,

It need more detailed documentation .

I've tried it and didn't create a vps with success .

I get an error that it couldn't find the os template ( I used the same values as on your site , I even bypass the custom fields and entered directly in the file the name of the template ).

 

I think it needs more testing on new whmcs installations .

Share this post


Link to post
Share on other sites

Hi all,

 

Sorry for the lack of explanation on my last post. I will attempt to explain things a bit better :)

 

Step One: Copy the contents of the "module" folder into the "module" folder where your WHMCS installation is.

 

Step Two: Run the Create Table statements that are in sql-queries.sql on your MySQL database where WHMCS is installed in.

 

Step Three: Utilities->Addon Modules->Virtuozzo and add all the names for the VZ servers that you have. This will allow all the VZ sample configs and OS's to be cached.

 

Step Four: In Setup->Products/Services, edit the product that is your VZ product.

s05.png

s06.png

 

Please note: the package name should be *exactly* the same as what is shown in the Virtuozzo control panel (under Container Samples). The Environment ID *must* exist as a Custom Field.

 

Step Five:

Edit the Virtuozzo Server, ensure that the module type is Virtuozzo, and the user name and password is the root password for the box.

s02.png

 

Step Six:

Ensure that there is a configurable option, with the option name "Operating System"

s04.png

 

Spaces in the name will be replaced with "-", [32 bit] will be replaced with -x86, [64 bit] will be replaced with -x86_64 (which is what they are called by VZ). Finally, everything will be turned lower case, and a dot put in front of the name, which is how EZ templates are named by the API. If something other then a EZ template is wanted, then something will need to be worked out to allow this to work.

 

This means that the display name in the option Ubuntu 8.04 [32 bit] will be transformed into .ubuntu-8.04-x86

 

If you have any other issues/questions, please reply to this post :)

Edited by timgws
Clarifying how the display name works

Share this post


Link to post
Share on other sites

New Version!

A new version has been released, 0.11. It fixes the following issues:

  • No Error was returned when the wrong user name and/or password was entered into the server configuration.
  • No more hard coded IP; you can now set an IP pool for VZ to use, and containers will automatically be assigned one IP in that pool.

Share this post


Link to post
Share on other sites

Hello,

 

I've added:

error_reporting(E_ALL ^ E_NOTICE);

ini_set("display_errors", 1);

To display any errors and when I create I get:

Fatal error: Uncaught exception 'VirtuozzoError' with message 'Could not find a configured Virtuozzo server to connect to.' in ....... lib_vz_api.php:57

mysql> SELECT * FROM `mod_vz_servers` LIMIT 0 , 30;

| 1 | vps1.domain.com | | | 0 | | |

 

mysql> SELECT * FROM `tblservers` WHERE `hostname` LIKE 'vps1.domain.com' LIMIT 0 , 30 ;

| 9 | vps1.domain.com | x.x.x.x | vps1.domain.com | 0.00 | | | | | | | | | | | 200 | virtuozzo | root | xx | | | 1 |

 

Then if I replace in lib_vz_api.php line 49 `servername`='vps1.domain.com' it works till:

 

I get: Error: Could not authenticate with server.

If in virtuozzo.php line 99 I replace (!$vz->Login($params['serverusername'], $params['serverpassword'])) with the actual user and password it works till:

 

I get: The configuration sample was not found on the server.Please check either the server login details, or check that the config name is exact.Also, check that the configuration name exists for the requested architecture.

 

The Operating System is Centos 5 [64bit]

On VZ i have centos-5-x86_64

Double checked the Package name and it's the same.

 

PS. the server name IP and password were changed in the mysql queries displayed here.

Share this post


Link to post
Share on other sites

ok , managed to create a vps with success , but with other modifications after those from above:

Added in the mod_vz_servers table in column arch: x86_64 because it was empty .

Changed in liv_vz_api.php line 292 the base_sample_id with the id I took from the table mod_vz_cache for that Product Name.

Share this post


Link to post
Share on other sites

Hi djaxel,

 

Thanks for submitting your reports on issues. I am going to have a look and see how it all works out for me if I try and replicate the issue. I thought I removed all the architecture-dependent code. Obviously not.

 

Also, from your original mod_vz_cache, what do your os_templates look like? For example, on mine it looks like this:

".debian-4.0-x86":"x86"

(Notice the dot in front? Do you have this too?)

 

The Operating System is Centos 5 [64bit], but there is no space between "64" and "bit"... I am going to work on the regex in a few days to make it a tad less restrictive, but you need that space. Otherwise it will look for centos-5-[64bit]-x86_64

 

If $vz->Login is not working, then you really need to check your server config, it *should* work :/

 

Thanks,

Tim

Share this post


Link to post
Share on other sites

Hi,

In mod_vz_cache I have:

{".centos-5-x86_64":"x86_64",".fedora-core-10-x86_64":"x86_64",".ubuntu-9.04-x86_64":"x86_64",".debian-5.0-x86_64":"x86_64","redhat-as3-minimal-x86_64":"x86_64"}

 

I used Centos 5 [64bit] because I think this is what I saw on your site , it doesn't matter for me if it has or not a space.

 

Believe me , I've triple checked the server config , I know it should work but it doesn't connect till I modify the file itself .

Share this post


Link to post
Share on other sites

I used Centos 5 [64bit] because I think this is what I saw on your site , it doesn't matter for me if it has or not a space.

 

On our site, we have Centos 5 [64 bit]. It might not matter to you if there is a space between the number and the bit, but it does matter to the code. It will not work without a space at the moment.

 

If you have .centos-5-x86_64 in your cache, you need to have CentOS 5 [64 bit] (or similar within the guidelines) as the name in your product selection.

 

Unfortunately, there is no way to specify values for the names in your Configurable Options. What I mean by this is that you can set the display name, but not the name that is sent to the module - that is the same as the display name. Unfortunately this means that hacks need to be done in the code to get names that VZ will understand.

 

Strange that it does not work for you though when you put it in the server config... it should work. Are you sure that there are no spaces etc in the password or username?

 

Thanks,

Tim

Share this post


Link to post
Share on other sites

Ok , found the problem.

I've removed everything and reinstalled the module.

The problem were that my vps package was a Dedicated/VPS Server type , so it didn't took the VZ server , I changed to Hosting type and it works.

But I did had to add manually to mod_vz_servers in column arch: x86_64

Now I get Configuration error: can't get specified '282c7d76-8e15-a54..........

The line 292 from lib_vz_api.php needs to use the right base_sample_id from mod_vz_cache , at this point I see that is hard coded , not using the database.

Share this post


Link to post
Share on other sites

Unfortunately, there is no way to specify values for the names in your Configurable Options. What I mean by this is that you can set the display name, but not the name that is sent to the module - that is the same as the display name. Unfortunately this means that hacks need to be done in the code to get names that VZ will understand.

 

I use Configurable Option Groups for other products with values like this:

value_to_pass_to_module|value_to_be_displayed

And it work fine , so it should work and for this module.

Did you try it?

Share this post


Link to post
Share on other sites

I've used the value from table cache and json_decode it , it works ok , but I'm sure you can do a better job an interogate the database to decode the value.

 

Create , change password and terminate functions work fine.

The suspend function stops the vps instead of suspending it.

The unsuspend function doesn't start/resume the vps ( but I'm receiving a success message in whmcs ).

 

If you can please try to change the module that would create a vps with more than 1 IP adress ( you can use the ConfigOptions , like you used for the Package Name).

 

Thanks .

I appreciate the work you did with this module.

Share this post


Link to post
Share on other sites

Hey djaxel!

 

Thank you very much about the hint with Configurable Option Groups with using the pipe. I did not know about that...

 

The only issue I have with providing more then one IP at a time is how do we email the customer about the IP?

Share this post


Link to post
Share on other sites

Hi,

I think the only solution is to use {$service_custom_fields.1} .

We can make 5 ( or even more from case to case) custom fiels and asigne with the vallue when the vps is created.

In the email we can use {$service_custom_fields.1}, etc to inform the client.

Share this post


Link to post
Share on other sites

and djaxel, the reason that the suspend button also stops the container was because of a decision from our staff members. See, the suspend button is not to suspend the container - you do that from within PIM. The reason is so you can suspend access to the VPS.

 

When you hit this button, it stops users from being able to log into the offline management. Although you can disable the VPS and keep it running, when you unsuspend the account this way, you are going to have to shut it down anyway.

 

Thanks,

Tim

Share this post


Link to post
Share on other sites

Hi,

Ok , I understand , but , I suspended a VPS , it stoped with success.

But then I hit the unsuspend button , I received a Module "Command Success Service Unsuspended Successfully" message in whmcs but the vps is still down ( offline ).

Share this post


Link to post
Share on other sites

Hi djaxel.

 

I am looking into the issue now, and will release a new version when it is fixed. Thank you :)

 

PS: Is anyone else actually using this mod? It seems like when a mod is not free, that there is always a lot more comments on it :/ It would be nice to hear feedback from more then one person. :]

Edited by timgws
Adding a plea for comments.

Share this post


Link to post
Share on other sites

djaxel, on line 456 of lib_vz_api.php. Could you please change:

$disabled = (bool)$mesg[0];

 

To:

$disabled = !(bool)$mesg[0];

 

and tell me how you go? I think it might actually be that simple :)

Share this post


Link to post
Share on other sites

Hi,

It's already: $disabled = !(bool)$mesg[0];

I'm using the latest version you posted on this topic. 0.11

Share this post


Link to post
Share on other sites

I've tried the other way

from:

$disabled = !(bool)$mesg[0];  

to:

$disabled = (bool)$mesg[0];  

 

and works fine now.

I don't know if it's correct and it doesn't affect other functions so please check.

Edited by djaxel

Share this post


Link to post
Share on other sites
I've tried the other way [snip] and works fine now.

 

Sorry, that was the way that I meant. I will release a new version in a few hours.

 

:]

Share this post


Link to post
Share on other sites

Thanks for the module but I'm having troubles suspending a VPS. It does return "Service Suspended Successfully" but when I login to PIM, I can see that it's still running.

 

Please advise.

Share this post


Link to post
Share on other sites

Hey Benoit,

 

Is there a Environment ID for the service you are trying to suspend? If there is not, it is not going to work.

 

Also, what version are you running?

 

Thanks,

Tim

Share this post


Link to post
Share on other sites

Yes there is. The Environment ID is the Container ID, right? We are running version 0.11 & virtuozzo 4.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

By using this site, you agree to our Terms of Use & Guidelines