import ovirtsdk4 as sdk
import ovirtsdk4.types as types
connection = sdk.Connection(
url='https://engine.example.com/ovirt-engine/api',
username='admin@internal',
password='password',
ca_file='ca.pem',
)
# 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='vm1',
memory = 512*1024*1024
cluster=types.Cluster(
name='Default',
),
template=types.Template(
name='Blank',
),
os=types.OperatingSystem(boot=types.Boot(devices=[types.BootDevice.HD)]
),
)
print("Virtual machine '%s' added." % vm.name)
# Close the connection to the server:
connection.close()
import ovirtsdk4 as sdk
import ovirtsdk4.types as types
connection = sdk.Connection(
url='https://engine.example.com/ovirt-engine/api',
username='admin@internal',
password='password',
ca_file='ca.pem',
)
# 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='vm1',
memory = 512*1024*1024
cluster=types.Cluster(
name='Default',
),
template=types.Template(
name='Blank',
),
os=types.OperatingSystem(boot=types.Boot(devices=[types.BootDevice.HD)]
),
)
print("Virtual machine '%s' added." % vm.name)
# Close the connection to the server:
connection.close()
Copy to ClipboardCopied!Toggle word wrapToggle overflow
如果 添加 请求成功,则输出文本的示例:
Virtual machine 'vm1' added.
Virtual machine 'vm1' added.
Copy to ClipboardCopied!Toggle word wrapToggle overflow