mirror of https://github.com/apache/jclouds.git
made nullcredentials default and refined usage changing the vcloud api version
This commit is contained in:
parent
0684dc2344
commit
a5abb14d20
|
@ -449,7 +449,7 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
size = sizeOrdering.max(Iterables.filter(sizesThatAreCompatibleWithOurImages,
|
size = sizeOrdering.max(Iterables.filter(sizesThatAreCompatibleWithOurImages,
|
||||||
sizePredicate));
|
sizePredicate));
|
||||||
} catch (NoSuchElementException exception) {
|
} catch (NoSuchElementException exception) {
|
||||||
throw new NoSuchElementException("size didn't match: " + toString() + "\n" + sizes);
|
throw new NoSuchElementException("size didn't match: " + toString() + "\n" + sizes.get());
|
||||||
}
|
}
|
||||||
logger.debug("<< matched size(%s)", size);
|
logger.debug("<< matched size(%s)", size);
|
||||||
return size;
|
return size;
|
||||||
|
@ -480,7 +480,7 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
logger.trace("<< best images(%s)", maxImages);
|
logger.trace("<< best images(%s)", maxImages);
|
||||||
return maxImages;
|
return maxImages;
|
||||||
} catch (NoSuchElementException exception) {
|
} catch (NoSuchElementException exception) {
|
||||||
throw new NoSuchElementException("image didn't match: " + toString() + "\n" + images);
|
throw new NoSuchElementException("image didn't match: " + toString() + "\n" + images.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,11 +18,15 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.compute.strategy;
|
package org.jclouds.compute.strategy;
|
||||||
|
|
||||||
|
import org.jclouds.compute.strategy.impl.ReturnNullCredentials;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
|
|
||||||
|
import com.google.inject.ImplementedBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Oleksiy Yarmula
|
* @author Oleksiy Yarmula
|
||||||
*/
|
*/
|
||||||
|
@ImplementedBy(ReturnNullCredentials.class)
|
||||||
public interface PopulateDefaultLoginCredentialsForImageStrategy {
|
public interface PopulateDefaultLoginCredentialsForImageStrategy {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package org.jclouds.compute.strategy.impl;
|
package org.jclouds.compute.strategy.impl;
|
||||||
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
|
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
|
||||||
|
@ -13,9 +11,6 @@ import org.jclouds.domain.Credentials;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ReturnNullCredentials implements PopulateDefaultLoginCredentialsForImageStrategy {
|
public class ReturnNullCredentials implements PopulateDefaultLoginCredentialsForImageStrategy {
|
||||||
|
|
||||||
public static final Pattern USER_PASSWORD_PATTERN = Pattern
|
|
||||||
.compile(".*[Uu]sername: ([a-z]+) ?.*\n[Pp]assword: ([^ ]+) ?\n.*");
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Credentials execute(Object resourceToAuthenticate) {
|
public Credentials execute(Object resourceToAuthenticate) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -75,10 +75,13 @@ public class BlueLockVCloudComputeServiceContextModule extends VCloudComputeServ
|
||||||
private static class BlueLockVCloudImageProvider extends VCloudImageProvider {
|
private static class BlueLockVCloudImageProvider extends VCloudImageProvider {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected BlueLockVCloudImageProvider(VCloudClient client,
|
protected BlueLockVCloudImageProvider(
|
||||||
|
VCloudClient client,
|
||||||
FindLocationForResourceInVDC findLocationForResourceInVDC,
|
FindLocationForResourceInVDC findLocationForResourceInVDC,
|
||||||
|
PopulateDefaultLoginCredentialsForImageStrategy populateDefaultLoginCredentialsForImageStrategy,
|
||||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
||||||
super(client, findLocationForResourceInVDC, executor);
|
super(client, findLocationForResourceInVDC,
|
||||||
|
populateDefaultLoginCredentialsForImageStrategy, executor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extremely important, as otherwise the size encoded into the name will throw off the
|
// Extremely important, as otherwise the size encoded into the name will throw off the
|
||||||
|
|
|
@ -22,8 +22,10 @@ package org.jclouds.vcloud.bluelock.compute;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.Architecture;
|
import org.jclouds.compute.domain.Architecture;
|
||||||
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
import org.jclouds.compute.domain.Template;
|
import org.jclouds.compute.domain.Template;
|
||||||
|
import org.jclouds.compute.domain.TemplateBuilder;
|
||||||
import org.jclouds.http.HttpResponseException;
|
import org.jclouds.http.HttpResponseException;
|
||||||
import org.jclouds.vcloud.VCloudClient;
|
import org.jclouds.vcloud.VCloudClient;
|
||||||
import org.jclouds.vcloud.compute.VCloudComputeServiceLiveTest;
|
import org.jclouds.vcloud.compute.VCloudComputeServiceLiveTest;
|
||||||
|
@ -52,6 +54,15 @@ public class BlueLockVCloudComputeServiceLiveTest extends VCloudComputeServiceLi
|
||||||
assertEquals(defaultTemplate.getSize().getCores(), 1.0d);
|
assertEquals(defaultTemplate.getSize().getCores(), 1.0d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Template buildTemplate(TemplateBuilder templateBuilder) {
|
||||||
|
Template template = super.buildTemplate(templateBuilder);
|
||||||
|
Image image = template.getImage();
|
||||||
|
assert image.getDefaultCredentials().account != null : image;
|
||||||
|
assert image.getDefaultCredentials().key != null : image;
|
||||||
|
return template;
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testErrorWhereAllNetworksReturn403() throws Exception {
|
public void testErrorWhereAllNetworksReturn403() throws Exception {
|
||||||
VCloudClient bluelockClient = VCloudClient.class.cast(context.getProviderSpecificContext()
|
VCloudClient bluelockClient = VCloudClient.class.cast(context.getProviderSpecificContext()
|
||||||
|
|
|
@ -46,7 +46,6 @@ public class VCloudPropertiesBuilder extends PropertiesBuilder {
|
||||||
Properties properties = super.defaultProperties();
|
Properties properties = super.defaultProperties();
|
||||||
properties.setProperty(PROPERTY_VCLOUD_VERSION, "0.8");
|
properties.setProperty(PROPERTY_VCLOUD_VERSION, "0.8");
|
||||||
properties.setProperty(PROPERTY_VCLOUD_SESSIONINTERVAL, 8 * 60 + "");
|
properties.setProperty(PROPERTY_VCLOUD_SESSIONINTERVAL, 8 * 60 + "");
|
||||||
properties.setProperty(PROPERTY_VCLOUD_XML_NAMESPACE, "http://www.vmware.com/vcloud/v0.8");
|
|
||||||
properties.setProperty(PROPERTY_VCLOUD_XML_SCHEMA,
|
properties.setProperty(PROPERTY_VCLOUD_XML_SCHEMA,
|
||||||
"http://vcloud.safesecureweb.com/ns/vcloud.xsd");
|
"http://vcloud.safesecureweb.com/ns/vcloud.xsd");
|
||||||
properties.setProperty(PROPERTY_VCLOUD_DEFAULT_DHCP_ENABLED, "false");
|
properties.setProperty(PROPERTY_VCLOUD_DEFAULT_DHCP_ENABLED, "false");
|
||||||
|
@ -58,10 +57,18 @@ public class VCloudPropertiesBuilder extends PropertiesBuilder {
|
||||||
|
|
||||||
public VCloudPropertiesBuilder(Properties properties) {
|
public VCloudPropertiesBuilder(Properties properties) {
|
||||||
super(properties);
|
super(properties);
|
||||||
|
setNs();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setNs() {
|
||||||
|
if (properties.getProperty(PROPERTY_VCLOUD_XML_NAMESPACE) == null)
|
||||||
|
properties.setProperty(PROPERTY_VCLOUD_XML_NAMESPACE, "http://www.vmware.com/vcloud/v"
|
||||||
|
+ properties.getProperty(PROPERTY_VCLOUD_VERSION));
|
||||||
}
|
}
|
||||||
|
|
||||||
public VCloudPropertiesBuilder(URI endpoint, String id, String secret) {
|
public VCloudPropertiesBuilder(URI endpoint, String id, String secret) {
|
||||||
super();
|
super();
|
||||||
|
setNs();
|
||||||
withCredentials(id, secret);
|
withCredentials(id, secret);
|
||||||
withEndpoint(endpoint);
|
withEndpoint(endpoint);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,8 @@ import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
import org.jclouds.compute.domain.internal.ImageImpl;
|
import org.jclouds.compute.domain.internal.ImageImpl;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
|
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
|
||||||
import org.jclouds.concurrent.ConcurrentUtils;
|
import org.jclouds.concurrent.ConcurrentUtils;
|
||||||
import org.jclouds.domain.Credentials;
|
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.vcloud.VCloudClient;
|
import org.jclouds.vcloud.VCloudClient;
|
||||||
|
@ -61,17 +61,19 @@ public class VCloudImageProvider implements Provider<Set<? extends Image>> {
|
||||||
|
|
||||||
private final VCloudClient client;
|
private final VCloudClient client;
|
||||||
private final FindLocationForResourceInVDC findLocationForResourceInVDC;
|
private final FindLocationForResourceInVDC findLocationForResourceInVDC;
|
||||||
|
private final PopulateDefaultLoginCredentialsForImageStrategy populateDefaultLoginCredentialsForImageStrategy;
|
||||||
private final ExecutorService executor;
|
private final ExecutorService executor;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected VCloudImageProvider(VCloudClient client,
|
protected VCloudImageProvider(
|
||||||
|
VCloudClient client,
|
||||||
FindLocationForResourceInVDC findLocationForResourceInVDC,
|
FindLocationForResourceInVDC findLocationForResourceInVDC,
|
||||||
|
PopulateDefaultLoginCredentialsForImageStrategy populateDefaultLoginCredentialsForImageStrategy,
|
||||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.findLocationForResourceInVDC = findLocationForResourceInVDC;
|
this.findLocationForResourceInVDC = findLocationForResourceInVDC;
|
||||||
|
this.populateDefaultLoginCredentialsForImageStrategy = populateDefaultLoginCredentialsForImageStrategy;
|
||||||
this.executor = executor;
|
this.executor = executor;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -105,7 +107,9 @@ public class VCloudImageProvider implements Provider<Set<? extends Image>> {
|
||||||
images.add(new ImageImpl(resource.getId(), name, resource.getId(),
|
images.add(new ImageImpl(resource.getId(), name, resource.getId(),
|
||||||
location, template.getLocation(), ImmutableMap
|
location, template.getLocation(), ImmutableMap
|
||||||
.<String, String> of(), template.getDescription(),
|
.<String, String> of(), template.getDescription(),
|
||||||
"", myOs, name, arch, new Credentials("root", null)));
|
"", myOs, name, arch,
|
||||||
|
populateDefaultLoginCredentialsForImageStrategy
|
||||||
|
.execute(template)));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}), executor));
|
}), executor));
|
||||||
|
|
|
@ -21,8 +21,6 @@ package org.jclouds.vcloud.hostingdotcom.compute.config;
|
||||||
import static org.jclouds.compute.domain.OsFamily.CENTOS;
|
import static org.jclouds.compute.domain.OsFamily.CENTOS;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
import org.jclouds.compute.domain.TemplateBuilder;
|
||||||
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
|
|
||||||
import org.jclouds.compute.strategy.impl.ReturnNullCredentials;
|
|
||||||
import org.jclouds.vcloud.compute.VCloudComputeClient;
|
import org.jclouds.vcloud.compute.VCloudComputeClient;
|
||||||
import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule;
|
import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule;
|
||||||
import org.jclouds.vcloud.hostingdotcom.compute.HostingDotComVCloudComputeClient;
|
import org.jclouds.vcloud.hostingdotcom.compute.HostingDotComVCloudComputeClient;
|
||||||
|
@ -44,7 +42,6 @@ public class HostingDotComVCloudComputeServiceContextModule extends
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
super.configure();
|
super.configure();
|
||||||
bind(VCloudComputeClient.class).to(HostingDotComVCloudComputeClient.class);
|
bind(VCloudComputeClient.class).to(HostingDotComVCloudComputeClient.class);
|
||||||
bind(PopulateDefaultLoginCredentialsForImageStrategy.class).to(ReturnNullCredentials.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue