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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391
|
#!/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
#
# On cygwin, the DLL is called cygvirtmod.dll
try:
import libvirtmod
except:
import cygvirtmod as libvirtmod
import types
# The root of all libvirt errors.
class libvirtError(Exception):
def __init__(self, defmsg, conn=None, dom=None, net=None, pool=None, vol=None):
if dom is not None:
conn = dom._conn
elif net is not None:
conn = net._conn
elif pool is not None:
conn = pool._conn
elif vol is not None:
conn = vol._conn
if conn is None:
err = virGetLastError()
else:
err = conn.virConnGetLastError()
if err is None:
msg = defmsg
else:
msg = err[2]
Exception.__init__(self, msg)
self.err = err
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]
#
# 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 information about the error being raised.
Returns 1 in case of success."""
return libvirtmod.virRegisterErrorHandler(f,ctx)
def openAuth(uri, auth, flags):
ret = libvirtmod.virConnectOpenAuth(uri, auth, flags)
if ret is None:raise libvirtError('virConnectOpenAuth() failed')
return virConnect(_obj=ret)
#
# Return library version.
#
def getVersion (name = None):
"""If no name parameter is passed (or name is None) then the
version of the libvirt library is returned as an integer.
If a name is passed and it refers to a driver linked to the
libvirt library, then this returns a tuple of (library version,
driver version).
If the name passed refers to a non-existent driver, then you
will get the exception 'no support for hypervisor'.
Versions numbers are integers: 1000000*major + 1000*minor + release."""
if name is None:
ret = libvirtmod.virGetVersion ();
else:
ret = libvirtmod.virGetVersion (name);
if ret is None: raise libvirtError ("virGetVersion() failed")
return ret
# 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
#
# Functions from module libvirt
#
def open(name):
"""This function should be called first to get a connection to
the Hypervisor and xen store """
ret = libvirtmod.virConnectOpen(name)
if ret is None:raise libvirtError('virConnectOpen() failed')
return virConnect(_obj=ret)
def openReadOnly(name):
"""This function should be called first to get a restricted
connection to the library functionalities. The set of APIs
usable are then restricted on the available methods to
control the domains. """
ret = libvirtmod.virConnectOpenReadOnly(name)
if ret is None:raise libvirtError('virConnectOpenReadOnly() failed')
return virConnect(_obj=ret)
def virInitialize():
"""Initialize the library. It's better to call this routine at
startup in multithreaded applications to avoid potential
race when initializing the library. """
ret = libvirtmod.virInitialize()
if ret == -1: raise libvirtError ('virInitialize() failed')
return ret
#
# Functions from module virterror
#
def virGetLastError():
"""Provide a pointer to the last error caught at the library
level Simpler but may not be suitable for multithreaded
accesses, in which case use virCopyLastError() """
ret = libvirtmod.virGetLastError()
return ret
def virResetLastError():
"""Reset the last error caught at the library level. """
libvirtmod.virResetLastError()
class virDomain:
def __init__(self, conn, _obj=None):
self._conn = conn
if _obj != None:self._o = _obj;return
self._o = None
def __del__(self):
if self._o != None:
libvirtmod.virDomainFree(self._o)
self._o = None
#
# virDomain functions from module libvirt
#
def ID(self):
"""Get the hypervisor ID number for the domain """
ret = libvirtmod.virDomainGetID(self._o)
return ret
def OSType(self):
"""Get the type of domain operation system. """
ret = libvirtmod.virDomainGetOSType(self._o)
if ret is None: raise libvirtError ('virDomainGetOSType() failed', dom=self)
return ret
def XMLDesc(self, flags):
"""Provide an XML description of the domain. The description
may be reused later to relaunch the domain with
virDomainCreateLinux(). """
ret = libvirtmod.virDomainGetXMLDesc(self._o, flags)
if ret is None: raise libvirtError ('virDomainGetXMLDesc() failed', dom=self)
return ret
def attachDevice(self, xml):
"""Create a virtual device attachment to backend. """
ret = libvirtmod.virDomainAttachDevice(self._o, xml)
if ret == -1: raise libvirtError ('virDomainAttachDevice() failed', dom=self)
return ret
def blockPeek(self, path, offset, size, buffer, flags):
"""This function allows you to read the contents of a domain's
disk device. Typical uses for this are to determine if the
domain has written a Master Boot Record (indicating that
the domain has completed installation), or to try to work
out the state of the domain's filesystems. (Note that in
the local case you might try to open the block device or
file directly, but that won't work in the remote case, nor
if you don't have sufficient permission. Hence the need for
this call). 'path' must be a device or file corresponding
to the domain. In other words it must be the precise string
returned in a <disk><source dev='...'/></disk> from
virDomainGetXMLDesc. 'offset' and 'size' represent an area
which must lie entirely within the device or file. 'size'
may be 0 to test if the call would succeed. 'buffer' is
the return buffer and must be at least 'size' bytes. NB.
The remote driver imposes a 64K byte limit on 'size'. For
your program to be able to work reliably over a remote
connection you should split large requests to <= 65536
bytes. """
ret = libvirtmod.virDomainBlockPeek(self._o, path, offset, size, buffer, flags)
if ret == -1: raise libvirtError ('virDomainBlockPeek() failed', dom=self)
return ret
def connect(self):
"""Provides the connection pointer associated with a domain.
The reference counter on the connection is not increased by
this call. WARNING: When writing libvirt bindings in other
languages, do not use this function. Instead, store the
connection and the domain object together. """
ret = libvirtmod.virDomainGetConnect(self._o)
if ret is None:raise libvirtError('virDomainGetConnect() failed', dom=self)
__tmp = virConnect(_obj=ret)
return __tmp
def coreDump(self, to, flags):
"""This method will dump the core of a domain on a given file
for analysis. Note that for remote Xen Daemon the file path
will be interpreted in the remote host. """
ret = libvirtmod.virDomainCoreDump(self._o, to, flags)
if ret == -1: raise libvirtError ('virDomainCoreDump() failed', dom=self)
return ret
def create(self):
"""launch a defined domain. If the call succeed the domain
moves from the defined to the running domains pools. """
ret = libvirtmod.virDomainCreate(self._o)
if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self)
return ret
def destroy(self):
"""Destroy the domain object. The running instance is shutdown
if not down already and all resources used by it are given
back to the hypervisor. This does not free the associated
virDomainPtr object. This function may require privileged
access """
ret = libvirtmod.virDomainDestroy(self._o)
if ret == -1: raise libvirtError ('virDomainDestroy() failed', dom=self)
return ret
def detachDevice(self, xml):
"""Destroy a virtual device attachment to backend. """
ret = libvirtmod.virDomainDetachDevice(self._o, xml)
if ret == -1: raise libvirtError ('virDomainDetachDevice() failed', dom=self)
return ret
def maxMemory(self):
"""Retrieve the maximum amount of physical memory allocated to
a domain. If domain is None, then this get the amount of
memory reserved to Domain0 i.e. the domain where the
application runs. """
ret = libvirtmod.virDomainGetMaxMemory(self._o)
if ret == 0: raise libvirtError ('virDomainGetMaxMemory() failed', dom=self)
return ret
def maxVcpus(self):
"""Provides the maximum number of virtual CPUs supported for
the guest VM. If the guest is inactive, this is basically
the same as virConnectGetMaxVcpus. If the guest is running
this will reflect the maximum number of virtual CPUs the
guest was booted with. """
ret = libvirtmod.virDomainGetMaxVcpus(self._o)
if ret == -1: raise libvirtError ('virDomainGetMaxVcpus() failed', dom=self)
return ret
def memoryPeek(self, start, size, buffer, flags):
"""This function allows you to read the contents of a domain's
memory. The memory which is read is controlled by the
'start', 'size' and 'flags' parameters. If 'flags' is
VIR_MEMORY_VIRTUAL then the 'start' and 'size' parameters
are interpreted as virtual memory addresses for whichever
task happens to be running on the domain at the moment.
Although this sounds haphazard it is in fact what you want
in order to read Linux kernel state, because it ensures
that pointers in the kernel image can be interpreted
coherently. 'buffer' is the return buffer and must be at
least 'size' bytes. 'size' may be 0 to test if the call
would succeed. NB. The remote driver imposes a 64K byte
limit on 'size'. For your program to be able to work
reliably over a remote connection you should split large
requests to <= 65536 bytes. """
ret = libvirtmod.virDomainMemoryPeek(self._o, start, size, buffer, flags)
if ret == -1: raise libvirtError ('virDomainMemoryPeek() failed', dom=self)
return ret
def migrate(self, dconn, flags, dname, uri, bandwidth):
"""Migrate the domain object from its current host to the
destination host given by dconn (a connection to the
destination host). Flags may be one of more of the
following: VIR_MIGRATE_LIVE Attempt a live migration. If
a hypervisor supports renaming domains during migration,
then you may set the dname parameter to the new name
(otherwise it keeps the same name). If this is not
supported by the hypervisor, dname must be None or else you
will get an error. Since typically the two hypervisors
connect directly to each other in order to perform the
migration, you may need to specify a path from the source
to the destination. This is the purpose of the uri
parameter. If uri is None, then libvirt will try to find
the best method. Uri may specify the hostname or IP
address of the destination host as seen from the source.
Or uri may be a URI giving transport, hostname, user, port,
etc. in the usual form. Refer to driver documentation for
the particular URIs supported. The maximum bandwidth (in
Mbps) that will be used to do migration can be specified
with the bandwidth parameter. If set to 0, libvirt will
choose a suitable default. Some hypervisors do not support
this feature and will return an error if bandwidth is not
0. To see which features are supported by the current
hypervisor, see virConnectGetCapabilities,
/capabilities/host/migration_features. There are many
limitations on migration imposed by the underlying
technology - for example it may not be possible to migrate
between different processors even with the same
architecture, or between different types of hypervisor. """
if dconn is None: dconn__o = None
else: dconn__o = dconn._o
ret = libvirtmod.virDomainMigrate(self._o, dconn__o, flags, dname, uri, bandwidth)
if ret is None:raise libvirtError('virDomainMigrate() failed', dom=self)
__tmp = virDomain(self,_obj=ret)
return __tmp
def name(self):
"""Get the public name for that domain """
ret = libvirtmod.virDomainGetName(self._o)
return ret
def reboot(self, flags):
"""Reboot a domain, the domain object is still usable there
after but the domain OS is being stopped for a restart.
Note that the guest OS may ignore the request. """
ret = libvirtmod.virDomainReboot(self._o, flags)
if ret == -1: raise libvirtError ('virDomainReboot() failed', dom=self)
return ret
def resume(self):
"""Resume an suspended domain, the process is restarted from
the state where it was frozen by calling
virSuspendDomain(). This function may requires privileged
access """
ret = libvirtmod.virDomainResume(self._o)
if ret == -1: raise libvirtError ('virDomainResume() failed', dom=self)
return ret
def save(self, to):
"""This method will suspend a domain and save its memory
contents to a file on disk. After the call, if successful,
the domain is not listed as running anymore (this may be a
problem). Use virDomainRestore() to restore a domain after
saving. """
ret = libvirtmod.virDomainSave(self._o, to)
if ret == -1: raise libvirtError ('virDomainSave() failed', dom=self)
return ret
def setAutostart(self, autostart):
"""Configure the domain to be automatically started when the
host machine boots. """
ret = libvirtmod.virDomainSetAutostart(self._o, autostart)
if ret == -1: raise libvirtError ('virDomainSetAutostart() failed', dom=self)
return ret
def setMaxMemory(self, memory):
"""Dynamically change the maximum amount of physical memory
allocated to a domain. If domain is None, then this change
the amount of memory reserved to Domain0 i.e. the domain
where the application runs. This function requires
privileged access to the hypervisor. """
ret = libvirtmod.virDomainSetMaxMemory(self._o, memory)
if ret == -1: raise libvirtError ('virDomainSetMaxMemory() failed', dom=self)
return ret
def setMemory(self, memory):
"""Dynamically change the target amount of physical memory
allocated to a domain. If domain is None, then this change
the amount of memory reserved to Domain0 i.e. the domain
where the application runs. This function may requires
privileged access to the hypervisor. """
ret = libvirtmod.virDomainSetMemory(self._o, memory)
if ret == -1: raise libvirtError ('virDomainSetMemory() failed', dom=self)
return ret
def setVcpus(self, nvcpus):
"""Dynamically change the number of virtual CPUs used by the
domain. Note that this call may fail if the underlying
virtualization hypervisor does not support it or if growing
the number is arbitrary limited. This function requires
privileged access to the hypervisor. """
ret = libvirtmod.virDomainSetVcpus(self._o, nvcpus)
if ret == -1: raise libvirtError ('virDomainSetVcpus() failed', dom=self)
return ret
def shutdown(self):
"""Shutdown a domain, the domain object is still usable there
after but the domain OS is being stopped. Note that the
guest OS may ignore the request. TODO: should we add an
option for reboot, knowing it may not be doable in the
general case ? """
ret = libvirtmod.virDomainShutdown(self._o)
if ret == -1: raise libvirtError ('virDomainShutdown() failed', dom=self)
return ret
def suspend(self):
"""Suspends an active domain, the process is frozen without
further access to CPU resources and I/O but the memory used
by the domain at the hypervisor level will stay allocated.
Use virDomainResume() to reactivate the domain. This
function may requires privileged access. """
ret = libvirtmod.virDomainSuspend(self._o)
if ret == -1: raise libvirtError ('virDomainSuspend() failed', dom=self)
return ret
def undefine(self):
"""Undefine a domain but does not stop it if it is running """
ret = libvirtmod.virDomainUndefine(self._o)
if ret == -1: raise libvirtError ('virDomainUndefine() failed', dom=self)
return ret
#
# virDomain functions from module python
#
def UUID(self):
"""Extract the UUID unique Identifier of a domain. """
ret = libvirtmod.virDomainGetUUID(self._o)
if ret is None: raise libvirtError ('virDomainGetUUID() failed', dom=self)
return ret
def UUIDString(self):
"""Fetch globally unique ID of the domain as a string. """
ret = libvirtmod.virDomainGetUUIDString(self._o)
if ret is None: raise libvirtError ('virDomainGetUUIDString() failed', dom=self)
return ret
def autostart(self):
"""Extract the autostart flag for a domain """
ret = libvirtmod.virDomainGetAutostart(self._o)
if ret == -1: raise libvirtError ('virDomainGetAutostart() failed', dom=self)
return ret
def blockStats(self, path):
"""Extracts block device statistics for a domain """
ret = libvirtmod.virDomainBlockStats(self._o, path)
return ret
def info(self):
"""Extract information about a domain. Note that if the
connection used to get the domain is limited only a partial
set of the information can be extracted. """
ret = libvirtmod.virDomainGetInfo(self._o)
if ret is None: raise libvirtError ('virDomainGetInfo() failed', dom=self)
return ret
def interfaceStats(self, path):
"""Extracts interface device statistics for a domain """
ret = libvirtmod.virDomainInterfaceStats(self._o, path)
return ret
def pinVcpu(self, vcpu, cpumap):
"""Dynamically change the real CPUs which can be allocated to
a virtual CPU. This function requires privileged access to
the hypervisor. """
ret = libvirtmod.virDomainPinVcpu(self._o, vcpu, cpumap)
if ret == -1: raise libvirtError ('virDomainPinVcpu() failed', dom=self)
return ret
def schedulerParameters(self):
"""Get the scheduler parameters, the @params array will be
filled with the values. """
ret = libvirtmod.virDomainGetSchedulerParameters(self._o)
if ret == -1: raise libvirtError ('virDomainGetSchedulerParameters() failed', dom=self)
return ret
def schedulerType(self):
"""Get the scheduler type. """
ret = libvirtmod.virDomainGetSchedulerType(self._o)
if ret is None: raise libvirtError ('virDomainGetSchedulerType() failed', dom=self)
return ret
def setSchedulerParameters(self, params):
"""Change the scheduler parameters """
ret = libvirtmod.virDomainSetSchedulerParameters(self._o, params)
if ret == -1: raise libvirtError ('virDomainSetSchedulerParameters() failed', dom=self)
return ret
def vcpus(self):
"""Extract information about virtual CPUs of domain, store it
in info array and also in cpumaps if this pointer is'nt
None. """
ret = libvirtmod.virDomainGetVcpus(self._o)
if ret == -1: raise libvirtError ('virDomainGetVcpus() failed', dom=self)
return ret
class virNetwork:
def __init__(self, conn, _obj=None):
self._conn = conn
if _obj != None:self._o = _obj;return
self._o = None
def __del__(self):
if self._o != None:
libvirtmod.virNetworkFree(self._o)
self._o = None
#
# virNetwork functions from module libvirt
#
def XMLDesc(self, flags):
"""Provide an XML description of the network. The description
may be reused later to relaunch the network with
virNetworkCreateXML(). """
ret = libvirtmod.virNetworkGetXMLDesc(self._o, flags)
if ret is None: raise libvirtError ('virNetworkGetXMLDesc() failed', net=self)
return ret
def bridgeName(self):
"""Provides a bridge interface name to which a domain may
connect a network interface in order to join the network. """
ret = libvirtmod.virNetworkGetBridgeName(self._o)
if ret is None: raise libvirtError ('virNetworkGetBridgeName() failed', net=self)
return ret
def connect(self):
"""Provides the connection pointer associated with a network.
The reference counter on the connection is not increased by
this call. WARNING: When writing libvirt bindings in other
languages, do not use this function. Instead, store the
connection and the network object together. """
ret = libvirtmod.virNetworkGetConnect(self._o)
if ret is None:raise libvirtError('virNetworkGetConnect() failed', net=self)
__tmp = virConnect(_obj=ret)
return __tmp
def create(self):
"""Create and start a defined network. If the call succeed the
network moves from the defined to the running networks
pools. """
ret = libvirtmod.virNetworkCreate(self._o)
if ret == -1: raise libvirtError ('virNetworkCreate() failed', net=self)
return ret
def destroy(self):
"""Destroy the network object. The running instance is
shutdown if not down already and all resources used by it
are given back to the hypervisor. This does not free the
associated virNetworkPtr object. This function may require
privileged access """
ret = libvirtmod.virNetworkDestroy(self._o)
if ret == -1: raise libvirtError ('virNetworkDestroy() failed', net=self)
return ret
def name(self):
"""Get the public name for that network """
ret = libvirtmod.virNetworkGetName(self._o)
return ret
def setAutostart(self, autostart):
"""Configure the network to be automatically started when the
host machine boots. """
ret = libvirtmod.virNetworkSetAutostart(self._o, autostart)
if ret == -1: raise libvirtError ('virNetworkSetAutostart() failed', net=self)
return ret
def undefine(self):
"""Undefine a network but does not stop it if it is running """
ret = libvirtmod.virNetworkUndefine(self._o)
if ret == -1: raise libvirtError ('virNetworkUndefine() failed', net=self)
return ret
#
# virNetwork functions from module python
#
def UUID(self):
"""Extract the UUID unique Identifier of a network. """
ret = libvirtmod.virNetworkGetUUID(self._o)
if ret is None: raise libvirtError ('virNetworkGetUUID() failed', net=self)
return ret
def UUIDString(self):
"""Fetch globally unique ID of the network as a string. """
ret = libvirtmod.virNetworkGetUUIDString(self._o)
if ret is None: raise libvirtError ('virNetworkGetUUIDString() failed', net=self)
return ret
def autostart(self):
"""Extract the autostart flag for a network. """
ret = libvirtmod.virNetworkGetAutostart(self._o)
if ret == -1: raise libvirtError ('virNetworkGetAutostart() failed', net=self)
return ret
def networkLookupByUUID(self, uuid):
"""Try to lookup a network on the given hypervisor based on
its UUID. """
ret = libvirtmod.virNetworkLookupByUUID(self._o, uuid)
if ret is None:raise libvirtError('virNetworkLookupByUUID() failed', net=self)
__tmp = virNetwork(self, _obj=ret)
return __tmp
class virStoragePool:
def __init__(self, conn, _obj=None):
self._conn = conn
if not isinstance(conn, virConnect):
self._conn = conn._conn
if _obj != None:self._o = _obj;return
self._o = None
def __del__(self):
if self._o != None:
libvirtmod.virStoragePoolFree(self._o)
self._o = None
#
# virStoragePool functions from module libvirt
#
def XMLDesc(self, flags):
"""Fetch an XML document describing all aspects of the storage
pool. This is suitable for later feeding back into the
virStoragePoolCreateXML method. """
ret = libvirtmod.virStoragePoolGetXMLDesc(self._o, flags)
if ret is None: raise libvirtError ('virStoragePoolGetXMLDesc() failed', pool=self)
return ret
def build(self, flags):
"""Build the underlying storage pool """
ret = libvirtmod.virStoragePoolBuild(self._o, flags)
if ret == -1: raise libvirtError ('virStoragePoolBuild() failed', pool=self)
return ret
def connect(self):
"""Provides the connection pointer associated with a storage
pool. The reference counter on the connection is not
increased by this call. WARNING: When writing libvirt
bindings in other languages, do not use this function.
Instead, store the connection and the pool object together. """
ret = libvirtmod.virStoragePoolGetConnect(self._o)
if ret is None:raise libvirtError('virStoragePoolGetConnect() failed', pool=self)
__tmp = virConnect(_obj=ret)
return __tmp
def create(self, flags):
"""Starts an inactive storage pool """
ret = libvirtmod.virStoragePoolCreate(self._o, flags)
if ret == -1: raise libvirtError ('virStoragePoolCreate() failed', pool=self)
return ret
def createXML(self, xmldesc, flags):
"""Create a storage volume within a pool based on an XML
description. Not all pools support creation of volumes """
ret = libvirtmod.virStorageVolCreateXML(self._o, xmldesc, flags)
if ret is None:raise libvirtError('virStorageVolCreateXML() failed', pool=self)
__tmp = virStorageVol(self, _obj=ret)
return __tmp
def delete(self, flags):
"""Delete the underlying pool resources. This is a
non-recoverable operation. The virStoragePoolPtr object
itself is not free'd. """
ret = libvirtmod.virStoragePoolDelete(self._o, flags)
if ret == -1: raise libvirtError ('virStoragePoolDelete() failed', pool=self)
return ret
def destroy(self):
"""Destroy an active storage pool. This will deactivate the
pool on the host, but keep any persistent config associated
with it. If it has a persistent config it can later be
restarted with virStoragePoolCreate(). This does not free
the associated virStoragePoolPtr object. """
ret = libvirtmod.virStoragePoolDestroy(self._o)
if ret == -1: raise libvirtError ('virStoragePoolDestroy() failed', pool=self)
return ret
def name(self):
"""Fetch the locally unique name of the storage pool """
ret = libvirtmod.virStoragePoolGetName(self._o)
return ret
def numOfVolumes(self):
"""Fetch the number of storage volumes within a pool """
ret = libvirtmod.virStoragePoolNumOfVolumes(self._o)
if ret == -1: raise libvirtError ('virStoragePoolNumOfVolumes() failed', pool=self)
return ret
def refresh(self, flags):
"""Request that the pool refresh its list of volumes. This may
involve communicating with a remote server, and/or
initializing new devices at the OS layer """
ret = libvirtmod.virStoragePoolRefresh(self._o, flags)
if ret == -1: raise libvirtError ('virStoragePoolRefresh() failed', pool=self)
return ret
def setAutostart(self, autostart):
"""Sets the autostart flag """
ret = libvirtmod.virStoragePoolSetAutostart(self._o, autostart)
if ret == -1: raise libvirtError ('virStoragePoolSetAutostart() failed', pool=self)
return ret
def storageVolLookupByName(self, name):
"""Fetch a pointer to a storage volume based on its name
within a pool """
ret = libvirtmod.virStorageVolLookupByName(self._o, name)
if ret is None:raise libvirtError('virStorageVolLookupByName() failed', pool=self)
__tmp = virStorageVol(self, _obj=ret)
return __tmp
def undefine(self):
"""Undefine an inactive storage pool """
ret = libvirtmod.virStoragePoolUndefine(self._o)
if ret == -1: raise libvirtError ('virStoragePoolUndefine() failed', pool=self)
return ret
#
# virStoragePool functions from module python
#
def UUID(self):
"""Extract the UUID unique Identifier of a storage pool. """
ret = libvirtmod.virStoragePoolGetUUID(self._o)
if ret is None: raise libvirtError ('virStoragePoolGetUUID() failed', pool=self)
return ret
def UUIDString(self):
"""Fetch globally unique ID of the storage pool as a string. """
ret = libvirtmod.virStoragePoolGetUUIDString(self._o)
if ret is None: raise libvirtError ('virStoragePoolGetUUIDString() failed', pool=self)
return ret
def autostart(self):
"""Extract the autostart flag for a storage pool """
ret = libvirtmod.virStoragePoolGetAutostart(self._o)
if ret == -1: raise libvirtError ('virStoragePoolGetAutostart() failed', pool=self)
return ret
def info(self):
"""Extract information about a storage pool. Note that if the
connection used to get the domain is limited only a partial
set of the information can be extracted. """
ret = libvirtmod.virStoragePoolGetInfo(self._o)
if ret is None: raise libvirtError ('virStoragePoolGetInfo() failed', pool=self)
return ret
def listVolumes(self):
"""list the storage volumes, stores the pointers to the names
in @names """
ret = libvirtmod.virStoragePoolListVolumes(self._o)
if ret is None: raise libvirtError ('virStoragePoolListVolumes() failed', pool=self)
return ret
class virStorageVol:
def __init__(self, conn, _obj=None):
self._conn = conn
if not isinstance(conn, virConnect):
self._conn = conn._conn
if _obj != None:self._o = _obj;return
self._o = None
def __del__(self):
if self._o != None:
libvirtmod.virStorageVolFree(self._o)
self._o = None
#
# virStorageVol functions from module libvirt
#
def XMLDesc(self, flags):
"""Fetch an XML document describing all aspects of the storage
volume """
ret = libvirtmod.virStorageVolGetXMLDesc(self._o, flags)
if ret is None: raise libvirtError ('virStorageVolGetXMLDesc() failed', vol=self)
return ret
def connect(self):
"""Provides the connection pointer associated with a storage
volume. The reference counter on the connection is not
increased by this call. WARNING: When writing libvirt
bindings in other languages, do not use this function.
Instead, store the connection and the volume object
together. """
ret = libvirtmod.virStorageVolGetConnect(self._o)
if ret is None:raise libvirtError('virStorageVolGetConnect() failed', vol=self)
__tmp = virConnect(_obj=ret)
return __tmp
def delete(self, flags):
"""Delete the storage volume from the pool """
ret = libvirtmod.virStorageVolDelete(self._o, flags)
if ret == -1: raise libvirtError ('virStorageVolDelete() failed', vol=self)
return ret
def key(self):
"""Fetch the storage volume key. This is globally unique, so
the same volume will have the same key no matter what host
it is accessed from """
ret = libvirtmod.virStorageVolGetKey(self._o)
if ret is None: raise libvirtError ('virStorageVolGetKey() failed', vol=self)
return ret
def name(self):
"""Fetch the storage volume name. This is unique within the
scope of a pool """
ret = libvirtmod.virStorageVolGetName(self._o)
return ret
def path(self):
"""Fetch the storage volume path. Depending on the pool
configuration this is either persistent across hosts, or
dynamically assigned at pool startup. Consult pool
documentation for information on getting the persistent
naming """
ret = libvirtmod.virStorageVolGetPath(self._o)
if ret is None: raise libvirtError ('virStorageVolGetPath() failed', vol=self)
return ret
def storagePoolLookupByVolume(self):
"""Fetch a storage pool which contains a particular volume """
ret = libvirtmod.virStoragePoolLookupByVolume(self._o)
if ret is None:raise libvirtError('virStoragePoolLookupByVolume() failed', vol=self)
__tmp = virStoragePool(self, _obj=ret)
return __tmp
#
# virStorageVol functions from module python
#
def info(self):
"""Extract information about a storage pool. Note that if the
connection used to get the domain is limited only a partial
set of the information can be extracted. """
ret = libvirtmod.virStorageVolGetInfo(self._o)
if ret is None: raise libvirtError ('virStorageVolGetInfo() failed', vol=self)
return ret
class virConnect:
def __init__(self, _obj=None):
if _obj != None:self._o = _obj;return
self._o = None
def __del__(self):
if self._o != None:
libvirtmod.virConnectClose(self._o)
self._o = None
#
# virConnect functions from module libvirt
#
def createLinux(self, xmlDesc, flags):
"""Launch a new Linux guest domain, based on an XML
description similar to the one returned by
virDomainGetXMLDesc() This function may requires privileged
access to the hypervisor. The domain is not persistent, so
its definition will disappear when it is destroyed, or if
the host is restarted (see virDomainDefineXML() to define
persistent domains). """
ret = libvirtmod.virDomainCreateLinux(self._o, xmlDesc, flags)
if ret is None:raise libvirtError('virDomainCreateLinux() failed', conn=self)
__tmp = virDomain(self,_obj=ret)
return __tmp
def createXML(self, xmlDesc):
"""Create and start a new virtual network, based on an XML
description similar to the one returned by
virNetworkGetXMLDesc() """
ret = libvirtmod.virNetworkCreateXML(self._o, xmlDesc)
if ret is None:raise libvirtError('virNetworkCreateXML() failed', conn=self)
__tmp = virNetwork(self, _obj=ret)
return __tmp
def createXML(self, xmlDesc, flags):
"""Create a new storage based on its XML description. The pool
is not persistent, so its definition will disappear when it
is destroyed, or if the host is restarted """
ret = libvirtmod.virStoragePoolCreateXML(self._o, xmlDesc, flags)
if ret is None:raise libvirtError('virStoragePoolCreateXML() failed', conn=self)
__tmp = virStoragePool(self, _obj=ret)
return __tmp
def defineXML(self, xml):
"""Define a domain, but does not start it. This definition is
persistent, until explicitly undefined with
virDomainUndefine(). """
ret = libvirtmod.virDomainDefineXML(self._o, xml)
if ret is None:raise libvirtError('virDomainDefineXML() failed', conn=self)
__tmp = virDomain(self,_obj=ret)
return __tmp
def findStoragePoolSources(self, type, srcSpec, flags):
"""Talks to a storage backend and attempts to auto-discover
the set of available storage pool sources. e.g. For iSCSI
this would be a set of iSCSI targets. For NFS this would be
a list of exported paths. The srcSpec (optional for some
storage pool types, e.g. local ones) is an instance of the
storage pool's source element specifying where to look for
the pools. srcSpec is not required for some types (e.g.,
those querying local storage resources only) """
ret = libvirtmod.virConnectFindStoragePoolSources(self._o, type, srcSpec, flags)
if ret is None: raise libvirtError ('virConnectFindStoragePoolSources() failed', conn=self)
return ret
def getCapabilities(self):
"""Provides capabilities of the hypervisor / driver. """
ret = libvirtmod.virConnectGetCapabilities(self._o)
if ret is None: raise libvirtError ('virConnectGetCapabilities() failed', conn=self)
return ret
def getFreeMemory(self):
"""provides the free memory available on the Node """
ret = libvirtmod.virNodeGetFreeMemory(self._o)
return ret
def getHostname(self):
"""This returns the system hostname on which the hypervisor is
running (the result of the gethostname(2) system call). If
we are connected to a remote system, then this returns the
hostname of the remote system. """
ret = libvirtmod.virConnectGetHostname(self._o)
if ret is None: raise libvirtError ('virConnectGetHostname() failed', conn=self)
return ret
def getMaxVcpus(self, type):
"""Provides the maximum number of virtual CPUs supported for a
guest VM of a specific type. The 'type' parameter here
corresponds to the 'type' attribute in the <domain> element
of the XML. """
ret = libvirtmod.virConnectGetMaxVcpus(self._o, type)
if ret == -1: raise libvirtError ('virConnectGetMaxVcpus() failed', conn=self)
return ret
def getType(self):
"""Get the name of the Hypervisor software used. """
ret = libvirtmod.virConnectGetType(self._o)
if ret is None: raise libvirtError ('virConnectGetType() failed', conn=self)
return ret
def getURI(self):
"""This returns the URI (name) of the hypervisor connection.
Normally this is the same as or similar to the string
passed to the virConnectOpen/virConnectOpenReadOnly call,
but the driver may make the URI canonical. If name == None
was passed to virConnectOpen, then the driver will return a
non-None URI which can be used to connect to the same
hypervisor later. """
ret = libvirtmod.virConnectGetURI(self._o)
if ret is None: raise libvirtError ('virConnectGetURI() failed', conn=self)
return ret
def lookupByID(self, id):
"""Try to find a domain based on the hypervisor ID number Note
that this won't work for inactive domains which have an ID
of -1, in that case a lookup based on the Name or UUId need
to be done instead. """
ret = libvirtmod.virDomainLookupByID(self._o, id)
if ret is None:raise libvirtError('virDomainLookupByID() failed', conn=self)
__tmp = virDomain(self,_obj=ret)
return __tmp
def lookupByName(self, name):
"""Try to lookup a domain on the given hypervisor based on its
name. """
ret = libvirtmod.virDomainLookupByName(self._o, name)
if ret is None:raise libvirtError('virDomainLookupByName() failed', conn=self)
__tmp = virDomain(self,_obj=ret)
return __tmp
def lookupByUUIDString(self, uuidstr):
"""Try to lookup a domain on the given hypervisor based on its
UUID. """
ret = libvirtmod.virDomainLookupByUUIDString(self._o, uuidstr)
if ret is None:raise libvirtError('virDomainLookupByUUIDString() failed', conn=self)
__tmp = virDomain(self,_obj=ret)
return __tmp
def migrate(self, domain, flags, dname, uri, bandwidth):
"""Migrate the domain object from its current host to the
destination host given by dconn (a connection to the
destination host). Flags may be one of more of the
following: VIR_MIGRATE_LIVE Attempt a live migration. If
a hypervisor supports renaming domains during migration,
then you may set the dname parameter to the new name
(otherwise it keeps the same name). If this is not
supported by the hypervisor, dname must be None or else you
will get an error. Since typically the two hypervisors
connect directly to each other in order to perform the
migration, you may need to specify a path from the source
to the destination. This is the purpose of the uri
parameter. If uri is None, then libvirt will try to find
the best method. Uri may specify the hostname or IP
address of the destination host as seen from the source.
Or uri may be a URI giving transport, hostname, user, port,
etc. in the usual form. Refer to driver documentation for
the particular URIs supported. The maximum bandwidth (in
Mbps) that will be used to do migration can be specified
with the bandwidth parameter. If set to 0, libvirt will
choose a suitable default. Some hypervisors do not support
this feature and will return an error if bandwidth is not
0. To see which features are supported by the current
hypervisor, see virConnectGetCapabilities,
/capabilities/host/migration_features. There are many
limitations on migration imposed by the underlying
technology - for example it may not be possible to migrate
between different processors even with the same
architecture, or between different types of hypervisor. """
if domain is None: domain__o = None
else: domain__o = domain._o
ret = libvirtmod.virDomainMigrate(domain__o, self._o, flags, dname, uri, bandwidth)
if ret is None:raise libvirtError('virDomainMigrate() failed', conn=self)
__tmp = virDomain(self,_obj=ret)
return __tmp
def networkDefineXML(self, xml):
"""Define a network, but does not create it """
ret = libvirtmod.virNetworkDefineXML(self._o, xml)
if ret is None:raise libvirtError('virNetworkDefineXML() failed', conn=self)
__tmp = virNetwork(self, _obj=ret)
return __tmp
def networkLookupByName(self, name):
"""Try to lookup a network on the given hypervisor based on
its name. """
ret = libvirtmod.virNetworkLookupByName(self._o, name)
if ret is None:raise libvirtError('virNetworkLookupByName() failed', conn=self)
__tmp = virNetwork(self, _obj=ret)
return __tmp
def networkLookupByUUIDString(self, uuidstr):
"""Try to lookup a network on the given hypervisor based on
its UUID. """
ret = libvirtmod.virNetworkLookupByUUIDString(self._o, uuidstr)
if ret is None:raise libvirtError('virNetworkLookupByUUIDString() failed', conn=self)
__tmp = virNetwork(self, _obj=ret)
return __tmp
def numOfDefinedDomains(self):
"""Provides the number of defined but inactive domains. """
ret = libvirtmod.virConnectNumOfDefinedDomains(self._o)
if ret == -1: raise libvirtError ('virConnectNumOfDefinedDomains() failed', conn=self)
return ret
def numOfDefinedNetworks(self):
"""Provides the number of inactive networks. """
ret = libvirtmod.virConnectNumOfDefinedNetworks(self._o)
if ret == -1: raise libvirtError ('virConnectNumOfDefinedNetworks() failed', conn=self)
return ret
def numOfDefinedStoragePools(self):
"""Provides the number of inactive storage pools """
ret = libvirtmod.virConnectNumOfDefinedStoragePools(self._o)
if ret == -1: raise libvirtError ('virConnectNumOfDefinedStoragePools() failed', conn=self)
return ret
def numOfDomains(self):
"""Provides the number of active domains. """
ret = libvirtmod.virConnectNumOfDomains(self._o)
if ret == -1: raise libvirtError ('virConnectNumOfDomains() failed', conn=self)
return ret
def numOfNetworks(self):
"""Provides the number of active networks. """
ret = libvirtmod.virConnectNumOfNetworks(self._o)
if ret == -1: raise libvirtError ('virConnectNumOfNetworks() failed', conn=self)
return ret
def numOfStoragePools(self):
"""Provides the number of active storage pools """
ret = libvirtmod.virConnectNumOfStoragePools(self._o)
if ret == -1: raise libvirtError ('virConnectNumOfStoragePools() failed', conn=self)
return ret
def restore(self, frm):
"""This method will restore a domain saved to disk by
virDomainSave(). """
ret = libvirtmod.virDomainRestore(self._o, frm)
if ret == -1: raise libvirtError ('virDomainRestore() failed', conn=self)
return ret
def storagePoolDefineXML(self, xml, flags):
"""Define a new inactive storage pool based on its XML
description. The pool is persistent, until explicitly
undefined. """
ret = libvirtmod.virStoragePoolDefineXML(self._o, xml, flags)
if ret is None:raise libvirtError('virStoragePoolDefineXML() failed', conn=self)
__tmp = virStoragePool(self, _obj=ret)
return __tmp
def storagePoolLookupByName(self, name):
"""Fetch a storage pool based on its unique name """
ret = libvirtmod.virStoragePoolLookupByName(self._o, name)
if ret is None:raise libvirtError('virStoragePoolLookupByName() failed', conn=self)
__tmp = virStoragePool(self, _obj=ret)
return __tmp
def storagePoolLookupByUUID(self, uuid):
"""Fetch a storage pool based on its globally unique id """
ret = libvirtmod.virStoragePoolLookupByUUID(self._o, uuid)
if ret is None:raise libvirtError('virStoragePoolLookupByUUID() failed', conn=self)
__tmp = virStoragePool(self, _obj=ret)
return __tmp
def storagePoolLookupByUUIDString(self, uuidstr):
"""Fetch a storage pool based on its globally unique id """
ret = libvirtmod.virStoragePoolLookupByUUIDString(self._o, uuidstr)
if ret is None:raise libvirtError('virStoragePoolLookupByUUIDString() failed', conn=self)
__tmp = virStoragePool(self, _obj=ret)
return __tmp
def storageVolLookupByKey(self, key):
"""Fetch a pointer to a storage volume based on its globally
unique key """
ret = libvirtmod.virStorageVolLookupByKey(self._o, key)
if ret is None:raise libvirtError('virStorageVolLookupByKey() failed', conn=self)
__tmp = virStorageVol(self, _obj=ret)
return __tmp
def storageVolLookupByPath(self, path):
"""Fetch a pointer to a storage volume based on its locally
(host) unique path """
ret = libvirtmod.virStorageVolLookupByPath(self._o, path)
if ret is None:raise libvirtError('virStorageVolLookupByPath() failed', conn=self)
__tmp = virStorageVol(self, _obj=ret)
return __tmp
#
# virConnect functions from module python
#
def getCellsFreeMemory(self, startCell, maxCells):
"""Returns the available memory for a list of cells """
ret = libvirtmod.virNodeGetCellsFreeMemory(self._o, startCell, maxCells)
if ret is None: raise libvirtError ('virNodeGetCellsFreeMemory() failed', conn=self)
return ret
def getInfo(self):
"""Extract hardware information about the Node. """
ret = libvirtmod.virNodeGetInfo(self._o)
if ret is None: raise libvirtError ('virNodeGetInfo() failed', conn=self)
return ret
def listDefinedDomains(self):
"""list the defined domains, stores the pointers to the names
in @names """
ret = libvirtmod.virConnectListDefinedDomains(self._o)
if ret is None: raise libvirtError ('virConnectListDefinedDomains() failed', conn=self)
return ret
def listDefinedNetworks(self):
"""list the defined networks, stores the pointers to the names
in @names """
ret = libvirtmod.virConnectListDefinedNetworks(self._o)
if ret is None: raise libvirtError ('virConnectListDefinedNetworks() failed', conn=self)
return ret
def listDefinedStoragePools(self):
"""list the defined storage pool, stores the pointers to the
names in @names """
ret = libvirtmod.virConnectListDefinedStoragePools(self._o)
if ret is None: raise libvirtError ('virConnectListDefinedStoragePools() failed', conn=self)
return ret
def listDomainsID(self):
"""Returns the list of the ID of the domains on the hypervisor """
ret = libvirtmod.virConnectListDomainsID(self._o)
if ret is None: raise libvirtError ('virConnectListDomainsID() failed', conn=self)
return ret
def listNetworks(self):
"""list the networks, stores the pointers to the names in
@names """
ret = libvirtmod.virConnectListNetworks(self._o)
if ret is None: raise libvirtError ('virConnectListNetworks() failed', conn=self)
return ret
def listStoragePools(self):
"""list the storage pools, stores the pointers to the names in
@names """
ret = libvirtmod.virConnectListStoragePools(self._o)
if ret is None: raise libvirtError ('virConnectListStoragePools() failed', conn=self)
return ret
def lookupByUUID(self, uuid):
"""Try to lookup a domain on the given hypervisor based on its
UUID. """
ret = libvirtmod.virDomainLookupByUUID(self._o, uuid)
if ret is None:raise libvirtError('virDomainLookupByUUID() failed', conn=self)
__tmp = virDomain(self,_obj=ret)
return __tmp
#
# virConnect functions from module virterror
#
def virConnGetLastError(self):
"""Provide a pointer to the last error caught on that
connection Simpler but may not be suitable for
multithreaded accesses, in which case use
virConnCopyLastError() """
ret = libvirtmod.virConnGetLastError(self._o)
return ret
def virConnResetLastError(self):
"""Reset the last error caught on that connection """
libvirtmod.virConnResetLastError(self._o)
# virStorageVolDeleteFlags
VIR_STORAGE_VOL_DELETE_NORMAL = 0
VIR_STORAGE_VOL_DELETE_ZEROED = 1
# virDomainMigrateFlags
VIR_MIGRATE_LIVE = 1
# virStoragePoolBuildFlags
VIR_STORAGE_POOL_BUILD_NEW = 0
VIR_STORAGE_POOL_BUILD_REPAIR = 1
VIR_STORAGE_POOL_BUILD_RESIZE = 2
# virDomainXMLFlags
VIR_DOMAIN_XML_SECURE = 1
VIR_DOMAIN_XML_INACTIVE = 2
# virDomainState
VIR_DOMAIN_NOSTATE = 0
VIR_DOMAIN_RUNNING = 1
VIR_DOMAIN_BLOCKED = 2
VIR_DOMAIN_PAUSED = 3
VIR_DOMAIN_SHUTDOWN = 4
VIR_DOMAIN_SHUTOFF = 5
VIR_DOMAIN_CRASHED = 6
# virErrorDomain
VIR_FROM_NONE = 0
VIR_FROM_XEN = 1
VIR_FROM_XEND = 2
VIR_FROM_XENSTORE = 3
VIR_FROM_SEXPR = 4
VIR_FROM_XML = 5
VIR_FROM_DOM = 6
VIR_FROM_RPC = 7
VIR_FROM_PROXY = 8
VIR_FROM_CONF = 9
VIR_FROM_QEMU = 10
VIR_FROM_NET = 11
VIR_FROM_TEST = 12
VIR_FROM_REMOTE = 13
VIR_FROM_OPENVZ = 14
VIR_FROM_XENXM = 15
VIR_FROM_STATS_LINUX = 16
VIR_FROM_LXC = 17
VIR_FROM_STORAGE = 18
VIR_FROM_NETWORK = 19
VIR_FROM_DOMAIN = 20
# virStorageVolType
VIR_STORAGE_VOL_FILE = 0
VIR_STORAGE_VOL_BLOCK = 1
# virStoragePoolDeleteFlags
VIR_STORAGE_POOL_DELETE_NORMAL = 0
VIR_STORAGE_POOL_DELETE_ZEROED = 1
# virConnectCredentialType
VIR_CRED_USERNAME = 1
VIR_CRED_AUTHNAME = 2
VIR_CRED_LANGUAGE = 3
VIR_CRED_CNONCE = 4
VIR_CRED_PASSPHRASE = 5
VIR_CRED_ECHOPROMPT = 6
VIR_CRED_NOECHOPROMPT = 7
VIR_CRED_REALM = 8
VIR_CRED_EXTERNAL = 9
# virConnectFlags
VIR_CONNECT_RO = 1
# virSchedParameterType
VIR_DOMAIN_SCHED_FIELD_INT = 1
VIR_DOMAIN_SCHED_FIELD_UINT = 2
VIR_DOMAIN_SCHED_FIELD_LLONG = 3
VIR_DOMAIN_SCHED_FIELD_ULLONG = 4
VIR_DOMAIN_SCHED_FIELD_DOUBLE = 5
VIR_DOMAIN_SCHED_FIELD_BOOLEAN = 6
# virErrorNumber
VIR_ERR_OK = 0
VIR_ERR_INTERNAL_ERROR = 1
VIR_ERR_NO_MEMORY = 2
VIR_ERR_NO_SUPPORT = 3
VIR_ERR_UNKNOWN_HOST = 4
VIR_ERR_NO_CONNECT = 5
VIR_ERR_INVALID_CONN = 6
VIR_ERR_INVALID_DOMAIN = 7
VIR_ERR_INVALID_ARG = 8
VIR_ERR_OPERATION_FAILED = 9
VIR_ERR_GET_FAILED = 10
VIR_ERR_POST_FAILED = 11
VIR_ERR_HTTP_ERROR = 12
VIR_ERR_SEXPR_SERIAL = 13
VIR_ERR_NO_XEN = 14
VIR_ERR_XEN_CALL = 15
VIR_ERR_OS_TYPE = 16
VIR_ERR_NO_KERNEL = 17
VIR_ERR_NO_ROOT = 18
VIR_ERR_NO_SOURCE = 19
VIR_ERR_NO_TARGET = 20
VIR_ERR_NO_NAME = 21
VIR_ERR_NO_OS = 22
VIR_ERR_NO_DEVICE = 23
VIR_ERR_NO_XENSTORE = 24
VIR_ERR_DRIVER_FULL = 25
VIR_ERR_CALL_FAILED = 26
VIR_ERR_XML_ERROR = 27
VIR_ERR_DOM_EXIST = 28
VIR_ERR_OPERATION_DENIED = 29
VIR_ERR_OPEN_FAILED = 30
VIR_ERR_READ_FAILED = 31
VIR_ERR_PARSE_FAILED = 32
VIR_ERR_CONF_SYNTAX = 33
VIR_ERR_WRITE_FAILED = 34
VIR_ERR_XML_DETAIL = 35
VIR_ERR_INVALID_NETWORK = 36
VIR_ERR_NETWORK_EXIST = 37
VIR_ERR_SYSTEM_ERROR = 38
VIR_ERR_RPC = 39
VIR_ERR_GNUTLS_ERROR = 40
VIR_WAR_NO_NETWORK = 41
VIR_ERR_NO_DOMAIN = 42
VIR_ERR_NO_NETWORK = 43
VIR_ERR_INVALID_MAC = 44
VIR_ERR_AUTH_FAILED = 45
VIR_ERR_INVALID_STORAGE_POOL = 46
VIR_ERR_INVALID_STORAGE_VOL = 47
VIR_WAR_NO_STORAGE = 48
VIR_ERR_NO_STORAGE_POOL = 49
VIR_ERR_NO_STORAGE_VOL = 50
# virDomainMemoryFlags
VIR_MEMORY_VIRTUAL = 1
# virDomainCreateFlags
VIR_DOMAIN_NONE = 0
# virStoragePoolState
VIR_STORAGE_POOL_INACTIVE = 0
VIR_STORAGE_POOL_BUILDING = 1
VIR_STORAGE_POOL_RUNNING = 2
VIR_STORAGE_POOL_DEGRADED = 3
# virVcpuState
VIR_VCPU_OFFLINE = 0
VIR_VCPU_RUNNING = 1
VIR_VCPU_BLOCKED = 2
# virErrorLevel
VIR_ERR_NONE = 0
VIR_ERR_WARNING = 1
VIR_ERR_ERROR = 2
|