/** * Search for a node instance whose name matches a given id * * @param id of the Node instance * @return the node instance with the given id or null */ private NodeInstance findNodeInstanceById(final String id) { for (NodeInstance ni : deploy.getNodeInstances()) { if (ni.getName().equals(id)) { return ni; } } return null; }
@Override public boolean equals(Object other) { if (other instanceof NodeInstance) { NodeInstance otherNode = (NodeInstance) other; return name.equals(otherNode.getName()) && type.equals(otherNode.getType()); } else { return false; } } }
/** * Update the runtime metadata of a node if already deployed * @param a description of a node */ public void updateNodeMetadata(NodeInstance a){ ComputeMetadata cm= getNodeByName(a.getName()); if(cm != null){ a.setPublicAddress(getNodeById(cm.getId()).getPublicAddresses().iterator().next()); a.setId(cm.getId()); } }
public ArrayList<Vertex> drawVerticesFromDeploymentModel(DeploymentModel dm){ ArrayList<Vertex> V=new ArrayList<Vertex>(); for(NodeInstance n : dm.getNodeInstances()){ Vertex v= new Vertex(n.getName(), "node",n); V.add(v); createVertice(v); } for(ArtefactInstance x : dm.getArtefactInstances()){ if(x.getDestination() == null){ Vertex v= new Vertex(x.getName(), "platform",x); V.add(v); createVertice(v); }else{ Vertex v= new Vertex(x.getName(), "soft",x); V.add(v); createVertice(v); } properties.setModel(new CPIMTable(V.get(0))); runtimeProperties.setModel(new CPSMTable(V.get(0))); } return V; }
public void createInstance(NodeInstance a){ try { Server template = new Server(); if(findResourceByName(a.getName(), ResourceType.SERVER).equals("")){ Node node= a.getType(); List<String> sshKeyList = new ArrayList<String> (); sshKeyList.add(findResourceByName(node.getSshKey(),ResourceType.SSHKEY)); template.setResourceName(a.getName()); Nic n=new Nic(); n.setNetworkUUID("89b1a8d2-42dc-3c0a-b5f1-c9f4fc5aacc8"); //TODO: to be added in the metamodel a.setId(findResourceByName(a.getName(), ResourceType.SERVER)); Thread.sleep(90000); a.setId(findResourceByName(a.getName(), ResourceType.SERVER)); Server temp=(Server)findObjectResourceByName(a.getName(), ResourceType.SERVER); a.setPublicAddress(temp.getNics().get(0).getIpAddresses().get(0).getIpAddress()); journal.log(Level.INFO, ">> Running node: " + a.getName() + " id: " + a.getId() + " with public address: " + a.getPublicAddress()); } catch (ExtilityException e) {
graph.addVertex(v); vv.getModel().getGraphLayout().setLocation(v, vv.getRenderContext().getMultiLayerTransformer().inverseTransform(e.getPoint())); Edge newEdge=new Edge(ai.getDestination().getName()+cnt, "destination"); Vertex dest=null; for(Vertex vDest : graph.getVertices()){ if(vDest.getName().equals(ai.getDestination().getName())){ graph.addEdge(newEdge, v, vDest); break;
ComputeMetadata cm= getNodeByName(a.getName()); template.getOptions().as(EC2TemplateOptions.class).securityGroups(node.getSecurityGroup()); template.getOptions().as(EC2TemplateOptions.class).keyPair(node.getSshKey()); template.getOptions().as(EC2TemplateOptions.class).userMetadata("Name", a.getName()); template.getOptions().as(EC2TemplateOptions.class).overrideLoginUser(a.getName());
public void handle(Upload command) { if (deploy == null) { final String text = "No deployment model. Please first load a deployment model"; final Message message = new Message(command, Category.ERROR, text); dispatch(message); } else { NodeInstance ownerNode=null; for(NodeInstance ni : deploy.getNodeInstances()){ if(ni.getName().equals(command.getArtifactId())) ownerNode=ni; } if(ownerNode != null){ Provider p = ownerNode.getType().getProvider(); JCloudsConnector jc = new JCloudsConnector(p.getName(), p.getLogin(), p.getPasswd()); ComputeMetadata c = jc.getNodeByName(command.getArtifactId()); jc.uploadFile(command.getLocalPath(), command.getRemotePath(), c.getId(), "ubuntu", ownerNode.getType().getPrivateKey()); }else{ final String text = "There is no node with this ID!"; final Message message = new Message(command, Category.ERROR, text); dispatch(message); } } //command.markAsCompleted(); }
initProperties(kni, ni); nodeInstances.put(ni.getName(), ni);
public void drawEdgesFromDeploymentModel(DeploymentModel dm, ArrayList<Vertex> v){ for(ArtefactInstance x : dm.getArtefactInstances()){ if(x.getDestination() != null){ Vertex v1=findVertex(x.getName(), v); Vertex v2=findVertex(x.getDestination().getName(), v); Edge e=new Edge("dest"+x.getName(), "destination"); createEdge(e, v1, v2); } } for(BindingInstance bi: dm.getBindingInstances()){ Vertex v1=findVertex(bi.getClient().getOwner().getName(), v); Vertex v2=findVertex(bi.getServer().getOwner().getName(), v); Edge e; if(bi.getClient().getType().getIsOptional()) e=new Edge(bi.getName(), "optional",bi); else e=new Edge(bi.getName(), "mandatory",bi); createEdge(e, v1, v2); } }