ramyelkest / libvirt-node Goto Github PK
View Code? Open in Web Editor NEWLibvirt bindings for NodeJS
License: GNU Lesser General Public License v2.1
Libvirt bindings for NodeJS
License: GNU Lesser General Public License v2.1
Hey,
Is getUUIDString()
working correctly? When I try to use it in the same way as I would use getName()
, getID()
or getOSType()
I get the following error:
ReferenceError: buf is not defined
at module.exports.getUUIDString (/vagrant/node_modules/libvirt-node/generated/libvirt-domain.js:870:66)
at domains.forEach.domain (/vagrant/src/server/models/Domains.js:50:41)
at Array.forEach (<anonymous>)
at Object.allCompact (/vagrant/src/server/models/Domains.js:46:17)
at compact (/vagrant/src/server/controllers/DomainsController.js:19:45)
at Layer.handle [as handle_request] (/vagrant/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/vagrant/node_modules/express/lib/router/index.js:317:13)
at /vagrant/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/vagrant/node_modules/express/lib/router/index.js:335:12)
at next (/vagrant/node_modules/express/lib/router/index.js:275:10)
It seems to require a buffer (buf
) to be passed in but I cannot figure out what to pass into that.
Here is a code example:
const domains = LibvirtClient.listAllDomains(0);
const domainsWithInfo = [];
domains.forEach(domain => {
const domainInfo = {};
domainInfo['name'] = domain.getName();
domainInfo['uuid'] = domain.getUUIDString(); // without this line, this loop works; with it is fails :(
domainInfo['id'] = domain.getID();
domainInfo['osType'] = domain.getOSType();
domainsWithInfo.push(domainInfo);
});
return domainsWithInfo;
Cheers
Hi, I am interested in getting involved in libvirt project, and libvirt-node for GSoC project. I am currently a student of the University of Tokyo Japan.
I would like to build this project locally but manual headers installation is required. So I currentlly check the build using docker in my local environment.
Is it ok to add Dockerfile and make rule to build this poject in the docker container as PR?
Currently long
, long long
, unsigned long
and unsigned long long
are mapped to napi_int64.
Two potential problems are
2^53
we need to validate if either is an issue in our API
In ./generated/libvirt-storage-pool.js
on line 156 (let retList = libvirt_native.virStoragePoolListAllVolumes(this.pool, flags);
) the first arg is this.pool
but this seems to be wrong as I get the error:
/vagrant/node_modules/libvirt-node/generated/libvirt-storage-pool.js:156
let retList = libvirt_native.virStoragePoolListAllVolumes(this.pool, flags);
^
TypeError: Wrong argument type 0
at module.exports.listAllVolumes (/vagrant/node_modules/libvirt-node/generated/libvirt-storage-pool.js:156:34)
This is the generated code:
/**
* Collect the list of storage volumes, and allocate an array to store those
* objects.
*
* TODO: params / returns
*/
listAllVolumes(flags = 0) {
let retList = libvirt_native.virStoragePoolListAllVolumes(this.pool, flags);
if (retList == null)
throw new Error('virStoragePoolListAllVolumes() failed');
return retList.map(ret => new virStorageVol(this.conn, ret));
}
Changing this.pool
to this.storagePool
fixes the issue.
Hi.
Im using libvirt-node in my project and i needed some api for monitoring my VMs.
i added them to whitelist as you said in DEVELOPMENT.md but when I try to regenerate the files I get the following error:
Error: Type 'virDomainPtr *' is not mapped to a napi type
I see that you mentioned this error in whitelist.js.
Is there anyway to fix it?
I would be thankful if you consider helping me .
@RamyElkest
Some api calls like virDomainGetHostname
require the user to free the returned string.
char *
(not const char) require user to freethere's too much logic in the impl default generator atm, this task should break them into finer grained generators(or functions..) so we can override subsections of the implementation
For instance virDomainGetMetadata
takes a uri string which is conditionally nullable
This should apply to virConnectOpen
as well
This will probably apply to all pointer types
This means in our type check we should check for napi_null/napi_undefined
as well as the type
@RamyElkest a new issue I am having now, is that Libvirt is spitting out lovely useful messages into the terminal but I cannot seem to get them in JS.
Terminal output after an error:
libvirt: Domain Config error : operation failed: domain 'created_from_post' already exists with uuid d6bd24d8-ff09-426d-ae23-e8c3cdb696e6
Error: virDomainDefineXML() failed
at module.exports.defineXML (/vagrant/node_modules/libvirt-node/generated/libvirt-connect.js:708:28)
at Object.create (/vagrant/src/server/models/Domains.js:67:38)
at create (/vagrant/src/server/controllers/DomainsController.js:34:21)
at Layer.handle [as handle_request] (/vagrant/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/vagrant/node_modules/express/lib/router/index.js:317:13)
at /vagrant/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/vagrant/node_modules/express/lib/router/index.js:335:12)
at next (/vagrant/node_modules/express/lib/router/index.js:275:10)
at nocache (/vagrant/node_modules/nocache/index.js:8:5)
at Layer.handle [as handle_request] (/vagrant/node_modules/express/lib/router/layer.js:95:5)
I can only get: virDomainDefineXML() failed
, but Domain Config error : operation failed: domain 'created_from_post' already exists with uuid d6bd24d8-ff09-426d-ae23-e8c3cdb696e6
would be way more useful to me :)
Is there something I am doing wrong, or could you make a change to expose these messages?
This is where I am using it: https://gitlab.com/atwright147/kvm-controller/commit/d3667b39bdb7457020d01358923949d8464b33c2
Sending a payload like:
{
"xmlString": "<domain type='kvm'><name>created_from_post</name><memory unit='MB'>512</memory><vcpu>1</vcpu><os><type arch='i686'>hvm</type></os><clock sync='localtime'/><devices><disk type='file' device='disk'><source file='/var/lib/libvirt/images/demo2.img'/><target dev='hda'/></disk><disk type='file' device='cdrom'><source file='/home/vagrant/Downloads/Core-current.iso'/><target dev='hdc'/><readonly/></disk><interface type='network'><source network='default'/></interface><graphics type='vnc' port='-1'/></devices></domain>"
}
optional arguments such as flags
and const char *
should default to 0
/null
respectively in the interface/wrapper
In libvirt-python flags
always default to 0
and it greps the info for optional
args to default to null
Virtualization is currently mis-spelt in Github repo topics (current spelling "virtulization").
Create .travis.yml etc
Hey,
I am very excited about this project and have been experimenting. I built a project in Express.js to use take advantage of libvirt-node.
I have successfully got it going, but only for one request. After that one request it crashes with the following error:
node: ../generated/libvirt-connect.c:943: libvirt_virConnectListAllDomains: Assertion `status == napi_ok' failed.
Do you have any idea what might be wrong?
This is the current Express App code: https://gitlab.com/atwright147/kvm-controller
registers callback
info passed through arguments
virStorageVolCreateXML
virStorageVolGetKey
virStoragePoolCreateXML
virStoragePoolGetUUID
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.