On Wed, Mar 26, 2014 at 06:43:47PM -0700, Jim Gibson wrote:
> 
> On Mar 26, 2014, at 6:30 PM, Benjamin Fernandis <benjo11...@gmail.com> wrote:
> 
> > Hi,
> > 
> > I am new with perl and we have virtual machines in our infra. i want to use 
> > perl sys::virt module to manage them, means to shutdown / start vm by 
> > script and for that i wrote below small code.
> > 
> > #!/usr/bin/perl
> > #
> > use strict;
> > use warnings;
> > 
> > use Sys::Virt;
> > 
> > 
> > my $vmm = Sys::Virt->new(uri => "qemu:///system");
> > 
> > my @domains = $vmm->list_domains();
> > 
> > foreach my $dom (@domains) {
> >         print "Domain ", $dom->get_id, " ", $dom->get_name, "\n";
> >       }
> > my $vm = 'win7';
> > 
> > $vm = $vmm->destroy();
> > 
> > 
> > and when i run it , i got below error.
> > 
> > Domain 10 win7
> > Can't locate object method "destroy" via package "Sys::Virt" at vm.pl line 
> > 18.
This error message means what it says ;-) 
A Perl module is a definition of a class; when you declared $vmm initially you
instantiated an object of the class Sys::Virt.
The class Sys::Virt does not have a method declared in it called destroy.  
Therefore your object cannot have a method called destroy.
You can use the command 'perldoc Sys::Virt' to look at the documentation for
this class or look at it on line via
http://search.cpan.org/~danberr/Sys-Virt-1.2.2/lib/Sys/Virt.pm


What are you expecting the destroy method to do?

Kind regards

Lesley

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to