missing commits

This commit is contained in:
Adrian Cole 2011-12-22 02:23:20 -08:00
parent 535c035ae6
commit 3a8ea09fb9
6 changed files with 28 additions and 13 deletions

View File

@ -20,28 +20,34 @@ package org.jclouds.ec2.compute.strategy;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.compute.strategy.impl.ReturnCredentialsBoundToImage; import org.jclouds.compute.strategy.impl.ReturnCredentialsBoundToImage;
import org.jclouds.domain.Credentials;
import org.jclouds.domain.LoginCredentials; import org.jclouds.domain.LoginCredentials;
import org.jclouds.domain.LoginCredentials.Builder; import org.jclouds.domain.LoginCredentials.Builder;
import org.jclouds.ec2.domain.Image; import org.jclouds.ec2.domain.Image;
import org.jclouds.javax.annotation.Nullable; import org.jclouds.javax.annotation.Nullable;
import com.google.common.collect.ImmutableMap;
/** /**
* @author Oleksiy Yarmula * @author Oleksiy Yarmula
*/ */
@Singleton @Singleton
public class EC2PopulateDefaultLoginCredentialsForImageStrategy extends ReturnCredentialsBoundToImage { public class EC2PopulateDefaultLoginCredentialsForImageStrategy extends ReturnCredentialsBoundToImage {
public EC2PopulateDefaultLoginCredentialsForImageStrategy() { public EC2PopulateDefaultLoginCredentialsForImageStrategy() {
this(null); this(null, ImmutableMap.<String, Credentials> of());
} }
@Inject @Inject
public EC2PopulateDefaultLoginCredentialsForImageStrategy(@Nullable @Named("image") LoginCredentials creds) { public EC2PopulateDefaultLoginCredentialsForImageStrategy(@Nullable @Named("image") LoginCredentials creds,
super(creds); Map<String, Credentials> credentialStore) {
super(creds, credentialStore);
} }
@Override @Override

View File

@ -83,7 +83,7 @@ public class EC2ImageParserTest {
.getInstance(Json.class)); .getInstance(Json.class));
Set<Image> result = DescribeImagesResponseHandlerTest.parseImages(resource); Set<Image> result = DescribeImagesResponseHandlerTest.parseImages(resource);
EC2ImageParser parser = new EC2ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(null), map, EC2ImageParser parser = new EC2ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(), map,
Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(defaultLocation)), Suppliers Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(defaultLocation)), Suppliers
.ofInstance(defaultLocation), new ReviseParsedImage.NoopReviseParsedImage()); .ofInstance(defaultLocation), new ReviseParsedImage.NoopReviseParsedImage());
return Sets.newLinkedHashSet(Iterables.filter(Iterables.transform(result, parser), Predicates.notNull())); return Sets.newLinkedHashSet(Iterables.filter(Iterables.transform(result, parser), Predicates.notNull()));

View File

