def __init__(self, maintain=True, save_conf=False): # TODO: Reset maintain to false # Connect to libvirt. if no connection can be made, sys.exit(1) # Other methods depend on the initial connection try: self.libvirt_conn = libvirt.open('qemu:///system') except: libvirt.virGetLastError() sys.exit(1) self.csr_amount = 4 self.iou_amount = 2 self.maintain = maintain self.save_conf = save_conf self.domain_list = self.libvirt_conn.listAllDomains(0) self.golden_image_path = r"/home/siem/development/build_tutorial/golden_image.qcow2" # TODO: make path variable, set image directory in ENV
def _report_libvirt_error(self): """Call virGetLastError function to get the last error information.""" err = libvirt.virGetLastError() if err[0] == 42: LOG.info("Running VSA VM not found on the host") else: LOG.error(" %s " % str(err[2])) raise vsa_excs.VsaStatusFailed()
def worker(): try: self.connection = libvirt.open(uri) self.last_error = None except libvirtError as e: self.last_error = 'Connection Failed: ' + str(e) + ' --- ' + repr(libvirt.virGetLastError()) self.connection = None return
def __connect_ssh(self): uri = 'qemu+ssh://%s@%s/system' % (self.login, self.host) try: self.connection = libvirt.open(uri) self.last_error = None except libvirtError as e: self.last_error = 'Connection Failed: ' + str(e) + ' --- ' + repr(libvirt.virGetLastError()) self.connection = None
def __connect_ssh(self): uri = "qemu+ssh://%s@%s/system" % (self.login, self.host) try: self.connection = libvirt.open(uri) self.last_error = None except libvirtError as e: self.last_error = f"Connection Failed: {str(e)} --- " + repr(libvirt.virGetLastError()) self.connection = None
def __connect_ssh(self): uri = '%s+ssh://%s@%s%s' % (self.hypervisor, self.login, self.host, self.path) try: self.connection = libvirt.open(uri) self.last_error = None except libvirtError as e: self.last_error = 'Connection Failed: ' + str(e) + ' --- ' + repr(libvirt.virGetLastError()) self.connection = None
def migrate_background( domain, source, destination, migrate_params, migrate_flags, ): # As it seems it is possible to call multiple functions in parallel # from different threads. try: domain.migrateToURI3( MIGRATE_CONFIG.get((source.dataset_obj['os'], destination.dataset_obj['os']))['uri'].format( destination=destination.fqdn), migrate_params, migrate_flags, ) except libvirtError as e: if virGetLastError()[0] == VIR_ERR_OPERATION_ABORTED: raise MigrationAborted('Migration aborted by user') raise MigrationError(e)
def report_libvirt_error(): """Call virGetLastError function to get the last error information.""" err = libvirt.virGetLastError() print('Error code: '+str(err[0]), file=sys.stderr) print('Error domain: '+str(err[1]), file=sys.stderr) print('Error message: '+err[2], file=sys.stderr) print('Error level: '+str(err[3]), file=sys.stderr) if err[4] != None: print('Error string1: '+err[4], file=sys.stderr) else: print('Error string1:', file=sys.stderr) if err[5] != None: print('Error string2: '+err[5], file=sys.stderr) else: print('Error string2:', file=sys.stderr) if err[6] != None: print('Error string3: '+err[6], file=sys.stderr) else: print('Error string3:', file=sys.stderr) print('Error int1: '+str(err[7]), file=sys.stderr) print('Error int2: '+str(err[8]), file=sys.stderr) exit(1)