blob: e1c4ff3feebbc2c744160fbad47ecde124b57fe5 (
plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
#!/usr/bin/python -u
#
# Those are the autogenerated Python bindings for libvirt.
# Check python/generator.py in the source distribution of libvir
# to find out more about the generation process
#
import libvirtmod
import types
# The root of all libvirt errors.
class libvirtError(Exception):
def __init__(self, msg, conn=None, dom=None, net=None):
Exception.__init__(self, msg)
if dom is not None:
conn = dom._conn
elif net is not None:
conn = net._conn
if conn is None:
self.err = virGetLastError()
else:
self.err = conn.virConnGetLastError()
def get_error_code(self):
if self.err is None:
return None
return self.err[0]
def get_error_domain(self):
if self.err is None:
return None
return self.err[1]
def get_error_message(self):
if self.err is None:
return None
return self.err[2]
def get_error_level(self):
if self.err is None:
return None
return self.err[3]
def get_str1(self):
if self.err is None:
return None
return self.err[4]
def get_str2(self):
if self.err is None:
return None
return self.err[5]
def get_str3(self):
if self.err is None:
return None
return self.err[6]
def get_int1(self):
if self.err is None:
return None
return self.err[7]
def get_int2(self):
if self.err is None:
return None
return self.err[8]
def __str__(self):
if self.get_error_message() is None:
return Exception.__str__(self)
else:
return Exception.__str__(self) + " " + self.get_error_message()
#
# register the libvirt global error handler
#
def registerErrorHandler(f, ctx):
"""Register a Python written function to for error reporting.
The function is called back as f(ctx, error), with error
being a list of informations about the error being raised.
Returns 1 in case of success."""
return libvirtmod.virRegisterErrorHandler(f,ctx)
# WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
#
# Everything before this line comes from libvir.py
# Everything after this line is automatically generated
#
# WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|