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; }
/** * Check whether the given component is a marked as being a "service". * * @param instance the component instance of interest * @return true if the instance is marked as being a service, false * otherwise */ private boolean isService(ComponentInstance instance) { assert instance != null: "Cannot check if 'null' is a service "; assert instance.getType() != null: "The given component has no type!"; if (instance.getType().hasProperty(IS_SERVICE)) { final Property isService = instance.getType().getProperties().get(IS_SERVICE); final String escapedValue = isService.getValue().trim().toUpperCase(); if (YES_MARKERS.contains(escapedValue)) { return true; } } return false; }
@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(); }
@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; } }
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; }
public ComponentInstanceGroup<T> ofType(String typeName) { final ComponentInstanceGroup<T> selected = new ComponentInstanceGroup<T>(); for (T instance: this) { if (instance.getType().isNamed(typeName)) { selected.add(instance); } } return selected; }
Component warComp = warCompi.getType();
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); }
/** * Find all the component that can be used as service providers for the * given required port * * @param requiredPort the port for which a provider is needed * @return the list of candidates service providers */ private List<ComponentInstance<?>> findAllCandidateProviders(RequiredPortInstance requiredPort) { assert requiredPort != null: "Unable to find service providers for 'null'"; final List<ComponentInstance<?>> candidates = new LinkedList<ComponentInstance<?>>(); final Deployment deployment = requiredPort.getDeployment(); for (Relationship eachRelationship: deployment.getRelationships()) { if (eachRelationship.getRequiredEnd().equals(requiredPort.getType())) { final ProvidedPort serverType = eachRelationship.getProvidedEnd(); for (ComponentInstance<?> eachComponent: deployment.getComponentInstances()) { if (eachComponent.getType().canProvide(serverType)) { candidates.add(eachComponent); } } } } return candidates; }
private ProvidedExecutionPlatformInstance initProvidedExecutionPlatformInstance(net.cloudml.core.ProvidedExecutionPlatformInstance kpepi, ComponentInstance ai) { if (kpepi != null) { ProvidedExecutionPlatform pepType = null; for (ProvidedExecutionPlatform pep: ai.getType().getProvidedExecutionPlatforms()) { if (pep.getName().equals(kpepi.getType().getName())) { pepType = pep; } } ProvidedExecutionPlatformInstance pepi = new ProvidedExecutionPlatformInstance(kpepi.getName(), pepType); pepi.getOwner().set(ai); convertProperties(kpepi, pepi); convertResources(kpepi, pepi); providedExecutionPlatformInstances.put(pepi.getName(), pepi); return pepi; } return null; }
protected void startImpactedComponents(Set<ComponentInstance> listOfAllComponentImpacted, Map<InternalComponentInstance, InternalComponentInstance> duplicatedGraph){ for(ComponentInstance ici: listOfAllComponentImpacted){ if(ici.isInternal()){ Provider p=ici.asInternal().externalHost().asVM().getType().getProvider(); Connector c2=ConnectorFactory.createIaaSConnector(p); for(Resource r: ici.getType().getResources()){ dep.start(c2,ci.getType(),ici.asInternal().externalHost().asVM(),r.getStartCommand()); } c2.closeConnection(); } coordinator.updateStatusInternalComponent(ici.getName(), InternalComponentInstance.State.RUNNING.toString(), CloudAppDeployer.class.getName()); } for(InternalComponentInstance ici: duplicatedGraph.values()){ coordinator.updateStatusInternalComponent(ici.getName(), InternalComponentInstance.State.RUNNING.toString(), CloudAppDeployer.class.getName()); } }
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()); } }
for (Resource r : host.getType().getResources()) { String configurationCommand = CloudMLQueryUtil.cloudmlStringRecover(r.getConfigureCommand(), r, x); configure(jc, n, ownerVM, configurationCommand, r.getRequireCredentials()); for (Resource r : host.getType().getResources()) { String startCommand = CloudMLQueryUtil.cloudmlStringRecover(r.getStartCommand(), r, x); start(jc, n, ownerVM, startCommand);
for (Resource r : serverComponent.getType().getResources()) { executeUploadCommands(serverComponent.asInternal(),owner,jc); for (Resource r : serverComponent.getType().getResources()) { executeRetrieveCommand(serverComponent.asInternal(),owner,jc); for (Resource r : serverComponent.getType().getResources()) { executeInstallCommand(serverComponent.asInternal(),owner,jc); for (Resource r : serverComponent.getType().getResources()) { String configurationCommand = r.getConfigureCommand(); configure(jc, n, owner, configurationCommand, r.getRequireCredentials()); for (Resource r : serverComponent.getType().getResources()) { String startCommand = CloudMLQueryUtil.cloudmlStringRecover(r.getStartCommand(), r, x); start(jc, n, owner, startCommand);
private void startExecutes(InternalComponentInstance x){ VMInstance ownerVM = x.externalHost().asVM(); //need some tests but if you need to build PaaS then it means that you want to deploy on IaaS VM n = ownerVM.getType(); Connector jc = ConnectorFactory.createIaaSConnector(n.getProvider()); ComponentInstance host = x.getHost(); if (!alreadyStarted.contains(host)) { if (host.isInternal()) { startExecutes(host.asInternal()); for (Resource r : host.getType().getResources()) { String startCommand = CloudMLQueryUtil.cloudmlStringRecover(r.getStartCommand(), r, x); start(jc, n, ownerVM, startCommand); } coordinator.updateStatusInternalComponent(host.getName(), State.RUNNING.toString(), CloudAppDeployer.class.getName()); alreadyStarted.add(host); } } jc.closeConnection(); }
coordinator.updateStatus(bi.getProvidedEnd().getOwner().get().getName(), ComponentInstance.State.PENDING, CloudAppDeployer.class.getName()); try{ Provider p = ((ExternalComponent) bi.getProvidedEnd().getOwner().get().getType()).getProvider(); PaaSConnector connector = ConnectorFactory.createPaaSConnector(p); String alias = res.getProperties().valueOf("db-binding-alias"); Component client = clienti.getType(); ComponentInstance pltfi = getDestination(clienti); if(pltfi.isExternal()){ ExternalComponent pltf = (ExternalComponent) pltfi.getType(); if(!pltf.isVM()){ if(client.hasProperty("temp-warfile")) { String endpoint = serveri.getType().asExternal().getEndPoint(); if(endpoint==null){ Map<String, String> env = System.getenv();
@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; }