How and where opennebula stores the information about Opennebula sunstone server. How it will assign the virtual machine id next to the last created vm. What logic it uses?

I want to know how opennebula assigns new virtual machine id. How it stores the virtual machine information. Where is all information about image, template, user and cluster pool history is stored. Can it be accessed via XML-RPC?