try {
NetworkEntity network =
new NetworkEntity(name, portGroup, AllocType.DHCP, null, null,
null, null);
networkDao.insert(network);
network.validate();
return network;
} catch (UniqueConstraintViolationException ex) {
logger.error("can not add a network with duplicated name");
throw BddException.ALREADY_EXISTS(ex, "Network", name);
}