@Override public void handle(Snapshot command) { if (isDeploymentLoaded()) { dispatch(new Message(command, Category.INFORMATION, "Generating snapshot ...")); VMInstance vmi = deploy.getComponentInstances().onlyVMs().withID(command.getVmId()); Connector c = ConnectorFactory.createIaaSConnector(vmi.getType().getProvider()); c.createSnapshot(vmi); } else { reportNoDeploymentLoaded(command); } }
@Override public void handle(Image command) { if (isDeploymentLoaded()) { dispatch(new Message(command, Category.INFORMATION, "Generating an image ...")); VMInstance vmi = deploy.getComponentInstances().onlyVMs().withID(command.getVmId()); Connector c = ConnectorFactory.createIaaSConnector(vmi.getType().getProvider()); c.createImage(vmi); } else { reportNoDeploymentLoaded(command); } }
public void run() { VMInstance vmi = deploy.getComponentInstances().onlyVMs().withID(id); if (vmi != null) { Provider provider = vmi.getType().getProvider(); Connector c = ConnectorFactory.createIaaSConnector(provider); for(InternalComponentInstance ici : vmi.hostedComponents()){ InternalComponent ic=ici.getType(); for(Resource r : ic.getResources()){ c.execCommand(vmi.getId(),r.getStopCommand(),"ubuntu",vmi.getType().getPrivateKey()); } } c.stopVM(vmi); coordinator.updateStatus(vmi.getName(), ComponentInstance.State.STOPPED, Facade.class.getName()); c.closeConnection(); } } });
public void run() { VMInstance vmi = deploy.getComponentInstances().onlyVMs().withID(id); if (vmi != null) { Provider provider = vmi.getType().getProvider(); Connector c = ConnectorFactory.createIaaSConnector(provider); c.startVM(vmi); coordinator.updateStatus(vmi.getName(), ComponentInstance.State.RUNNING, Facade.class.getName()); for(InternalComponentInstance ici : vmi.hostedComponents()){ InternalComponent ic=ici.getType(); for(Resource r : ic.getResources()){ c.execCommand(vmi.getId(),r.getStartCommand(),"ubuntu",vmi.getType().getPrivateKey()); } } c.closeConnection(); } }}); ts.get(i).start();
@Override public void handle(ScaleOut command) { dispatch(new Message(command, Category.INFORMATION, "Scaling out VM: " + command.getVmId())); VMInstance vmi = deploy.getComponentInstances().onlyVMs().withID(command.getVmId()); if (vmi == null) { dispatch(new Message(command, Category.ERROR, "Cannot find a VM with this ID!")); } else { Boolean success=true; if(command.getNb() > 1) { success=deployer.scaleOut(vmi, command.getNb()); } else { success=deployer.scaleOut(vmi); } /*if(!success){ if (coordinator != null) { coordinator.ack("MaxVMsReached", command.getClass().getName()); } }*/ } }
@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); } }