0
Xen Summit 2008 Tokyo 2008/11/21 paperboy&co. Gosuke Miyashita
Agenda <ul><li>About me </li></ul><ul><li>Purpose of this talk </li></ul><ul><li>What is libvirt </li></ul><ul><li>libvirt...
About me <ul><li>Gosuke Miyashita </li></ul><ul><ul><li>http://mizzy.org/ </li></ul></ul><ul><li>Technical manager at pape...
Purpose of this talk <ul><li>I seek how to manage Xen domains on many host machines </li></ul><ul><li>I need a simple and ...
 
What is libvirt? <ul><li>The virtualization API </li></ul><ul><li>A library intracts with virtualization systems </li></ul...
What can you do with libvirt? <ul><li>Get  Dom0 info </li></ul><ul><ul><li>CPU model/threads/cores, memory size and so on ...
libvirt Xen driver(local) xend xenstored xen hypervisor libvirt Perl Python OCaml Ruby Java C# C
libvirt Xen driver(remote) xend xenstored xen hypervisor libvirtd Perl Python OCaml Ruby Java C# C libvirt Over a network
 
Perl code example <ul><li>use   Sys::Virt ; </li></ul><ul><li># connect to the remote host </li></ul><ul><li>my   $vmm  = ...
Python code example <ul><li>import  libvirt </li></ul><ul><li># connect to the remote host </li></ul><ul><li>conn = libvir...
 
Avahi support <ul><li>libvirt is integrated with Avahi </li></ul><ul><li>Ahahi is a one of mDNS implementation </li></ul><...
Perl example with libvirt and avahi <ul><li>use   Net::Bonjour ; </li></ul><ul><li>use   Sys::Virt ; </li></ul><ul><li># d...
Func <ul><li>Fedora Unified Network Controller </li></ul><ul><ul><li>https://fedorahosted.org/func/ </li></ul></ul><ul><li...
Func virt module sample code <ul><li>import  func.overlord.client as fc </li></ul><ul><li># call state method of virt modu...
 
Upcoming SlideShare
Loading in...5
×

Xen Summit 2008 Tokyo - Operating Xen domains through LL(Perl/Python) with libvirt

3,583

Published on

Published in: Technology
0 Comments
6 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,583
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
75
Comments
0
Likes
6
Embeds 0
No embeds

No notes for slide