@ -21,6 +21,7 @@ package org.jclouds.trmk.vcloud_0_8.compute.strategy;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -31,6 +32,7 @@ import javax.inject.Singleton;
import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.compute.strategy.impl.ReturnCredentialsBoundToImage; import org.jclouds.compute.strategy.impl.ReturnCredentialsBoundToImage;
import org.jclouds.domain.Credentials;
import org.jclouds.domain.LoginCredentials; import org.jclouds.domain.LoginCredentials;
import org.jclouds.javax.annotation.Nullable; import org.jclouds.javax.annotation.Nullable;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
@ -42,8 +44,9 @@ import org.jclouds.trmk.vcloud_0_8.domain.VAppTemplate;
@Singleton @Singleton
public class ParseVAppTemplateDescriptionToGetDefaultLoginCredentials extends ReturnCredentialsBoundToImage { public class ParseVAppTemplateDescriptionToGetDefaultLoginCredentials extends ReturnCredentialsBoundToImage {
@Inject @Inject
public ParseVAppTemplateDescriptionToGetDefaultLoginCredentials(@Nullable @Named("image") LoginCredentials creds) { public ParseVAppTemplateDescriptionToGetDefaultLoginCredentials(@Nullable @Named("image") LoginCredentials creds,
super(creds); Map<String, Credentials> credentialStore) {
super(creds, credentialStore);
} }
@Resource @Resource

View File

@ -32,6 +32,7 @@ import org.jclouds.trmk.vcloud_0_8.compute.strategy.ParseVAppTemplateDescription
import org.jclouds.trmk.vcloud_0_8.domain.VAppTemplate; import org.jclouds.trmk.vcloud_0_8.domain.VAppTemplate;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
/** /**
@ -47,7 +48,8 @@ public class PopulateDefaultLoginCredentialsForVAppTemplateTest {
VAppTemplate template = createMock(VAppTemplate.class); VAppTemplate template = createMock(VAppTemplate.class);
expect(template.getDescription()).andReturn(description).atLeastOnce(); expect(template.getDescription()).andReturn(description).atLeastOnce();
replay(template); replay(template);
ParseVAppTemplateDescriptionToGetDefaultLoginCredentials converter = new ParseVAppTemplateDescriptionToGetDefaultLoginCredentials(null); ParseVAppTemplateDescriptionToGetDefaultLoginCredentials converter = new ParseVAppTemplateDescriptionToGetDefaultLoginCredentials(
null, ImmutableMap.<String, Credentials> of());
Credentials creds = converter.execute(template); Credentials creds = converter.execute(template);
assertEquals(creds.identity, "vcloud"); assertEquals(creds.identity, "vcloud");
assertEquals(creds.credential, "$Ep455l0ud!2"); assertEquals(creds.credential, "$Ep455l0ud!2");
@ -61,7 +63,8 @@ public class PopulateDefaultLoginCredentialsForVAppTemplateTest {
VAppTemplate template = createMock(VAppTemplate.class); VAppTemplate template = createMock(VAppTemplate.class);
expect(template.getDescription()).andReturn(description).atLeastOnce(); expect(template.getDescription()).andReturn(description).atLeastOnce();
replay(template); replay(template);
ParseVAppTemplateDescriptionToGetDefaultLoginCredentials converter = new ParseVAppTemplateDescriptionToGetDefaultLoginCredentials(null); ParseVAppTemplateDescriptionToGetDefaultLoginCredentials converter = new ParseVAppTemplateDescriptionToGetDefaultLoginCredentials(
null, ImmutableMap.<String, Credentials> of());
Credentials creds = converter.execute(template); Credentials creds = converter.execute(template);
assertEquals(creds.identity, "ecloud"); assertEquals(creds.identity, "ecloud");
assertEquals(creds.credential, "$Ep455l0ud!2"); assertEquals(creds.credential, "$Ep455l0ud!2");
@ -75,7 +78,8 @@ public class PopulateDefaultLoginCredentialsForVAppTemplateTest {
VAppTemplate template = createMock(VAppTemplate.class); VAppTemplate template = createMock(VAppTemplate.class);
expect(template.getDescription()).andReturn(description).atLeastOnce(); expect(template.getDescription()).andReturn(description).atLeastOnce();
replay(template); replay(template);
ParseVAppTemplateDescriptionToGetDefaultLoginCredentials converter = new ParseVAppTemplateDescriptionToGetDefaultLoginCredentials(null); ParseVAppTemplateDescriptionToGetDefaultLoginCredentials converter = new ParseVAppTemplateDescriptionToGetDefaultLoginCredentials(
null, ImmutableMap.<String, Credentials> of());
Credentials creds = converter.execute(template); Credentials creds = converter.execute(template);
assertEquals(creds.identity, "vpncubed"); assertEquals(creds.identity, "vpncubed");
assertEquals(creds.credential, "vpncubed"); assertEquals(creds.credential, "vpncubed");
@ -89,7 +93,8 @@ public class PopulateDefaultLoginCredentialsForVAppTemplateTest {
VAppTemplate template = createMock(VAppTemplate.class); VAppTemplate template = createMock(VAppTemplate.class);
expect(template.getDescription()).andReturn(description).atLeastOnce(); expect(template.getDescription()).andReturn(description).atLeastOnce();
replay(template); replay(template);
ParseVAppTemplateDescriptionToGetDefaultLoginCredentials converter = new ParseVAppTemplateDescriptionToGetDefaultLoginCredentials(null); ParseVAppTemplateDescriptionToGetDefaultLoginCredentials converter = new ParseVAppTemplateDescriptionToGetDefaultLoginCredentials(
null, ImmutableMap.<String, Credentials> of());
Credentials creds = converter.execute(template); Credentials creds = converter.execute(template);
assertEquals(creds.identity, "ecloud"); assertEquals(creds.identity, "ecloud");
assertEquals(creds.credential, "TmrkCl0ud1s#1!"); assertEquals(creds.credential, "TmrkCl0ud1s#1!");
@ -103,7 +108,8 @@ public class PopulateDefaultLoginCredentialsForVAppTemplateTest {
VAppTemplate template = createMock(VAppTemplate.class); VAppTemplate template = createMock(VAppTemplate.class);
expect(template.getDescription()).andReturn(description).atLeastOnce(); expect(template.getDescription()).andReturn(description).atLeastOnce();
replay(template); replay(template);
ParseVAppTemplateDescriptionToGetDefaultLoginCredentials converter = new ParseVAppTemplateDescriptionToGetDefaultLoginCredentials(null); ParseVAppTemplateDescriptionToGetDefaultLoginCredentials converter = new ParseVAppTemplateDescriptionToGetDefaultLoginCredentials(
null, ImmutableMap.<String, Credentials> of());
Credentials creds = converter.execute(template); Credentials creds = converter.execute(template);
assertEquals(creds.identity, "Administrator"); assertEquals(creds.identity, "Administrator");
assertEquals(creds.credential, null); assertEquals(creds.credential, null);

View File

@ -192,7 +192,7 @@ public class AWSEC2ImageParserTest {
.getInstance(Json.class)); .getInstance(Json.class));
Set<Image> result = DescribeImagesResponseHandlerTest.parseImages(resource); Set<Image> result = DescribeImagesResponseHandlerTest.parseImages(resource);
EC2ImageParser parser = new EC2ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(null), map, EC2ImageParser parser = new EC2ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(), map,
Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(defaultLocation)), Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(defaultLocation)),
Suppliers.ofInstance(defaultLocation), new AWSEC2ReviseParsedImage(map)); Suppliers.ofInstance(defaultLocation), new AWSEC2ReviseParsedImage(map));
return Sets.newLinkedHashSet(Iterables.filter(Iterables.transform(result, parser), Predicates.notNull())); return Sets.newLinkedHashSet(Iterables.filter(Iterables.transform(result, parser), Predicates.notNull()));

View File

@ -120,7 +120,7 @@ public class EucalyptusPartnerCloudReviseParsedImageTest {
.getInstance(Json.class)); .getInstance(Json.class));
Set<Image> result = DescribeImagesResponseHandlerTest.parseImages(resource); Set<Image> result = DescribeImagesResponseHandlerTest.parseImages(resource);
EC2ImageParser parser = new EC2ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(null), map, EC2ImageParser parser = new EC2ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(), map,
Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(defaultLocation)), Suppliers Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(defaultLocation)), Suppliers
.ofInstance(defaultLocation), new EucalyptusPartnerCloudReviseParsedImage(map)); .ofInstance(defaultLocation), new EucalyptusPartnerCloudReviseParsedImage(map));
return Sets.newLinkedHashSet(Iterables.filter(Iterables.transform(result, parser), Predicates.notNull())); return Sets.newLinkedHashSet(Iterables.filter(Iterables.transform(result, parser), Predicates.notNull()));