public Deployment scaleOut(ExternalComponentInstance eci, Provider provider){ if(eci.isVM()){ scaleOut(eci.asVM(),provider); return currentModel; }else{ Deployment targetModel=cloneCurrentModel(); ExternalComponentInstance eci2=targetModel.getComponentInstances().onlyExternals().firstNamed(eci.getName()); ExternalComponent ec=eci2.getType().asExternal(); ec.setProvider(provider); eci2.setStatus(ComponentInstance.State.STOPPED); dep.deploy(targetModel); return targetModel; } }
public void externalComponentInstanceToPOJO(net.cloudml.core.ExternalComponentInstance kExternalComponentInstance) { checkForNull(kExternalComponentInstance, "Cannot convert null!"); if (kExternalComponentInstance instanceof net.cloudml.core.ExternalComponentInstance) { assert externalComponents.containsKey(kExternalComponentInstance.getType().getName()); ExternalComponentInstance ni = new ExternalComponentInstance(kExternalComponentInstance.getName(), externalComponents.get(kExternalComponentInstance.getType().getName())); //ni.setPublicAddress(kExternalComponentInstance.getPublicAddress()); convertProperties(kExternalComponentInstance, ni); initProvidedExecutionPlatformInstances(kExternalComponentInstance, ni); convertAndAddProvidedPortInstances(kExternalComponentInstance.getProvidedPortInstances(), ni); externalComponentInstances.put(ni.getName(), ni); model.getComponentInstances().add(ni); } else { throw new IllegalArgumentException("Unknown subtype of ExternalComponentInstance '" + kExternalComponentInstance.getClass().getName()); } }
@Override public boolean equals(Object other) { if (other instanceof ExternalComponentInstance) { ExternalComponentInstance otherCompInst = (ExternalComponentInstance) other; Boolean match = getName().equals(otherCompInst.getName()) && getType().equals(otherCompInst.getType()); return match; } else { return false; } } }
if (!alreadyDeployed.contains(instance) && (instance.getRequiredExecutionPlatform() != null)) { ExternalComponentInstance host = instance.externalHost(); if (host.isVM()) { VMInstance ownerVM = host.asVM(); VM n = ownerVM.getType(); ExternalComponent ownerType = (ExternalComponent) host.getType(); Provider p = ownerType.getProvider(); PaaSConnector connector = ConnectorFactory.createPaaSConnector(p); instance.getName(), instance.getName(), host.getName(), stack, minRam, instance.getType().hasProperty("version") ? instance.getType().getProperties().valueOf("version") : "default-cloudml" ); host.setPublicAddress(url); if(instance.hasProperty("containerSize")){ String size =instance.getProperties().valueOf("containerSize"); for(InternalComponentInstance ici: host.hostedComponents()){ coordinator.updateStatusInternalComponent(ici.getName(), InternalComponentInstance.State.RUNNING.toString(), CloudAppDeployer.class.getName()); coordinator.updateStatusInternalComponent(host.getName(), ComponentInstance.State.RUNNING.toString(), CloudAppDeployer.class.getName());
if(p.getValue().startsWith("$")){ if(p.getValue().equals("${this.host.id}")){ value=c.externalHost().asVM().getId(); value=c.externalHost().getName(); value=c.externalHost().getType().getName(); value=c.externalHost().asVM().getType().getProvider().getName(); setEnvVar(c.externalHost().asVM(), p.getName().split(":")[1], value);
ExternalComponent ec = eci.getType().asExternal(); PyHrapiConnector connector = ConnectorFactory.createLoadBalancerProvider(ec.getEndPoint()); String substext = null; try{ Property p = eci.getProperties().get("subLoadBalancers"); substext = p.getValue(); Map backend = connector.getBackEnd(eci.getName()+"Back"); ((Deployment)eci.getOwner().get()) .getComponentInstances() .firstNamed(sub) .asExternal(); ExternalComponent subEc = subEci.getType().asExternal(); String subEndPoint = subEc.getEndPoint(); if(subEndPoint.startsWith("https://")) String accessPort = subEci.hasProperty("port") ? subEci.getProperties().valueOf("port") : "8080"; subEndPoint = subEndPoint.split(":")[0].trim()+":"+accessPort; subEci.getName(), subEndPoint); connector.addPool(eci.getName()+"Back", backend)); journal.log(Level.INFO, ">>Delete Target: "+ connector.deleteTarget(eci.getName()+"Back", "targetOneHold")); connector.start();
ExternalComponent ec = eci.getType(); Provider p = eci.getType().getProvider(); PaaSConnector connector = null; if(!ec.getServiceType().toLowerCase().equals("loadbalancer")) //LoadBalancer need a special connector... ec.hasProperty("DB-Engine") ? ec.getProperties().valueOf("DB-Engine") : null, ec.hasProperty("DB-Version") ? ec.getProperties().valueOf("DB-Version") : null, eci.getName(), ec.hasProperty("DB-Name") ? ec.getProperties().valueOf("DB-Name") : null, ec.getLogin(), null, ec.hasProperty("securityGroup") ? ec.getProperties().valueOf("securityGroup") : ""); String pa=connector.getDBEndPoint(eci.getName(), 600); eci.setPublicAddress(pa); coordinator.updateIP(n.getName(),pa,CloudAppDeployer.class.getName()); coordinator.updateStatus(n.getName(), ComponentInstance.State.RUNNING, CloudAppDeployer.class.getName()); String url = connector.createQueue(n.getName()); eci.setPublicAddress(url); coordinator.updateStatus(n.getName(), ComponentInstance.State.RUNNING, CloudAppDeployer.class.getName()); String GATEWAY = eci.getName()+"GateWay"; gateway.put("gateway", GATEWAY); gateway.put("protocol", "http"); gateway.put("defaultBack", eci.getName()+"Back"); Map<String, String> endpoints = new HashMap<String, String>(); String accessPort = eci.hasProperty("port") ? eci.getProperties().valueOf("port") : "8080"; endpoints.put("endOne", "0.0.0.0:"+accessPort); //TODO: Now only support one load balancer
keci.setName(eni.getName()); keci.setType(this.externalComponents.get(eni.getType().getName())); convertAndAddProvidedPortInstances(eni.getProvidedPorts().toList(), keci);
private static InternalComponent fromCloudmlToModaMP(InternalComponentInstance toTranslate){ InternalComponent toReturn = new InternalComponent(); String id = toTranslate.getName(); toReturn.setId(id); toReturn.setType(String.valueOf(toTranslate.getType().getName())); toReturn.addRequiredComponent(toTranslate.externalHost().getName()); return toReturn; } //Translate a cloud provider from cloudML to Monitoring Platform QoS-model
public VMInstance asVM() { if (!isVM()) { throw new IllegalStateException("Unable to cast an plain external component instance to a VM instance"); } return (VMInstance) this; }
public final boolean isVM() { return getType().isVM(); }
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()); } }
ComponentInstance serveri = bi.getProvidedEnd().getOwner().get(); ComponentInstance clienti = bi.getRequiredEnd().getOwner().get(); if (serveri.isExternal() && "database".equals(((ExternalComponentInstance<ExternalComponent>) serveri).getType().getServiceType())) { //For DB for (Resource res : bi.getType().getResources()) { ConfigValet valet = ConfigValet.createValet(bi, res); String destinationIpAddress = getDestination(server.getOwner().get()).getPublicAddress(); int destinationPortNumber = server.getType().getPortNumber(); String ipAddress = getDestination(clientInternal.getOwner().get()).getPublicAddress(); if(clientResource == null) return; // ignore configuration if there is no resource at all else if (serveri.isExternal() && "loadbalancer".equals(((ExternalComponentInstance<ExternalComponent>) serveri).getType().getServiceType())) { //For Loadbalancer String endpoint = serveri.getType().asExternal().getEndPoint(); if(endpoint==null){ if(clienti.isExternal()){ ExternalComponentInstance<ExternalComponent> exclienti = ((ExternalComponentInstance) clienti); ipAddress = exclienti.getPublicAddress(); port = String.valueOf(bi.getRequiredEnd().getType().getPortNumber()); ipAddress = getDestination(clienti).getPublicAddress(); port = String.valueOf(bi.getRequiredEnd().getType().getPortNumber()); ExternalComponent pltf = clienti.asInternal().externalHost().getType(); PaaSConnector connector = (PaaSConnector) ConnectorFactory.createPaaSConnector(pltf.getProvider()); connector.setEnvVar(clienti.getName(), s.getName(), serveri2.getPublicAddress());
/** * Compares the vms between the targeted and the current deployment model */ public void compareECs() { journal.log(Level.INFO, ">> Comparing ExternalComponents ..."); Boolean match = false; for (ExternalComponentInstance ni : currentDM.getComponentInstances().onlyExternals()) { secondloop: { for (ExternalComponentInstance ni2 : targetDM.getComponentInstances().onlyExternals()) { match = ni.equals(ni2); if (match) { matchingECs.put(ni, ni2); break secondloop; } } } if (!match) { removeEC(ni); } } //add the rest addECs(); }
public ExternalComponentInstance<? extends ExternalComponent> instantiates(String name) { return new ExternalComponentInstance<ExternalComponent>(name, this); }
((ExternalComponentInstance)res2).setStatus(ComponentInstance.State.PENDING); journal.log(Level.INFO, ">> No former status, updating the model.."); wrapper.eSet("/componentInstances[name='" + name + "']", wrapper.makePair("status", "" + newState + ""));
if(p.getValue().startsWith("$")){ if(p.getValue().equals("${this.host.id}")){ value=c.externalHost().asVM().getId(); value=c.externalHost().getName(); value=c.externalHost().getType().getName(); value=c.externalHost().asVM().getType().getProvider().getName(); return setEnvVarCommand(c.externalHost().asVM(), p.getName().split(":")[1], value);
public VMInstanceGroup onlyVMs() { final VMInstanceGroup selection = new VMInstanceGroup(); for (final T instance: this) { if (instance.isExternal()) { final ExternalComponentInstance<? extends ExternalComponent> external = instance.asExternal(); if (external.isVM()) { selection.add(external.asVM()); } } } return selection; }
@Override public void handle(Upload command) { if (isDeploymentLoaded()) { ExternalComponentInstance ownerVM = null; for (ExternalComponentInstance ni: deploy.getComponentInstances().onlyExternals()) { if (ni.getName().equals(command.getArtifactId())) { ownerVM = ni; } } if (ownerVM != null && ownerVM instanceof VMInstance) { Provider p = ((VMInstance) ownerVM).getType().getProvider(); JCloudsConnector jc = new JCloudsConnector(p.getName(), p.getCredentials().getLogin(), p.getCredentials().getPassword()); ComputeMetadata c = jc.getVMByName(command.getArtifactId()); jc.uploadFile(command.getLocalPath(), command.getRemotePath(), c.getId(), "ubuntu", ((VM) ownerVM.getType()).getPrivateKey()); } else { final String text = "There is no VM with this ID!"; final Message message = new Message(command, Category.ERROR, text); dispatch(message); } } else { reportNoDeploymentLoaded(command); } }