Check if port or adapter is connected before starting/stopping a packet capture. Fixes #196.

This commit is contained in:
Jeremy committed 2015-06-01 15:42:17 -06:00
1 parent 05aafb9538
commit 9df290f192
3 files changed
+24

No files matched your search

@@ -871,6 +871,10 @@ class VirtualBoxVM(BaseVM):
raise VirtualBoxError("Sorry, packet capturing on a started VirtualBox VM is not supported.")
nio = adapter.get_nio(0)
if not nio:
raise VirtualBoxError("Adapter {} is not connected".format(adapter_number))
if nio.capturing:
raise VirtualBoxError("Packet capture is already activated on adapter {adapter_number}".format(adapter_number=adapter_number))
@@ -893,6 +897,10 @@ class VirtualBoxVM(BaseVM):
adapter_number=adapter_number))
nio = adapter.get_nio(0)
if not nio:
raise VirtualBoxError("Adapter {} is not connected".format(adapter_number))
nio.stopPacketCapture()
log.info("VirtualBox VM '{name}' [{id}]: stopping packet capture on adapter {adapter_number}".format(name=self.name,