static File baseDirFor(BundleResourceDeployment rd, Configuration referencedConfiguration) { File root = getMetadataRoot(referencedConfiguration); return baseDirFor(rd.getBundleDeployment().getDestination().getId(), root); }
@Override public void deleteBundleDeployment(Subject subject, int bundleDeploymentId) throws Exception { BundleDeployment doomed = this.entityManager.find(BundleDeployment.class, bundleDeploymentId); if (null == doomed) { return; } checkDeployBundleAuthz(subject, doomed.getBundleVersion().getBundle().getId(), doomed.getDestination() .getGroup().getId()); // only allow deployments to be deleted if they are not started or finished if (BundleDeploymentStatus.PENDING == doomed.getStatus() || BundleDeploymentStatus.SUCCESS == doomed.getStatus() || BundleDeploymentStatus.FAILURE == doomed.getStatus() || BundleDeploymentStatus.MIXED == doomed.getStatus()) { // change the pointer like in the linked list (ie. when removing B from A -> B -> C, it should result // in following situation: A -> C) Query q = entityManager.createNamedQuery(BundleDeployment.QUERY_UPDATE_FOR_DEPLOYMENT_REMOVE); q.setParameter("bundleId", doomed.getId()); q.executeUpdate(); entityManager.flush(); entityManager.remove(doomed); } else { throw new IllegalArgumentException("Can not delete deployment with status [" + doomed.getStatus() + "]"); } }
BundleDestination dest = bundleResourceDeployment.getBundleDeployment().getDestination(); String destBaseDirName = dest.getDestinationBaseDirectoryName(); String relativeDeployDir = dest.getDeployDir();
@Override public PageList<BundleDeployment> findBundleDeploymentsByCriteria(Subject subject, BundleDeploymentCriteria criteria) { CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria); // filter by bundles that are viewable if (!authorizationManager.hasGlobalPermission(subject, Permission.VIEW_BUNDLES)) { generator.setAuthorizationBundleFragment(CriteriaQueryGenerator.AuthorizationTokenType.BUNDLE, subject.getId(), "bundleVersion.bundle"); } CriteriaQueryRunner<BundleDeployment> queryRunner = new CriteriaQueryRunner<BundleDeployment>(criteria, generator, entityManager); PageList<BundleDeployment> result = queryRunner.execute(); // The result currently holds bundle deployments for bundles viewable by the caller, but we must remove // those bundle deployments for destinations not viewable by the user. In essence we wanted two authz tokens, // one for bundle and one for resource group, but we can only supply one. if (!(result.isEmpty() || authorizationManager.isInventoryManager(subject))) { for (Iterator<BundleDeployment> i = result.iterator(); i.hasNext();) { BundleDeployment bd = i.next(); int groupId = bd.getDestination().getGroup().getId(); if (!authorizationManager.canViewGroup(subject, groupId)) { i.remove(); } } } return result; }
.getDestination().getGroup().getId()); String name = getBundleDeploymentNameImpl(subject, liveDeployment.getDestination(), null, prevDeployment); String desc = (null != deploymentDescription) ? deploymentDescription : prevDeployment.getDescription(); Configuration config = (null == prevDeployment.getConfiguration()) ? null : prevDeployment.getConfiguration()
BundleDestination destination = newDeployment.getDestination(); ResourceGroup group = destination.getGroup();
private String getConnectionString(BundleResourceDeployment resourceDeployment) { ResourceContainer rc = inventoryManager.getResourceContainer(resourceDeployment.getResource()); BundleDestination dest = resourceDeployment.getBundleDeployment().getDestination(); ResourceType type = rc.getResource().getResourceType(); String specName = dest.getDestinationSpecificationName(); String relativeDeployDir = dest.getDeployDir(); Configuration config = new Configuration(); config.put(new PropertySimple("deployDir", relativeDeployDir)); ConnectionStringAvailableProperties props = new ConnectionStringAvailableProperties(rc, measurementManager, config); for (ResourceTypeBundleConfiguration.BundleDestinationSpecification spec : type .getResourceTypeBundleConfiguration().getBundleDestinationSpecifications()) { if (specName.equals(spec.getName())) { ResourceTypeBundleConfiguration.BundleDestinationDefinition def = (ResourceTypeBundleConfiguration.BundleDestinationDefinition) spec; String rawConnectionString = def.getConnectionString(); if (rawConnectionString == null) { return null; } TokenReplacingReader trr = new TokenReplacingReader(new StringReader(rawConnectionString), props); try { return StreamUtil.slurp(trr); } finally { StreamUtil.safeClose(trr); } } } return null; }
if (containsDestination(destinations, deployment.getDestination())) filteredDeployments.add(deployment);
result.setErrorMessage("The patch to revert to (" + stopPid + ") was not previously deployed by RHQ. This means that this server joined the resource group '" + request.getResourceDeployment().getBundleDeployment().getDestination().getGroup().getName() + "' after this patch was already deployed. To prevent accidental damage no changes will be made to the server.");
.getDestination().getGroup().getId());
bc.addFilterDestinationId(deployment.getDestination().getId()); Bundle bundle = bundleManager.findBundlesByCriteria(subject, bc).get(0); deployment.getDestination().setBundle(bundle);
rd.getBundleDeployment().getDestination().getName()); if (saveDestinationName.failed()) { return saveDestinationName.errorMessage;
int destinationId = resourceDeployment.getBundleDeployment().getDestination().getId(); int activeDestinationId = metadata.result.getDestinationId();
"Target resource is not of a type that can have bundles deployed to it [resource=" + bundleTarget.getName() + "; id=" + bundleTarget.getId() + "]. Fix target group for destination [" + deployment.getDestination().getName() + "]", null); bundleManager.addBundleResourceDeploymentHistoryInNewTrans(subject, resourceDeployment.getId(), history);
.getResourceTypeBundleConfiguration().getBundleDestinationSpecifications(); String specName = resourceDeployment.getBundleDeployment().getDestination() .getDestinationSpecificationName();