mirror of https://github.com/apache/jclouds.git
fixed multi nodes creation issue
This commit is contained in:
parent
6fea7cc950
commit
7d0bd78770
|
@ -97,8 +97,18 @@ public class LibvirtComputeServiceAdapter implements ComputeServiceAdapter<Domai
|
|||
// cloning volume
|
||||
String poolName = storageVol.storagePoolLookupByVolume().getName();
|
||||
StoragePool storagePool = client.storagePoolLookupByName(poolName);
|
||||
StorageVol clonedVol = cloneVolume(storagePool, storageVol);
|
||||
|
||||
StorageVol clonedVol = null; //cloneVolume(storagePool, storageVol);
|
||||
boolean cloned = false;
|
||||
int retry = 0;
|
||||
while(!cloned && retry<10) {
|
||||
try {
|
||||
clonedVol = cloneVolume(storagePool, storageVol);
|
||||
cloned = true;
|
||||
} catch (LibvirtException e) {
|
||||
retry++;
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
// define Domain
|
||||
String xmlFinal = generateClonedDomainXML(domain.getXMLDesc(0), clonedVol);
|
||||
Domain newDomain = client.domainDefineXML(xmlFinal);
|
||||
|
@ -163,9 +173,9 @@ public class LibvirtComputeServiceAdapter implements ComputeServiceAdapter<Domai
|
|||
@Override
|
||||
public void destroyNode(String id) {
|
||||
try {
|
||||
client.domainLookupByUUIDString(id).finalize();
|
||||
client.domainLookupByUUIDString(id).destroy();
|
||||
|
||||
/* TODO
|
||||
/*
|
||||
XMLBuilder builder = XMLBuilder.parse(new InputSource(new StringReader(
|
||||
client.domainLookupByUUIDString(id).getXMLDesc(0)
|
||||
)));
|
||||
|
@ -175,7 +185,7 @@ public class LibvirtComputeServiceAdapter implements ComputeServiceAdapter<Domai
|
|||
storageVol.delete(0);
|
||||
|
||||
client.domainLookupByUUIDString(id).undefine();
|
||||
*/
|
||||
*/
|
||||
} catch (LibvirtException e) {
|
||||
propogate(e);
|
||||
} catch (Exception e) {
|
||||
|
@ -206,7 +216,7 @@ public class LibvirtComputeServiceAdapter implements ComputeServiceAdapter<Domai
|
|||
|
||||
private static StorageVol cloneVolume(StoragePool storagePool, StorageVol from) throws LibvirtException,
|
||||
XPathExpressionException, ParserConfigurationException, SAXException, IOException, TransformerException {
|
||||
return storagePool.storageVolCreateXML(generateClonedVolumeXML(from.getXMLDesc(0)), 0);
|
||||
return storagePool.storageVolCreateXMLFrom(generateClonedVolumeXML(from.getXMLDesc(0)), from, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -86,13 +86,14 @@ public class LibvirtExperimentLiveTest {
|
|||
* You can control the default template via overriding a method in standalonecomputeservicexontextmodule
|
||||
*/
|
||||
|
||||
Set<? extends NodeMetadata> nodeMetadataSet = context.getComputeService().runNodesWithTag("tty", 2);
|
||||
Set<? extends NodeMetadata> nodeMetadataSet = context.getComputeService().runNodesWithTag("tty", 1);
|
||||
for (NodeMetadata nodeMetadata : nodeMetadataSet) {
|
||||
|
||||
context.getComputeService().suspendNode(nodeMetadata.getId());
|
||||
Thread.sleep(3000);
|
||||
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) {
|
||||
e.printStackTrace();
|
||||
|
|
Loading…
Reference in New Issue