mirror of https://github.com/apache/jclouds.git
removed provider-specific image parsing from base classes
This commit is contained in:
parent
2d888fb18e
commit
b351223f5e
|
@ -45,7 +45,6 @@ import org.jclouds.domain.internal.LocationImpl;
|
|||
import org.jclouds.ec2.compute.strategy.ReviseParsedImage;
|
||||
import org.jclouds.ec2.domain.Image.Architecture;
|
||||
import org.jclouds.ec2.domain.Image.ImageType;
|
||||
import org.jclouds.location.Provider;
|
||||
import org.jclouds.logging.Logger;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
@ -66,19 +65,16 @@ public class EC2ImageParser implements Function<org.jclouds.ec2.domain.Image, Im
|
|||
private final PopulateDefaultLoginCredentialsForImageStrategy credentialProvider;
|
||||
private final Supplier<Set<? extends Location>> locations;
|
||||
private final Supplier<Location> defaultLocation;
|
||||
private final String provider;
|
||||
private final Map<OsFamily, Map<String, String>> osVersionMap;
|
||||
private final ReviseParsedImage reviseParsedImage;
|
||||
|
||||
@Inject
|
||||
public
|
||||
EC2ImageParser(PopulateDefaultLoginCredentialsForImageStrategy credentialProvider,
|
||||
public EC2ImageParser(PopulateDefaultLoginCredentialsForImageStrategy credentialProvider,
|
||||
Map<OsFamily, Map<String, String>> osVersionMap, @Memoized Supplier<Set<? extends Location>> locations,
|
||||
Supplier<Location> defaultLocation, @Provider String provider, ReviseParsedImage reviseParsedImage) {
|
||||
Supplier<Location> defaultLocation, ReviseParsedImage reviseParsedImage) {
|
||||
this.credentialProvider = checkNotNull(credentialProvider, "credentialProvider");
|
||||
this.locations = checkNotNull(locations, "locations");
|
||||
this.defaultLocation = checkNotNull(defaultLocation, "defaultLocation");
|
||||
this.provider = checkNotNull(provider, "provider");
|
||||
this.osVersionMap = checkNotNull(osVersionMap, "osVersionMap");
|
||||
this.reviseParsedImage = checkNotNull(reviseParsedImage, "reviseParsedImage");
|
||||
}
|
||||
|
@ -98,7 +94,7 @@ public class EC2ImageParser implements Function<org.jclouds.ec2.domain.Image, Im
|
|||
|
||||
OperatingSystemBuilder osBuilder = new OperatingSystemBuilder();
|
||||
osBuilder.is64Bit(from.getArchitecture() == Architecture.X86_64);
|
||||
OsFamily family = parseOsFamilyOrUnrecognized(provider, from.getImageLocation());
|
||||
OsFamily family = parseOsFamilyOrUnrecognized(from.getImageLocation());
|
||||
osBuilder.family(family);
|
||||
osBuilder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(family, from.getImageLocation(),
|
||||
osVersionMap));
|
||||
|
|
|
@ -85,7 +85,7 @@ public class EC2ImageParserTest {
|
|||
Set<Image> result = DescribeImagesResponseHandlerTest.parseImages(resource);
|
||||
EC2ImageParser parser = new EC2ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(), map,
|
||||
Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(defaultLocation)), Suppliers
|
||||
.ofInstance(defaultLocation), "ec2", new ReviseParsedImage.NoopReviseParsedImage());
|
||||
.ofInstance(defaultLocation), new ReviseParsedImage.NoopReviseParsedImage());
|
||||
return Sets.newLinkedHashSet(Iterables.filter(Iterables.transform(result, parser), Predicates.notNull()));
|
||||
}
|
||||
|
||||
|
|
|
@ -132,17 +132,14 @@ public class ComputeServiceUtils {
|
|||
return total;
|
||||
}
|
||||
|
||||
public static org.jclouds.compute.domain.OsFamily parseOsFamilyOrUnrecognized(String provider, String in) {
|
||||
public static org.jclouds.compute.domain.OsFamily parseOsFamilyOrUnrecognized(String in) {
|
||||
org.jclouds.compute.domain.OsFamily myOs = null;
|
||||
for (org.jclouds.compute.domain.OsFamily os : org.jclouds.compute.domain.OsFamily.values()) {
|
||||
if (in.toLowerCase().replaceAll("\\s", "").indexOf(os.toString()) != -1) {
|
||||
myOs = os;
|
||||
}
|
||||
}
|
||||
if (myOs == null && provider.indexOf("nebula") != -1) {
|
||||
myOs = OsFamily.UBUNTU;
|
||||
}
|
||||
return OsFamily.UNRECOGNIZED;
|
||||
return myOs != null ? myOs : OsFamily.UNRECOGNIZED;
|
||||
}
|
||||
|
||||
public static String createExecutionErrorMessage(Map<?, Exception> executionExceptions) {
|
||||
|
@ -209,6 +206,8 @@ public class ComputeServiceUtils {
|
|||
if (osVersionMap.containsKey(family)) {
|
||||
if (osVersionMap.get(family).containsKey(in))
|
||||
return osVersionMap.get(family).get(in);
|
||||
if (osVersionMap.get(family).containsValue(in))
|
||||
return in;
|
||||
CONTAINS_SUBSTRING contains = new CONTAINS_SUBSTRING(in.replace('-', '.'));
|
||||
try {
|
||||
String key = Iterables.find(osVersionMap.get(family).keySet(), contains);
|
||||
|
|
|
@ -165,7 +165,7 @@ public class AWSEC2ImageParserTest {
|
|||
Set<Image> result = DescribeImagesResponseHandlerTest.parseImages(resource);
|
||||
EC2ImageParser parser = new EC2ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(), map,
|
||||
Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(defaultLocation)), Suppliers
|
||||
.ofInstance(defaultLocation), "ec2", new AWSEC2ReviseParsedImage(map));
|
||||
.ofInstance(defaultLocation), new AWSEC2ReviseParsedImage(map));
|
||||
return Sets.newLinkedHashSet(Iterables.filter(Iterables.transform(result, parser), Predicates.notNull()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ public class EucalyptusPartnerCloudReviseParsedImageTest {
|
|||
Set<Image> result = DescribeImagesResponseHandlerTest.parseImages(resource);
|
||||
EC2ImageParser parser = new EC2ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(), map,
|
||||
Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(defaultLocation)), Suppliers
|
||||
.ofInstance(defaultLocation), "ec2", new EucalyptusPartnerCloudReviseParsedImage(map));
|
||||
.ofInstance(defaultLocation), new EucalyptusPartnerCloudReviseParsedImage(map));
|
||||
return Sets.newLinkedHashSet(Iterables.filter(Iterables.transform(result, parser), Predicates.notNull()));
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import static org.testng.Assert.assertEquals;
|
|||
import java.io.IOException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jclouds.compute.domain.ExecResponse;
|
||||
import org.jclouds.deltacloud.domain.Instance;
|
||||
import org.jclouds.deltacloud.domain.InstanceAction;
|
||||
import org.jclouds.deltacloud.domain.InstanceState;
|
||||
|
@ -31,7 +32,6 @@ import org.jclouds.deltacloud.options.CreateInstanceOptions;
|
|||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.net.IPSocket;
|
||||
import org.jclouds.ssh.ExecResponse;
|
||||
import org.jclouds.ssh.SshClient;
|
||||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
||||
import org.testng.annotations.AfterGroups;
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.nova.ec2;
|
|||
|
||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||
import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS;
|
||||
import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_CC_AMIs;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
|
@ -38,7 +37,6 @@ public class NovaEC2PropertiesBuilder extends EC2PropertiesBuilder {
|
|||
Properties properties = super.defaultProperties();
|
||||
properties.setProperty(PROPERTY_ENDPOINT, "YOU_MUST_SET_" + PROPERTY_ENDPOINT);
|
||||
properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "*");
|
||||
properties.setProperty(PROPERTY_EC2_CC_AMIs, "");
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,14 +31,17 @@ import javax.inject.Named;
|
|||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.compute.config.CustomizationResponse;
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.compute.domain.Template;
|
||||
import org.jclouds.compute.strategy.AddNodeWithTagStrategy;
|
||||
import org.jclouds.compute.strategy.CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap;
|
||||
import org.jclouds.compute.strategy.ListNodesStrategy;
|
||||
import org.jclouds.compute.strategy.impl.EncodeTagIntoNameRunNodesAndAddToSetStrategy;
|
||||
import org.jclouds.compute.util.ComputeUtils;
|
||||
import org.jclouds.ibmdev.IBMDeveloperCloudClient;
|
||||
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
|
@ -48,18 +51,22 @@ public class CreateKeyPairEncodeTagIntoNameRunNodesAndAddToSet extends EncodeTag
|
|||
private final Map<String, String> credentialsMap;
|
||||
|
||||
@Inject
|
||||
protected CreateKeyPairEncodeTagIntoNameRunNodesAndAddToSet(AddNodeWithTagStrategy addNodeWithTagStrategy,
|
||||
ListNodesStrategy listNodesStrategy, @Named("NAMING_CONVENTION") String nodeNamingConvention,
|
||||
ComputeUtils utils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor,
|
||||
protected CreateKeyPairEncodeTagIntoNameRunNodesAndAddToSet(
|
||||
AddNodeWithTagStrategy addNodeWithTagStrategy,
|
||||
ListNodesStrategy listNodesStrategy,
|
||||
@Named("NAMING_CONVENTION") String nodeNamingConvention,
|
||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor,
|
||||
CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.Factory customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory,
|
||||
IBMDeveloperCloudClient client, @Named("CREDENTIALS") Map<String, String> credentialsMap) {
|
||||
super(addNodeWithTagStrategy, listNodesStrategy, nodeNamingConvention, utils, executor);
|
||||
super(addNodeWithTagStrategy, listNodesStrategy, nodeNamingConvention, executor,
|
||||
customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory);
|
||||
this.client = checkNotNull(client, "client");
|
||||
this.credentialsMap = checkNotNull(credentialsMap, "credentialsMap");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<?, Future<Void>> execute(String tag, int count, Template template, Set<NodeMetadata> nodes,
|
||||
Map<NodeMetadata, Exception> badNodes) {
|
||||
public Map<?, Future<Void>> execute(String tag, int count, Template template, Set<NodeMetadata> goodNodes,
|
||||
Map<NodeMetadata, Exception> badNodes, Multimap<NodeMetadata, CustomizationResponse> customizationResponses) {
|
||||
String keyAsText = template.getOptions().getPublicKey();
|
||||
if (keyAsText != null) {
|
||||
template.getOptions().dontAuthorizePublicKey();
|
||||
|
@ -72,7 +79,7 @@ public class CreateKeyPairEncodeTagIntoNameRunNodesAndAddToSet extends EncodeTag
|
|||
} else {
|
||||
credentialsMap.put(tag, client.generateKeyPair(tag).getKeyMaterial());
|
||||
}
|
||||
return super.execute(tag, count, template, nodes, badNodes);
|
||||
return super.execute(tag, count, template, goodNodes, badNodes, customizationResponses);
|
||||
}
|
||||
|
||||
}
|
|
@ -35,20 +35,21 @@ import java.util.Properties;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jclouds.compute.domain.ExecResponse;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.http.HttpResponseException;
|
||||
import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
|
||||
import org.jclouds.ibmdev.domain.Address;
|
||||
import org.jclouds.ibmdev.domain.Image;
|
||||
import org.jclouds.ibmdev.domain.Instance;
|
||||
import org.jclouds.ibmdev.domain.Instance.Software;
|
||||
import org.jclouds.ibmdev.domain.InstanceType;
|
||||
import org.jclouds.ibmdev.domain.Key;
|
||||
import org.jclouds.ibmdev.domain.Location;
|
||||
import org.jclouds.ibmdev.domain.Offering;
|
||||
import org.jclouds.ibmdev.domain.StorageOffering;
|
||||
import org.jclouds.ibmdev.domain.StorageOffering.Format;
|
||||
import org.jclouds.ibmdev.domain.Volume;
|
||||
import org.jclouds.ibmdev.domain.Instance.Software;
|
||||
import org.jclouds.ibmdev.domain.StorageOffering.Format;
|
||||
import org.jclouds.ibmdev.predicates.AddressFree;
|
||||
import org.jclouds.ibmdev.predicates.InstanceActive;
|
||||
import org.jclouds.ibmdev.predicates.InstanceActiveOrFailed;
|
||||
|
@ -60,7 +61,6 @@ import org.jclouds.predicates.InetSocketAddressConnect;
|
|||
import org.jclouds.predicates.RetryablePredicate;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
import org.jclouds.ssh.ExecResponse;
|
||||
import org.jclouds.ssh.SshClient;
|
||||
import org.jclouds.ssh.SshException;
|
||||
import org.jclouds.ssh.jsch.JschSshClient;
|
||||
|
|
Loading…
Reference in New Issue