private void addComponents() { addedComponents = new ArrayList<InternalComponentInstance>(targetDM.getComponentInstances().onlyInternals()); addedComponents.removeAll(matchingComponents.values()); }
private InternalComponentInstance findClient(Deployment container) throws IllegalStateException { final InternalComponentInstance clientComponent = container.getComponentInstances().onlyInternals().firstNamed(client); if (clientComponent == null) { final String error = String.format("Unable to find the internal component instance '%s'", client); throw new IllegalStateException(error); } return clientComponent; } }
@Override protected List<ProvidedPortInstance> collectCandidates(Deployment deployment) { ArrayList<ProvidedPortInstance> candidates = new ArrayList<ProvidedPortInstance>(); for (InternalComponentInstance artefactInstance : deployment.getComponentInstances().onlyInternals()) { for (ProvidedPortInstance serverPort : artefactInstance.getProvidedPorts()) { if (isCandidate(bindingType, serverPort)) { candidates.add(serverPort); } } } return candidates; }
private void removeEC(ExternalComponentInstance<? extends ExternalComponent> ni) { removedECs.put(ni,currentDM.getComponentInstances().onlyInternals().hostedOn(ni).toList()); //create action }
public void internalComponentInstancesToPOJO(List<net.cloudml.core.InternalComponentInstance> componentInstances) { int counter = 0; for (net.cloudml.core.InternalComponentInstance ici: componentInstances) { internalComponentInstanceToPOJO((net.cloudml.core.InternalComponentInstance) ici); counter++; } assert counter == model.getComponentInstances().onlyInternals().size(); assert counter == internalComponentInstances.size(); }
private void visitPuppetResources(ComponentInstance ci){ InternalComponentInstanceGroup icig= currentModel.getComponentInstances().onlyInternals().hostedOn(ci); if(icig !=null){ for(ComponentInstance c : icig){ InternalComponentInstance ici; PuppetResource pr=findPuppetResource(c); if(pr != null) manifest+=pr.getManifestEntry()+System.lineSeparator(); visitPuppetResources(c); } } }
private void migrateAllHostedComponents(Deployment deployment) { final InternalComponentInstanceGroup hosted = deployment.getComponentInstances().onlyInternals().hostedOn(artefactInstance); for (InternalComponentInstance hostedComponent: hosted) { getLibrary().migrate(deployment, hostedComponent); } }
/** * Compares the components between the targeted and the current deployment * model */ public void compareComponents() { journal.log(Level.INFO, ">> Comparing Internal Components ..."); Boolean match = false; for (InternalComponentInstance ni : currentDM.getComponentInstances().onlyInternals()) { secondloop: { for (InternalComponentInstance ni2 : targetDM.getComponentInstances().onlyInternals()) { match = ni.equals(ni2); if (ni.equals(ni2) && ni.externalHost().equals(ni2.externalHost())) { matchingComponents.put(ni, ni2); break secondloop; } } } if (!match) { removedComponents.add(ni); } } //add the rest addComponents(); }
for(InternalComponentInstance c: d.getComponentInstances().onlyInternals()){ for(Property p : c.getProperties()){ if(p.getName().startsWith("env:")){ for(Property p : ic.getProperties()){ if(p.getName().contains("env:")){ for(InternalComponentInstance ici: d.getComponentInstances().ofType(ic.getName()).onlyInternals()){ prepareSetEnv(d,ici,p);
private void allHosted(ComponentInstance ci, Deployment target){ InternalComponentInstanceGroup icig= currentModel.getComponentInstances().onlyInternals().hostedOn(ci); if(icig !=null){ hostedGroup.addAll(icig); for(ComponentInstance c : icig){ InternalComponentInstance ici; if(ci.isExternal()) ici=getLibrary().replicateComponentInstance(target, c, host).asInternal(); else ici=getLibrary().replicateComponentInstance(target, c, mapping.get(ci)).asInternal(); mapping.put(c.asInternal(), ici); allHosted(c, target); } } }
@Override public Void applyTo(Deployment deployment) { final InternalComponentInstanceGroup hosted = deployment.getComponentInstances().onlyInternals().hostedOn(instance); for(InternalComponentInstance hostedComponent: hosted) { getLibrary().migrate(deployment, hostedComponent); } getLibrary().stop(deployment, instance); deployment.getComponentInstances().remove(instance); return NOTHING; }
@Override public void handle(ViewComponentInstance command) { if (isDeploymentLoaded()) { final ComponentInstance instance = deploy.getComponentInstances().onlyInternals().firstNamed(command.getComponentId()); if (instance == null) { final String text = String.format("No artefact instance with ID \"%s\"", command.getComponentId()); final Message message = new Message(command, Category.ERROR, text); dispatch(message); } else { final ComponentInstanceData data = new ComponentInstanceData(command, instance); dispatch(data); } } else { reportNoDeploymentLoaded(command); } }
configureWithRelationships(new RelationshipInstanceGroup(diff.getAddedRelationships())); configureSaas(new ComponentInstanceGroup<InternalComponentInstance>(diff.getAddedComponents())); configureWithPuppet(targetModel.getComponentInstances().onlyInternals()); generatePuppetManifestAndConfigure();
@Override public InternalComponentInstance applyTo(Deployment target) { final String instanceName = getLibrary().createUniqueComponentInstanceName(target, type); InternalComponentInstanceBuilder builder = anInternalComponentInstance() .named(instanceName) .ofType(type.getName()) .hostedBy(host.getName()); builder.integrateIn(target); InternalComponentInstance instance = target.getComponentInstances().onlyInternals().firstNamed(instanceName); resolveDependencies(target, instance); return instance; }
private static Model getModelUpdates(ComponentInstanceGroup instances, ProviderGroup providers) { Model model = new Model(); //go top down to remove the synched ones //prepare the VMs list VMInstanceGroup VMs = instances.onlyVMs(); for (VMInstance i : VMs) { String location = i.getType().getLocation(); if(!location.isEmpty()) { model.add(fromCloudmlToModaMP(location)); } model.add(fromCloudmlToModaMP(i)); instances.remove(i); } //prepare the InternalComponents list InternalComponentInstanceGroup internalComponents = instances.onlyInternals(); for (InternalComponentInstance i : internalComponents) { model.add(fromCloudmlToModaMP(i)); instances.remove(i); } //prepare for providers list if(providers!=null){ for (Provider i : providers) { model.add(fromCloudmlToModaMP(i)); instances.remove(i); } } return model; }
configureSaas(targetModel.getComponentInstances().onlyInternals()); configureWithPuppet(targetModel.getComponentInstances().onlyInternals()); generatePuppetManifestAndConfigure(); configureWithRelationships(new RelationshipInstanceGroup(diff.getAddedRelationships())); configureSaas(new ComponentInstanceGroup<InternalComponentInstance>(diff.getAddedComponents())); configureWithPuppet(targetModel.getComponentInstances().onlyInternals()); generatePuppetManifestAndConfigure();
@Override public ComponentInstance applyTo(Deployment target) { ComponentInstance result=null; if(instance.isInternal()){ final String instanceName = getLibrary().createUniqueComponentInstanceName(target, instance.asInternal().getType()); InternalComponentInstanceBuilder builder = anInternalComponentInstance() .named(instanceName) .ofType(instance.asInternal().getType().getName()) .hostedBy(host.getName()); builder.integrateIn(target); result = target.getComponentInstances().onlyInternals().firstNamed(instanceName); } if(instance.isExternal()){ result=getLibrary().provision(target, instance.getType()); } return result; }
public net.cloudml.core.CloudMLModel toKMF(Deployment deploy) { kDeploy.setName(deploy.getName()); convertProperties(deploy,kDeploy,factory); providersToKmf(deploy.getProviders().toList()); externalComponentToKmf(deploy.getComponents().onlyExternals().toList()); internalComponentsToKmf(deploy.getComponents().onlyInternals().toList()); externalComponentInstanceToKmf(deploy.getComponentInstances().onlyExternals().toList()); internalComponentInstancesToKmf(deploy.getComponentInstances().onlyInternals().toList()); executesToKmf(deploy.getExecuteInstances().toList()); relationshipsToKmf(deploy.getRelationships()); relationshipInstancesToKmf(deploy.getRelationshipInstances().toList()); return kDeploy; }