mirror of https://github.com/apache/jclouds.git
[NOVA] change some access modifiers to simplify the downstream provider impl
modify the BasicAuthenticator in Keystone destroy node if creation timeouts
This commit is contained in:
parent
647df25d90
commit
aa64e0d3e2
|
@ -64,10 +64,10 @@ public abstract class BaseAuthenticator<C> implements Function<Credentials, Acce
|
|||
String usernameOrAccessKey = input.identity;
|
||||
|
||||
if (!tenantName.isPresent() && input.identity.indexOf(':') != -1) {
|
||||
tenantName = Optional.of(input.identity.substring(0, input.identity.indexOf(':')));
|
||||
usernameOrAccessKey = input.identity.substring(input.identity.indexOf(':') + 1);
|
||||
tenantName = Optional.of(input.identity.substring(0, input.identity.lastIndexOf(':')));
|
||||
usernameOrAccessKey = input.identity.substring(input.identity.lastIndexOf(':') + 1);
|
||||
}
|
||||
|
||||
|
||||
String passwordOrSecretKey = input.credential;
|
||||
|
||||
C creds = createCredentials(usernameOrAccessKey, passwordOrSecretKey);
|
||||
|
|
|
@ -21,7 +21,10 @@ import static com.google.common.base.Preconditions.checkState;
|
|||
import static com.google.common.collect.Iterables.contains;
|
||||
import static com.google.common.collect.Iterables.filter;
|
||||
import static com.google.common.collect.Iterables.transform;
|
||||
import static java.lang.String.format;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
import static org.jclouds.compute.util.ComputeServiceUtils.metadataAndTagsAsCommaDelimitedValue;
|
||||
import static org.jclouds.util.Predicates2.retry;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -127,16 +130,27 @@ public class NovaComputeServiceAdapter implements
|
|||
}
|
||||
}
|
||||
|
||||
String regionId = template.getLocation().getId();
|
||||
final String regionId = template.getLocation().getId();
|
||||
String imageId = template.getImage().getProviderId();
|
||||
String flavorId = template.getHardware().getProviderId();
|
||||
|
||||
logger.debug(">> creating new server region(%s) name(%s) image(%s) flavor(%s) options(%s)", regionId, name, imageId, flavorId, options);
|
||||
ServerCreated lightweightServer = novaApi.getServerApi(regionId).create(name, imageId, flavorId, options);
|
||||
final ServerCreated lightweightServer = novaApi.getServerApi(regionId).create(name, imageId, flavorId, options);
|
||||
if (!retry(new Predicate<String>() {
|
||||
@Override
|
||||
public boolean apply(String serverId) {
|
||||
Server server = novaApi.getServerApi(regionId).get(serverId);
|
||||
return server != null && server.getAddresses() != null && !server.getAddresses().isEmpty();
|
||||
}
|
||||
}, 30 * 60, 1, SECONDS).apply(lightweightServer.getId())) {
|
||||
final String message = format("Server %s was not created within %sms so it will be destroyed.", name, "30 * 60");
|
||||
logger.warn(message);
|
||||
destroyNode(lightweightServer.getId());
|
||||
throw new IllegalStateException(message);
|
||||
}
|
||||
logger.trace("<< server(%s)", lightweightServer.getId());
|
||||
|
||||
Server server = novaApi.getServerApi(regionId).get(lightweightServer.getId());
|
||||
|
||||
logger.trace("<< server(%s)", server.getId());
|
||||
|
||||
ServerInRegion serverInRegion = new ServerInRegion(server, regionId);
|
||||
if (!privateKey.isPresent() && lightweightServer.getAdminPass().isPresent())
|
||||
credentialsBuilder.password(lightweightServer.getAdminPass().get());
|
||||
|
|
|
@ -57,7 +57,7 @@ public class ImageToOperatingSystem implements Function<Image, OperatingSystem>
|
|||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
private final Map<OsFamily, Map<String, String>> osVersionMap;
|
||||
protected final Map<OsFamily, Map<String, String>> osVersionMap;
|
||||
|
||||
@Inject
|
||||
public ImageToOperatingSystem(Map<OsFamily, Map<String, String>> osVersionMap) {
|
||||
|
|
|
@ -144,7 +144,7 @@ public class ServerInRegionToNodeMetadata implements Function<ServerInRegion, No
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
private static final Predicate<Address> isPrivateAddress = new Predicate<Address>() {
|
||||
public static final Predicate<Address> isPrivateAddress = new Predicate<Address>() {
|
||||
public boolean apply(Address in) {
|
||||
return InetAddresses2.IsPrivateIPAddress.INSTANCE.apply(in.getAddr());
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ public class ServerInRegionToNodeMetadata implements Function<ServerInRegion, No
|
|||
|
||||
};
|
||||
|
||||
private enum AddressToStringTransformationFunction implements Function<Address, String> {
|
||||
public enum AddressToStringTransformationFunction implements Function<Address, String> {
|
||||
INSTANCE;
|
||||
@Override
|
||||
public String apply(Address address) {
|
||||
|
|
|
@ -64,9 +64,9 @@ public class ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddT
|
|||
CreateNodesWithGroupEncodedIntoNameThenAddToSet {
|
||||
|
||||
private final AllocateAndAddFloatingIpToNode createAndAddFloatingIpToNode;
|
||||
private final LoadingCache<RegionAndName, SecurityGroupInRegion> securityGroupCache;
|
||||
private final LoadingCache<RegionAndName, KeyPair> keyPairCache;
|
||||
private final NovaApi novaApi;
|
||||
protected final LoadingCache<RegionAndName, SecurityGroupInRegion> securityGroupCache;
|
||||
protected final LoadingCache<RegionAndName, KeyPair> keyPairCache;
|
||||
protected final NovaApi novaApi;
|
||||
|
||||
@Inject
|
||||
protected ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet(
|
||||
|
|
Loading…
Reference in New Issue