2016-08-04 2 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() 
Смежные вопросы