destroy() implemented

This commit is contained in:
andreaturli 2010-11-10 21:43:06 +01:00
parent 47aff91e1e
commit 5a177e9c76
3 changed files with 7 additions and 15 deletions

View File

@ -25,15 +25,18 @@ import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.Constants; import org.jclouds.Constants;
import org.jclouds.compute.ComputeService;
import org.jclouds.compute.ComputeServiceAdapter; import org.jclouds.compute.ComputeServiceAdapter;
import org.jclouds.compute.config.StandaloneComputeServiceContextModule; import org.jclouds.compute.config.StandaloneComputeServiceContextModule;
import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.compute.internal.BaseComputeService;
import org.jclouds.compute.suppliers.DefaultLocationSupplier; import org.jclouds.compute.suppliers.DefaultLocationSupplier;
import org.jclouds.domain.Location; import org.jclouds.domain.Location;
import org.jclouds.libvirt.Datacenter; import org.jclouds.libvirt.Datacenter;
import org.jclouds.libvirt.Image; import org.jclouds.libvirt.Image;
import org.jclouds.libvirt.compute.LibvirtComputeService;
import org.jclouds.libvirt.compute.functions.DatacenterToLocation; import org.jclouds.libvirt.compute.functions.DatacenterToLocation;
import org.jclouds.libvirt.compute.functions.DomainToHardware; import org.jclouds.libvirt.compute.functions.DomainToHardware;
import org.jclouds.libvirt.compute.functions.DomainToNodeMetadata; import org.jclouds.libvirt.compute.functions.DomainToNodeMetadata;
@ -73,6 +76,8 @@ StandaloneComputeServiceContextModule<Domain, Domain, Image, Datacenter> {
}).to(DomainToHardware.class); }).to(DomainToHardware.class);
bind(new TypeLiteral<Function<Datacenter, Location>>() { bind(new TypeLiteral<Function<Datacenter, Location>>() {
}).to(DatacenterToLocation.class); }).to(DatacenterToLocation.class);
bind(ComputeService.class).to(LibvirtComputeService.class);
} }
@Provides @Provides

View File

@ -174,18 +174,6 @@ public class LibvirtComputeServiceAdapter implements ComputeServiceAdapter<Domai
public void destroyNode(String id) { public void destroyNode(String id) {
try { try {
client.domainLookupByUUIDString(id).destroy(); client.domainLookupByUUIDString(id).destroy();
/*
XMLBuilder builder = XMLBuilder.parse(new InputSource(new StringReader(
client.domainLookupByUUIDString(id).getXMLDesc(0)
)));
String diskFileName = builder.xpathFind("//devices/disk[@device='disk']/source").getElement().getAttribute("file");
System.out.println(" :P " +diskFileName);
StorageVol storageVol = client.storageVolLookupByPath(diskFileName);
storageVol.delete(0);
client.domainLookupByUUIDString(id).undefine();
*/
} catch (LibvirtException e) { } catch (LibvirtException e) {
propogate(e); propogate(e);
} catch (Exception e) { } catch (Exception e) {

View File

@ -88,11 +88,10 @@ public class LibvirtExperimentLiveTest {
Set<? extends NodeMetadata> nodeMetadataSet = context.getComputeService().runNodesWithTag("tty", 1); Set<? extends NodeMetadata> nodeMetadataSet = context.getComputeService().runNodesWithTag("tty", 1);
for (NodeMetadata nodeMetadata : nodeMetadataSet) { for (NodeMetadata nodeMetadata : nodeMetadataSet) {
/*
context.getComputeService().suspendNode(nodeMetadata.getId()); context.getComputeService().suspendNode(nodeMetadata.getId());
context.getComputeService().resumeNode(nodeMetadata.getId()); context.getComputeService().resumeNode(nodeMetadata.getId());
*/
// TODO seems that destroy is intended to be a force shutoff, not a delete VM ...
context.getComputeService().destroyNode(nodeMetadata.getId()); context.getComputeService().destroyNode(nodeMetadata.getId());
} }
} catch (Exception e) { } catch (Exception e) {