mirror of https://github.com/apache/jclouds.git
Merge branch 'master' of https://github.com/andreaturli/jclouds
* 'master' of https://github.com/andreaturli/jclouds: fix on jclouds-vsphere
This commit is contained in:
commit
2c4f866d9b
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -33,7 +33,7 @@ public class ViComputeServiceContextSpec extends RestContextSpec<ComputeService,
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ViComputeServiceContextSpec(String endpoint, String identity, String credential, Iterable<Module> 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<Datacenter, Location> {
|
|||
|
||||
@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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* 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<Datacenter, Location> {
|
||||
|
||||
@Override
|
||||
public Location apply(Datacenter from) {
|
||||
return new LocationImpl(LocationScope.ZONE, from.id + "", from.name, null);
|
||||
}
|
||||
|
||||
}
|
|
@ -51,6 +51,7 @@ public class ViImageToImage implements Function<org.jclouds.vi.Image, Image> {
|
|||
|
||||
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) {
|
||||
|
|
|
@ -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<VirtualMachine, Hardwa
|
|||
|
||||
builder.ram((int) from.getConfig().getHardware().getMemoryMB());
|
||||
List<Volume> 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<Volume>) volumes);
|
||||
Float size = new Float(21345);
|
||||
String id = "dglffdbdflmb";
|
||||
volumes.add(new VolumeImpl(id, Volume.Type.LOCAL, size, null, true, false));
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -59,18 +59,18 @@ public class VirtualMachineToNodeMetadata implements Function<VirtualMachine, No
|
|||
.put(VirtualMachinePowerState.poweredOff, NodeState.TERMINATED)//
|
||||
.build();
|
||||
|
||||
private final Function<VirtualMachine, Hardware> findHardwareForDomain;
|
||||
private final FindLocationForDomain findLocationForDomain;
|
||||
private final FindImageForDomain findImageForDomain;
|
||||
private final Function<VirtualMachine, Hardware> findHardwareForVirtualMachine;
|
||||
private final FindLocationForVirtualMachine findLocationForVirtualMachine;
|
||||
private final FindImageForVirtualMachine findImageForVirtualMachine;
|
||||
private final Map<String, Credentials> credentialStore;
|
||||
|
||||
@Inject
|
||||
VirtualMachineToNodeMetadata(Map<String, Credentials> credentialStore, Function<VirtualMachine, Hardware> findHardwareForDomain,
|
||||
FindLocationForDomain findLocationForDomain, FindImageForDomain findImageForDomain) {
|
||||
VirtualMachineToNodeMetadata(Map<String, Credentials> credentialStore, Function<VirtualMachine, Hardware> 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<VirtualMachine, No
|
|||
// convert the result object to a jclouds NodeMetadata
|
||||
NodeMetadataBuilder builder = new NodeMetadataBuilder();
|
||||
try {
|
||||
builder.id(from.getMOR().get_value() + "");
|
||||
builder.id(from.getConfig().getInstanceUuid());
|
||||
builder.providerId(from.getConfig().getLocationId() + "");
|
||||
builder.name(from.getName());
|
||||
builder.location(findLocationForDomain.apply(from));
|
||||
builder.location(findLocationForVirtualMachine.apply(from));
|
||||
builder.tag(parseTagFromName(from.getName()));
|
||||
|
||||
builder.operatingSystem(new OperatingSystemBuilder().description(from.getConfig().getGuestFullName()).build());
|
||||
builder.hardware(findHardwareForDomain.apply(from));
|
||||
builder.operatingSystem(new OperatingSystemBuilder()
|
||||
.name(from.getConfig().getGuestFullName())
|
||||
.description(from.getConfig().getGuestFullName())
|
||||
.is64Bit(from.getConfig().getGuestId().contains("64"))
|
||||
.build());
|
||||
builder.hardware(findHardwareForVirtualMachine.apply(from));
|
||||
|
||||
builder.state(domainStateToNodeState.get(from.getRuntime().getPowerState()));
|
||||
// builder.publicAddresses(ImmutableSet.<String> of(from.publicAddress));
|
||||
// builder.privateAddresses(ImmutableSet.<String> 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<VirtualMachine, No
|
|||
}
|
||||
|
||||
@Singleton
|
||||
public static class FindImageForDomain extends FindResourceInSet<VirtualMachine, Image> {
|
||||
public static class FindImageForVirtualMachine extends FindResourceInSet<VirtualMachine, Image> {
|
||||
|
||||
@Inject
|
||||
public FindImageForDomain(@Memoized Supplier<Set<? extends Image>> hardware) {
|
||||
public FindImageForVirtualMachine(@Memoized Supplier<Set<? extends Image>> hardware) {
|
||||
super(hardware);
|
||||
}
|
||||
|
||||
|
@ -117,10 +121,10 @@ public class VirtualMachineToNodeMetadata implements Function<VirtualMachine, No
|
|||
}
|
||||
|
||||
@Singleton
|
||||
public static class FindLocationForDomain extends FindResourceInSet<VirtualMachine, Location> {
|
||||
public static class FindLocationForVirtualMachine extends FindResourceInSet<VirtualMachine, Location> {
|
||||
|
||||
@Inject
|
||||
public FindLocationForDomain(@Memoized Supplier<Set<? extends Location>> hardware) {
|
||||
public FindLocationForVirtualMachine(@Memoized Supplier<Set<? extends Location>> hardware) {
|
||||
super(hardware);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<VirtualMac
|
|||
|
||||
@Override
|
||||
public Iterable<VirtualMachine> listHardwareProfiles() {
|
||||
return listNodes();
|
||||
// TODO
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Image> listImages() {
|
||||
/*
|
||||
int i = 1;
|
||||
List<Image> images = Lists.newArrayList();
|
||||
try {
|
||||
String[] domains = client.listDefinedDomains();
|
||||
List<Image> 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<VirtualMac
|
|||
ManagedEntity[] vmEntities = new InventoryNavigator(client.getRootFolder()).searchManagedEntities("VirtualMachine");
|
||||
List<VirtualMachine> 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<VirtualMac
|
|||
datacenterEntities = new InventoryNavigator(client.getRootFolder()).searchManagedEntities("Datacenter");
|
||||
List<Datacenter> 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<VirtualMac
|
|||
}
|
||||
|
||||
@Override
|
||||
public VirtualMachine getNode(String id) {
|
||||
VirtualMachine vm = null;
|
||||
/*
|
||||
public VirtualMachine getNode(String vmName) {
|
||||
|
||||
Folder rootFolder = client.getRootFolder();
|
||||
|
||||
try {
|
||||
d = client.domainLookupByUUIDString(id);
|
||||
} catch (LibvirtException e) {
|
||||
if (e.getMessage().indexOf("Domain not found: no domain with matching uuid") != -1)
|
||||
return null;
|
||||
propogate(e);
|
||||
return (VirtualMachine) new InventoryNavigator(
|
||||
rootFolder).searchManagedEntity("VirtualMachine", vmName);
|
||||
} catch (InvalidProperty e) {
|
||||
return propogate(e);
|
||||
} catch (RuntimeFault e) {
|
||||
return propogate(e);
|
||||
} catch (RemoteException e) {
|
||||
return propogate(e);
|
||||
}
|
||||
*/
|
||||
return vm;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,11 +33,10 @@ public class ViComputeServiceContextBuilderTest {
|
|||
Properties restProperties = new Properties();
|
||||
restProperties.setProperty("vi.contextbuilder", ViComputeServiceContextBuilder.class.getName());
|
||||
restProperties.setProperty("vi.propertiesbuilder", ViPropertiesBuilder.class.getName());
|
||||
restProperties.setProperty("vi.endpoint", "https://localhost/sdk");
|
||||
restProperties.setProperty("vi.endpoint", "https://localhost/sdk");
|
||||
|
||||
ComputeServiceContext context = new ComputeServiceContextFactory(restProperties).createContext("vi",
|
||||
"identity", "credential");
|
||||
|
||||
context.close();
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import com.vmware.vim25.mo.ServiceInstance;
|
|||
*/
|
||||
@Test(groups = "live", enabled = true, sequential = true, testName = "vi.ViComputeServiceLiveTest")
|
||||
public class ViComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||
|
||||
public ViComputeServiceLiveTest() {
|
||||
provider = "vi";
|
||||
}
|
||||
|
@ -50,7 +51,7 @@ public class ViComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
|||
|
||||
public void testAssignability() throws Exception {
|
||||
@SuppressWarnings("unused")
|
||||
RestContext<ServiceInstance, ServiceInstance> goGridContext = new ComputeServiceContextFactory().createContext(
|
||||
RestContext<ServiceInstance, ServiceInstance> viContext = new ComputeServiceContextFactory().createContext(
|
||||
provider, identity, credential).getProviderSpecificContext();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<? extends Location> locations = context.getComputeService().listAssignableLocations();
|
||||
//
|
||||
// Set<? extends ComputeMetadata> nodes = context.getComputeService().listNodes();
|
||||
|
||||
|
||||
/* Template defaultTemplate = context.getComputeService().templateBuilder()
|
||||
.hardwareId("d106ae67-5a1b-8f91-b311-83c93bcb0a1f").imageId("1") //.locationId("")
|
||||
.build();*/
|
||||
|
||||
// TODO
|
||||
// Set<? extends Hardware> hardwares = context.getComputeService().listHardwareProfiles();
|
||||
//
|
||||
// Set<? extends Image> 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<? extends NodeMetadata> nodeMetadataSet = context.getComputeService().runNodesWithTag("tty", 1);
|
||||
|
||||
/* Template defaultTemplate = context.getComputeService().templateBuilder()
|
||||
.hardwareId("d106ae67-5a1b-8f91-b311-83c93bcb0a1f").imageId("1") //.locationId("")
|
||||
.build();
|
||||
Set<? extends NodeMetadata> 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();
|
||||
|
|
Loading…
Reference in New Issue