/** * Upload resources associated to an internal component on a specified * external component * * @param x the internal component with upload commands * @param owner the external component on which the resources are about to * be uploaded * @param jc the connector used to upload */ private void executeUploadCommands(InternalComponentInstance x, VMInstance owner, Connector jc) { journal.log(Level.INFO, ">> Upload "+x.getType().getName()); unlessNotNull("Cannot upload with an argument at null", x, owner, jc); for (Resource r : x.getType().getResources()) { for (String path : r.getUploadCommand().keySet()) { jc.uploadFile(path, r.getUploadCommand().get(path), owner.getId(), "ubuntu", owner.getType().getPrivateKey()); } } }
/** * Prepare an artefact before it starts. Retrieves its resources, builds its PaaS and installs it * @param x an ArtefactInstance * @param dm the deployment model used to build the artefact's PaaS * @throws MalformedURLException */ private void prepareAnArtefact(ArtefactInstance x, List<ArtefactInstance> artefacts, List<BindingInstance> bindings) { Connector jc; if(!alreadyDeployed.contains(x) && (x.getDestination() != null)){ NodeInstance ownerNode = x.getDestination(); Node n=ownerNode.getType(); jc=ConnectorFactory.createConnector(n.getProvider()); for(String path : x.getType().getResource().getUploadCommand().keySet()){ jc.uploadFile(path, x.getType().getResource().getUploadCommand().get(path), ownerNode.getId(), "ubuntu", n.getPrivateKey()); } jc.execCommand(ownerNode.getId(), x.getType().getResource().getRetrievingResourceCommand(),"ubuntu",n.getPrivateKey()); alreadyDeployed.add(x); buildPaas(x,bindings); jc.execCommand(ownerNode.getId(), x.getType().getResource().getDeployingResourceCommand(),"ubuntu",n.getPrivateKey()); jc.closeConnection(); } }
private void setResourceProperties(Resource r, net.cloudml.core.Resource kr){ kr.setName(r.getName()); kr.setInstallCommand(r.getInstallCommand()); kr.setDownloadCommand(r.getRetrieveCommand()); kr.setConfigureCommand(r.getConfigureCommand()); kr.setStartCommand(r.getStartCommand()); kr.setStopCommand(r.getStopCommand()); kr.setRequireCredentials(r.getRequireCredentials()); kr.setExecuteLocally(r.getExecuteLocally()); convertProperties(r,kr,factory); String kup = ""; for (Map.Entry<String, String> up: r.getUploadCommand().entrySet()) { kup += up.getKey() + " " + up.getValue() + ";"; } kr.setUploadCommand(kup); }
kr.setStopCommand(a.getResource().getStopResourceCommand()); for(Entry<String, String> up : a.getResource().getUploadCommand().entrySet()){ net.cloudml.core.UploadCommand kup = factory.createUploadCommand(); kup.setSource(up.getKey());