private void addECs() { addedECs = new ArrayList<ExternalComponentInstance<? extends ExternalComponent>>(targetDM.getComponentInstances().onlyExternals()); addedECs.removeAll(matchingECs.values()); }
public VMInstance selectDestination() { JPanel panel = new JPanel(); panel.add(new JLabel("Please make a selection:")); DefaultComboBoxModel model = new DefaultComboBoxModel(); for (ExternalComponentInstance n : dm.getComponentInstances().onlyExternals()) { model.addElement(n); } JComboBox comboBox = new JComboBox(model); panel.add(comboBox); int result = JOptionPane.showConfirmDialog(null, panel, "Destination", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); switch (result) { case JOptionPane.OK_OPTION: return ((VMInstance) comboBox.getSelectedItem()); } return null; }
public void externalComponentInstancesToPOJO(List<net.cloudml.core.ExternalComponentInstance> componentInstances) { int counter = 0; for (net.cloudml.core.ExternalComponentInstance kc: componentInstances) { externalComponentInstanceToPOJO((net.cloudml.core.ExternalComponentInstance) kc); counter++; } assert counter == model.getComponentInstances().onlyExternals().size(); assert externalComponentInstances.size() == counter; }
/** * 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 ArrayList<Vertex> drawVerticesFromDeploymentModel(Deployment dm) { ArrayList<Vertex> V = new ArrayList<Vertex>(); for (ExternalComponentInstance n : dm.getComponentInstances().onlyExternals()) { Vertex v = new Vertex(n.getName(), "node", n); V.add(v); createVertice(v); } for (ComponentInstance x : dm.getComponentInstances()) { if (x instanceof InternalComponentInstance) { InternalComponentInstance ix = (InternalComponentInstance) x; if (ix.getRequiredExecutionPlatform() == null) { Vertex v = new Vertex(x.getName(), "platform", ix); V.add(v); createVertice(v); } else { Vertex v = new Vertex(x.getName(), "soft", ix); V.add(v); createVertice(v); } }//TODO else } return V; }
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; } }
@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); } }
setExternalServices(targetModel.getComponentInstances().onlyExternals());
@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); } }
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; }