private String vmFormatting(ComponentInstance<? extends Component> subject) { return "label=\"" + subject.getName() + "\", style=\"filled\""; }
@Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("Instance " + getName() + " : " + getType().getName()); for(PortInstance p : this.getProvidedPorts()) builder.append("-Provided port:"+p.getName()); return builder.toString(); }
public String toString(){ String result=" Component instances:\n"; for(ComponentInstance c: components){ if(c.isExternal()){ if(c.asExternal().isVM()){ result+=" VM-> "+c.asExternal().asVM().getId()+"::"+c.getName()+"\n"; }else{ result+=" External component-> "+c.getQualifiedName()+"\n"; } }else{ result+=" Instance component-> "+c.getQualifiedName()+"\n"; } } return result; } }
public boolean canBeUninstalled() { return !isUsed() && isInternal(); }
@Override public boolean equals(Object other) { if (other == null) { return false; } if (other instanceof ComponentInstance) { ComponentInstance otherCompInst = (ComponentInstance) other; Boolean match = getName().equals(otherCompInst.getName()) && type.equals(otherCompInst.getType()); return match; } else { return false; } }
protected void configureImpactedComponents(Set<ComponentInstance> listOfAllComponentImpacted, Map<InternalComponentInstance, InternalComponentInstance> duplicatedGraph){ for(ComponentInstance ici: listOfAllComponentImpacted){ coordinator.updateStatusInternalComponent(ici.getName(), InternalComponentInstance.State.INSTALLED.toString(), CloudAppDeployer.class.getName()); if(ici.isInternal()){ Provider p=ici.asInternal().externalHost().asVM().getType().getProvider(); Connector c2=ConnectorFactory.createIaaSConnector(p); for(Resource r: ici.getType().getResources()){ dep.configure(c2, ci.getType(), ici.asInternal().externalHost().asVM(), r.getConfigureCommand(),false); } c2.closeConnection(); } coordinator.updateStatusInternalComponent(ici.getName(), InternalComponentInstance.State.CONFIGURED.toString(), CloudAppDeployer.class.getName()); } }
/** * Extract the tag that can be identified on the given component instance. * * @param componentInstance the component whose tags are needed * @param tagged the already initialised maps of tags, to be filled in */ private void extractTags(ComponentInstance componentInstance, Map<String, List<String>> tagged) { assert componentInstance != null: "Unable to extract tags from 'null'"; assert !tagged.isEmpty(): "The map of tag must have been initialized"; if (componentInstance.isExternal()) { tagged.get(EXTERNAL.getLabel()).add(componentInstance.getName()); if (componentInstance.asExternal().isVM()) { tagged.get(VM.getLabel()).add(componentInstance.getName()); } } if (componentInstance.isInternal()) { tagged.get(INTERNAL.getLabel()).add(componentInstance.getName()); } if (isService(componentInstance)) { tagged.get(SERVICE.getLabel()).add(componentInstance.getName()); } else { tagged.get(NOT_SERVICE.getLabel()).add(componentInstance.getName()); } }
@Override public Requirement from(ComponentInstance<?> instance) { requireValidComponent(instance); Requirement requirements = nothing(); if (instance.isInternal()) { final InternalComponentInstance internalInstance = instance.asInternal(); for (RequiredPortInstance eachDependency: internalInstance.getRequiredPorts()) { if (eachDependency.isBound()) { requirements = requirements.and(require(eachDependency.findProvider().getName())); } } requirements = requirements.and(require(internalInstance.getHost().getName())); } return requirements; }
/** * @return the external component at the bottom of the underlying software * stack. For instance, if an application, is running on the top of a war * container, itself running on linux virtual machine, externalHost will * return the linux VM. */ public ExternalComponentInstance<? extends ExternalComponent> externalHost() { final ComponentInstance<? extends Component> directHost = getHost(); if(directHost != null){ if (directHost.isInternal()) { return directHost.asInternal().externalHost(); } return directHost.asExternal(); }else{ return null; } }
private PuppetResource findPuppetResource(ComponentInstance ci){ for(Resource r: ci.getType().getResources()){ if(r instanceof PuppetResource){ if(skeleton == null) skeleton=(PuppetResource)r; return (PuppetResource)r; } } return null; }
private ComponentInstance<? extends Component> rejectIfInvalid(ComponentInstance<? extends Component> host) { if (host == null) { throw new IllegalArgumentException("'null' is not a valid destination for installation"); } if (!host.canHost(type)) { final String error = String.format("Illegal installation: '%s' cannot host component of type '%s'", host.getName(), type.getName()); throw new IllegalArgumentException(error); } return host; }
public ExternalComponentInstanceGroup onlyExternals() { final ExternalComponentInstanceGroup externalInstances = new ExternalComponentInstanceGroup(); for (final T instance: this) { if (instance.isExternal()) { externalInstances.add(instance.asExternal()); } } return externalInstances; }
public InternalComponentInstanceGroup onlyInternals() { final InternalComponentInstanceGroup internalInstances = new InternalComponentInstanceGroup(); for (final T instance: this) { if (instance.isInternal()) { internalInstances.add(instance.asInternal()); } } return internalInstances; }
for(Property p : c.getProperties()){ if(p.getName().startsWith("env:")){ if(c.getHost().asExternal().isVM()){ prepareSetEnv(d,c,p);
private ProvidedPortInstance findServerPort(Deployment container) { final ComponentInstance server = findServer(container); final ProvidedPort portType = server.getType().getProvidedPorts().firstNamed(serverPort); final ProvidedPortInstance port = server.getProvidedPorts().ofType(portType); if (port == null) { final String error = String.format("Unable to find the provided port '%s' in '%s'", serverPort, server); throw new IllegalStateException(error); } return port; }
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 dispatchTo(Visitor visitor, ComponentInstance<? extends Component> instance) { for (ProvidedPortInstance port : instance.getProvidedPorts()) { visitor.visitProvidedPortInstance(port); } for (ProvidedExecutionPlatformInstance platform : instance.getProvidedExecutionPlatforms()) { visitor.visitProvidedExecutionPlatformInstance(platform); } }
public void convertAndAddProvidedPortInstances(List<net.cloudml.core.ProvidedPortInstance> ppi, ComponentInstance ai) { ProvidedPortInstanceGroup ppig=new ProvidedPortInstanceGroup(); for (net.cloudml.core.ProvidedPortInstance kapi: ppi) { ProvidedPortInstance api = new ProvidedPortInstance(kapi.getName(), providedPorts.get(ai.getType().getName() + "_" + kapi.getType().getName())); api.getOwner().set(ai); convertProperties(kapi, api); //ai.getProvidedPorts().add(api); ppig.add(api); providedPortInstances.put(api.getName(), api); } ai.setProvidedPorts(ppig); }
private void addRelationships() { addedRelationships = new ArrayList<RelationshipInstance>(targetDM.getRelationshipInstances()); addedRelationships.removeAll(matchingRelationships.values()); for (RelationshipInstance ni : addedRelationships) { int i = currentDM.getComponentInstances().toList().indexOf(ni.getRequiredEnd().getOwner().get()); if (i >= 0) { ComponentInstance a = currentDM.getComponentInstances().toList().get(i); if (a.isInternal()) { int j = ((InternalComponentInstance) a).getRequiredPorts().toList().indexOf(ni.getRequiredEnd()); ni.setRequiredEnd(((InternalComponentInstance) a).getRequiredPorts().toList().get(j)); } } i = currentDM.getComponentInstances().toList().indexOf(ni.getProvidedEnd().getOwner().get()); if (i >= 0) { ComponentInstance a = currentDM.getComponentInstances().toList().get(i); int j = a.getProvidedPorts().toList().indexOf(ni.getProvidedEnd()); List<ProvidedPortInstance> l = a.getProvidedPorts().toList(); ni.setProvidedEnd(l.get(j)); } } }