private void addECs() { addedECs = new ArrayList<ExternalComponentInstance<? extends ExternalComponent>>(targetDM.getComponentInstances().onlyExternals()); addedECs.removeAll(matchingECs.values()); }
private void addComponents() { addedComponents = new ArrayList<InternalComponentInstance>(targetDM.getComponentInstances().onlyInternals()); addedComponents.removeAll(matchingComponents.values()); }
public ComponentInstanceGroup<T> hosting(InternalComponentInstance component) { final ComponentInstanceGroup<T> selected = new ComponentInstanceGroup<T>(); for (T instance: this) { if (instance.isHosting(component)) { selected.add(instance); } } return selected; }
/** * Convert a list of ExternalCOmpnents model from CloudMl in a format * compatible with MODAClouds Monitoring Platform's APIs * * @param addedECs the list */ public static Model fromCloudmlToModaMP(List<ExternalComponentInstance<? extends org.cloudml.core.ExternalComponent>> addedECs, List<InternalComponentInstance> addedICs) { //create a new list for avoid changes in the original one ComponentInstanceGroup supportList = new ComponentInstanceGroup(); supportList.addAll(addedECs); supportList.addAll(addedICs); //call the actual translator return getModelUpdates(supportList, null); }
public final ComponentInstanceGroup<ComponentInstance<? extends Component>> instances() { if (owner.isUndefined()) { return new ComponentInstanceGroup<ComponentInstance<? extends Component>>(); } return getDeployment().getComponentInstances().ofType(getName()); }
public void remove(VMInstance vmi, Deployment target){ if(nbOfReplicats > minReplicats){ if(baseInstances.contains(vmi)){ target.getComponentInstances().onlyVMs().remove(vmi); nbOfReplicats--; }else{ throw new IllegalArgumentException("This VM is not part of the Pool"); } }else{ throw new IllegalStateException("You already reached the minimum number of replicats"); } }
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; }
setExternalServices(targetModel.getComponentInstances().onlyExternals()); configureSaas(targetModel.getComponentInstances().onlyInternals()); configureWithPuppet(targetModel.getComponentInstances().onlyInternals()); generatePuppetManifestAndConfigure(); prepareComponents(new ComponentInstanceGroup(diff.getAddedComponents()), targetModel.getRelationshipInstances()); configureWithRelationships(new RelationshipInstanceGroup(diff.getAddedRelationships())); configureSaas(new ComponentInstanceGroup<InternalComponentInstance>(diff.getAddedComponents())); configureWithPuppet(targetModel.getComponentInstances().onlyInternals()); generatePuppetManifestAndConfigure();
for(VMInstance c: d.getComponentInstances().onlyVMs()){ setEnvVar(c,"MODACLOUDS_TOWER4CLOUDS_MANAGER_IP",ip); setEnvVar(c,"MODACLOUDS_TOWER4CLOUDS_MANAGER_PORT",port); 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 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(); }
ComponentInstanceGroup supportList = new ComponentInstanceGroup(); supportList.addAll(removedECs); VMInstanceGroup removedVMs = supportList.onlyVMs();
@Override public boolean add(T element) { element.getOwner().set(Deployment.this); if (firstNamed(element.getName()) != null) { //final String error = String.format("Component instance name must be unique! There is already a component instance named '%s'.", element.getName()); //throw new IllegalStateException(error); return false; } return super.add(element); }
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 void handle(Burst command){ dispatch(new Message(command, Category.INFORMATION, "Bursting out External Component: " + command.getEcId()+" to "+ command.getProviderID())); VMInstance vmi = deploy.getComponentInstances().onlyVMs().withID(command.getEcId()); Provider p=deploy.getProviders().firstNamed(command.getProviderID()); if(p == null){ dispatch(new Message(command, Category.ERROR, "Cannot find a Provider with this ID!")); return; } if (vmi == null) { ExternalComponentInstance eci=deploy.getComponentInstances().onlyExternals().firstNamed(command.getEcId()); if(eci == null){ dispatch(new Message(command, Category.ERROR, "Cannot find a External component with this ID!")); }else{ deployer.scaleOut(eci,p); } } else { deployer.scaleOut(vmi,p); } }
@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; }
prepareComponents(new ComponentInstanceGroup(diff.getAddedComponents()), targetModel.getRelationshipInstances()); configureWithRelationships(new RelationshipInstanceGroup(diff.getAddedRelationships())); configureSaas(new ComponentInstanceGroup<InternalComponentInstance>(diff.getAddedComponents())); configureWithPuppet(targetModel.getComponentInstances().onlyInternals()); generatePuppetManifestAndConfigure();
/** * 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 boolean remove(Object o) { Boolean b=super.remove(o); if (b && o instanceof ComponentInstance) { final ComponentInstance<? extends Component> instance = (ComponentInstance<? extends Component>) o; instance.getOwner().discard(); } return b; } }
public void reset(){ setCurrentModel(null); alreadyDeployed=new ComponentInstanceGroup<ComponentInstance<? extends Component>>(); alreadyStarted=new ComponentInstanceGroup<ComponentInstance<? extends Component>>(); }