Skip to content

Commit

Permalink
[api] virDomainIsUpdated, virConnectGetSysinfo, virConnectIsAlive
Browse files Browse the repository at this point in the history
  • Loading branch information
tralamazza committed Apr 5, 2012
1 parent 51a2c6f commit e3cad7b
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/domain.cc
Expand Up @@ -132,6 +132,8 @@ namespace NodeLibvirt {
Domain::IsActive);
NODE_SET_PROTOTYPE_METHOD(t, "isPersistent",
Domain::IsPersistent);
NODE_SET_PROTOTYPE_METHOD(t, "isUpdated",
Domain::IsUpdated);
NODE_SET_PROTOTYPE_METHOD(t, "getInterfaceStats",
Domain::GetInterfaceStats);
NODE_SET_PROTOTYPE_METHOD(t, "coreDump",
Expand Down Expand Up @@ -782,6 +784,21 @@ namespace NodeLibvirt {
return scope.Close(Boolean::New(is_persistent));
}

Handle<Value> Domain::IsUpdated(const Arguments& args) {
HandleScope scope;

Domain *domain = ObjectWrap::Unwrap<Domain>(args.This());

int ret = virDomainIsUpdated(domain->domain_);

if(ret == -1) {
ThrowException(Error::New(virGetLastError()));
return Null();
}

return scope.Close(Boolean::New(ret == 1));
}

Handle<Value> Domain::Reboot(const Arguments& args) {
HandleScope scope;
unsigned int flags = 0;
Expand Down
1 change: 1 addition & 0 deletions src/domain.h
Expand Up @@ -41,6 +41,7 @@ namespace NodeLibvirt {
static Handle<Value> GetMaxVcpus(const Arguments& args);
static Handle<Value> IsActive(const Arguments& args);
static Handle<Value> IsPersistent(const Arguments& args);
static Handle<Value> IsUpdated(const Arguments& args);
static Handle<Value> Reboot(const Arguments& args);
static Handle<Value> Save(const Arguments& args);
static Handle<Value> Restore(const Arguments& args);
Expand Down
37 changes: 37 additions & 0 deletions src/hypervisor.cc
Expand Up @@ -117,6 +117,9 @@ namespace NodeLibvirt {
NODE_SET_PROTOTYPE_METHOD(t, "getMaxVcpus",
Hypervisor::GetMaxVcpus);

NODE_SET_PROTOTYPE_METHOD(t, "getSysinfo",
Hypervisor::GetSysinfo);

NODE_SET_PROTOTYPE_METHOD(t, "getType",
Hypervisor::GetType);

Expand All @@ -132,6 +135,9 @@ namespace NodeLibvirt {
NODE_SET_PROTOTYPE_METHOD(t, "isConnectionSecure",
Hypervisor::IsConnectionSecure);

NODE_SET_PROTOTYPE_METHOD(t, "isConnectionAlive",
Hypervisor::IsConnectionAlive);

NODE_SET_PROTOTYPE_METHOD(t, "closeConnection",
Hypervisor::CloseConnection);

Expand Down Expand Up @@ -504,6 +510,23 @@ namespace NodeLibvirt {
return scope.Close(version);
}

Handle<Value> Hypervisor::GetSysinfo(const Arguments& args) {
HandleScope scope;

Hypervisor *hypervisor = ObjectWrap::Unwrap<Hypervisor>(args.This());

const char* info_ = virConnectGetSysinfo(hypervisor->conn_, 0);

if(info_ == NULL) {
ThrowException(Error::New(virGetLastError()));
return Null();
}

Local<String> info = String::New(info_);

return scope.Close(info);
}

Handle<Value> Hypervisor::GetType(const Arguments& args) {
HandleScope scope;
const char* type_ = NULL;
Expand Down Expand Up @@ -643,6 +666,20 @@ namespace NodeLibvirt {
return False();
}

Handle<Value> Hypervisor::IsConnectionAlive(const Arguments& args) {
HandleScope scope;

Hypervisor *hypervisor = ObjectWrap::Unwrap<Hypervisor>(args.This());

int ret = virConnectIsAlive(hypervisor->conn_);

if(ret == -1) {
ThrowException(Error::New(virGetLastError()));
}

return (ret == 1) ? True() : False();
}

Handle<Value> Hypervisor::GetBaselineCPU(const Arguments& args) {
HandleScope scope;
char **xmlCPUs = NULL;
Expand Down
2 changes: 2 additions & 0 deletions src/hypervisor.h
Expand Up @@ -32,6 +32,7 @@ namespace NodeLibvirt {

static Handle<Value> GetCapabilities(const Arguments& args);
static Handle<Value> GetHostname(const Arguments& args);
static Handle<Value> GetSysinfo(const Arguments& args);
static Handle<Value> GetType(const Arguments& args);
static Handle<Value> GetConnectionUri(const Arguments& args);
static Handle<Value> GetVersion(const Arguments& args);
Expand All @@ -41,6 +42,7 @@ namespace NodeLibvirt {
static Handle<Value> CompareCPU(const Arguments& args);
static Handle<Value> IsConnectionEncrypted(const Arguments& args);
static Handle<Value> IsConnectionSecure(const Arguments& args);
static Handle<Value> IsConnectionAlive(const Arguments& args);
static Handle<Value> CloseConnection(const Arguments& args);

//virConnectList functions
Expand Down

0 comments on commit e3cad7b

Please sign in to comment.