- Notifications
You must be signed in to change notification settings - Fork7
Libvirt bindings for Node.js®
License
vmngr/libvirt-old
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Libvirt bindings for Node.js®.
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();})();
$ sudo apt install build-essential libvirt-dev$ npm i @vmngr/libvirt
Install Homebrew and Xcode first if not already installed.
$ brew install libvirt$ npm i @vmngr/libvirt
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.
About
Libvirt bindings for Node.js®