• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Xen Summit 2008 Tokyo - Operating Xen domains through LL(Perl/Python) with libvirt
 

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

on

  • 5,626 views

 

Statistics

Views

Total Views
5,626
Views on SlideShare
5,529
Embed Views
97

Actions

Likes
6
Downloads
74
Comments
0

2 Embeds 97

http://coderwall.com 92
http://www.slideshare.net 5

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

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

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