libivrt constants

This commit is contained in:
andreaturli 2010-11-11 11:40:10 +01:00
parent 5a177e9c76
commit 02611ad2ef
3 changed files with 29 additions and 2 deletions

View File

@ -19,6 +19,8 @@
package org.jclouds.libvirt.compute;
import static org.jclouds.libvirt.LibvirtConstants.PROPERTY_LIBVIRT_DOMAIN_DIR;
import java.util.List;
import java.util.Properties;
@ -39,6 +41,9 @@ public class LibvirtComputeServiceContextBuilder extends StandaloneComputeServic
public LibvirtComputeServiceContextBuilder(Properties props) {
super(props);
if (!properties.containsKey(PROPERTY_LIBVIRT_DOMAIN_DIR))
properties.setProperty(PROPERTY_LIBVIRT_DOMAIN_DIR, "/etc/libvirt/qemu");
}
@Override

View File

@ -19,7 +19,11 @@
package org.jclouds.libvirt.compute.domain;
import static com.google.common.collect.Maps.newLinkedHashMap;
import static org.jclouds.libvirt.LibvirtConstants.PROPERTY_LIBVIRT_DOMAIN_DIR;
import java.net.URI;
import java.util.Map;
import javax.inject.Named;
import javax.inject.Singleton;
@ -48,6 +52,7 @@ import org.libvirt.Domain;
import org.libvirt.LibvirtException;
import com.google.common.base.Function;
import com.google.common.base.Splitter;
import com.google.common.base.Supplier;
import com.google.inject.Injector;
import com.google.inject.Key;
@ -90,7 +95,9 @@ StandaloneComputeServiceContextModule<Domain, Domain, Image, Datacenter> {
@Override
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
String domainDir = injector.getInstance(Key.get(String.class, Names.named("jclouds.libvirt.domain-dir")));
//String domainDir = injector.getInstance(Key.get(String.class, Names.named(PROPERTY_LIBVIRT_DOMAIN_DIR)));
String domainDir = "";
System.out.println("++++ domain dir: " + domainDir);
String hardwareId = searchForHardwareIdInDomainDir(domainDir);
String image = searchForImageIdInDomainDir(domainDir);
return template.hardwareId(hardwareId).imageId(image) ;
@ -105,4 +112,16 @@ StandaloneComputeServiceContextModule<Domain, Domain, Image, Datacenter> {
// TODO
return "c7ff2039-a9f1-a659-7f91-e0f82f59d52e";
}
/*
* Map<String, URI> regions = newLinkedHashMap();
for (String region : Splitter.on(',').split(regionString)) {
regions.put(
region,
URI.create(injector.getInstance(Key.get(String.class,
Names.named(Constants.PROPERTY_ENDPOINT + "." + region)))));
}
return regions;
*/
}

View File

@ -20,6 +20,7 @@
package org.jclouds.libvirt.compute.strategy;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.libvirt.LibvirtConstants.PROPERTY_LIBVIRT_DOMAIN_DIR;
import java.io.IOException;
import java.io.StringReader;
@ -63,6 +64,7 @@ import com.google.common.base.Splitter;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.inject.name.Named;
import com.jamesmurty.utils.XMLBuilder;
/**
@ -76,8 +78,9 @@ public class LibvirtComputeServiceAdapter implements ComputeServiceAdapter<Domai
private final Connect client;
@Inject
public LibvirtComputeServiceAdapter(Connect client) {
public LibvirtComputeServiceAdapter(Connect client, @Named(PROPERTY_LIBVIRT_DOMAIN_DIR) String domainDir) {
this.client = checkNotNull(client, "client");
System.out.println(domainDir);
}
@Override