/** * Transform a snapshot into an image * @param vmi the VMInstance to use * @param snapshotID identifier of the snapshot * @return id of the image */ public String snapshotToImage(VMInstance vmi, String snapshotID){ AMIApi ami=ec2api.getAMIApi().get(); journal.log(Level.INFO, ">> Creating an image from snapshot: "+snapshotID); String id=ami.registerUnixImageBackedByEbsInRegion("eu-west-1",vmi.getName()+"-image",snapshotID); journal.log(Level.INFO, ">> Image created with ID: "+id); return id; }
@Override public void startVM(VMInstance a) { journal.log(Level.INFO, ">> Starting VM: "+a.getName()); try{ novaComputeService.resumeNode(a.getId()); }catch(Exception exception){ journal.log(Level.INFO, ">> Check VM status!"); } }
@Override public void stopVM(VMInstance a) { journal.log(Level.INFO, ">> Stopping VM: "+a.getName()); try{ novaComputeService.suspendNode(a.getId()); }catch(Exception exception){ journal.log(Level.INFO, ">> Check VM status!"); } }
@Override public void startVM(VMInstance a) { journal.log(Level.INFO, ">> Starting VM: "+a.getName()); cloudSigmaApi.startServer(a.getId()); }
@Override public void stopVM(VMInstance a) { journal.log(Level.INFO, ">> Stopping VM: "+a.getName()); compute.suspendNode(a.getId()); }
@Override public void startVM(VMInstance a) { journal.log(Level.INFO, ">> Starting VM: "+a.getName()); compute.resumeNode(a.getId()); }
@Override public void stopVM(VMInstance a) { journal.log(Level.INFO, ">> Stopping VM: "+a.getName()); cloudSigmaApi.stopServer(a.getId()); } }
private void provisionVM(VMInstance vmi){ Connector c2=ConnectorFactory.createIaaSConnector(vmi.getType().getProvider()); HashMap<String,Object> result=c2.createInstance(ci); c2.closeConnection(); coordinator.updateStatusInternalComponent(ci.getName(), result.get("status").toString(), CloudAppDeployer.class.getName()); coordinator.updateStatus(vmi.getName(), ComponentInstance.State.RUNNING, CloudAppDeployer.class.getName()); coordinator.updateIP(ci.getName(),result.get("publicAddress").toString(),CloudAppDeployer.class.getName()); } }
/** * Update the runtime metadata of a VM if already deployed * @param a description of a VM */ public void updateVMMetadata(VMInstance a){ ComputeMetadata cm= getVMByName(a.getName()); if(cm != null){ if(((NodeMetadata)cm).getPublicAddresses().size() > 0) a.setPublicAddress(((NodeMetadata)cm).getPublicAddresses().iterator().next()); a.setId(cm.getId()); a.setStatus(ComponentInstance.State.RUNNING); } }
@Override public void startVM(VMInstance a) { try { journal.log(Level.INFO, ">> Starting VM: "+a.getName()); Job startJob=service.changeServerStatus(a.getId(), ServerStatus.RUNNING, true, null, null); service.waitForJob(startJob.getResourceUUID(), false); } catch (ExtilityException e) { e.printStackTrace(); } }
@Override public void stopVM(VMInstance a) { try { journal.log(Level.INFO, ">> Stopping VM: "+a.getName()); Job startJob=service.changeServerStatus(a.getId(), ServerStatus.STOPPED, true, null, null); service.waitForJob(startJob.getResourceUUID(), false); } catch (ExtilityException e) { e.printStackTrace(); } }
/** * Update the runtime metadata of a VM if already deployed * @param a description of a VM */ public void updateVMMetadata(VMInstance a){ ComputeMetadata cm= getVMByName(a.getName()); if(cm != null){ a.setPublicAddress(getVMById(cm.getId()).getPublicAddresses().iterator().next()); a.setId(cm.getId()); runtimeInformation.put("publicAddress", a.getPublicAddress()); } }
@Override public void updateVMMetadata(VMInstance a) { ComputeMetadata cm= getVMByName(a.getName()); if(cm != null){ a.setPublicAddress(getVMById(cm.getId()).getPublicAddresses().iterator().next()); a.setId(cm.getId()); } }
public void install(VMInstance vmi){ try { startPuppetAgent(vmi.getType().getPrivateKey(),vmi.getType().getLogin(), vmi.getType().getPasswd(), vmi.getName(), vmi.getPublicAddress()); } catch (Exception e) { e.printStackTrace(); } }
/** * Generate the manifest file for each VM from the manifestEntry of each puppet resource and start puppet. */ private void generatePuppetManifestAndConfigure(){ for(VMInstance vmi : currentModel.getComponentInstances().onlyVMs()){ PuppetManifestGenerator pmg = new PuppetManifestGenerator(vmi, currentModel); String path=pmg.generate(); if(path != null){ managePuppet(pmg.getSkeleton(), vmi, vmi.getName(), path); } } }
public void vmInstanceToPOJO(net.cloudml.core.VMInstance kVmInstance) { net.cloudml.core.VMInstance kVM = (net.cloudml.core.VMInstance) kVmInstance; assert vms.containsKey(kVM.getType().getName()); VMInstance ni = new VMInstance(kVM.getName(), vms.get(kVM.getType().getName())); ni.setPublicAddress(kVM.getPublicAddress()); ni.setHostname(kVM.getHostname()); convertProperties(kVM, ni); initProvidedExecutionPlatformInstances(kVmInstance, ni); vmInstances.put(ni.getName(), ni); model.getComponentInstances().add(ni); }
private static VM fromCloudmlToModaMP(VMInstance toTranslate) { VM toReturn = new VM(); //KB entity field String id = toTranslate.getName(); toReturn.setId(id); toReturn.setType(String.valueOf(toTranslate.getType().getName())); toReturn.setCloudProvider(toTranslate.getType().getProvider().getName()); toReturn.setLocation(toTranslate.getType().getLocation()); toReturn.setNumberOfCPUs(toTranslate.getCore()); return toReturn; } //Translate an internal component from cloudML to Monitoring Platform QoS-model
@Override public String toString() { return "VMInstance: " + getName() + " Type:" + getType().getName() + "{\n" + "minRam:" + (getType()).getMinRam() + "\n" + "minCore" + (getType()).getMinCores() + "\n" + "minDisk" + (getType()).getMinStorage() + "\n" + "OS" + (getType()).getOs() + "\n" + "location" + (getType()).getLocation() + "\n" + "publicAdress" + getPublicAddress() + "\n" + "groupName" + (getType()).getGroupName(); }