From: Stefan S. <sts...@on...> - 2007-05-22 09:25:55
|
Hello Folks! I'm new to the ViPerlToolkit. Yesterday, I made my first hands on experience with a small script that should be able to start, stop and clone a VM on our ESX server. Everything worked fine until I started to create my CloneVm method, that makes use of the CloneVM_Task method of the VirtualMachine MOB. Additionally I didn't want to pass the username, password and webservice variables via commandline, so I replaced Util::connect with Vim::login -- now I cannot access the Util::trace function and when I run my CloneVm method I get the following error: "Can't call method "serialize" on unblessed reference at C:/Perl/site/lib/VMware/VIM2Stub.pm line 366." Would somebody please be as kind as to review the punch of code below and tell me of any mistakes I made? -- use VMware::VIM2Runtime; use VMware::VILib; Vim::login (service_url => $webservice, user_name => $username, password => $password ); my $vm = Vim::find_entity_view (view_type => "VirtualMachine", filter => { "name" => $vm_name }); &CloneVm; sub CloneVm { my ($vm) = @_; my $relocatespec = eval { VirtualMachineRelocateSpec->new (datastore => $vm->datastore, host => $vm->summary->runtime->host, pool => $vm->resourcePool) } or Util::trace (0,"ARGH"); my $clonespec = eval { VirtualMachineCloneSpec->new (powerOn => 0, template => 0, location => $relocatespec) } or Util::trace (0,"GRML"); $vm->CloneVM( folder => $vm->parent, name => Opts::get_option("vmname_dest"), spec => $clonespec ); } Vim::logout; -- Regards, Stefan. -- Stefan Schlesinger //////////////////////////////////////////// /////// |