Transcript of "Xen Summit 2008 Tokyo - Operating Xen domains through LL(Perl/Python) with libvirt"

  1. 1. Xen Summit 2008 Tokyo 2008/11/21 paperboy&co. Gosuke Miyashita
  2. 2. Agenda <ul><li>About me </li></ul><ul><li>Purpose of this talk </li></ul><ul><li>What is libvirt </li></ul><ul><li>libvirt Xen driver architecture </li></ul><ul><li>libvirt sample codes with Perl/Python </li></ul><ul><li>Related tools (Avahi and Func) </li></ul>
  3. 3. About me <ul><li>Gosuke Miyashita </li></ul><ul><ul><li>http://mizzy.org/ </li></ul></ul><ul><li>Technical manager at paperboy&co. </li></ul><ul><ul><li>Web hosting, blog, ec hosting and so on for indivisuals </li></ul></ul><ul><li>Thinking introduce virtualization technologies to our services </li></ul>
  4. 4. Purpose of this talk <ul><li>I seek how to manage Xen domains on many host machines </li></ul><ul><li>I need a simple and customizable tool </li></ul><ul><li>It may be fast to develop my own tool </li></ul><ul><li>libvirt is the one for developing my own Xen management tool </li></ul><ul><li>Why python and perl? </li></ul><ul><ul><li>These languages may be used widly in system administration </li></ul></ul>
  5. 6. What is libvirt? <ul><li>The virtualization API </li></ul><ul><li>A library intracts with virtualization systems </li></ul><ul><ul><li>Xen, QEMU, KVM, LXC and OpenVZ </li></ul></ul><ul><li>Language bindings </li></ul><ul><ul><li>C, Python, Perl, OCaml, Ruby, Java and C# </li></ul></ul><ul><li>Support multiple authentication methods </li></ul><ul><ul><li>SSH, TLS and X.509, SASL and Kerberos </li></ul></ul><ul><li>Avahi multicast DNS support </li></ul>
  6. 7. What can you do with libvirt? <ul><li>Get Dom0 info </li></ul><ul><ul><li>CPU model/threads/cores, memory size and so on </li></ul></ul><ul><li>List domains </li></ul><ul><li>Get domain info </li></ul><ul><ul><li>id, uuid, name, xml description, os type and state </li></ul></ul><ul><li>Various domain operations </li></ul><ul><ul><li>create, shutdown, reboot, suspend, resume </li></ul></ul><ul><ul><li>set/get max memory/memory size, get max vcpus </li></ul></ul><ul><li>Network, Storage operations (excluded in this talk) </li></ul><ul><li>See http://libvirt.org/html/libvirt-libvirt.html </li></ul>
  7. 8. libvirt Xen driver(local) xend xenstored xen hypervisor libvirt Perl Python OCaml Ruby Java C# C
  8. 9. libvirt Xen driver(remote) xend xenstored xen hypervisor libvirtd Perl Python OCaml Ruby Java C# C libvirt Over a network
  9. 11. Perl code example <ul><li>use Sys::Virt ; </li></ul><ul><li># connect to the remote host </li></ul><ul><li>my $vmm = </li></ul><ul><li>Sys::Virt->new( uri => &quot;xen://remote_host/“ ); </li></ul><ul><li># get domains </li></ul><ul><li>my @doms = $vmm->list_domains; </li></ul><ul><li># print state of each domains </li></ul><ul><li>for my $dom ( @doms ) { </li></ul><ul><li>printf &quot; %s: %s &quot; , </li></ul><ul><li>$dom->get_name, $dom->get_info->{ state }; </li></ul><ul><li>} </li></ul>
  10. 12. Python code example <ul><li>import libvirt </li></ul><ul><li># connect to the remote host </li></ul><ul><li>conn = libvirt.open(‘ xen://remote_host/’ ) </li></ul><ul><li># get domain ids </li></ul><ul><li>ids = conn.listDomainsID() </li></ul><ul><li># print state of each domains </li></ul><ul><li>for id in ids: </li></ul><ul><li>vm = conn.lookupByID(id) </li></ul><ul><li>print &quot;%s: %s&quot; % ( vm.name(), vm.info()[0] ) </li></ul>
  11. 14. Avahi support <ul><li>libvirt is integrated with Avahi </li></ul><ul><li>Ahahi is a one of mDNS implementation </li></ul><ul><li>You can discover hosts with libvirtd running by mDNS client automatically </li></ul>
  12. 15. Perl example with libvirt and avahi <ul><li>use Net::Bonjour ; </li></ul><ul><li>use Sys::Virt ; </li></ul><ul><li># discover hosts with libvirtd running </li></ul><ul><li>my $res = </li></ul><ul><li>Net::Bonjour->new( 'libvirt' ); </li></ul><ul><li>$res->discover; </li></ul><ul><li># access libvirtd on each host </li></ul><ul><li>for my $host ( $res->entries ) { </li></ul><ul><li>my $vmm = </li></ul><ul><li>Sys::Virt->new( uri => ‘xen://’ . $host->address ); </li></ul><ul><li>.... </li></ul><ul><li>} </li></ul>
  13. 16. Func <ul><li>Fedora Unified Network Controller </li></ul><ul><ul><li>https://fedorahosted.org/func/ </li></ul></ul><ul><li>Sysadmin application framework made of Python </li></ul><ul><li>A programming framework for “Exec some operations for multiple hosts” </li></ul><ul><li>Many modules </li></ul><ul><ul><li>yum, user, service, command, smart, virt ... </li></ul></ul><ul><li>Virt module uses libvirt </li></ul>
  14. 17. Func virt module sample code <ul><li>import func.overlord.client as fc </li></ul><ul><li># call state method of virt module on all hosts </li></ul><ul><li>results = fc.Client( &quot;*&quot; ).virt.state() </li></ul><ul><li># create domain if domain state is ‘shutdown’ </li></ul><ul><li>for ( host, vms ) in results.iteritems(): </li></ul><ul><li>if vms[0] == 'REMOTE_ERROR': </li></ul><ul><li>continue </li></ul><ul><li>for vm in vms: </li></ul><ul><li>( domain, state ) = vm.split( ' ' ) </li></ul><ul><li>if state == 'shutdown' : </li></ul><ul><li>fc.Client(host).virt.create(domain) </li></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×