1
2
3
4
5
6
7 import libvirt
8
9 from lib.cuckoo.common.abstracts import LibVirtMachinery
10 from lib.cuckoo.common.exceptions import CuckooCriticalError
11 from lib.cuckoo.common.exceptions import CuckooMachineError
12
13 -class ESX(LibVirtMachinery):
14 """Virtualization layer for ESXi/ESX based on python-libvirt."""
15
30
32 for credential in credentials:
33 if credential[0] == libvirt.VIR_CRED_AUTHNAME:
34 credential[4] = self.options.esx.username
35 elif credential[0] == libvirt.VIR_CRED_NOECHOPROMPT:
36 credential[4] = self.options.esx.password
37 else:
38 raise CuckooCriticalError("ESX machinery did not recieve an object to inject a username or password into")
39
40 return 0
41
43 """Return the already-connected single connection handle if set, otherwise set it."""
44 if self.global_conn is None:
45 self.global_conn = self._global_connect()
46 return self.global_conn
47
49 """Set the single connection handle."""
50 try:
51 self.auth = [[libvirt.VIR_CRED_AUTHNAME, libvirt.VIR_CRED_NOECHOPROMPT], self._auth_callback, None]
52 return libvirt.openAuth(self.dsn, self.auth, 0)
53 except libvirt.libvirtError as libvex:
54 raise CuckooCriticalError("libvirt returned an exception on connection: %s" % libvex)
55
57 """Using one global connection we now disconnect in the destructor, ignore requests to disconnect."""
58 pass
59
61 self.global_conn.close()
62