mirror of https://github.com/apache/jclouds.git
cosmetic fixes
This commit is contained in:
parent
3e30910b86
commit
b0a9263486
|
@ -44,6 +44,7 @@ import org.xml.sax.InputSource;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import com.jamesmurty.utils.XMLBuilder;
|
import com.jamesmurty.utils.XMLBuilder;
|
||||||
|
@ -69,7 +70,6 @@ public class DomainToHardware implements Function<Domain, Hardware> {
|
||||||
builder.processors(processors);
|
builder.processors(processors);
|
||||||
|
|
||||||
builder.ram((int) from.getInfo().maxMem);
|
builder.ram((int) from.getInfo().maxMem);
|
||||||
// TODO volumes
|
|
||||||
List<Volume> volumes = Lists.newArrayList();
|
List<Volume> volumes = Lists.newArrayList();
|
||||||
XMLBuilder xmlBuilder = XMLBuilder.parse(new InputSource(new StringReader(from.getXMLDesc(0))));
|
XMLBuilder xmlBuilder = XMLBuilder.parse(new InputSource(new StringReader(from.getXMLDesc(0))));
|
||||||
Document doc = xmlBuilder.getDocument();
|
Document doc = xmlBuilder.getDocument();
|
||||||
|
@ -85,22 +85,22 @@ public class DomainToHardware implements Function<Domain, Hardware> {
|
||||||
}
|
}
|
||||||
builder.volumes((List<Volume>) volumes);
|
builder.volumes((List<Volume>) volumes);
|
||||||
} catch (LibvirtException e) {
|
} catch (LibvirtException e) {
|
||||||
// TODO Auto-generated catch block
|
propagate(e);
|
||||||
e.printStackTrace();
|
|
||||||
} catch (XPathExpressionException e) {
|
} catch (XPathExpressionException e) {
|
||||||
// TODO Auto-generated catch block
|
propagate(e);
|
||||||
e.printStackTrace();
|
|
||||||
} catch (ParserConfigurationException e) {
|
} catch (ParserConfigurationException e) {
|
||||||
// TODO Auto-generated catch block
|
propagate(e);
|
||||||
e.printStackTrace();
|
|
||||||
} catch (SAXException e) {
|
} catch (SAXException e) {
|
||||||
// TODO Auto-generated catch block
|
propagate(e);
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// TODO Auto-generated catch block
|
propagate(e);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected <T> T propagate(Exception e) {
|
||||||
|
Throwables.propagate(e);
|
||||||
|
assert false;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -26,6 +26,7 @@ import java.io.StringReader;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
import java.util.Random;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -69,221 +70,216 @@ import com.jamesmurty.utils.XMLBuilder;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class LibvirtComputeServiceAdapter implements ComputeServiceAdapter<Domain, Domain, Image, Datacenter> {
|
public class LibvirtComputeServiceAdapter implements ComputeServiceAdapter<Domain, Domain, Image, Datacenter> {
|
||||||
|
|
||||||
private final Connect client;
|
private final Connect client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public LibvirtComputeServiceAdapter(Connect client) {
|
public LibvirtComputeServiceAdapter(Connect client) {
|
||||||
this.client = checkNotNull(client, "client");
|
this.client = checkNotNull(client, "client");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Domain runNodeWithTagAndNameAndStoreCredentials(String tag, String name, Template template,
|
public Domain runNodeWithTagAndNameAndStoreCredentials(String tag, String name, Template template,
|
||||||
Map<String, Credentials> credentialStore) {
|
Map<String, Credentials> credentialStore) {
|
||||||
// create the backend object using parameters from the template.
|
|
||||||
// Domain from = client.createDomainInDC(template.getLocation().getId(), name,
|
|
||||||
// Integer.parseInt(template.getImage().getProviderId()),
|
|
||||||
// Integer.parseInt(template.getHardware().getProviderId()));
|
|
||||||
// store the credentials so that later functions can use them
|
|
||||||
// credentialStore.put(from.id + "", new Credentials(from.loginUser, from.password));
|
|
||||||
|
|
||||||
//String[] domains;
|
try {
|
||||||
try {
|
Domain domain = null;
|
||||||
//domains = client.listDefinedDomains();
|
String domainName = tag;
|
||||||
String xmlDesc = "";
|
domain = client.domainLookupByName(domainName);
|
||||||
Domain domain = null;
|
XMLBuilder builder = XMLBuilder.parse(new InputSource(new StringReader(domain.getXMLDesc(0))));
|
||||||
//for (String domainName : domains) {
|
Document doc = builder.getDocument();
|
||||||
// domain = client.domainLookupByName(domainName);
|
XPathExpression expr = null;
|
||||||
// if (domainName.equals(tag)) {
|
NodeList nodes = null;
|
||||||
String domainName = tag;
|
String xpathString = "//devices/disk[@device='disk']/source/@file"; // +
|
||||||
domain = client.domainLookupByName(domainName);
|
expr = XPathFactory.newInstance().newXPath().compile(xpathString);
|
||||||
System.out.println("domain name " + domain.getName());
|
nodes = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
|
||||||
XMLBuilder builder = XMLBuilder.parse(new InputSource(new StringReader(domain.getXMLDesc(0))));
|
String diskFileName = nodes.item(0).getNodeValue();
|
||||||
Document doc = builder.getDocument();
|
StorageVol storageVol = client.storageVolLookupByPath(diskFileName);
|
||||||
XPathExpression expr = null;
|
|
||||||
NodeList nodes = null;
|
|
||||||
String xpathString = "//devices/disk[@device='disk']/source/@file"; // +
|
|
||||||
expr = XPathFactory.newInstance().newXPath().compile(xpathString);
|
|
||||||
nodes = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
|
|
||||||
String diskFileName = nodes.item(0).getNodeValue();
|
|
||||||
StorageVol storageVol = client.storageVolLookupByPath(diskFileName);
|
|
||||||
|
|
||||||
// cloning volume
|
// cloning volume
|
||||||
String poolName = "default";
|
String poolName = "default";
|
||||||
StoragePool storagePool = client.storagePoolLookupByName(poolName);
|
StoragePool storagePool = client.storagePoolLookupByName(poolName);
|
||||||
StorageVol clonedVol = cloneVolume(storagePool, storageVol);
|
StorageVol clonedVol = cloneVolume(storagePool, storageVol);
|
||||||
|
|
||||||
System.out.println(clonedVol.getXMLDesc(0));
|
// define Domain
|
||||||
// define Domain
|
String xmlFinal = generateClonedDomainXML(domain.getXMLDesc(0));
|
||||||
String xmlFinal = generateClonedDomainXML(domain.getXMLDesc(0));
|
domain = client.domainDefineXML(xmlFinal);
|
||||||
domain = client.domainDefineXML(xmlFinal);
|
domain.create();
|
||||||
|
|
||||||
domain.create();
|
// store the credentials so that later functions can use them
|
||||||
|
credentialStore.put(domain.getUUIDString() + "", new Credentials("identity", "credential"));
|
||||||
|
return domain;
|
||||||
|
} catch (LibvirtException e) {
|
||||||
|
return propogate(e);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return propogate(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// store the credentials so that later functions can use them
|
@Override
|
||||||
credentialStore.put(domain.getUUIDString() + "", new Credentials("identity", "credential"));
|
public Iterable<Domain> listHardwareProfiles() {
|
||||||
|
return listNodes();
|
||||||
|
}
|
||||||
|
|
||||||
//}
|
@Override
|
||||||
//}
|
public Iterable<Image> listImages() {
|
||||||
return domain;
|
int i = 1;
|
||||||
} catch (LibvirtException e) {
|
try {
|
||||||
return propogate(e);
|
String[] domains = client.listDefinedDomains();
|
||||||
} catch (Exception e) {
|
List<Image> images = Lists.newArrayList();
|
||||||
return propogate(e);
|
for (String domainName : domains) {
|
||||||
}
|
images.add(new Image(i++, domainName));
|
||||||
}
|
}
|
||||||
|
return images;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return propogate(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<Domain> listHardwareProfiles() {
|
public Iterable<Domain> listNodes() {
|
||||||
return listNodes();
|
try {
|
||||||
}
|
List<Domain> domains = Lists.newArrayList();
|
||||||
|
for (String domain : client.listDefinedDomains()) {
|
||||||
|
domains.add(client.domainLookupByName(domain));
|
||||||
|
}
|
||||||
|
return domains;
|
||||||
|
} catch (LibvirtException e) {
|
||||||
|
return propogate(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<Image> listImages() {
|
public Iterable<Datacenter> listLocations() {
|
||||||
// return ImmutableSet.of();
|
return ImmutableSet.of(new Datacenter(1, "SFO"));
|
||||||
// TODO
|
}
|
||||||
// return client.listImages();
|
|
||||||
int i = 1;
|
|
||||||
try {
|
|
||||||
String[] domains = client.listDefinedDomains();
|
|
||||||
List<Image> images = Lists.newArrayList();
|
|
||||||
for (String domainName : domains) {
|
|
||||||
images.add(new Image(i++, domainName));
|
|
||||||
}
|
|
||||||
return images;
|
|
||||||
} catch (Exception e) {
|
|
||||||
return propogate(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<Domain> listNodes() {
|
public Domain getNode(String id) {
|
||||||
try {
|
try {
|
||||||
List<Domain> domains = Lists.newArrayList();
|
return client.domainLookupByUUIDString(id);
|
||||||
for (String domain : client.listDefinedDomains()) {
|
} catch (LibvirtException e) {
|
||||||
domains.add(client.domainLookupByName(domain));
|
return propogate(e);
|
||||||
}
|
}
|
||||||
return domains;
|
}
|
||||||
} catch (LibvirtException e) {
|
|
||||||
return propogate(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected <T> T propogate(LibvirtException e) {
|
@Override
|
||||||
Throwables.propagate(e);
|
public void destroyNode(String id) {
|
||||||
assert false;
|
try {
|
||||||
return null;
|
client.domainLookupByUUIDString(id).finalize();
|
||||||
}
|
|
||||||
|
|
||||||
protected <T> T propogate(Exception e) {
|
/* TODO
|
||||||
Throwables.propagate(e);
|
XMLBuilder builder = XMLBuilder.parse(new InputSource(new StringReader(
|
||||||
assert false;
|
client.domainLookupByUUIDString(id).getXMLDesc(0)
|
||||||
return null;
|
)));
|
||||||
}
|
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);
|
||||||
|
|
||||||
@Override
|
client.domainLookupByUUIDString(id).undefine();
|
||||||
public Iterable<Datacenter> listLocations() {
|
*/
|
||||||
return ImmutableSet.of(new Datacenter(1, "SFO"));
|
} catch (LibvirtException e) {
|
||||||
}
|
propogate(e);
|
||||||
|
} catch (Exception e) {
|
||||||
|
propogate(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Domain getNode(String id) {
|
public void rebootNode(String id) {
|
||||||
try {
|
try {
|
||||||
return client.domainLookupByUUIDString(id);
|
client.domainLookupByUUIDString(id).reboot(0);
|
||||||
} catch (LibvirtException e) {
|
} catch (LibvirtException e) {
|
||||||
return propogate(e);
|
propogate(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected <T> T propogate(LibvirtException e) {
|
||||||
public void destroyNode(String id) {
|
Throwables.propagate(e);
|
||||||
try {
|
assert false;
|
||||||
client.domainLookupByUUIDString(id).destroy();
|
return null;
|
||||||
} catch (LibvirtException e) {
|
}
|
||||||
propogate(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
protected <T> T propogate(Exception e) {
|
||||||
public void rebootNode(String id) {
|
Throwables.propagate(e);
|
||||||
try {
|
assert false;
|
||||||
client.domainLookupByUUIDString(id).reboot(0);
|
return null;
|
||||||
} catch (LibvirtException e) {
|
}
|
||||||
propogate(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static StorageVol cloneVolume(StoragePool storagePool, StorageVol from) throws LibvirtException,
|
private static StorageVol cloneVolume(StoragePool storagePool, StorageVol from) throws LibvirtException,
|
||||||
XPathExpressionException, ParserConfigurationException, SAXException, IOException, TransformerException {
|
XPathExpressionException, ParserConfigurationException, SAXException, IOException, TransformerException {
|
||||||
String fromXML = from.getXMLDesc(0);
|
String fromXML = from.getXMLDesc(0);
|
||||||
String clonedXML = generateClonedVolumeXML(fromXML);
|
String clonedXML = generateClonedVolumeXML(fromXML);
|
||||||
return storagePool.storageVolCreateXMLFrom(clonedXML, from, 0);
|
return storagePool.storageVolCreateXMLFrom(clonedXML, from, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String generateClonedVolumeXML(String fromXML) throws ParserConfigurationException, SAXException,
|
private static String generateClonedVolumeXML(String fromXML) throws ParserConfigurationException, SAXException,
|
||||||
IOException, XPathExpressionException, TransformerException {
|
IOException, XPathExpressionException, TransformerException {
|
||||||
|
|
||||||
Properties outputProperties = new Properties();
|
Properties outputProperties = new Properties();
|
||||||
// Explicitly identify the output as an XML document
|
// Explicitly identify the output as an XML document
|
||||||
outputProperties.put(javax.xml.transform.OutputKeys.METHOD, "xml");
|
outputProperties.put(javax.xml.transform.OutputKeys.METHOD, "xml");
|
||||||
// Pretty-print the XML output (doesn't work in all cases)
|
// Pretty-print the XML output (doesn't work in all cases)
|
||||||
outputProperties.put(javax.xml.transform.OutputKeys.INDENT, "yes");
|
outputProperties.put(javax.xml.transform.OutputKeys.INDENT, "yes");
|
||||||
// Get 2-space indenting when using the Apache transformer
|
// Get 2-space indenting when using the Apache transformer
|
||||||
outputProperties.put("{http://xml.apache.org/xslt}indent-amount", "2");
|
outputProperties.put("{http://xml.apache.org/xslt}indent-amount", "2");
|
||||||
|
|
||||||
XMLBuilder builder = XMLBuilder.parse(new InputSource(new StringReader(fromXML)));
|
XMLBuilder builder = XMLBuilder.parse(new InputSource(new StringReader(fromXML)));
|
||||||
|
|
||||||
String cloneAppend = "-clone";
|
String cloneAppend = "-clone";
|
||||||
builder.xpathFind("//volume/name").t(cloneAppend);
|
builder.xpathFind("//volume/name").t(cloneAppend);
|
||||||
builder.xpathFind("//volume/key").t(cloneAppend);
|
builder.xpathFind("//volume/key").t(cloneAppend);
|
||||||
builder.xpathFind("//volume/target/path").t(cloneAppend);
|
builder.xpathFind("//volume/target/path").t(cloneAppend);
|
||||||
|
|
||||||
return builder.asString(outputProperties);
|
return builder.asString(outputProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String generateClonedDomainXML(String fromXML) throws ParserConfigurationException, SAXException,
|
private static String generateClonedDomainXML(String fromXML) throws ParserConfigurationException, SAXException,
|
||||||
IOException, XPathExpressionException, TransformerException {
|
IOException, XPathExpressionException, TransformerException {
|
||||||
|
|
||||||
Properties outputProperties = new Properties();
|
Properties outputProperties = new Properties();
|
||||||
// Explicitly identify the output as an XML document
|
// Explicitly identify the output as an XML document
|
||||||
outputProperties.put(javax.xml.transform.OutputKeys.METHOD, "xml");
|
outputProperties.put(javax.xml.transform.OutputKeys.METHOD, "xml");
|
||||||
// Pretty-print the XML output (doesn't work in all cases)
|
// Pretty-print the XML output (doesn't work in all cases)
|
||||||
outputProperties.put(javax.xml.transform.OutputKeys.INDENT, "yes");
|
outputProperties.put(javax.xml.transform.OutputKeys.INDENT, "yes");
|
||||||
// Get 2-space indenting when using the Apache transformer
|
// Get 2-space indenting when using the Apache transformer
|
||||||
outputProperties.put("{http://xml.apache.org/xslt}indent-amount", "2");
|
outputProperties.put("{http://xml.apache.org/xslt}indent-amount", "2");
|
||||||
|
|
||||||
XMLBuilder builder = XMLBuilder.parse(new InputSource(new StringReader(fromXML)));
|
XMLBuilder builder = XMLBuilder.parse(new InputSource(new StringReader(fromXML)));
|
||||||
|
|
||||||
String cloneAppend = "-clone";
|
String cloneAppend = "-clone";
|
||||||
|
builder.xpathFind("//domain/name").t(cloneAppend);
|
||||||
|
// change uuid domain
|
||||||
|
Element oldChild = builder.xpathFind("//domain/uuid").getElement();
|
||||||
|
Node newNode = oldChild.cloneNode(true);
|
||||||
|
newNode.getFirstChild().setNodeValue(UUID.randomUUID().toString());
|
||||||
|
builder.getDocument().getDocumentElement().replaceChild(newNode, oldChild);
|
||||||
|
|
||||||
builder.xpathFind("//domain/name").t(cloneAppend);
|
String fromVolPath = builder.xpathFind("//domain/devices/disk/source").getElement().getAttribute("file");
|
||||||
// change uuid domain
|
builder.xpathFind("//domain/devices/disk/source").a("file", fromVolPath + cloneAppend);
|
||||||
Element oldChild = builder.xpathFind("//domain/uuid").getElement();
|
// TODO generate valid MAC address
|
||||||
Node newNode = oldChild.cloneNode(true);
|
String fromMACaddress = builder.xpathFind("//domain/devices/interface/mac").getElement().getAttribute("address");
|
||||||
newNode.getFirstChild().setNodeValue(UUID.randomUUID().toString());
|
|
||||||
builder.getDocument().getDocumentElement().replaceChild(newNode, oldChild);
|
|
||||||
|
|
||||||
builder.xpathFind("//domain/devices/disk/source").a("file", "/var/lib/libvirt/images/ttylinux.img-clone");
|
builder.xpathFind("//domain/devices/interface/mac").a("address", "52:54:00:5c:dd:eb");
|
||||||
// TODO generate valid MAC address
|
return builder.asString(outputProperties);
|
||||||
builder.xpathFind("//domain/devices/interface/mac").a("address", "52:54:00:5c:dd:eb");
|
}
|
||||||
return builder.asString(outputProperties);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resumeNode(String id) {
|
public void resumeNode(String id) {
|
||||||
try {
|
try {
|
||||||
client.domainLookupByUUIDString(id).resume();
|
client.domainLookupByUUIDString(id).resume();
|
||||||
} catch (LibvirtException e) {
|
} catch (LibvirtException e) {
|
||||||
propogate(e);
|
propogate(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void suspendNode(String id) {
|
public void suspendNode(String id) {
|
||||||
try {
|
try {
|
||||||
client.domainLookupByUUIDString(id).suspend();
|
client.domainLookupByUUIDString(id).suspend();
|
||||||
} catch (LibvirtException e) {
|
} catch (LibvirtException e) {
|
||||||
propogate(e);
|
propogate(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,11 +21,13 @@ package org.jclouds.libvirt.compute;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.compute.ComputeServiceContext;
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||||
import org.jclouds.compute.RunNodesException;
|
import org.jclouds.compute.RunNodesException;
|
||||||
import org.jclouds.compute.StandaloneComputeServiceContextSpec;
|
import org.jclouds.compute.StandaloneComputeServiceContextSpec;
|
||||||
import org.jclouds.compute.domain.Template;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
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.domain.LibvirtComputeServiceContextModule;
|
import org.jclouds.libvirt.compute.domain.LibvirtComputeServiceContextModule;
|
||||||
|
@ -65,6 +67,7 @@ public class LibvirtExperimentLiveTest {
|
||||||
endpoint, apiversion, identity, credential, new LibvirtComputeServiceContextModule(), ImmutableSet
|
endpoint, apiversion, identity, credential, new LibvirtComputeServiceContextModule(), ImmutableSet
|
||||||
.<Module> of()));
|
.<Module> of()));
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
/*
|
/*
|
||||||
System.out.println("images " + context.getComputeService().listImages());
|
System.out.println("images " + context.getComputeService().listImages());
|
||||||
|
@ -83,9 +86,16 @@ public class LibvirtExperimentLiveTest {
|
||||||
* You can control the default template via overriding a method in standalonecomputeservicexontextmodule
|
* You can control the default template via overriding a method in standalonecomputeservicexontextmodule
|
||||||
*/
|
*/
|
||||||
|
|
||||||
context.getComputeService().runNodesWithTag("ttylinux", 1/*, defaultTemplate*/);
|
Set<? extends NodeMetadata> nodeMetadataSet = context.getComputeService().runNodesWithTag("ttylinux", 1);
|
||||||
|
|
||||||
} catch (RunNodesException e) {
|
for (NodeMetadata nodeMetadata : nodeMetadataSet) {
|
||||||
|
context.getComputeService().suspendNode(nodeMetadata.getId());
|
||||||
|
Thread.sleep(2000);
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
|
|
Loading…
Reference in New Issue