가상 머신 생성은 여러 단계로 수행됩니다. 여기에서 다루는 첫 번째 단계는 가상 머신 오브젝트 자체를 생성하는 것입니다.
예 3.11. 가상 머신 생성
이 예제에서는 다음 요구 사항이 있는 가상 머신 vm1 을 생성합니다.
바이트로 표시된 512MB의 메모리입니다.
Default 클러스터에 연결되므로 Default 데이터 센터에 연결합니다.
기본 Blank 템플릿 기반.
가상 하드 디스크 드라이브에서 부팅됩니다.
V4
V4에서는 add 메서드를 사용하여 옵션이 유형 로서 추가됩니다.
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