【发布时间】:2019-04-23 04:08:13
【问题描述】:
我想通过Python API接口备份服务器上的VM,我通过ovirt-engine备份VM。如何使用 Ovirtsdk4 进行备份?
试了很多次,还是报错
import logging
import ovirtsdk4 as sdk
logging.basicConfig(level=logging.DEBUG, filename='example.log')
def get_connection():
# Create the connection to the server:
return sdk.Connection(
url='https://172.32.42.75/ovirt-engine/api',
username='admin@internal',
password='password',
ca_file='/etc/pki/ovirt-engine/ca.pem',
debug=True,
log=logging.getLogger(),
)
if __name__ == "__main__":
# Set VM name
vm_name = 'myvm'
# Create a connection to the server:
connection = get_connection()
# Get a reference to the root service:
system_service = connection.system_service()
# Get the reference to the "vms" service:
vms_service = system_service.vms_service()
# Locate VM service
try:
vm = vms_service.list(search="name=%s" % vm_name, all_content=True)[0]
ovf_filename = "%s.ovf" % vm.id
with open(ovf_filename, "wb") as ovf_file:
ovf_file.write(vm.initialization.configuration.data)
finally:
# Close the connection to the server:
connection.close()
我希望执行备份的虚拟机可以使用 Python API oVirt 正常运行。error of ovirtsdk4
【问题讨论】:
标签: python python-2.7