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

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    5 Favorites

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

    1. Xen Summit 2008 Tokyo 2008/11/21 paperboy&co. Gosuke Miyashita
    2. 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)
    3. 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
    4. 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
    5.  
    6. 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
    7. 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
    8. libvirt Xen driver(local) xend xenstored xen hypervisor libvirt Perl Python OCaml Ruby Java C# C
    9. libvirt Xen driver(remote) xend xenstored xen hypervisor libvirtd Perl Python OCaml Ruby Java C# C libvirt Over a network
    10.  
    11. 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 };
      • }
    12. 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] )
    13.  
    14. 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
    15. 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 );
      • ....
      • }
    16. 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
    17. 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)
    18.  

    + mizzymizzy, 2 years ago

    custom

    2011 views, 5 favs, 0 embeds more stats

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 2011
      • 2011 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 5
    • Downloads 42
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories