وبلاگ بلیان

Foundations of Libvirt Development (How to Set Up and Maintain a Virtual Machine Environment with Python)

جلد کتاب Foundations of Libvirt Development (How to Set Up and Maintain a Virtual Machine Environment with Python)

معرفی کتاب «Foundations of Libvirt Development (How to Set Up and Maintain a Virtual Machine Environment with Python)» نوشتهٔ Shantel Tessier و W. David Ashley، منتشرشده توسط نشر Apress Distributed by Springer Science + Business Media در سال 2019. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است.

کتاب «مبانی توسعه لیب‌ویرت» (Foundations of Libvirt Development) نوشتهٔ دبلیو. دیوید اشلی، راهنمایی جامع و عملی برای برنامه‌نویسان و مدیران سیستم است که می‌خواهند با استفاده از زبان پایتون، محیط‌های مجازی‌سازی مبتنی بر لیب‌ویرت را مدیریت کنند. این کتاب که توسط انتشارات معتبر آپرس (Apress) در سال ۲۰۱۹ منتشر شده، با تکیه بر مثال‌های عینی، شما را از مفاهیم پایه تا پیاده‌سازی پروژه‌های پیشرفته همراهی می‌کند.

دربارهٔ کتاب «مبانی توسعه لیب‌ویرت»

«مبانی توسعه لیب‌ویرت» به بررسی مفاهیم اساسی توسعه با کتابخانه لیب‌ویرت (libvirt) می‌پردازد و نحوهٔ ارتباط با محیط‌های مجازی‌سازی لینوکس مانند کی‌ای‌ام (KVM)، زن (XEN)، ویرتوزو (Virtuozzo)، وی‌ام‌ویر (VMWare ESX)، ال‌ایکس‌سی (LXC)، بهایو (Bhyve) و موارد دیگر را آموزش می‌دهد. این کتاب که به طور خاص بر زبان برنامه‌نویسی پایتون تمرکز دارد، شما را برای راه‌اندازی و نگهداری یک محیط ماشین مجازی آماده می‌کند. ساختار کتاب به گونه‌ای طراحی شده است که ابتدا با مروری بر مفاهیم مجازی‌سازی آغاز شده و سپس به مباحث تخصصی‌تر لیب‌ویرت با استفاده از پایتون می‌پردازد. از جمله مباحث محوری این کتاب می‌توان به مدیریت سیستم‌عامل‌ها و شبکه‌های مجازی، اتصالات، استخرهای ذخیره‌سازی، و مدیریت رویدادها و خطاها اشاره کرد. یکی از نقاط قوت کتاب، بررسی جامع تعاریف طرحوارهٔ اکس‌ام‌ال (XML schema) برای دامنه‌ها، شبکه‌ها، دستگاه‌ها، فیلترینگ شبکه، ذخیره‌سازی و گره‌ها است. در واقع، کتاب به شما نشان می‌دهد که چگونه از رابط برنامه‌نویسی کاربردی (API) لیب‌ویرت برای کنترل ماشین‌های مجازی تحت سیستم کی‌ای‌ام استفاده کنید؛ سیستمی که یکی از پرکاربردترین راه‌حل‌های مجازی‌سازی در دنیای متن‌باز محسوب می‌شود.

دربارهٔ نویسنده

دبلیو. دیوید اشلی (W. David Ashley) نویسنده و مدرس با سابقه در حوزهٔ نرم‌افزارهای متن‌باز، به ویژه لینوکس است. او به عنوان یکی از اعضای تیم مستندسازی فدورا (Fedora) فعالیت داشته و اخیراً رهبری پروژهٔ مستندسازی لیب‌ویرت را بر عهده داشته است و برنامه‌های پایتون مرتبط با آن را نیز نوشته است. اشلی در طول سی سال فعالیت حرفه‌ای خود به عنوان توسعه‌دهنده نرم‌افزار و مشاور فناوری اطلاعات، با بیش از بیست زبان برنامه‌نویسی مختلف کار کرده و تجربهٔ ارزشمندی را در شرکت‌های بزرگی مانند آی‌بی‌ام (IBM) و امریکن ایرلاینز (American Airlines) کسب کرده است. این پیشینهٔ غنی، به کتاب او عمق و اعتبار ویژه‌ای بخشیده است.

چرا باید «مبانی توسعه لیب‌ویرت» را بخوانید؟

  • یادگیری عملی و مبتنی بر مثال: این کتاب با ارائهٔ مثال‌های گسترده و کدهای کاربردی، مفاهیم انتزاعی را به مهارت‌های قابل اجرا تبدیل می‌کند.
  • تمرکز انحصاری بر پایتون: اگر توسعه‌دهنده پایتون هستید، این کتاب دقیقاً همان منبعی است که برای تسلط بر مدیریت ماشین‌های مجازی با لیب‌ویرت به آن نیاز دارید، چرا که سایر زبان‌ها را پوشش نمی‌دهد و بر عمق مطالب افزوده است.
  • پوشش چرخهٔ کامل حیات اشیای مجازی: از ایجاد تا تخریب، کتاب تمام آنچه را که برای مدیریت یک شیء مجازی در طول چرخهٔ حیاتش نیاز است، پوشش می‌دهد.
  • آشنایی با طرحواره‌های اکس‌ام‌ال لیب‌ویرت: درک عمیق از ساختار اکس‌ام‌ال برای پیکربندی دامنه‌ها، شبکه‌ها و دستگاه‌ها، یکی از کلیدی‌ترین مهارت‌هایی است که در این کتاب فرا می‌گیرید.
  • منبعی بی‌نظیر و منحصربه‌فرد: این کتاب به عنوان یکی از معدود منابعی است که به طور تخصصی به اتصال پایتون و لیب‌ویرت پرداخته و برای حرفه‌ای‌های این حوزه بسیار ارزشمند است.

این کتاب برای چه کسانی مناسب است؟

این کتاب برای مدیران و متصدیان ماشین‌های مجازی در محیط‌های یونیکس و لینوکس طراحی شده است؛ از کسانی که کدهای مربوط به یک ماشین مجازی را مدیریت می‌کنند تا متخصصانی که مسئولیت نصب و راه‌اندازی مجموعه‌ای کامل از ماشین‌های مجازی را بر عهده دارند. همچنین، توسعه‌دهندگان پایتون که به دنبال ورود به حوزهٔ مجازی‌سازی یا خودکارسازی مدیریت زیرساخت هستند، مخاطبان اصلی این کتاب محسوب می‌شوند.

سوالات متداول

آیا این کتاب برای افرادی که آشنایی مقدماتی با پایتون دارند نیز مناسب است؟

بله، این کتاب با مرور مفاهیم پایهٔ مجازی‌سازی شروع می‌شود و با فرض اینکه خواننده آشنایی اولیه با برنامه‌نویسی پایتون را دارد، گام‌به‌گام او را به سمت مباحث پیشرفته‌تر هدایت می‌کند.

آیا کتاب صرفاً به تئوری پرداخته یا مثال‌های عملی نیز ارائه می‌دهد؟

این کتاب کاملاً رویکردی عملی دارد و با ارائهٔ مثال‌های کدنویسی متعدد، به خواننده نشان می‌دهد که چگونه مفاهیم را در عمل پیاده‌سازی کند. حتی شامل پروژه‌های نمونه برای درک بهتر مطالب است.

آیا این کتاب به مجازی‌سازی با کی‌ای‌ام محدود شده یا محیط‌های دیگر را نیز پوشش می‌دهد؟

اگرچه تمرکز اصلی کتاب بر کنترل ماشین‌های مجازی تحت سیستم کی‌ای‌ام است، اما در ابتدا به معرفی و مقایسهٔ طیف وسیعی از محیط‌های مجازی‌سازی مانند زن، وی‌ام‌ویر و ال‌ایکس‌سی می‌پردازد تا دید جامعی به خواننده بدهد.

