commiunication with opennebula 4.8 via python xmlrpc

740 views Asked by At

I'm trying to communicate with opennebula 4.8 via xmlrpc and python. Here is the code:

import xmlrpclib
import re
import hashlib

server = 'http://10.1.7.205:2633/RPC2'
user = "oneadmin"
password = "pass"
password = hashlib.sha1(password).hexdigest()
one_auth = '{0}:{1}'.format(user, password)

def getProxy():
    return xmlrpclib.ServerProxy(server)

def getVMInfo(id):
    response = getProxy().one.vm.info(one_auth,id)
    if response[0]:
        return response[1]
    else:
        raise Exception(response[1])

-->

Exception: [VirtualMachineInfo] User couldn't be authenticated, aborting call.

I have this example from the oca package , but its not working with new version of opennebula and the author don't work on this project anymore.

1

There are 1 answers

0
Ting-jen Yen On

I had a similar problem, though I am using OpenNebula 4.0.1, using PHP. It seems that somehow the password in the authenticated string is no long hashed. (It was using hashed password in OpenNebula 3.0 when I wrote my old code.) You may try to remove the line using sha1 hash function, and try again.

It does not look very secure this way. One the other hand, if somebody gets your code already, and he/she/it can go on to do anything OpenNebula APIs provide, hashed or not should not make much difference.