3.18. 가상 머신 시작

가상 머신을 시작할 수 있습니다.

예 3.16. 가상 머신 시작

이 예제에서는 시작 방법을 사용하여 가상 시스템을 시작합니다.

V4

import time
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()

# Find the virtual machine:
vm = vms_service.list(search='name=vm1')[0]

# Locate the service that manages the virtual machine, as that is where
# the action methods are defined:
vm_service = vms_service.vm_service(vm.id)

# Call the "start" method of the service to start it:
vm_service.start()

# Wait until the virtual machine is up:
while True:
    time.sleep(5)
    vm = vm_service.get()
    if vm.status == types.VmStatus.UP:
        break

print("Started '%s'." % vm.name())

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

시작 요청이 성공하면 예제에 텍스트가 출력됩니다.

Started 'vm1'.

UP 상태는 가상 머신이 실행 중임을 나타냅니다.