如何修复“ovirtsdk4.Error:Error while sending HTTP request:”错误在oVi中

2024-06-16 14:59:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我想通过pythonapi接口备份服务器上的VM,并通过ovirt引擎备份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()

我希望执行备份的VM可以使用pythonapi oVirt正常运行。error of ovirtsdk4


Tags: thetonameserverloggingservicevm备份