Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Libvirt bindings for Node.js®

License

NotificationsYou must be signed in to change notification settings

vmngr/libvirt-old

Repository files navigation

Cover image

vmngr / libvirt

Alpha badgeCI badgeLicense badgeContributors badgeIssues badgePR badge

Libvirt bindings for Node.js®.

Example Usage

importlibvirt,{DomainBuilder,domainDescToXml,domainDescFromXml,}from"@vmngr/libvirt";consturi=process.env.LIBVIRT_URI||"qemu:///system";consthypervisor=newlibvirt.Hypervisor({ uri});(async()=>{awaithypervisor.connectOpen();// parse xml templateconsttemplate=awaitdomainDescFromXml("<domain>...</domain>");// build new domain descriptionconstdomain=newDomainBuilder().fromTemplate(template).setName("test1").setUUID("148d0864-2354-4c27-b82c-731bdd3f320c").addDisk({type:"file",device:"disk",driver:{name:"qemu",type:"qcow2"},source:{file:"/home/leon/test1.img"},target:{dev:"vda",bus:"virtio"},}).addInterface({type:"network",source:{network:"default"},mac:{address:"52:54:00:8e:c6:5f"},model:{type:"virtio"},}).build();// define and boot domainconstxml=domainDescToXml(domain);awaithypervisor.domainCreateXML(xml);// list active domainsconstactiveDomains=awaithypervisor.connectListAllDomains(libvirt.ConnectListAllDomainsFlags.ACTIVE);// log active domain namesconstactiveDomainNames=awaitPromise.all(activeDomains.map((domain)=>hypervisor.domainGetName(domain)));console.log(activeDomainNames);awaithypervisor.connectClose();})();

Install

Debian / Ubuntu

$ sudo apt install build-essential libvirt-dev$ npm i @vmngr/libvirt

MacOS

Install Homebrew and Xcode first if not already installed.

$ brew install libvirt$ npm i @vmngr/libvirt

Contribute

Any contribution is welcome! To check wether your contribution conforms our style guide run the following tasks:

$ pip install cppcheck# required once$ git submodule update --init --recursive# required once$ npm run lint/bindings$ npm run lint/lib$ npm run lint/examples

MIT License

Copyright (c) 2019 Leon Rinkelleon@rinkel.me and vmngr/libvirt contributers

Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.


[8]ページ先頭

©2009-2025 Movatter.jp