11![ Cover image] [ cover ]
22
3- # vmngr / libvirt
3+ # Unraid / libvirt bindings
44
55![ Alpha badge] [ alphabadge ]
66![ CI badge] [ cibadge ]
@@ -15,87 +15,92 @@ Libvirt bindings for Node.js®.
1515
1616``` typescript
1717import libvirt , {
18- DomainBuilder ,
19- domainDescToXml ,
20- domainDescFromXml ,
21- } from " @vmngr /libvirt" ;
18+ DomainBuilder ,
19+ domainDescToXml ,
20+ domainDescFromXml ,
21+ } from " @unraid /libvirt" ;
2222
2323const uri = process .env .LIBVIRT_URI || " qemu:///system" ;
2424const hypervisor = new libvirt .Hypervisor ({ uri });
2525
2626(async () => {
27-
28- await hypervisor .connectOpen ();
29-
30- // parse xml template
31- const template = await domainDescFromXml (" <domain>...</domain>" );
32-
33- // build new domain description
34- const domain = new DomainBuilder ()
35- .fromTemplate (template )
36-
37- .setName (" test1" )
38- .setUUID (" 148d0864-2354-4c27-b82c-731bdd3f320c" )
39-
40- .addDisk ({
41- type: " file" , device: " disk" ,
42- driver: { name: " qemu" , type: " qcow2" },
43- source: { file: " /home/leon/test1.img" },
44- target: { dev: " vda" , bus: " virtio" },
45- })
46-
47- .addInterface ({
48- type: " network" ,
49- source: { network: " default" },
50- mac: { address: " 52:54:00:8e:c6:5f" },
51- model: { type: " virtio" },
52- })
53-
54- .build ();
55-
56- // define and boot domain
57- const xml = domainDescToXml (domain );
58- await hypervisor .domainCreateXML (xml );
59-
60- // list active domains
61- const activeDomains = await hypervisor .connectListAllDomains (
62- libvirt .ConnectListAllDomainsFlags .ACTIVE );
63-
64- // log active domain names
65- const activeDomainNames = await Promise .all (activeDomains
66- .map ((domain ) => hypervisor .domainGetName (domain )));
67- console .log (activeDomainNames );
68-
69- await hypervisor .connectClose ();
70-
27+ await hypervisor .connectOpen ();
28+
29+ // parse xml template
30+ const template = await domainDescFromXml (" <domain>...</domain>" );
31+
32+ // build new domain description
33+ const domain = new DomainBuilder ()
34+ .fromTemplate (template )
35+
36+ .setName (" test1" )
37+ .setUUID (" 148d0864-2354-4c27-b82c-731bdd3f320c" )
38+
39+ .addDisk ({
40+ type: " file" ,
41+ device: " disk" ,
42+ driver: { name: " qemu" , type: " qcow2" },
43+ source: { file: " /home/leon/test1.img" },
44+ target: { dev: " vda" , bus: " virtio" },
45+ })
46+
47+ .addInterface ({
48+ type: " network" ,
49+ source: { network: " default" },
50+ mac: { address: " 52:54:00:8e:c6:5f" },
51+ model: { type: " virtio" },
52+ })
53+
54+ .build ();
55+
56+ // define and boot domain
57+ const xml = domainDescToXml (domain );
58+ await hypervisor .domainCreateXML (xml );
59+
60+ // list active domains
61+ const activeDomains = await hypervisor .connectListAllDomains (
62+ libvirt .ConnectListAllDomainsFlags .ACTIVE
63+ );
64+
65+ // log active domain names
66+ const activeDomainNames = await Promise .all (
67+ activeDomains .map ((domain ) => hypervisor .domainGetName (domain ))
68+ );
69+ console .log (activeDomainNames );
70+
71+ await hypervisor .connectClose ();
7172})();
7273```
7374
7475## Install
7576
7677### Debian / Ubuntu
78+
7779``` bash
78- $ sudo apt install build-essential libvirt-dev
79- $ npm i @vmngr /libvirt
80+ sudo apt install build-essential libvirt-dev
81+ npm i @unraid /libvirt
8082```
8183
8284### MacOS
85+
8386Install Homebrew and Xcode first if not already installed.
87+
8488``` bash
85- $ brew install libvirt
86- $ npm i @vmngr /libvirt
89+ brew install libvirt
90+ npm i @unraid /libvirt
8791```
8892
8993## Contribute
9094
9195Any contribution is welcome! To check wether your contribution conforms our style guide run the following tasks:
96+
9297``` bash
93- $ pip install cppcheck # required once
94- $ git submodule update --init --recursive # required once
98+ pip install cppcheck # required once
99+ git submodule update --init --recursive # required once
95100
96- $ npm run lint/bindings
97- $ npm run lint/lib
98- $ npm run lint/examples
101+ pnpm run lint/bindings
102+ pnpm run lint/lib
103+ pnpm run lint/examples
99104```
100105
101106---
@@ -122,9 +127,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
122127OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
123128SOFTWARE.
124129
125-
126130[ cover ] : cover.png " Cover image "
127-
128131[ alphabadge ] : https://img.shields.io/badge/-alpha-green " Alpha badge "
129132[ licensebadge ] : https://img.shields.io/github/license/vmngr/libvirt " License badge "
130133[ cibadge ] : https://github.com/vmngr/libvirt/workflows/CI/badge.svg " CI badge "
0 commit comments