forked from RedHatQE/openshift-python-wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvirtual_machine.py
More file actions
36 lines (33 loc) · 967 Bytes
/
virtual_machine.py
File metadata and controls
36 lines (33 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from ocp_resources.resource import get_client
from ocp_resources.virtual_machine import VirtualMachine
client = get_client()
# Define a VM
vm = VirtualMachine(
client=client,
name="vm-example",
namespace="namespace-example",
body={
"spec": {
"runStrategy": "Halted",
"template": {
"spec": {
"domain": {
"devices": {"disks": [{"name": "disk0", "disk": {"bus": "virtio"}}]},
"resources": {"requests": {"memory": "64Mi"}},
},
"volumes": [
{
"name": "disk0",
"containerDisk": {"image": "kubevirt/cirros-container-disk-demo"},
}
],
},
},
}
},
)
# VM operations
vm.create()
vm.start()
vm.vmi.wait_until_running(timeout=180)
vm.stop()