mirror of https://github.com/apache/jclouds.git
Issue 440: renamed vsphere->vi, made sure all sandbox modules compile
This commit is contained in:
parent
79e5df9ace
commit
0064787912
|
@ -45,6 +45,12 @@
|
||||||
<artifactId>libvirt</artifactId>
|
<artifactId>libvirt</artifactId>
|
||||||
<version>0.4.6</version>
|
<version>0.4.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>1.4</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sun.jna</groupId>
|
<groupId>com.sun.jna</groupId>
|
||||||
<artifactId>jna</artifactId>
|
<artifactId>jna</artifactId>
|
||||||
|
@ -57,19 +63,19 @@
|
||||||
<version>0.3</version>
|
<version>0.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>org.jclouds</groupId>
|
||||||
<artifactId>jclouds-core</artifactId>
|
<artifactId>jclouds-core</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<type>test-jar</type>
|
<type>test-jar</type>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>org.jclouds</groupId>
|
||||||
<artifactId>jclouds-compute</artifactId>
|
<artifactId>jclouds-compute</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>org.jclouds</groupId>
|
||||||
<artifactId>jclouds-compute</artifactId>
|
<artifactId>jclouds-compute</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<type>test-jar</type>
|
<type>test-jar</type>
|
||||||
|
@ -82,13 +88,13 @@
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>org.jclouds</groupId>
|
||||||
<artifactId>jclouds-log4j</artifactId>
|
<artifactId>jclouds-log4j</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>org.jclouds</groupId>
|
||||||
<artifactId>jclouds-jsch</artifactId>
|
<artifactId>jclouds-jsch</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
|
|
|
@ -19,18 +19,18 @@
|
||||||
|
|
||||||
package org.jclouds.libvirt.compute.domain;
|
package org.jclouds.libvirt.compute.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Predicates.notNull;
|
||||||
|
import static com.google.common.collect.Iterables.filter;
|
||||||
|
import static com.google.common.collect.Iterables.transform;
|
||||||
import static org.jclouds.libvirt.LibvirtConstants.PROPERTY_LIBVIRT_DOMAIN_DIR;
|
import static org.jclouds.libvirt.LibvirtConstants.PROPERTY_LIBVIRT_DOMAIN_DIR;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.FileInputStream;
|
||||||
import java.io.StringReader;
|
import java.io.FileNotFoundException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
|
||||||
import javax.xml.xpath.XPathExpressionException;
|
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
||||||
|
@ -40,8 +40,8 @@ import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
|
||||||
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.suppliers.DefaultLocationSupplier;
|
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
import org.jclouds.http.functions.ParseSax;
|
||||||
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.functions.DatacenterToLocation;
|
import org.jclouds.libvirt.compute.functions.DatacenterToLocation;
|
||||||
|
@ -49,24 +49,22 @@ import org.jclouds.libvirt.compute.functions.DomainToHardware;
|
||||||
import org.jclouds.libvirt.compute.functions.DomainToNodeMetadata;
|
import org.jclouds.libvirt.compute.functions.DomainToNodeMetadata;
|
||||||
import org.jclouds.libvirt.compute.functions.LibvirtImageToImage;
|
import org.jclouds.libvirt.compute.functions.LibvirtImageToImage;
|
||||||
import org.jclouds.libvirt.compute.strategy.LibvirtComputeServiceAdapter;
|
import org.jclouds.libvirt.compute.strategy.LibvirtComputeServiceAdapter;
|
||||||
import org.jclouds.rest.annotations.Provider;
|
import org.jclouds.location.Provider;
|
||||||
|
import org.jclouds.location.suppliers.OnlyLocationOrFirstZone;
|
||||||
import org.libvirt.Connect;
|
import org.libvirt.Connect;
|
||||||
import org.libvirt.Domain;
|
import org.libvirt.Domain;
|
||||||
import org.libvirt.LibvirtException;
|
import org.libvirt.LibvirtException;
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.Attributes;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.io.Files;
|
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Key;
|
import com.google.inject.Key;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
import com.google.inject.name.Names;
|
import com.google.inject.name.Names;
|
||||||
import com.jamesmurty.utils.XMLBuilder;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -85,7 +83,7 @@ public class LibvirtComputeServiceContextModule extends
|
||||||
bind(new TypeLiteral<ComputeServiceAdapter<Domain, Domain, Image, Datacenter>>() {
|
bind(new TypeLiteral<ComputeServiceAdapter<Domain, Domain, Image, Datacenter>>() {
|
||||||
}).to(LibvirtComputeServiceAdapter.class);
|
}).to(LibvirtComputeServiceAdapter.class);
|
||||||
bind(new TypeLiteral<Supplier<Location>>() {
|
bind(new TypeLiteral<Supplier<Location>>() {
|
||||||
}).to(DefaultLocationSupplier.class);
|
}).to(OnlyLocationOrFirstZone.class);
|
||||||
bind(new TypeLiteral<Function<Domain, NodeMetadata>>() {
|
bind(new TypeLiteral<Function<Domain, NodeMetadata>>() {
|
||||||
}).to(DomainToNodeMetadata.class);
|
}).to(DomainToNodeMetadata.class);
|
||||||
bind(new TypeLiteral<Function<Image, org.jclouds.compute.domain.Image>>() {
|
bind(new TypeLiteral<Function<Image, org.jclouds.compute.domain.Image>>() {
|
||||||
|
@ -109,7 +107,8 @@ public class LibvirtComputeServiceContextModule extends
|
||||||
@Override
|
@Override
|
||||||
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
||||||
String domainDir = injector.getInstance(Key.get(String.class, Names.named(PROPERTY_LIBVIRT_DOMAIN_DIR)));
|
String domainDir = injector.getInstance(Key.get(String.class, Names.named(PROPERTY_LIBVIRT_DOMAIN_DIR)));
|
||||||
String hardwareId = searchForHardwareIdInDomainDir(domainDir);
|
String hardwareId = searchForHardwareIdInDomainDir(domainDir, injector.getInstance(ParseSax.Factory.class),
|
||||||
|
injector.getProvider(UUIDHandler.class));
|
||||||
String image = searchForImageIdInDomainDir(domainDir);
|
String image = searchForImageIdInDomainDir(domainDir);
|
||||||
return template.hardwareId(hardwareId).imageId(image);
|
return template.hardwareId(hardwareId).imageId(image);
|
||||||
}
|
}
|
||||||
|
@ -120,26 +119,58 @@ public class LibvirtComputeServiceContextModule extends
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private String searchForHardwareIdInDomainDir(String domainDir) {
|
private String searchForHardwareIdInDomainDir(String domainDir, final ParseSax.Factory factory,
|
||||||
|
final javax.inject.Provider<UUIDHandler> provider) {
|
||||||
|
|
||||||
Collection<File> xmlDomains = FileUtils.listFiles(new File(domainDir), new WildcardFileFilter("*.xml"), null);
|
// TODO: remove commons-io dependency
|
||||||
String uuid = "";
|
return Iterables.<String> getLast(filter(transform(FileUtils.listFiles(new File(domainDir),
|
||||||
|
new WildcardFileFilter("*.xml"), null), new Function<File, String>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String apply(File input) {
|
||||||
try {
|
try {
|
||||||
String fromXML = Files.toString(Iterables.get(xmlDomains, 0), Charsets.UTF_8);
|
return factory.create(provider.get()).parse(new FileInputStream(input));
|
||||||
XMLBuilder builder = XMLBuilder.parse(new InputSource(new StringReader(fromXML)));
|
} catch (FileNotFoundException e) {
|
||||||
uuid = builder.xpathFind("/domain/uuid").getElement().getTextContent();
|
// log error.
|
||||||
} catch (IOException e) {
|
return null;
|
||||||
e.printStackTrace();
|
|
||||||
} catch (ParserConfigurationException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (SAXException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (XPathExpressionException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}), notNull()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class UUIDHandler extends ParseSax.HandlerWithResult<String> {
|
||||||
|
private StringBuilder currentText = new StringBuilder();
|
||||||
|
|
||||||
|
private boolean inDomain;
|
||||||
|
private String uuid;
|
||||||
|
|
||||||
|
public String getResult() {
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
||||||
|
if (qName.equals("domain")) {
|
||||||
|
inDomain = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void endElement(String uri, String localName, String qName) {
|
||||||
|
if (qName.equalsIgnoreCase("uuid") && inDomain) {
|
||||||
|
this.uuid = currentText.toString();
|
||||||
|
} else if (qName.equalsIgnoreCase("domain")) {
|
||||||
|
inDomain = false;
|
||||||
|
}
|
||||||
|
currentText = new StringBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void characters(char ch[], int start, int length) {
|
||||||
|
currentText.append(ch, start, length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Map<String, URI> regions = newLinkedHashMap(); for (String region :
|
* Map<String, URI> regions = newLinkedHashMap(); for (String region :
|
||||||
* Splitter.on(',').split(regionString)) { regions.put( region,
|
* Splitter.on(',').split(regionString)) { regions.put( region,
|
||||||
|
|
|
@ -29,17 +29,22 @@
|
||||||
<relativePath>../../project/pom.xml</relativePath>
|
<relativePath>../../project/pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>org.jclouds.api</groupId>
|
<groupId>org.jclouds.api</groupId>
|
||||||
<artifactId>vsphere</artifactId>
|
<artifactId>vi</artifactId>
|
||||||
<name>jclouds example components for a vijava lib for vSphere</name>
|
<name>jclouds example components for a vijava lib for VI 4 (VMware Infrastructure)</name>
|
||||||
<properties>
|
<properties>
|
||||||
<!-- when instances are hung, open a ticket and add here -->
|
<!-- when instances are hung, open a ticket and add here -->
|
||||||
<jclouds.compute.blacklist.nodes>trmkrun-ccc,test.trmk-924</jclouds.compute.blacklist.nodes>
|
<jclouds.compute.blacklist.nodes>trmkrun-ccc,test.trmk-924</jclouds.compute.blacklist.nodes>
|
||||||
<test.libvirt.endpoint>test:///default</test.libvirt.endpoint>
|
<test.vi.endpoint>test:///default</test.vi.endpoint>
|
||||||
<test.libvirt.apiversion>1.0</test.libvirt.apiversion>
|
<test.vi.apiversion>1.0</test.vi.apiversion>
|
||||||
<test.libvirt.identity>FIXME</test.libvirt.identity>
|
<test.vi.identity>FIXME</test.vi.identity>
|
||||||
<test.libvirt.credential>FIXME</test.libvirt.credential>
|
<test.vi.credential>FIXME</test.vi.credential>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>1.4</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jvnet.hudson</groupId>
|
<groupId>org.jvnet.hudson</groupId>
|
||||||
<artifactId>vijava</artifactId>
|
<artifactId>vijava</artifactId>
|
||||||
|
@ -107,20 +112,20 @@
|
||||||
<configuration>
|
<configuration>
|
||||||
<systemProperties>
|
<systemProperties>
|
||||||
<property>
|
<property>
|
||||||
<name>test.libvirt.endpoint</name>
|
<name>test.vi.endpoint</name>
|
||||||
<value>${test.libvirt.endpoint}</value>
|
<value>${test.vi.endpoint}</value>
|
||||||
</property>
|
</property>
|
||||||
<property>
|
<property>
|
||||||
<name>test.libvirt.apiversion</name>
|
<name>test.vi.apiversion</name>
|
||||||
<value>${test.libvirt.apiversion}</value>
|
<value>${test.vi.apiversion}</value>
|
||||||
</property>
|
</property>
|
||||||
<property>
|
<property>
|
||||||
<name>test.libvirt.identity</name>
|
<name>test.vi.identity</name>
|
||||||
<value>${test.libvirt.identity}</value>
|
<value>${test.vi.identity}</value>
|
||||||
</property>
|
</property>
|
||||||
<property>
|
<property>
|
||||||
<name>test.libvirt.credential</name>
|
<name>test.vi.credential</name>
|
||||||
<value>${test.libvirt.credential}</value>
|
<value>${test.vi.credential}</value>
|
||||||
</property>
|
</property>
|
||||||
<property>
|
<property>
|
||||||
<name>jclouds.compute.blacklist.nodes</name>
|
<name>jclouds.compute.blacklist.nodes</name>
|
|
@ -19,18 +19,19 @@
|
||||||
|
|
||||||
package org.jclouds.vi.compute.config;
|
package org.jclouds.vi.compute.config;
|
||||||
|
|
||||||
|
import static com.google.common.base.Predicates.notNull;
|
||||||
|
import static com.google.common.collect.Iterables.filter;
|
||||||
|
import static com.google.common.collect.Iterables.transform;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.FileInputStream;
|
||||||
import java.io.StringReader;
|
import java.io.FileNotFoundException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.rmi.RemoteException;
|
import java.rmi.RemoteException;
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
|
||||||
import javax.xml.xpath.XPathExpressionException;
|
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
||||||
|
@ -40,27 +41,25 @@ import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
|
||||||
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.suppliers.DefaultLocationSupplier;
|
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.rest.annotations.Provider;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.location.Provider;
|
||||||
|
import org.jclouds.location.suppliers.OnlyLocationOrFirstZone;
|
||||||
import org.jclouds.vi.Image;
|
import org.jclouds.vi.Image;
|
||||||
import org.jclouds.vi.compute.functions.DatacenterToLocation;
|
import org.jclouds.vi.compute.functions.DatacenterToLocation;
|
||||||
import org.jclouds.vi.compute.functions.ViImageToImage;
|
import org.jclouds.vi.compute.functions.ViImageToImage;
|
||||||
import org.jclouds.vi.compute.functions.VirtualMachineToHardware;
|
import org.jclouds.vi.compute.functions.VirtualMachineToHardware;
|
||||||
import org.jclouds.vi.compute.functions.VirtualMachineToNodeMetadata;
|
import org.jclouds.vi.compute.functions.VirtualMachineToNodeMetadata;
|
||||||
import org.jclouds.vi.compute.strategy.ViComputeServiceAdapter;
|
import org.jclouds.vi.compute.strategy.ViComputeServiceAdapter;
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.Attributes;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.io.Files;
|
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
import com.jamesmurty.utils.XMLBuilder;
|
|
||||||
import com.vmware.vim25.mo.Datacenter;
|
import com.vmware.vim25.mo.Datacenter;
|
||||||
import com.vmware.vim25.mo.ServiceInstance;
|
import com.vmware.vim25.mo.ServiceInstance;
|
||||||
import com.vmware.vim25.mo.VirtualMachine;
|
import com.vmware.vim25.mo.VirtualMachine;
|
||||||
|
@ -83,7 +82,7 @@ public class ViComputeServiceContextModule
|
||||||
bind(new TypeLiteral<ComputeServiceAdapter<VirtualMachine, VirtualMachine, Image, Datacenter>>() {
|
bind(new TypeLiteral<ComputeServiceAdapter<VirtualMachine, VirtualMachine, Image, Datacenter>>() {
|
||||||
}).to(ViComputeServiceAdapter.class);
|
}).to(ViComputeServiceAdapter.class);
|
||||||
bind(new TypeLiteral<Supplier<Location>>() {
|
bind(new TypeLiteral<Supplier<Location>>() {
|
||||||
}).to(DefaultLocationSupplier.class);
|
}).to(OnlyLocationOrFirstZone.class);
|
||||||
bind(new TypeLiteral<Function<VirtualMachine, NodeMetadata>>() {
|
bind(new TypeLiteral<Function<VirtualMachine, NodeMetadata>>() {
|
||||||
}).to(VirtualMachineToNodeMetadata.class);
|
}).to(VirtualMachineToNodeMetadata.class);
|
||||||
bind(new TypeLiteral<Function<Image, org.jclouds.compute.domain.Image>>() {
|
bind(new TypeLiteral<Function<Image, org.jclouds.compute.domain.Image>>() {
|
||||||
|
@ -106,9 +105,9 @@ public class ViComputeServiceContextModule
|
||||||
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
||||||
// String domainDir = injector.getInstance(Key.get(String.class,
|
// String domainDir = injector.getInstance(Key.get(String.class,
|
||||||
// Names.named(PROPERTY_LIBVIRT_DOMAIN_DIR)));
|
// Names.named(PROPERTY_LIBVIRT_DOMAIN_DIR)));
|
||||||
// String domainDir = "";
|
// String domainDir = "";
|
||||||
// String hardwareId = searchForHardwareIdInDomainDir(domainDir);
|
// String hardwareId = searchForHardwareIdInDomainDir(domainDir);
|
||||||
// String image = searchForImageIdInDomainDir(domainDir);
|
// String image = searchForImageIdInDomainDir(domainDir);
|
||||||
return template.hardwareId("vm-1221").imageId("winNetEnterprise64Guest");
|
return template.hardwareId("vm-1221").imageId("winNetEnterprise64Guest");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,26 +117,58 @@ public class ViComputeServiceContextModule
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private String searchForHardwareIdInDomainDir(String domainDir) {
|
private String searchForHardwareIdInDomainDir(String domainDir, final ParseSax.Factory factory,
|
||||||
|
final javax.inject.Provider<UUIDHandler> provider) {
|
||||||
|
|
||||||
Collection<File> xmlDomains = FileUtils.listFiles(new File(domainDir), new WildcardFileFilter("*.xml"), null);
|
//TODO: remove commons-io dependency
|
||||||
String uuid = "";
|
return Iterables.<String>getLast(filter(transform(FileUtils.listFiles(new File(domainDir), new WildcardFileFilter("*.xml"), null),
|
||||||
|
new Function<File, String>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String apply(File input) {
|
||||||
try {
|
try {
|
||||||
String fromXML = Files.toString(Iterables.get(xmlDomains, 0), Charsets.UTF_8);
|
return factory.create(provider.get()).parse(new FileInputStream(input));
|
||||||
XMLBuilder builder = XMLBuilder.parse(new InputSource(new StringReader(fromXML)));
|
} catch (FileNotFoundException e) {
|
||||||
uuid = builder.xpathFind("/domain/uuid").getElement().getTextContent();
|
// log error.
|
||||||
} catch (IOException e) {
|
return null;
|
||||||
e.printStackTrace();
|
|
||||||
} catch (ParserConfigurationException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (SAXException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (XPathExpressionException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}), notNull()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class UUIDHandler extends ParseSax.HandlerWithResult<String> {
|
||||||
|
private StringBuilder currentText = new StringBuilder();
|
||||||
|
|
||||||
|
private boolean inDomain;
|
||||||
|
private String uuid;
|
||||||
|
|
||||||
|
public String getResult() {
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
||||||
|
if (qName.equals("domain")) {
|
||||||
|
inDomain = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void endElement(String uri, String localName, String qName) {
|
||||||
|
if (qName.equalsIgnoreCase("uuid") && inDomain) {
|
||||||
|
this.uuid = currentText.toString();
|
||||||
|
} else if (qName.equalsIgnoreCase("domain")) {
|
||||||
|
inDomain = false;
|
||||||
|
}
|
||||||
|
currentText = new StringBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void characters(char ch[], int start, int length) {
|
||||||
|
currentText.append(ch, start, length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Map<String, URI> regions = newLinkedHashMap(); for (String region :
|
* Map<String, URI> regions = newLinkedHashMap(); for (String region :
|
||||||
* Splitter.on(',').split(regionString)) { regions.put( region,
|
* Splitter.on(',').split(regionString)) { regions.put( region,
|
|
@ -46,10 +46,22 @@
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-core</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-core</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>test-jar</type>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ning</groupId>
|
<groupId>com.ning</groupId>
|
||||||
<artifactId>async-http-client</artifactId>
|
<artifactId>async-http-client</artifactId>
|
||||||
<version>1.4.0</version>
|
<version>1.4.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mortbay.jetty</groupId>
|
<groupId>org.mortbay.jetty</groupId>
|
||||||
|
|
|
@ -88,7 +88,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<executions>:%s/
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>integration</id>
|
<id>integration</id>
|
||||||
<phase>integration-test</phase>
|
<phase>integration-test</phase>
|
||||||
|
|
|
@ -33,24 +33,26 @@
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<relativePath>../../project/pom.xml</relativePath>
|
<relativePath>../../project/pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>org.jclouds.api</groupId>
|
<groupId>org.jclouds.provider</groupId>
|
||||||
|
<artifactId>ibmdev</artifactId>
|
||||||
<name>jclouds IBMDeveloperCloud core</name>
|
<name>jclouds IBMDeveloperCloud core</name>
|
||||||
<description>jclouds components to access IBMDeveloperCloud</description>
|
<description>jclouds components to access IBMDeveloperCloud</description>
|
||||||
|
|
||||||
<!-- bootstrapping: need to fetch the project POM -->
|
<!-- bootstrapping: need to fetch the project POM -->
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>jclouds-sonatype-snapshots-nexus</id>
|
<id>jclouds-sona-snapshots-nexus</id>
|
||||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||||
<snapshots>
|
<snapshots>
|
||||||
|
<enabled>true</enabled>
|
||||||
</snapshots>
|
</snapshots>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<jclouds.test.identity>${jclouds.ibmdev.user}</jclouds.test.identity>
|
<test.ibmdev.endpoint>https://www-147.ibm.com/computecloud/enterprise/api/rest</test.ibmdev.endpoint>
|
||||||
<jclouds.test.credential>${jclouds.ibmdev.password}</jclouds.test.credential>
|
<test.ibmdev.apiversion>20100331</test.ibmdev.apiversion>
|
||||||
<jclouds.test.endpoint>https://www-147.ibm.com/computecloud/enterprise/api/rest</jclouds.test.endpoint>
|
<test.ibmdev.identity>FIXME</test.ibmdev.identity>
|
||||||
|
<test.ibmdev.credential>FIXME</test.ibmdev.credential>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -65,6 +67,18 @@
|
||||||
<type>test-jar</type>
|
<type>test-jar</type>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-compute</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-compute </artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>test-jar</type>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j</artifactId>
|
||||||
|
@ -82,18 +96,49 @@
|
||||||
<artifactId>jclouds-jsch</artifactId>
|
<artifactId>jclouds-jsch</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jclouds</groupId>
|
|
||||||
<artifactId>jclouds-compute</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jclouds</groupId>
|
|
||||||
<artifactId>jclouds-compute</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<type>test-jar</type>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>live</id>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>integration</id>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>test</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<systemProperties>
|
||||||
|
<property>
|
||||||
|
<name>test.ibmdev.endpoint</name>
|
||||||
|
<value>${test.ibmdev.endpoint}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>test.ibmdev.apiversion</name>
|
||||||
|
<value>${test.ibmdev.apiversion}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>test.ibmdev.identity</name>
|
||||||
|
<value>${test.ibmdev.identity}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>test.ibmdev.credential</name>
|
||||||
|
<value>${test.ibmdev.credential}</value>
|
||||||
|
</property>
|
||||||
|
</systemProperties>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<relativePath>../../project/pom.xml</relativePath>
|
<relativePath>../../project/pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>org.jclouds.api</groupId>
|
<groupId>org.jclouds.provider</groupId>
|
||||||
<artifactId>rimuhosting</artifactId>
|
<artifactId>rimuhosting</artifactId>
|
||||||
<name>jclouds RimuHosting provider</name>
|
<name>jclouds RimuHosting provider</name>
|
||||||
<description>ComputeService implementation of RimuHosting datacenters </description>
|
<description>ComputeService implementation of RimuHosting datacenters </description>
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<relativePath>../../project/pom.xml</relativePath>
|
<relativePath>../../project/pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>org.jclouds.api</groupId>
|
<groupId>org.jclouds.provider</groupId>
|
||||||
<artifactId>savvis</artifactId>
|
<artifactId>savvis</artifactId>
|
||||||
<name>jclouds savvis core</name>
|
<name>jclouds savvis core</name>
|
||||||
<description>jclouds components to access savvis</description>
|
<description>jclouds components to access savvis</description>
|
||||||
|
|
|
@ -63,6 +63,18 @@
|
||||||
<type>test-jar</type>
|
<type>test-jar</type>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-blobstore</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-blobstore</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>test-jar</type>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j</artifactId>
|
||||||
|
|
Loading…
Reference in New Issue