
- Image by simonov via Flickr
PHP I have heard described as “the working man’s programming language”, or shall we say the working persons language. On the web in particular PHP has become the dominant language, Rasmus Lerdorf’s little collection of hacks is now powering websites all over the place, including this one. However, in the enterprise other languages such as Perl have maintained a stonger presence. In the virtualisation space, VMware has for a long time had a Perl toolkit. This, perhaps, has meant that internal projects have been harder to get started. But this is changing, in this post we’ll look at using PHP with both VMware and Zeus ZXTM.
PHP, is one of the easiest ways of creating a dynamic web page. You can create something quite clever and useful with relatively little effort.
For example, we can talk to a Zeus ZXTM load balancer and identify all the running virtual servers, using only a few lines of PHP:
<?
$conn = new SoapClient( "VirtualServer.wsdl",
array( 'login' => "username",
'password' => "password" ));
$names = $conn->getVirtualServerNames();
$enabled = $conn->getEnabled( $names );
for ($i=0; $i < count( $names ); $i++) {
if ( $enabled[$i] )
print "$names[$i]\n";
}
?>
In PHP we can also connect to a VMware VirtualCenter server and gather information:
< ?phprequire_once("lib/nusoap.php">; $myconnection = new soapclient(”https://myVCserverIP/sdk”); $namespace="urn:vim2"; $soapmsg[data]=new soapval('_this','ServiceInstance','ServiceInstance'); $result=$myconnection->call("RetreiveServiceContent",$soapmsg,$namespace); print_r($result);?>
Expanding this code further you should be able to learn more about the virtual infrastructure that provides your web servers and monitor the ZXTM server that balances the load between the web servers. This could allow you to build a very simple “control panel” of your infrastructure. This control panel might be useful for providing information to management for example.
A good example like this might be the catalyst to allow you to implement a larger project, perhaps using something like Perl or the ZXTM’s very similar TrafficScript language. Using TrafficScript for example you can already control VMware with the VMPoolControl Java Extension where a simple bit of code like this:
$slm = slm.conforming(); if ( $slm < 80 ) {java.run("com.zeus.vmware.VMPoolControl", "poweron", "webservice"); }
could easily provision VMware virtual machines to match load.
References:
http://www.run-virtual.com/?page_id=125
http://knowledgehub.zeus.com/code/2005/10/20/list_running_virtual_servers_using_php5
http://knowledgehub.zeus.com/articles/2008/08/29/vmware_vi_and_dynamic_provisioning_with
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=d04a9ca1-2442-473f-956a-7fb9f7b91643)

Related Articles
No user responded in this post
Leave A Reply