From 13562c8d7b36bc00ed1f6fa7bea0bb000921cc63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20S=2E=20Montero?= Date: Thu, 16 Apr 2009 20:13:47 +0000 Subject: [PATCH] Added missing methods in the client API git-svn-id: http://svn.opennebula.org/one/trunk@474 3034c82b-c49b-4eb3-8279-a7acafdc01c0 --- include/OneClient.h | 73 ++++++++++++++++-------- src/client/OneClient_C_Wrapper.cc | 94 ++++++++++++++++++++++--------- 2 files changed, 117 insertions(+), 50 deletions(-) diff --git a/include/OneClient.h b/include/OneClient.h index f344dff4b4..4b09bae289 100644 --- a/include/OneClient.h +++ b/include/OneClient.h @@ -48,19 +48,19 @@ public: OneClient(string oneurl="localhost",unsigned int socket=2633) { ostringstream oss; - + oss << "http://" << oneurl << ":" << socket << "/RPC2"; url=oss.str(); - + session = "oneclient"; }; - + ~OneClient(){}; /* ---------------------------------------------------------------------- */ /* ONE Virtual Machine Methods */ /* ---------------------------------------------------------------------- */ - + /** * Add a new VM to the VM pool and starts it. * @param template_file path, description of the Virtual Machine template @@ -77,8 +77,8 @@ public: * @param error if an error occurs this is the error message * @return -1 if an error occurs, 0 on success. */ - int allocate_template(const string& template_file, - int& vmid, + int allocate_template(const string& template_file, + int& vmid, string& error); /** @@ -108,7 +108,7 @@ public: */ int shutdown(int vmid, string& error) { - return action(vmid,"shutdown",error); + return action(vmid,"shutdown",error); }; /** @@ -119,7 +119,7 @@ public: */ int hold(int vmid, string& error) { - return action(vmid,"hold",error); + return action(vmid,"hold",error); }; /** @@ -130,7 +130,7 @@ public: */ int release(int vmid, string& error) { - return action(vmid,"release",error); + return action(vmid,"release",error); }; /** @@ -139,9 +139,9 @@ public: * @param error if an error occurs this is the error message * @return -1 if an error occurs, 0 on success. */ - int stop(int vmid, string& error) + int stop(int vmid, string& error) { - return action(vmid,"stop",error); + return action(vmid,"stop",error); }; /** @@ -152,7 +152,7 @@ public: */ int suspend(int vmid, string& error) { - return action(vmid,"suspend",error); + return action(vmid,"suspend",error); }; /** @@ -163,13 +163,36 @@ public: */ int resume(int vmid, string& error) { - return action(vmid,"resume",error); + return action(vmid,"resume",error); + }; + + + /** + * Cancel the execution of a VM, + * @param vmid the vm identifier to resume. + * @param error if an error occurs this is the error message + * @return -1 if an error occurs, 0 on success. + */ + int cancel(int vmid, string& error) + { + return action(vmid,"cancel",error); + }; + + /** + * Remove the VM from the DB + * @param vmid the vm identifier to resume. + * @param error if an error occurs this is the error message + * @return -1 if an error occurs, 0 on success. + */ + int finalize(int vmid, string& error) + { + return action(vmid,"finalize",error); }; /** * Gets information on a virtual machine * @param vmid the vm identifier. - * @param info the VM information + * @param info the VM information * @param error if an error occurs this is the error message * @return -1 if an error occurs, 0 on success. */ @@ -177,8 +200,8 @@ public: /* ---------------------------------------------------------------------- */ /* ONE Host Methods */ - /* ---------------------------------------------------------------------- */ - + /* ---------------------------------------------------------------------- */ + /** * Gets system info from a single host ( "hid" ). * @param hid the host id to get for information @@ -212,7 +235,7 @@ public: * @param error if an error occurs this is the error message * @return -1 if an error occurs, 0 on success. */ - int host_disable(int hid, string& error) + int host_disable(int hid, string& error) { return host_available(hid,false,error); }; @@ -225,8 +248,8 @@ public: * @param error if an error occurs this is the error message * @return -1 if an error occurs, 0 on success. */ - int host_allocate(string& name, - string& im_mad, + int host_allocate(string& name, + string& im_mad, string& vmm_mad, int& hid, string& error); @@ -236,7 +259,7 @@ private: * URl - url to connect to ONE. */ string url; - + /** * Session - Client session id */ @@ -261,7 +284,7 @@ private: int host_available(int hid, bool enable, string& error); }; -extern "C" +extern "C" { void c_oneStart(); @@ -271,7 +294,7 @@ extern "C" int c_oneMigrate(int vmid, int hid, int flag); int c_oneAllocate(char* vm_template); - + int c_oneAllocateTemplate(char* vm_template); int c_oneAction(int vmid,char* action); @@ -283,7 +306,11 @@ extern "C" int c_oneStop(int vmid); int c_oneResume(int vmid); - + + int c_oneCancel(int vmid); + + int c_oneFinalize(int vmid); + int c_oneVmInfo(int vmid, char* ret_info,int leng); void c_oneFree(); diff --git a/src/client/OneClient_C_Wrapper.cc b/src/client/OneClient_C_Wrapper.cc index 8f21bef58a..995ca626c0 100644 --- a/src/client/OneClient_C_Wrapper.cc +++ b/src/client/OneClient_C_Wrapper.cc @@ -50,16 +50,16 @@ void c_oneFree() int c_oneDeploy(int vmid, int hid) { string info; - + if(!client) return -1; - + if(client->deploy(vmid,hid,info) <0) { cerr<migrate(vmid,hid,(bool)flag,info) <0) { cerr<allocate(template_file,vmid, info)) <0) { cerr<allocate_template(template_str,vmid, info)) <0) { cerr<shutdown(vmid,info) <0) { cerr<suspend(vmid,info) <0) { cerr<stop(vmid,info) <0) { cerr<resume(vmid,info) <0) { cerr<cancel(vmid,info) <0) + { + cerr<finalize(vmid,info) <0) + { + cerr<info(vmid,info,error) <0) { cerr<