diff --git a/SConstruct b/SConstruct index 2045ab4f2f..917346a2fe 100644 --- a/SConstruct +++ b/SConstruct @@ -140,7 +140,6 @@ else: # SCONS scripts to build build_scripts=[ - 'src/client/SConstruct', 'src/sql/SConstruct', 'src/log/SConstruct', 'src/common/SConstruct', diff --git a/install.sh b/install.sh index 17b8fe2637..4b1ad07b31 100755 --- a/install.sh +++ b/install.sh @@ -251,10 +251,10 @@ INSTALL_ETC_FILES[17]="OCCI_ETC_TEMPLATE_FILES:$ETC_LOCATION/occi_templates" BIN_FILES="src/nebula/oned \ src/scheduler/src/sched/mm_sched \ - src/client/ruby/onevm \ - src/client/ruby/onehost \ - src/client/ruby/onevnet \ - src/client/ruby/oneuser \ + src/cli/onevm \ + src/cli/onehost \ + src/cli/onevnet \ + src/cli/oneuser \ share/scripts/one" #------------------------------------------------------------------------------- @@ -263,9 +263,8 @@ BIN_FILES="src/nebula/oned \ # Library files, to be installed under $LIB_LOCATION #------------------------------------------------------------------------------- -INCLUDE_FILES="include/OneClient.h" -LIB_FILES="src/client/liboneapi.a \ - src/client/liboneapi.so" +INCLUDE_FILES="" +LIB_FILES="" #------------------------------------------------------------------------------- # Ruby library files, to be installed under $LIB_LOCATION/ruby @@ -278,8 +277,8 @@ RUBY_LIB_FILES="src/mad/ruby/one_mad.rb \ src/mad/ruby/CommandManager.rb \ src/mad/ruby/OpenNebulaDriver.rb \ src/mad/ruby/VirtualMachineDriver.rb \ - src/client/ruby/client_utilities.rb \ - src/client/ruby/command_parse.rb \ + src/cli/client_utilities.rb \ + src/cli/command_parse.rb \ src/oca/ruby/OpenNebula.rb \ src/tm_mad/TMScript.rb" diff --git a/src/client/ruby/client_utilities.rb b/src/cli/client_utilities.rb similarity index 100% rename from src/client/ruby/client_utilities.rb rename to src/cli/client_utilities.rb diff --git a/src/client/ruby/command_parse.rb b/src/cli/command_parse.rb similarity index 100% rename from src/client/ruby/command_parse.rb rename to src/cli/command_parse.rb diff --git a/src/client/ruby/onehost b/src/cli/onehost similarity index 100% rename from src/client/ruby/onehost rename to src/cli/onehost diff --git a/src/client/ruby/oneuser b/src/cli/oneuser similarity index 100% rename from src/client/ruby/oneuser rename to src/cli/oneuser diff --git a/src/client/ruby/onevm b/src/cli/onevm similarity index 100% rename from src/client/ruby/onevm rename to src/cli/onevm diff --git a/src/client/ruby/onevnet b/src/cli/onevnet similarity index 100% rename from src/client/ruby/onevnet rename to src/cli/onevnet diff --git a/src/client/OneClient.cc b/src/client/OneClient.cc deleted file mode 100644 index 91097d0047..0000000000 --- a/src/client/OneClient.cc +++ /dev/null @@ -1,487 +0,0 @@ -/* -------------------------------------------------------------------------- */ -/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ -/* not use this file except in compliance with the License. You may obtain */ -/* a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ -/* See the License for the specific language governing permissions and */ -/* limitations under the License. */ -/* -------------------------------------------------------------------------- */ - -#include "OneClient.h" -#include -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -int OneClient::allocate(string template_file, int& vmid, string& error) -{ - - try{ - - string str_template=""; - ifstream file; - char c; - - file.open(template_file.c_str()); - - if ( file.good() == false ) - { - error = "Could not open file\n"; - return -1; - } - - file.get(c); - - while (file.good()) - { - str_template+=c; - file.get(c); - } - - file.close(); - - xmlrpc_c::value result; - - this->call(url, - "one.vmallocate", - "ss", - &result, - session.c_str(), - str_template.c_str()); - - xmlrpc_c::value_array resultArray = xmlrpc_c::value_array(result); - vector const - paramArrayValue(resultArray.vectorValueValue()); - - //check posible errors - xmlrpc_c::value_boolean const status(paramArrayValue[0]); - - if(static_cast(status) == true) - { - xmlrpc_c::value_int const _vmid (paramArrayValue[1]); - - vmid = static_cast(_vmid); - return 0; - } - else - { - xmlrpc_c::value_string const valueS(paramArrayValue[1]); - - error=static_cast(valueS); - return -1; - } - } - catch (std::exception const &e) - { - ostringstream oss; - oss << "XML-RPC Error: " << e.what() << endl; - - error=oss.str(); - return -1; - } -}; - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -int OneClient::allocate_template(const string& str_template, - int& vmid, - string& error) -{ - try{ - xmlrpc_c::value result; - - this->call(url, - "one.vmallocate", - "ss", - &result, - session.c_str(), - str_template.c_str()); - - xmlrpc_c::value_array resultArray = xmlrpc_c::value_array(result); - vector const - paramArrayValue(resultArray.vectorValueValue()); - - //check posible errors - xmlrpc_c::value_boolean const status(paramArrayValue[0]); - - if(static_cast(status) == true) - { - xmlrpc_c::value_int const _vmid (paramArrayValue[1]); - - vmid = static_cast(_vmid); - return 0; - } - else - { - xmlrpc_c::value_string const valueS(paramArrayValue[1]); - - error=static_cast(valueS); - return -1; - } - } - catch (std::exception const &e) - { - ostringstream oss; - oss << "XML-RPC Error: " << e.what() << endl; - - error=oss.str(); - return -1; - } -}; - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -int OneClient::deploy(int vmid, int hid, string& error) -{ - try { - xmlrpc_c::value result; - - this->call(url,"one.vmdeploy","sii", &result,session.c_str(),vmid,hid); - - xmlrpc_c::value_array resultArray = xmlrpc_c::value_array(result); - - vector const - paramArrayValue(resultArray.vectorValueValue()); - - //check posible errors - xmlrpc_c::value_boolean const status(paramArrayValue[0]); - - if(static_cast(status) == true) - { - return 0; - } - else - { - xmlrpc_c::value_string const valueS(paramArrayValue[1]); - - error=static_cast(valueS); - return -1; - } - } - catch (std::exception const &e) - { - ostringstream oss; - oss << "XML-RPC Error: " << e.what() << endl; - - error=oss.str(); - return -1; - } -}; - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -int OneClient::migrate(int vmid, int hid, bool live, string& error) -{ - try { - xmlrpc_c::value result; - - this->call(url, - "one.vmmigrate", - "siib", - &result, - session.c_str(), - vmid,hid,live); - - xmlrpc_c::value_array resultArray = xmlrpc_c::value_array(result); - vector const - paramArrayValue(resultArray.vectorValueValue()); - - //check posible errors - xmlrpc_c::value_boolean const status(paramArrayValue[0]); - - if(static_cast(status) == true) - { - return 0; - } - else - { - xmlrpc_c::value_string const valueS(paramArrayValue[1]); - - error=static_cast(valueS); - return -1; - } - } - catch (std::exception const &e) - { - ostringstream oss; - oss << "XML-RPC Error: " << e.what() << endl; - - error=oss.str(); - return -1; - } -} - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -int OneClient::action(int vmid, const char * action, string& error) -{ - try { - xmlrpc_c::value result; - - this->call(url, - "one.vmaction", - "ssi", - &result, - session.c_str(), - action, - vmid); - - xmlrpc_c::value_array resultArray = xmlrpc_c::value_array(result); - vector const - paramArrayValue(resultArray.vectorValueValue()); - - //check posible errors - xmlrpc_c::value_boolean const status(paramArrayValue[0]); - - if(static_cast(status) == true) - { - return 0; - } - else - { - xmlrpc_c::value_string const valueS(paramArrayValue[1]); - - error=static_cast(valueS); - return -1; - } - } - catch (std::exception const &e) - { - ostringstream oss; - oss << "XML-RPC Error: " << e.what() << endl; - - error=oss.str(); - return -1; - } -} - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -int OneClient::info(int vmid, string& info, string& error) -{ - try{ - xmlrpc_c::value result; - this->call(url,"one.vmget_info","si",&result,session.c_str(),vmid); - - xmlrpc_c::value_array resultArray = xmlrpc_c::value_array(result); - vector const - paramArrayValue(resultArray.vectorValueValue()); - - //check posible errors - xmlrpc_c::value_boolean const status(paramArrayValue[0]); - - xmlrpc_c::value_string const valueS(paramArrayValue[1]); - - if(static_cast(status) == true) - { - info = static_cast(valueS); - return 0; - } - else - { - error = static_cast(valueS); - return -1; - } - } - catch (std::exception const &e) - { - ostringstream oss; - oss << "XML-RPC Error: " << e.what() << endl; - - error=oss.str(); - return -1; - } -} - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -int OneClient::host_info(int hid, string& info, string& error) -{ - try{ - xmlrpc_c::value result; - this->call(url,"one.hostinfo","si",&result,session.c_str(),hid); - - xmlrpc_c::value_array resultArray = xmlrpc_c::value_array(result); - vector const - paramArrayValue(resultArray.vectorValueValue()); - - //check posible Errors: - xmlrpc_c::value_boolean const status(paramArrayValue[0]); - - xmlrpc_c::value_string const valueS (paramArrayValue[1]); - - if(static_cast(status) == true) - { - info = static_cast(valueS); - return 0; - } - else - { - error = static_cast(valueS); - return -1; - } - } - catch (std::exception const &e) - { - ostringstream oss; - oss << "XML-RPC Error: " << e.what() << endl; - - error=oss.str(); - return -1; - } -} - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -int OneClient::host_delete(int hid, string& error) -{ - try { - xmlrpc_c::value result; - this->call(url, "one.hostdelete", "si", &result,session.c_str(), hid); - - xmlrpc_c::value_array resultArray = xmlrpc_c::value_array(result); - vector const - paramArrayValue(resultArray.vectorValueValue()); - - //check posible errors - xmlrpc_c::value_boolean const status(paramArrayValue[0]); - - if(static_cast(status) == true) - { - return 0; - } - else - { - xmlrpc_c::value_string const valueS(paramArrayValue[1]); - - error=static_cast(valueS); - return -1; - } - } - catch (std::exception const &e) - { - ostringstream oss; - oss << "XML-RPC Error: " << e.what() << endl; - - error=oss.str(); - return -1; - } -} - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -int OneClient::host_available(int hid, bool enable, string& error) -{ - - try{ - xmlrpc_c::value result; - this->call(url, - "one.hostenable", - "sib", - &result, - session.c_str(), - hid, - enable); - - xmlrpc_c::value_array resultArray = xmlrpc_c::value_array(result); - vector const - paramArrayValue(resultArray.vectorValueValue()); - - //check posible errors - xmlrpc_c::value_boolean const status(paramArrayValue[0]); - - if(static_cast(status) == true) - { - return 0; - } - else - { - xmlrpc_c::value_string const valueS(paramArrayValue[1]); - - error=static_cast(valueS); - return -1; - } - } - catch (std::exception const &e) - { - ostringstream oss; - oss << "XML-RPC Error: " << e.what() << endl; - - error=oss.str(); - return -1; - } -} - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -int OneClient::host_allocate(string& name, - string& im_mad, - string& vmm_mad, - int& hid, - string& error) -{ - - try{ - xmlrpc_c::value result; - this->call(url, - "one.hostallocate", - "sssssb", - &result, - session.c_str(), - name.c_str(), - im_mad.c_str(), - vmm_mad.c_str(), - "tm_mad", - true); - - xmlrpc_c::value_array resultArray = xmlrpc_c::value_array(result); - vector const - paramArrayValue(resultArray.vectorValueValue()); - - //check posible errors: - xmlrpc_c::value_boolean const status(paramArrayValue[0]); - - if (static_cast(status) == true) - { - xmlrpc_c::value_int const valueI (paramArrayValue[1]); - - hid = static_cast(valueI); - return 0; - - } - else - { - xmlrpc_c::value_string const valueS = (paramArrayValue[1]); - - error=static_cast(valueS); - return -1; - } - } - catch (std::exception const &e) - { - ostringstream oss; - oss << "XML-RPC Error: " << e.what() << endl; - - error=oss.str(); - return -1; - } -} - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - diff --git a/src/client/OneClient_C_Wrapper.cc b/src/client/OneClient_C_Wrapper.cc deleted file mode 100644 index a8acc4a04a..0000000000 --- a/src/client/OneClient_C_Wrapper.cc +++ /dev/null @@ -1,263 +0,0 @@ -/* -------------------------------------------------------------------------- */ -/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ -/* not use this file except in compliance with the License. You may obtain */ -/* a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ -/* See the License for the specific language governing permissions and */ -/* limitations under the License. */ -/* -------------------------------------------------------------------------- */ - -#include "OneClient.h" -#include -#include -using namespace std; - -/* ************************************************************************** */ -#define ONED_PORT 60222 -OneClient* client=0; -/* ************************************************************************** */ - - -void c_oneStart() -{ -#ifdef ONED_PORT - client=new OneClient("localhost",ONED_PORT); -#else - client=new OneClient("localhost"); -#endif -}; - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -void c_oneFree() -{ - if(client) - delete client; -}; - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -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<