public synchronized void destroy() throws IOException {
URL url = virtualBox.getManagerUrl();
final VirtualBoxManager vboxMgr = VirtualBoxManager
.createInstance(null);
vboxMgr.connect(url.toString(), "user", "pwd");
MacAddress mac = null;
for (Map.Entry<MacAddress, InterfaceAddress> e : MacAddress
.getAddresses().entrySet()) {
if (e.getValue().getAddress()
.equals(Networking.getPrimaryAddress())) {
mac = e.getKey();
}
}
IVirtualBox vbox = vboxMgr.getVBox();
for (final IMachine m : vbox.getMachines()) {
MacAddress mmac = new MacAddress(m.getNetworkAdapter(0L)
.getMACAddress());
if (mmac.equals(mac)) {
EXEC_SVC.submit(new Callable<Void>() {
@Override
public Void call() throws Exception {
synchronized (OperatingSystemIE.this) {
context.getBundle(0).stop();