if (volumes.get(volume.getUuid()) != null)
{
throw new PluginException("Volume already exists");
}
Volume created = new Volume();
created.setUuid(volume.getUuid());
created.setSizeInMB(volume.getSizeInMB());
created.setAvailableInMB(volume.getSizeInMB());
created.setUsedInMB(0L);
IscsiAddress iscsiAddress = new IscsiAddress();
iscsiAddress.setPortal(device.getIp());
iscsiAddress.setIqn("iqn.1993-08.org.debian:01:b22bb69c97d3");
iscsiAddress.setLun(0);
created.setIscsiAddress(iscsiAddress);
volumes.put(created.getUuid(), created);
// Update the available size in the pool
Pool updatedPool = pools.get(pool.getName());
updatedPool.setUsedInMB(updatedPool.getUsedInMB() + created.getSizeInMB());
updatedPool.setAvailableInMB(updatedPool.getSizeInMB() - updatedPool.getUsedInMB());
return created;
}