XML-RPC action question

Hi all,

I have a probably obvious question but I didn’t see this in the documentation.
I just want to be sure that I understand all right without bad assumptions, I want to know the rules :slight_smile:

So, I wanted to know after which XML-RPC actions I should make additional one.XXX.info call to be sure that the action has been executed with success.

Could I suppose that all actions creating/deleting something (one.vm.allocate, one.vm.delete, or one.vm.disksnapshotcreate, or one.vm.disksaveas …) should be followed by an info call to be sure that the action succeed, and the entity is created/deleted ?

For instance, when I take a snapshot with “one.vm.disksnapshotcreate” I have an immediate response and I see that the action is in progress, but I don’t have the final result.
It’s a kind of asynchronous stuff, I just now that the action is started, but it may fail, am I right ?

Is it still true for all actions launched by one.vm.action (like terminate-hard for instance) ?
In fact I just want to be sure that I know what I’m doing on every action I make.

But for commands like one.vm.chown, it’s fast to execute and with immediate result ?

Sorry if it’s obvious

Have a good day :slight_smile:

1 Like


When you make an xml-rpc request it should give a you a status back as per the docs


The response is shown in hex but it’s actually returned as the decimal equivalent

But this will only show you if the action has been completed , so a reboot would return success if the reboot action has been sent but doesn’t necessarily say mean the VM has finished rebooting .

It depends what you are using , I do all mine via JavaScript / Ajax to a php script to execute the curl against the xml-rpc server so for an action for example such as deploy I just loop around getting the current status wait 2 seconds then get the status wait 2 seconds for a maximum of 5 iterations for example .

If when I check the status in the loop it’s running i know it’s done and just show the user an Ajax loader for example while it’s looping, If by the end of it it is still pending for example I can prompt the user and ask if they want to continue waiting or not, if they don’t I return the current status e.g. rebooting , then the user can refresh manually.

I think the point is with the API you are just dumping a command to opennebula , it only tells you if it has started that command correctly and to get anything else back you will have to program manually.

It’s probably also worth looking at the VM lifecycle


Which is a pretty big doc but just shows how much there is to it.

There is also the lcm_state and previous_lcm_state aswell which you could program some logic against.

so for your example one.vm.snapshotcreate you receive in progress as it returns the current status after the action has been submitted , you would then in this case have to keep looping through checking the status and if it fails do something etc.

I would generally just check every action regardless so even for a chown or create user, check that the ownership is what you expect it to be.


Thank you for sharing your experience :slight_smile:

In fact I’m looking on how I could leverage the network traffic around some automated VM related code.
I see that I can’t remove some requests, so I will try to make smaller requests.

In what VM actions refers, if a VM state change is required an asynchronous action will be triggered to the LCM so you will need to do an info call for checking the status when the action finish.

In OpenNebula 5.10 we have introduced a new feature that could help to avoid the polling (one.*.info calls). You can find some info here: http://docs.opennebula.org/5.9/integration/infrastructure_integration/hook_manager_events.html

You can test this new feature in the RC, as it’s a new feature any new feature will be useful, so don’t hesitate to asks if there is something wrong!

I was aware of the hooks in their old version, and the fact that there would be updated soon, but I didn’t seen the doc of the new hooks, so thank you for pointing this. :slight_smile:
I’ll try this as soon as possible, when I’ll have a 5.9 version available.

Will it be possible to use the ZeroMQ socket from a external remote tool ? (there is some authentication … ? )

By the way, trying to reduce network traffic, I need to know if I’m doing things in the right way:

For instance, calling one.vm.info method to check the effect of an action on a VM is a bit heavy as I retrieve all the metadatas (with a lot that I don’t need).

Until now, I saw some VM with up to 90 Kib of metadata (with the command: sudo onevm show -x ID | wc -c)
It’s mainly due to history records, snapshots, template size with disk and nics … (so for a new VM it not so heavy, but anyway, it’s more than 10 Kib ).

To retrieve much less informations, I can call one.vmpool.info and one.vmpool.infoextended with a filter on a tag (I can see it for one.vmpool.info method with the command: sudo onevm list --search "ID=id" -x | wc -c)
For the VM stated above, I retrieve only 2Kib of informations !

So, depending on the information I need to retrieve, I’m able to retrieve 3 levels of informations using VM ID with one.vm.info, one.vmpool.info or one.vmpool.infoextended.
But I’m a bit surprised to have to call some vmpool methods to retrieve informations on only one VM. I feel like I’m doing something unexpected.

In addition, filtering on the ID for VM pool methods is not documented here (it’s possible with the NAME etc…): http://docs.opennebula.org/5.8/operation/vm_management/vm_instances.html#searching-vm-instances

It would be nice to have an info method (for a single VM) that allow to retrieve several level of informations, in passing some optional parameters to retrieve some “sections” I need: “history”, “monitoring”, “template” etc…
It’s just an example but it would be really nice :slight_smile:

For now I suppose that I could just use vmpool methods with filtering, if you confirm me that it’s expected to be able to filter by ID (as it’s not documented I’m not sure that it’s official).

Also, it would be nice to know how much does it stress the database if I make a lot of filtering on VM pools at once (if a lot of VM are deployed at the same times) ?

Will it be possible to use the ZeroMQ socket from a external remote tool ? (there is some authentication … ? )

Yes, that totally the idea, currently there is no authentication (we will implement that) so we suggest to configure the onehem server to listen locally or in a trusted network. You can find an example of a custom component using the Hook Manager Events here: https://opennebula.org/monitoring-opennebula-events-with-graphite-grafana/

Regarding the “info” methods currently there is no plan for changing that. As a tip, you already have a call for retrieving only the monitoring info: http://docs.opennebula.org/5.8/integration/system_interfaces/api.html#one-vm-monitoring

In addition, filtering on the ID for VM pool methods is not documented here (it’s possible with the NAME etc…)

This behavior is documented in the API documentation. But as you said it could be useful to add it to that section.

Hello @cgonzalez @ahuertas
I am working on XML-RPC methods and having following queries:

  1. one.vm.action method takes two parameters id and action, so how can we add scheduled action to it using XML-RPC call.
    CLI provides a command to do the same "onevm poweroff 0 --schedule “09/23 14:15” "
    How can we add scheduled time for action using API call?

  2. I want to update the running vm and add a custom var.
    one.vm.update method provides the field to update but I am not able to add a new custom vars(context=>custom vars)

Please suggest and guide on the above queries.
Looking for some solution approach as haven’t got much deep in any of the document for these queries.
Thanks in advance!!