2016-08-04 58 views

回答

0

這應該在Python SDK版本4爲你工作:

import logging 

import ovirtsdk4 as sdk 
import ovirtsdk4.types as types 

logging.basicConfig(level=logging.DEBUG, filename='example.log') 

# This example will connect to the server and create a new virtual machine with specific quota: 

# Create the connection to the server: 
connection = sdk.Connection(
    url='https://engine40.example.com/ovirt-engine/api', 
    username='[email protected]', 
    password='123', 
    ca_file='ca.pem', 
    debug=True, 
    log=logging.getLogger(), 
) 

# Get the reference to the "vms" service: 
vms_service = connection.system_service().vms_service() 

# Use the "add" method to create a new virtual machine: 
vms_service.add(
    types.Vm(
     name='myvm', 
     cluster=types.Cluster(
      name='mycluster', 
     ), 
     template=types.Template(
      name='Blank', 
     ), 
     quota=types.Quota(
      id='8ed65137-1260-4ac1-bd67-c399cca2d75d', 
     ), 
    ), 
) 

# Close the connection to the server: 
connection.close()