@Override public void uninstall(ProductInstance productInstance) throws NodeExecutionException, FSMViolationException, EntityNotFoundException { Status previousStatus = productInstance.getStatus(); try { validator.validateUninstall(productInstance); productInstance.setStatus(Status.UNINSTALLING); productInstance = productInstanceDao.update(productInstance); Product product = productDao.load(productInstance.getProductRelease().getProduct().getName()); if (INSTALATOR_PUPPET.equals(product.getMapMetadata().get("installator"))) { puppetInstallator.callService( productInstance.getVm(), productInstance.getVdc(), productInstance.getProductRelease(), UNINSTALL); } else { chefInstallator.callService(productInstance, UNINSTALL); } productInstance.setStatus(Status.UNINSTALLED); productInstanceDao.update(productInstance); } catch (InstallatorException e) { restoreInstance(previousStatus, productInstance); throw new SdcRuntimeException(e); } catch (RuntimeException e) { // by default restore the previous state when a runtime is thrown restoreInstance(previousStatus, productInstance); throw new SdcRuntimeException(e); } }
@Override public ProductInstance load(String vdc, String name) throws EntityNotFoundException { ProductInstance instance = productInstanceDao.load(name); if (!instance.getVdc().equals(vdc)) { throw new EntityNotFoundException(ProductInstance.class, "vdc", vdc); } return instance; }
public ProductInstance load(VM vm, ProductRelease productRelease, String vdc) throws EntityNotFoundException { ProductInstance instance = productInstanceDao.load( vm.getFqn() + "_" + productRelease.getProduct().getName() + "_" + productRelease.getVersion()); if (!instance.getVdc().equals(vdc)) { throw new EntityNotFoundException(ProductInstance.class, "vdc", vdc); } return instance; }