From f4afd8a53f70e44ca233e7e4056066fc2bb35b4c Mon Sep 17 00:00:00 2001 From: andreaturli Date: Sun, 12 Dec 2010 16:34:25 +0100 Subject: [PATCH] fix on jclouds-vsphere --- .../src/main/java/org/jclouds/vi/Image.java | 4 +- .../jclouds/vi/compute/ViComputeService.java | 3 -- .../ViComputeServiceContextBuilder.java | 5 -- .../compute/ViComputeServiceContextSpec.java | 2 +- .../vi/compute/ViPropertiesBuilder.java | 4 +- .../config/ViComputeServiceContextModule.java | 14 ++--- .../functions/DatacenterToLocation.java | 4 +- .../functions/LibvirtNodeToLocation.java | 42 --------------- .../vi/compute/functions/ViImageToImage.java | 1 + .../functions/VirtualMachineToHardware.java | 47 +++++++---------- .../VirtualMachineToNodeMetadata.java | 38 +++++++------- .../strategy/ViComputeServiceAdapter.java | 51 ++++++++++--------- .../ViComputeServiceContextBuilderTest.java | 3 +- .../vi/compute/ViComputeServiceLiveTest.java | 3 +- .../vi/compute/ViExperimentLiveTest.java | 45 ++++++++-------- 15 files changed, 103 insertions(+), 163 deletions(-) delete mode 100644 sandbox/vsphere/src/main/java/org/jclouds/vi/compute/functions/LibvirtNodeToLocation.java diff --git a/sandbox/vsphere/src/main/java/org/jclouds/vi/Image.java b/sandbox/vsphere/src/main/java/org/jclouds/vi/Image.java index 069b5bfd67..463029bbf6 100644 --- a/sandbox/vsphere/src/main/java/org/jclouds/vi/Image.java +++ b/sandbox/vsphere/src/main/java/org/jclouds/vi/Image.java @@ -28,10 +28,10 @@ import com.google.common.base.Objects; */ public class Image { - public int id; + public String id; public String name; - public Image(int id, String name) { + public Image(String id, String name) { this.id = id; this.name = name; } diff --git a/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/ViComputeService.java b/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/ViComputeService.java index f5b240a3fa..72a6fc5f8d 100644 --- a/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/ViComputeService.java +++ b/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/ViComputeService.java @@ -19,7 +19,6 @@ package org.jclouds.vi.compute; -import java.io.StringReader; import java.util.Map; import java.util.Set; import java.util.concurrent.ExecutorService; @@ -49,12 +48,10 @@ import org.jclouds.compute.strategy.SuspendNodeStrategy; import org.jclouds.compute.util.ComputeUtils; import org.jclouds.domain.Credentials; import org.jclouds.domain.Location; -import org.xml.sax.InputSource; import com.google.common.base.Predicate; import com.google.common.base.Supplier; import com.google.common.base.Throwables; -import com.jamesmurty.utils.XMLBuilder; import com.vmware.vim25.mo.ServiceInstance; /** diff --git a/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/ViComputeServiceContextBuilder.java b/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/ViComputeServiceContextBuilder.java index 8baff48f3d..26565137e2 100644 --- a/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/ViComputeServiceContextBuilder.java +++ b/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/ViComputeServiceContextBuilder.java @@ -19,8 +19,6 @@ package org.jclouds.vi.compute; -import static org.jclouds.vi.ViConstants.PROPERTY_LIBVIRT_DOMAIN_DIR; - import java.util.List; import java.util.Properties; @@ -38,9 +36,6 @@ public class ViComputeServiceContextBuilder extends StandaloneComputeServiceCont public ViComputeServiceContextBuilder(Properties props) { super(ServiceInstance.class, props); - - if (!properties.containsKey(PROPERTY_LIBVIRT_DOMAIN_DIR)) - properties.setProperty(PROPERTY_LIBVIRT_DOMAIN_DIR, "/etc/libvirt/qemu"); } @Override diff --git a/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/ViComputeServiceContextSpec.java b/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/ViComputeServiceContextSpec.java index c28e15f75c..ad186a411a 100644 --- a/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/ViComputeServiceContextSpec.java +++ b/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/ViComputeServiceContextSpec.java @@ -33,7 +33,7 @@ public class ViComputeServiceContextSpec extends RestContextSpec modules) { - super("vsphere", endpoint, "1", identity, credential, ComputeService.class, ComputeService.class, + super("vi", endpoint, "1", identity, credential, ComputeService.class, ComputeService.class, PropertiesBuilder.class, (Class) ViComputeServiceContextBuilder.class, modules); } diff --git a/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/ViPropertiesBuilder.java b/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/ViPropertiesBuilder.java index 98a154751f..4823cdbcbb 100644 --- a/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/ViPropertiesBuilder.java +++ b/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/ViPropertiesBuilder.java @@ -29,7 +29,7 @@ import java.util.Properties; import org.jclouds.PropertiesBuilder; /** - * Builds properties used in Libvirt Clients + * Builds properties used in vi Clients * * @author Andrea Turli */ @@ -37,7 +37,7 @@ public class ViPropertiesBuilder extends PropertiesBuilder { @Override protected Properties defaultProperties() { Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_LIBVIRT_DOMAIN_DIR, "/etc/libvirt/qemu"); +// properties.setProperty(PROPERTY_LIBVIRT_DOMAIN_DIR, "/etc/libvirt/qemu"); properties.setProperty(PROPERTY_TIMEOUT_NODE_SUSPENDED, 120 * 1000 + ""); // auth fail sometimes happens in EC2, as the rc.local script that injects the diff --git a/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/config/ViComputeServiceContextModule.java b/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/config/ViComputeServiceContextModule.java index 981bf94052..0d908458f4 100644 --- a/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/config/ViComputeServiceContextModule.java +++ b/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/config/ViComputeServiceContextModule.java @@ -19,8 +19,6 @@ package org.jclouds.vi.compute.config; -import static org.jclouds.vi.ViConstants.PROPERTY_LIBVIRT_DOMAIN_DIR; - import java.io.File; import java.io.IOException; import java.io.StringReader; @@ -45,7 +43,6 @@ import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.suppliers.DefaultLocationSupplier; import org.jclouds.domain.Location; import org.jclouds.rest.annotations.Provider; -import org.jclouds.vi.Datacenter; import org.jclouds.vi.Image; import org.jclouds.vi.compute.functions.DatacenterToLocation; import org.jclouds.vi.compute.functions.ViImageToImage; @@ -61,11 +58,10 @@ import com.google.common.base.Supplier; import com.google.common.collect.Iterables; import com.google.common.io.Files; import com.google.inject.Injector; -import com.google.inject.Key; import com.google.inject.Provides; import com.google.inject.TypeLiteral; -import com.google.inject.name.Names; import com.jamesmurty.utils.XMLBuilder; +import com.vmware.vim25.mo.Datacenter; import com.vmware.vim25.mo.ServiceInstance; import com.vmware.vim25.mo.VirtualMachine; @@ -97,16 +93,14 @@ public class ViComputeServiceContextModule extends protected ServiceInstance createConnection(@Provider URI endpoint, @Named(Constants.PROPERTY_IDENTITY) String identity, @Named(Constants.PROPERTY_CREDENTIAL) String credential) throws RemoteException, MalformedURLException { - System.out.println(endpoint); - System.out.println(identity); - System.out.println(credential); return new ServiceInstance(endpoint.toURL(), identity, credential, true); } @Override protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) { - String domainDir = injector.getInstance(Key.get(String.class, Names.named(PROPERTY_LIBVIRT_DOMAIN_DIR))); - String hardwareId = searchForHardwareIdInDomainDir(domainDir); + //String domainDir = injector.getInstance(Key.get(String.class, Names.named(PROPERTY_LIBVIRT_DOMAIN_DIR))); + String domainDir = ""; + String hardwareId = searchForHardwareIdInDomainDir(domainDir); String image = searchForImageIdInDomainDir(domainDir); return template.hardwareId(hardwareId).imageId(image); } diff --git a/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/functions/DatacenterToLocation.java b/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/functions/DatacenterToLocation.java index d5ac03464d..e07d865770 100644 --- a/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/functions/DatacenterToLocation.java +++ b/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/functions/DatacenterToLocation.java @@ -24,9 +24,9 @@ import javax.inject.Singleton; import org.jclouds.domain.Location; import org.jclouds.domain.LocationScope; import org.jclouds.domain.internal.LocationImpl; -import org.jclouds.vi.Datacenter; import com.google.common.base.Function; +import com.vmware.vim25.mo.Datacenter; /** * @author Adrian Cole @@ -36,7 +36,7 @@ public class DatacenterToLocation implements Function { @Override public Location apply(Datacenter from) { - return new LocationImpl(LocationScope.ZONE, from.id + "", from.name, null); + return new LocationImpl(LocationScope.ZONE, from.getName() + "", from.getName(), null); } } diff --git a/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/functions/LibvirtNodeToLocation.java b/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/functions/LibvirtNodeToLocation.java deleted file mode 100644 index 9482ec7220..0000000000 --- a/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/functions/LibvirtNodeToLocation.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.jclouds.vi.compute.functions; - -import javax.inject.Singleton; - -import org.jclouds.domain.Location; -import org.jclouds.domain.LocationScope; -import org.jclouds.domain.internal.LocationImpl; -import org.jclouds.vi.Datacenter; - -import com.google.common.base.Function; - -/** - * @author Adrian Cole - */ -@Singleton -public class LibvirtNodeToLocation implements Function { - - @Override - public Location apply(Datacenter from) { - return new LocationImpl(LocationScope.ZONE, from.id + "", from.name, null); - } - -} diff --git a/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/functions/ViImageToImage.java b/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/functions/ViImageToImage.java index 7fdedf6538..8275831d22 100644 --- a/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/functions/ViImageToImage.java +++ b/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/functions/ViImageToImage.java @@ -51,6 +51,7 @@ public class ViImageToImage implements Function { OsFamily family = null; try { + // TODO family = OsFamily.fromValue(from.name); builder.operatingSystem(new OperatingSystemBuilder().name(from.name).family(family).description(from.name).build()); } catch (IllegalArgumentException e) { diff --git a/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/functions/VirtualMachineToHardware.java b/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/functions/VirtualMachineToHardware.java index 281de80a11..8a6938766b 100644 --- a/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/functions/VirtualMachineToHardware.java +++ b/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/functions/VirtualMachineToHardware.java @@ -19,31 +19,23 @@ package org.jclouds.vi.compute.functions; -import java.io.IOException; -import java.io.StringReader; import java.util.List; import javax.inject.Singleton; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathExpression; -import javax.xml.xpath.XPathExpressionException; -import javax.xml.xpath.XPathFactory; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.HardwareBuilder; import org.jclouds.compute.domain.Processor; import org.jclouds.compute.domain.Volume; import org.jclouds.compute.domain.internal.VolumeImpl; -import org.w3c.dom.Document; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; import com.google.common.base.Function; import com.google.common.base.Throwables; import com.google.common.collect.Lists; -import com.jamesmurty.utils.XMLBuilder; +import com.vmware.vim25.VirtualDevice; +import com.vmware.vim25.VirtualDeviceBackingInfo; +import com.vmware.vim25.VirtualDisk; +import com.vmware.vim25.VirtualDiskFlatVer2BackingInfo; import com.vmware.vim25.mo.VirtualMachine; /** @@ -67,26 +59,21 @@ public class VirtualMachineToHardware implements Function volumes = Lists.newArrayList(); - - /* - XMLBuilder xmlBuilder = XMLBuilder.parse(new InputSource(new StringReader(from.getXMLDesc(0)))); - Document doc = xmlBuilder.getDocument(); - XPathExpression expr = XPathFactory.newInstance().newXPath().compile("//devices/disk[@device='disk']/source/@file"); - NodeList nodes = (NodeList) expr.evaluate(doc, XPathConstants.NODESET); - String diskFileName = nodes.item(0).getNodeValue(); - for (int i = 0; i < nodes.getLength(); i++) { - StorageVol storageVol = from.getConnect().storageVolLookupByPath(diskFileName); - String id = storageVol.getKey(); - float size = new Long(storageVol.getInfo().capacity).floatValue(); - volumes.add(new VolumeImpl(id, Volume.Type.LOCAL, size, null, true, false)); + // look for volumes + VirtualDevice[] devices = from.getConfig().getHardware().getDevice(); + for (VirtualDevice virtualDevice : devices) { + if(virtualDevice.getDeviceInfo().getLabel().contains("Hard disk")) { + if(virtualDevice instanceof VirtualDisk) { + VirtualDisk disk = (VirtualDisk) virtualDevice; + VirtualDeviceBackingInfo backingInfo = disk.getBacking(); + if(backingInfo instanceof VirtualDiskFlatVer2BackingInfo) { + VirtualDiskFlatVer2BackingInfo diskFlatVer2BackingInfo = (VirtualDiskFlatVer2BackingInfo) backingInfo; + volumes.add(new VolumeImpl(diskFlatVer2BackingInfo.getUuid(), Volume.Type.LOCAL, new Float(disk.getCapacityInKB() + ""), diskFlatVer2BackingInfo.getFileName(), true, false)); + } + } + } } - */ - - // TODO builder.volumes((List) volumes); - Float size = new Float(21345); - String id = "dglffdbdflmb"; - volumes.add(new VolumeImpl(id, Volume.Type.LOCAL, size, null, true, false)); return builder.build(); } diff --git a/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/functions/VirtualMachineToNodeMetadata.java b/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/functions/VirtualMachineToNodeMetadata.java index 6fd5d2d3d7..f11883f2a9 100644 --- a/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/functions/VirtualMachineToNodeMetadata.java +++ b/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/functions/VirtualMachineToNodeMetadata.java @@ -59,18 +59,18 @@ public class VirtualMachineToNodeMetadata implements Function findHardwareForDomain; - private final FindLocationForDomain findLocationForDomain; - private final FindImageForDomain findImageForDomain; + private final Function findHardwareForVirtualMachine; + private final FindLocationForVirtualMachine findLocationForVirtualMachine; + private final FindImageForVirtualMachine findImageForVirtualMachine; private final Map credentialStore; @Inject - VirtualMachineToNodeMetadata(Map credentialStore, Function findHardwareForDomain, - FindLocationForDomain findLocationForDomain, FindImageForDomain findImageForDomain) { + VirtualMachineToNodeMetadata(Map credentialStore, Function findHardwareForVirtualMachine, + FindLocationForVirtualMachine findLocationForVirtualMachine, FindImageForVirtualMachine findImageForVirtualMachine) { this.credentialStore = checkNotNull(credentialStore, "credentialStore"); - this.findHardwareForDomain = checkNotNull(findHardwareForDomain, "findHardwareForDomain"); - this.findLocationForDomain = checkNotNull(findLocationForDomain, "findLocationForDomain"); - this.findImageForDomain = checkNotNull(findImageForDomain, "findImageForDomain"); + this.findHardwareForVirtualMachine = checkNotNull(findHardwareForVirtualMachine, "findHardwareForVirtualMachine"); + this.findLocationForVirtualMachine = checkNotNull(findLocationForVirtualMachine, "findLocationForVirtualMachine"); + this.findImageForVirtualMachine = checkNotNull(findImageForVirtualMachine, "findImageForVirtualMachine"); } @Override @@ -79,19 +79,23 @@ public class VirtualMachineToNodeMetadata implements Function of(from.publicAddress)); // builder.privateAddresses(ImmutableSet. of(from.privateAddress)); - builder.credentials(credentialStore.get("node#" + from.getMOR().get_value())); + builder.credentials(credentialStore.get("node#" + from.getName())); } catch (Exception e) { // TODO Auto-generated catch block @@ -101,10 +105,10 @@ public class VirtualMachineToNodeMetadata implements Function { + public static class FindImageForVirtualMachine extends FindResourceInSet { @Inject - public FindImageForDomain(@Memoized Supplier> hardware) { + public FindImageForVirtualMachine(@Memoized Supplier> hardware) { super(hardware); } @@ -117,10 +121,10 @@ public class VirtualMachineToNodeMetadata implements Function { + public static class FindLocationForVirtualMachine extends FindResourceInSet { @Inject - public FindLocationForDomain(@Memoized Supplier> hardware) { + public FindLocationForVirtualMachine(@Memoized Supplier> hardware) { super(hardware); } diff --git a/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/strategy/ViComputeServiceAdapter.java b/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/strategy/ViComputeServiceAdapter.java index a0ac47bec2..47326098f1 100644 --- a/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/strategy/ViComputeServiceAdapter.java +++ b/sandbox/vsphere/src/main/java/org/jclouds/vi/compute/strategy/ViComputeServiceAdapter.java @@ -20,7 +20,6 @@ package org.jclouds.vi.compute.strategy; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vi.ViConstants.PROPERTY_LIBVIRT_DOMAIN_DIR; import java.rmi.RemoteException; import java.util.List; @@ -33,14 +32,14 @@ import org.jclouds.compute.ComputeService; import org.jclouds.compute.ComputeServiceAdapter; import org.jclouds.compute.domain.Template; import org.jclouds.domain.Credentials; -import org.jclouds.vi.Datacenter; import org.jclouds.vi.Image; import com.google.common.base.Throwables; import com.google.common.collect.Lists; -import com.google.inject.name.Named; import com.vmware.vim25.InvalidProperty; import com.vmware.vim25.RuntimeFault; +import com.vmware.vim25.mo.Datacenter; +import com.vmware.vim25.mo.Folder; import com.vmware.vim25.mo.InventoryNavigator; import com.vmware.vim25.mo.ManagedEntity; import com.vmware.vim25.mo.ServiceInstance; @@ -116,25 +115,25 @@ public class ViComputeServiceAdapter implements ComputeServiceAdapter listHardwareProfiles() { - return listNodes(); + // TODO + return null; } @Override public Iterable listImages() { - /* - int i = 1; + List images = Lists.newArrayList(); try { - String[] domains = client.listDefinedDomains(); - List images = Lists.newArrayList(); - for (String domainName : domains) { - images.add(new Image(i++, domainName)); + + ManagedEntity[] entities = new InventoryNavigator( + client.getRootFolder()).searchManagedEntities("VirtualMachine"); + for (ManagedEntity entity : entities) { + VirtualMachine vm = (VirtualMachine) entity; + images.add(new Image(vm.getConfig().getGuestId(), vm.getConfig().getGuestFullName())); } return images; } catch (Exception e) { return propogate(e); } - */ - return null; } @Override @@ -143,8 +142,8 @@ public class ViComputeServiceAdapter implements ComputeServiceAdapter vms = Lists.newArrayList(); for (ManagedEntity entity : vmEntities) { - System.out.println(entity.getName()); - vms.add((VirtualMachine) entity); + VirtualMachine vm = (VirtualMachine) entity; + vms.add(vm); } return vms; } catch (InvalidProperty e) { @@ -164,7 +163,7 @@ public class ViComputeServiceAdapter implements ComputeServiceAdapter datacenters = Lists.newArrayList(); for (int i = 0; i< datacenterEntities.length; i++) { - datacenters.add(new Datacenter(i, datacenterEntities[i].getName())); + datacenters.add((Datacenter) datacenterEntities[i]); } return datacenters; } catch (InvalidProperty e) { @@ -178,18 +177,20 @@ public class ViComputeServiceAdapter implements ComputeServiceAdapter goGridContext = new ComputeServiceContextFactory().createContext( + RestContext viContext = new ComputeServiceContextFactory().createContext( provider, identity, credential).getProviderSpecificContext(); } } diff --git a/sandbox/vsphere/src/test/java/org/jclouds/vi/compute/ViExperimentLiveTest.java b/sandbox/vsphere/src/test/java/org/jclouds/vi/compute/ViExperimentLiveTest.java index c9bb37b772..f4a4859cee 100644 --- a/sandbox/vsphere/src/test/java/org/jclouds/vi/compute/ViExperimentLiveTest.java +++ b/sandbox/vsphere/src/test/java/org/jclouds/vi/compute/ViExperimentLiveTest.java @@ -25,9 +25,11 @@ import java.util.Set; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.domain.ComputeMetadata; +import org.jclouds.compute.domain.Hardware; +import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.Template; -import org.jclouds.vi.compute.ViComputeServiceContextSpec; +import org.jclouds.domain.Location; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -57,37 +59,38 @@ public class ViExperimentLiveTest { try { context = new ComputeServiceContextFactory().createContext(new ViComputeServiceContextSpec( endpoint, identity, credential)); - context.getComputeService().listNodes(); - - /* - * /* System.out.println("images " + context.getComputeService().listImages()); - * System.out.println("nodes " + context.getComputeService().listNodes()); - * System.out.println("hardware profiles " + - * context.getComputeService().listHardwareProfiles()); - */ +// Set locations = context.getComputeService().listAssignableLocations(); +// +// Set nodes = context.getComputeService().listNodes(); - -/* Template defaultTemplate = context.getComputeService().templateBuilder() - .hardwareId("d106ae67-5a1b-8f91-b311-83c93bcb0a1f").imageId("1") //.locationId("") - .build();*/ - + // TODO +// Set hardwares = context.getComputeService().listHardwareProfiles(); +// +// Set images = context.getComputeService().listImages(); + + NodeMetadata node = context.getComputeService().getNodeMetadata("provaVM"); + System.out.println(node); /* * We will probably make a default template out of properties at some point You can control * the default template via overriding a method in standalonecomputeservicexontextmodule */ - - Set nodeMetadataSet = context.getComputeService().runNodesWithTag("tty", 1); + + /* Template defaultTemplate = context.getComputeService().templateBuilder() + .hardwareId("d106ae67-5a1b-8f91-b311-83c93bcb0a1f").imageId("1") //.locationId("") + .build(); + Set nodeMetadataSet = context.getComputeService().runNodesWithTag("MyServer", 1); for (NodeMetadata nodeMetadata : nodeMetadataSet) { - /* - * context.getComputeService().suspendNode(nodeMetadata.getId()); - * context.getComputeService().resumeNode(nodeMetadata.getId()); - */ + +// context.getComputeService().suspendNode(nodeMetadata.getId()); +// context.getComputeService().resumeNode(nodeMetadata.getId()); + context.getComputeService().destroyNode(nodeMetadata.getId()); } } catch (Exception e) { e.printStackTrace(); + */ } finally { if (context != null) context.close();