Here’s a simple example to connect to a hypervisor
[cc lang=”perl”]
#!/usr/bin/perl
use Data::Dumper;
require VMware::VIRuntime;
VMware::VIRuntime->import();
use strict;
# try logging into a node:
my $conn;
my $hyp = shift || ‘vhost31′;
print “performing action on $hyp\n”;
eval {
$conn = Vim->new(service_url=>”https://$hyp/sdk”);
$conn->login(user_name=>’root’,password=>’cluster’);
};
[/cc]
Now you probably want to do something since you’re connected. The best way is to go over and read the VMware API documentation. The Reference Guide seems to be the best. You have to do a lot of guessing since it isn’t necessarily written for any language. Hopefully I’ll be able to post more on using this later. If you want to huge example, you can look at the ESX plugin in the xCAT source tree. We do pretty much everything you could think of with it. Since its open source, you can use it however you want.
Comments are closed.