Jump to content

vmware module - seeking higher power :)


A320guy

Recommended Posts

Hello there.

 

I thought it would be really great to have a vmware module.

 

I downloaded the vmware sdk for perl and got to work.

 

I successfully suspended a virtual machine using the following perl script from a remote computer.

 

./vmware-vsphere-cli-distrib/apps/vm/vmcontrol.pl --username root --password mypass --operation poweroff --vmname TestServer --url https://192.168.1.44:443/sdk/webService

 

It works terrifically!

 

Now my problem is trying to integrate it into whmcs. I downloaded the module development kit from whmcs and proceed to create my own server module for vmware.

 

I immeadiately skipped to the suspend account function and put my code in but it just doesn't work inside this moduel, always returns the "Error message goes here" result.

 

Now, obviously, this code will need to be chopped up a bit for variables as you don't want to hard code the ip, username, password, and server name but I thought for a quick trial I would include it all.

 

Please, anyone who can help please do. Here is the function as I have it written.

 

function vmware_SuspendAccount($params) {

       # Code to perform action goes here...
echo exec('./vmware-vsphere-cli-distrib/apps/vm/vmcontrol.pl --username root --password serverdude1 --operation poweroff --vmname Garland_PC --url https://192.168.1.44:443/sdk/webService');

   if ($successful) {
               $result = "success";
       } else {
               $result = "Error message goes here...";
       }
       return $result;
}

 

Since all the other modules are encrypted, I have nothing to go by.

Link to comment
Share on other sites

  • 2 weeks later...

Any word or progress on this? I am currently in the process of moving our environment to vSphere and using vCenter server for management.

 

I was looking at just writing my own module and using the Web Services API SDK that VMware has published for java and/or perl. If someone has already done this and I am just overlooking it, that would be great to know before I dive in...:roll:

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

i'm probly way tooo late to answer the first qwestion but i mite as well in case some one else is looking for that answer.

 

at the moment you are runing thecommand (if it works) but not returning an answer to the script i've been working on afew scripts of my own and found that if you dont return an answer the script assumes it failed.

 

try this ...... you need to add some thing to make "$successful" ture like this

function vmware_SuspendAccount($params) {

       # Code to perform action goes here...
echo exec('./vmware-vsphere-cli-distrib/apps/vm/vmcontrol.pl --username root --password serverdude1 --operation poweroff --vmname Garland_PC --url https://192.168.1.44:443/sdk/webService');
   $successful = "ture"; // you need to add your own checking system to check if the comand worked or not


   if ($successful) {
               $result = "success";
       } else {
               $result = "Error message goes here...";
       }
       return $result;
}

 

 

any one feel free to corect me if i'm wrong

Tom

Link to comment
Share on other sites

  • 3 weeks later...

I have a pretty good start at a module, waiting on word from the WHMCS developers for a couple things, but I have the basis of the module, features are as follows:

 

- Show basic usage information

- Show current vm power status

- Provide power control functions (client and admin)

- Provisioning vm's

- Suspend server during service suspension

 

I will keep you posted as I finish the development.

Link to comment
Share on other sites

at the moment you are runing thecommand (if it works) but not returning an answer to the script i've been working on afew scripts of my own and found that if you dont return an answer the script assumes it failed.

Only a return result of "success" means it worked - all other returns are treated as an error state/message

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated