How does the CLI invoke core methods?

for instance in src/cli/onevm the vm.allocate(template,on_hold) -which is written in ruby- is called which I believe sends a command to the correct .cc file to execute the correct function with the correct parameters. so my question is which part of the code is responsible for this behavior? and how does it work?

and if you can be so kind please drop links to articles that shade some light onto that subject .

I have been searching for days for the answer to this question and couldn’t reach an answer on my own.

All help is much appreciated.

The CLI use the ruby binding for sending messages to oned service. It use an XMLRPC client used for sending request to the service.

The source files of the ruby bindings are available here: https://github.com/OpenNebula/one/tree/master/src/oca/ruby/opennebula

You can find some examples here: http://docs.opennebula.org/5.8/integration/system_interfaces/ruby.html

Also the XML-RPC API docs are available here: http://docs.opennebula.org/5.8/integration/system_interfaces/api.html

1 Like

I am searching to create a custom CLI command ,trying to write /create utility, under src/cli/ which is written in ruby.
so my question is which part is responsible for behavior and how CLI works? Does it call XML-RPC API with the CLI commands parameters as request to API call.
Please help sharing details on the flow or articles that would be relevant to subject.
@cgonzalez @ruben @ahuertas Team could help with same.
Thanks in Advance!

@vholer could you please help with the above issue?

I think you should just take one of the commands under src/cli/ and read through it to understand how it works. In general, the main executable src/cli/ (e.g., src/cli/onehost) defines all the subcommands and their parameters and does some of the small actions directly, or calls one the helper class from src/cli/one_helper/ (e.g., src/cli/one_helper/onehost_helper.rb) to do the job. It interacts with the OpenNebula over the XML-RPC via the Ruby OCA library (Ruby OpenNebula Cloud API — OpenNebula 6.0.3 documentation).

Best,
Vlastimil