Discover the essential concepts of libvirt development and see how to interface to Linux virtualization environments, such as QEMU/KVM, XEN, Virtuozzo, VMWare ESX, LXC, Bhyve, and more. This book will prepare you to set up and maintain a virtual machine environment. You'll start by reviewing virtualization in general and then move on to libvirt-specific concepts using Python, including virtualized operating systems and networks, connections, storage pools, and event and error handling. This work concludes with a comprehensive look at the XML schema definitions for domains, networks, devices, network filtering, storage, node devices, and more. The libvirt API covers the entire life cycle of virtual objects, from creation to destruction. It contains everything needed for the management of a virtual object during that life cycle. While libvirt has APIs that support many languages, Foundations of Libvirt Development concentrates on Python exclusively, and how to use the APIs to control virtual machines under the QEMU/KVM system. and more. What You'll Learn • Interface Python to the libvirt library. • Review the class layout and methods of the libvirt library. • Install and manipulate virtual machines via Python/libvirt. • Create XML to manipulate domains, networks, and devices. • Write Python programs to perform libvirt functions without human intervention. Who This Book Is For Maintainers of virtual machines in a UNIX/Linux environment ranging from managing code on a single virtual machine through an entire installation of virtual machines. Table of Contents 5 About the Author 14 About the Technical Reviewer 15 Acknowledgments 16 Chapter 1: Introduction 17 What This Book Covers 17 Book Conventions 18 Computer Commands 19 File Names 19 Programming Language Elements and Literals 19 Computer Output and Source Code 20 Notes and Warnings 20 Chapter 2: Architecture 22 Object Model 22 Hypervisor Connections 22 Guest Domains 23 Virtual Networks 24 Storage Pools 25 Storage Volumes 26 Host Devices 27 Driver Model 28 Remote Management 31 Basic Usage 32 Data Transports 32 Authentication Schemes 34 Generating TLS Certificates 35 Public Key Infrastructure Setup 36 Summary 37 Chapter 3: Connecting to Domains 38 Overview 38 open 39 openReadOnly 40 openAuth 41 close 43 URI Formats 44 Local URIs 44 Remote URIs 46 Capability Information Methods 51 Host Information 57 getHostname 58 getMaxVcpus 58 getInfo 59 getCellsFreeMemory 61 getType 62 getVersion 63 getLibVersion 64 getURI 65 isEncrypted 65 isSecure 66 isAlive 67 compareCPU 68 getFreeMemory 69 getFreePages 70 getMemoryParameters 71 getMemoryStats 72 getSecurityModel 73 getSysinfo 73 getCPUMap 74 getCPUStats 75 getCPUModelNames 76 Summary 76 Chapter 4: Guest Domains 77 Domain Overview 77 Listing Domains 81 Obtaining State Information About a Domain 85 Fetching the ID of a Domain 86 Fetching the UUID of a Domain 87 Fetching the OS Type of a Domain 88 Determining Whether the Domain Has a Current Snapshot 89 Determining Whether the Domain Has Managed Save Images 90 Fetching the Hostname of the Domain 91 Getting the Domain Hardware Information 92 Determining Whether the Domain Is Running 93 Determining Whether the Domain Is Persistent 94 Determining Whether the Domain Is Updated 95 Determining the Max Memory of the Domain 96 Determining the Max VCPUs of the Domain 97 Fetching the Name of the Domain 99 Fetching the State of the Domain 100 Extracting the Time Information from the Domain 101 Extracting the Network Interface Addresses from a Domain 102 Lifecycle Control 104 Provisioning and Starting 105 Methods for Provisioning 105 Booting a Transient Guest Domain 106 Defining and Booting a Persistent Guest Domain 107 New Guest Domain Provisioning Techniques 108 CD-ROM/ISO Image Provisioning 110 PXE Boot Provisioning 112 Direct Kernel Boot Provisioning 114 Stopping 118 Suspending/Resuming and Saving/Restoring 119 Migrating 123 Autostarting 128 Domain Configuration 129 Boot Modes 129 Memory/CPU Resources 130 Monitoring Performance 132 Domain Block Device Performance 133 vCPU Performance 134 Memory Statistics 136 I/O Statistics 137 Device Configuration 138 Emulator 140 Disks 141 Networking 143 Mice, Keyboard, and Tablets 145 USB Device Passthrough 147 PCI Device Passthrough 147 Block Device Jobs 149 Summary 152 Chapter 5: Storage Pools and Volumes 153 Pools Overview 153 NFS Storage Pools 154 iSCSI Storage Pools 154 Other Storage Pools 155 Listing Pools 157 Pool Usage 158 Lifecycle Control 161 Discovering Pool Sources 163 Pool Configuration 164 Volume Overview 165 Listing Volumes 166 Volume Information 167 Creating and Deleting Volumes 168 Cloning Volumes 170 Configuring Volumes 173 Summary 173 Chapter 6: Virtual Networks 174 Listing Networks 175 Lifecycle Control 177 Network Configuration 179 Summary 180 Chapter 7: Network Interfaces 181 XML Interface Description Format 182 Retrieving Information About Interfaces 184 Enumerating Interfaces 184 Obtaining a virInterface Instance for an Interface 186 Retrieving Detailed Interface Information 187 Retrieving Interface Network Addresses 189 Managing Interface Configuration Files 190 Defining an Interface Configuration 190 Using changeRollback 193 Using changeBegin 193 Using changeCommit 194 Interface Lifecycle Management 195 Activating an Interface 195 Deactivating an Interface 195 Summary 196 Chapter 8: Error Handling 197 The libvirtError Class 197 Using virGetLastError 206 Subclassing libvirtError 207 Registering an Error Handler Function 209 Summary 211 Chapter 9: Event and Timer Handling 212 Event Handling 212 Timer Handling 216 Summary 217 Chapter 10: Using the QEMU Guest Agent 218 Installing the QEMU Guest Agent 219 Using the QEMU Guest Agent 219 virsh and the QEMU Guest Agent 221 QEMU Guest Agent Time Commands 223 QEMU Guest Agent Network Interface Commands 225 Python and the QEMU Guest Agent 227 QEMU Guest Agent Time Commands 230 QEMU Guest Agent Network Interface Commands 234 Summary 236 Chapter 11: Debugging/Logging 237 Logging Facilities 237 Environment Variables 239 Summary 240 Chapter 12: A Sample Problem 241 Problem Statement 241 Solution Requirements 242 Using Guest Domains to Solve the Problem 243 Introducing virsh 243 Introducing the Python libvirt Module 244 New Problems Introduced by Using Guest Domains 244 Sample Solution 245 Implementing the Job Information Store 246 Reading the Store 247 Using runJobOnDemand.py 248 Summary 254 Chapter 13: Storing Information About Virtual Machines 255 Deciding What Information Should Be Stored 255 Using Simple Text Files 256 Using a Simple Database 259 Summary 261 Chapter 14: Securing Virtual Machines 262 Host Security 262 Guest Domain Security 264 Summary 264 Appendix A: Libvirt XML Schemas 265 Element and Attribute Overview 342 Host Capabilities 343 Guest Capabilities 344 Node Device XML Format 344 Snapshot XML Format 347 Snapshot XML Samples 349 The Domain Capabilities XML Format 352 Element and Attribute Overview 352 CPU Allocation 353 BIOS Bootloader 353 CPU Configuration 354 IO Threads 355 Hard Drives, Floppy Disks, and CD-ROMs 356 Graphical Framebuffers 357 Video Device 357 Host Device Assignment 358 Features 359 Network Filters 360 Goals and Background 360 Concepts 361 Filtering Chains 363 Filtering Chain Priorities 365 Usage of Variables in Filters 366 Automatic IP Address Detection 369 Reserved Variables 371 Element and Attribute Overview 372 References to Other Filters 372 Filter Rules 373 Supported Protocols 375 MAC (Ethernet) 377 VLAN (802.1Q) (Since 0.9.8) 378 STP (Spanning Tree Protocol) (Since 0.9.8) 379 ARP/RARP 380 IPv4 382 IPv6 383 TCP/UDP/SCTP 385 ICMP 386 IGMP, ESP, AH, UDPLITE, ALL 388 TCP/UDP/SCTP over IPV6 389 ICMPv6 391 IGMP, ESP, AH, UDPLITE, ALL over IPv6 392 Advanced Filter Configuration Topics 393 Connection Tracking 393 Limiting Number of Connections 394 Command-Line Tools 396 Writing Your Own Filters 398 Custom Filter 1 399 Custom Filter 2 402 Limitations 407 VM Migration 407 VLAN Filtering on Linux 408 The Domain Schema 265 Example Paravirtualized XEN Schemas 314 Paravirtualized Guest Bootloader 314 Paravirtualized Guest Direct Kernel Boot 315 Fully Virtualized Guest BIOS Boot 316 Fully Virtualized Guest Direct Kernel Boot 317 Example Paravirtualized KVM and Qemu Schemas 319 QEMU Emulated Guest on x86_64 319 KVM Hardware Accelerated Guest on i686 320 The Networks Schema 321 The Network Schema Details 322 The Connectivity Schema 322 Setting a VLAN Tag (on Supported Network Types Only) 324 Portgroups 325 Static Routes 326 Addressing 326 Example Configurations 328 NAT-Based Network 328 Routed Network Config 329 Isolated Network Config 331 Isolated IPv6 Network Config 332 Using an Existing Host Bridge 333 Using a macvtap “Direct” Connection 333 Network Config with No Gateway Address 334 Storage Pool XML 335 General Metadata 335 Source Elements 336 Target Elements 337 Storage Volume XML 338 Storage Volume XML 338 Target Elements 339 Backing Store Element 340 Volume Examples 340 Index 409
دانلود کتاب Foundations of Libvirt Development (How to Set Up and Maintain a Virtual Machine Environment with Python)