@Override public void integrateIn(Deployment container) { final InternalComponent component = build(); container.getComponents().add(component); }
public void externalComponentsToPOJO(List<net.cloudml.core.ExternalComponent> components) { int counter = 0; for (net.cloudml.core.ExternalComponent c: components) { externalComponentToPOJO(c); counter++; } assert counter == model.getComponents().onlyExternals().size(); assert counter == externalComponents.size(); }
public InternalComponentGroup internalComponents() { return components.onlyInternals(); }
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; }
@Override public VMInstance applyTo(Deployment target) { VM existingVM=vmi.asExternal().asVM().getType(); VM v=target.getComponents().onlyVMs().firstNamed(existingVM.getName()+"-fromImage"); StandardLibrary lib=getLibrary(); if(v == null){//in case a type for the snapshot has already been created target.getComponents().add(v);
protected VM findVMGenerated(String fromName, String extension){ for(VM v: currentModel.getComponents().onlyVMs()){ if(v.getName().contains(fromName) && v.getName().contains(extension)){ return v; } } return null; }
public Deployment clone(){ Deployment tmp=new Deployment(); tmp.getComponents().addAll(this.getComponents()); tmp.getComponentInstances().addAll(this.getComponentInstances()); tmp.getExecuteInstances().addAll(this.getExecuteInstances()); tmp.getProviders().addAll(this.getProviders()); tmp.getRelationshipInstances().addAll(this.getRelationshipInstances()); tmp.getClouds().addAll(this.getClouds()); tmp.getRelationships().addAll(this.getRelationships()); tmp.setName(this.getName()); return tmp; }
private Component findServer(Deployment container) throws IllegalStateException { final Component server = container.getComponents().firstNamed(serverName); if (server == null) { final String error = String.format("component type '%s' not found", serverName); throw new IllegalStateException(formatError(error)); } return server; }
@Override public void validate(Report report) { if (providers.isEmpty() && components.isEmpty() && componentInstances.isEmpty() && relationships.isEmpty() && relationshipInstances.isEmpty()) { report.addWarning("empty deployment model"); } }
private List<VM> vmFromAProvider(Provider p){ ArrayList<VM> result=new ArrayList<VM>(); for(VM v : currentModel.getComponents().onlyVMs()){ if(v.getProvider().getName().equals(p.getName())){ result.add(v); } } return result; }
/** * Update the currentModel with the targetModel and preserve all the CPSM * metadata * * @param diff a model comparator */ public void updateCurrentModel(CloudMLModelComparator diff) { if (diff != null) { currentModel.getComponents().addAll(targetModel.getComponents()); currentModel.getRelationships().addAll(targetModel.getRelationships()); currentModel.getComponentInstances().removeAll(diff.getRemovedComponents()); currentModel.getRelationshipInstances().removeAll(diff.getRemovedRelationships()); currentModel.getComponentInstances().removeAll(diff.getRemovedECs().keySet()); currentModel.getExecuteInstances().removeAll(diff.getRemovedExecutes()); alreadyDeployed.removeAll(diff.getRemovedComponents()); alreadyStarted.removeAll(diff.getRemovedComponents()); currentModel.getComponentInstances().replaceAll(diff.getAddedComponents()); currentModel.getRelationshipInstances().replaceAll(diff.getAddedRelationships()); currentModel.getComponentInstances().replaceAll(diff.getAddedECs()); currentModel.getExecuteInstances().replaceAll(diff.getAddedExecutes()); } else { throw new IllegalArgumentException("Cannot update current model without comparator!"); } }
@Override public void handle(ViewComponent command) { if (isDeploymentLoaded()) { final Component type = deploy.getComponents().firstNamed(command.getComponentId()); if (type == null) { final String text = String.format("No artefact type with ID \"%s\"", command.getComponentId()); final Message message = new Message(command, Category.ERROR, text); dispatch(message); } else { final ComponentData data = new ComponentData(command, type); dispatch(data); } } else { reportNoDeploymentLoaded(command); } }
public synchronized void commitModifications(List<String> modifications) { for (String modi : modifications) { String[] parsed = modi.split("\\s+"); if ("add".equals(parsed[0])) { if ("in".equals(parsed[4]) && "root".equals(parsed[5]) && "nodeTypes".equals(parsed[6])) { // FIXME: We should know which provider is responsible for the new VM we add! final Provider provider = new Provider("Missing Provider"); repo.getRoot().getProviders().add(provider); repo.getRoot().getComponents().add(new VM(parsed[3], provider)); } } } }
private ExternalComponent findType(Deployment container) { final ExternalComponent type = container.getComponents().onlyExternals().firstNamed(getTypeName()); if (type == null) { final String error = String.format("Unable to find an external component type named '%s'!", getTypeName()); throw new IllegalStateException(error); } return type; } }
@Override protected List<InternalComponent> collectCandidates(Deployment deployment) { List<InternalComponent> candidates = new ArrayList<InternalComponent>(); for (InternalComponent artefact : deployment.getComponents().onlyInternals()) { if (isCandidate(artefact)) { candidates.add(artefact); } } return candidates; }
private VM findType(Deployment container) throws IllegalStateException { final VM type = container.getComponents().onlyVMs().firstNamed(getTypeName()); if (type == null) { final String error = String.format("Unable to find a VM type named '%s'", getTypeName()); throw new IllegalStateException(error); } return type; } }
private void saveMetadata(Deployment deploy2) { if (isDeploymentLoaded()) { diff = new CloudMLModelComparator(deploy, deploy2); diff.compareCloudMLModel(); deploy.setName(deploy2.getName()); deploy.getComponents().addAll(deploy2.getComponents()); deploy.getRelationships().addAll(deploy2.getRelationships()); deploy.getRelationshipInstances().removeAll(diff.getRemovedRelationships()); deploy.getExecuteInstances().removeAll(diff.getRemovedExecutes()); deploy.getComponentInstances().removeAll(diff.getRemovedECs().keySet()); deploy.getComponentInstances().removeAll(diff.getRemovedComponents()); deploy.getRelationshipInstances().replaceAll(diff.getAddedRelationships()); deploy.getComponentInstances().replaceAll(diff.getAddedECs()); deploy.getExecuteInstances().replaceAll(diff.getAddedExecutes()); deploy.getComponentInstances().replaceAll(diff.getAddedComponents()); } else { deploy = deploy2; } }
@Override public boolean add(Component component) { if (firstNamed(component.getName()) != null) { //final String error = String.format("Component name must be unique! There is already a component named '%s'.", component.getName()); //throw new IllegalStateException(error); return false; } component.getOwner().set(Deployment.this); return super.add(component); }
public DefaultListModel fillList(){ DefaultListModel lm=new DefaultListModel(); for(ExternalComponent n:dmodel.getComponents().onlyExternals()){ lm.addElement(n.getName()); } for(Component n:dmodel.getComponents()){ lm.addElement(n.getName()); } for(Relationship b:dmodel.getRelationships()){ lm.addElement(b.getName()); } return lm; }