mirror of https://github.com/apache/jclouds.git
Issue 112: updated vcloud version
git-svn-id: http://jclouds.googlecode.com/svn/trunk@2383 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
fc5f675be5
commit
de66d187ae
|
@ -41,16 +41,13 @@ import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
|||
* @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx" />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Timeout(duration = 45, timeUnit = TimeUnit.SECONDS)
|
||||
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
|
||||
public interface VCloudClient {
|
||||
|
||||
@Timeout(duration = 90, timeUnit = TimeUnit.SECONDS)
|
||||
Catalog getCatalog();
|
||||
|
||||
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
|
||||
VDC getDefaultVDC();
|
||||
|
||||
@Timeout(duration = 90, timeUnit = TimeUnit.SECONDS)
|
||||
TasksList getDefaultTasksList();
|
||||
|
||||
Task deployVApp(String vAppId);
|
||||
|
|
|
@ -28,13 +28,12 @@ import java.util.concurrent.Future;
|
|||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.http.filters.BasicAuthentication;
|
||||
import org.jclouds.rest.annotations.Endpoint;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.rest.annotations.ResponseParser;
|
||||
import org.jclouds.rest.domain.NamedLink;
|
||||
import org.jclouds.rest.domain.NamedResource;
|
||||
import org.jclouds.vcloud.endpoints.Org;
|
||||
import org.jclouds.vcloud.functions.ParseLoginResponseFromHeaders;
|
||||
|
||||
|
@ -54,7 +53,7 @@ public interface VCloudLogin {
|
|||
String getVCloudToken();
|
||||
|
||||
@Org
|
||||
Map<String, NamedLink> getOrgs();
|
||||
Map<String, NamedResource> getOrgs();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,6 +62,6 @@ public interface VCloudLogin {
|
|||
*/
|
||||
@POST
|
||||
@ResponseParser(ParseLoginResponseFromHeaders.class)
|
||||
@Consumes(MediaType.APPLICATION_XML)
|
||||
@Consumes(VCloudMediaType.ORGLIST_XML)
|
||||
Future<VCloudSession> login();
|
||||
}
|
||||
|
|
|
@ -31,7 +31,26 @@ import javax.ws.rs.core.MediaType;
|
|||
* @see MediaType
|
||||
*/
|
||||
public class VCloudMediaType {
|
||||
/**
|
||||
* "application/vnd.vmware.vcloud.organizationList+xml"
|
||||
*/
|
||||
public final static String VCLOUD_XML = "application/vnd.vmware.vcloud.vcloud+xml";
|
||||
|
||||
/**
|
||||
* "application/vnd.vmware.vcloud.organizationList+xml"
|
||||
*/
|
||||
public final static MediaType VCLOUD_XML_TYPE = new MediaType("application",
|
||||
"vnd.vmware.vcloud.vcloud+xml");
|
||||
/**
|
||||
* "application/vnd.vmware.vcloud.organizationList+xml"
|
||||
*/
|
||||
public final static String ORGLIST_XML = "application/vnd.vmware.vcloud.organizationList+xml";
|
||||
|
||||
/**
|
||||
* "application/vnd.vmware.vcloud.organizationList+xml"
|
||||
*/
|
||||
public final static MediaType ORGLIST_XML_TYPE = new MediaType("application",
|
||||
"vnd.vmware.vcloud.organizationList+xml");
|
||||
/**
|
||||
* "application/vnd.vmware.vcloud.org+xml"
|
||||
*/
|
||||
|
|
|
@ -30,7 +30,6 @@ import java.util.concurrent.Future;
|
|||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.rest.annotations.Endpoint;
|
||||
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||
|
@ -53,6 +52,6 @@ public interface VCloudVersions {
|
|||
@GET
|
||||
@XMLResponseParser(SupportedVersionsHandler.class)
|
||||
@Path("/versions")
|
||||
@Consumes(MediaType.APPLICATION_XML)
|
||||
@Consumes(VCloudMediaType.VCLOUD_XML)
|
||||
Future<SortedMap<String, URI>> getSupportedVersions();
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ public class VCloudDiscoveryRestClientModule extends AbstractModule {
|
|||
return new ExpirableSupplier<VCloudSession>(new Supplier<VCloudSession>() {
|
||||
public VCloudSession get() {
|
||||
try {
|
||||
return login.login().get(45, TimeUnit.SECONDS);
|
||||
return login.login().get(180, TimeUnit.SECONDS);
|
||||
} catch (Exception e) {
|
||||
Utils.<RuntimeException> rethrowIfRuntimeOrSameType(e);
|
||||
throw new RuntimeException("Error logging in", e);
|
||||
|
@ -123,7 +123,7 @@ public class VCloudDiscoveryRestClientModule extends AbstractModule {
|
|||
protected URI provideAuthenticationURI(VCloudVersions versionService,
|
||||
@Named(PROPERTY_VCLOUD_VERSION) String version) throws InterruptedException,
|
||||
ExecutionException, TimeoutException {
|
||||
return versionService.getSupportedVersions().get(30, TimeUnit.SECONDS).get(version);
|
||||
return versionService.getSupportedVersions().get(180, TimeUnit.SECONDS).get(version);
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
|
|
@ -109,7 +109,7 @@ public class VCloudRestClientModule extends AbstractModule {
|
|||
@Singleton
|
||||
protected Organization provideOrganization(VCloudDiscovery discovery)
|
||||
throws ExecutionException, TimeoutException, InterruptedException {
|
||||
return discovery.getOrganization().get(90, TimeUnit.SECONDS);
|
||||
return discovery.getOrganization().get(180, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
@ -140,7 +140,7 @@ public class VCloudRestClientModule extends AbstractModule {
|
|||
@Singleton
|
||||
protected URI provideDefaultNetwork(VCloudAsyncClient client)
|
||||
throws InterruptedException, ExecutionException, TimeoutException {
|
||||
return client.getDefaultVDC().get(60, TimeUnit.SECONDS)
|
||||
return client.getDefaultVDC().get(180, TimeUnit.SECONDS)
|
||||
.getAvailableNetworks().values().iterator().next()
|
||||
.getLocation();
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ import org.jclouds.http.HttpResponse;
|
|||
import org.jclouds.http.HttpResponseException;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.http.functions.ParseSax.Factory;
|
||||
import org.jclouds.rest.domain.NamedLink;
|
||||
import org.jclouds.rest.domain.NamedResource;
|
||||
import org.jclouds.vcloud.VCloudToken;
|
||||
import org.jclouds.vcloud.VCloudLogin.VCloudSession;
|
||||
import org.jclouds.vcloud.endpoints.Org;
|
||||
|
@ -53,7 +53,7 @@ import com.google.common.base.Function;
|
|||
*/
|
||||
@Singleton
|
||||
public class ParseLoginResponseFromHeaders implements Function<HttpResponse, VCloudSession> {
|
||||
static final Pattern pattern = Pattern.compile("vcloud-token=(.*); path=.*");
|
||||
static final Pattern pattern = Pattern.compile("vcloud-token=(.*); [Pp]ath=.*");
|
||||
|
||||
private final ParseSax.Factory factory;
|
||||
private final Provider<OrgListHandler> orgHandlerProvider;
|
||||
|
@ -76,7 +76,7 @@ public class ParseLoginResponseFromHeaders implements Function<HttpResponse, VCl
|
|||
boolean matchFound = matcher.find();
|
||||
|
||||
if (matchFound) {
|
||||
final Map<String, NamedLink> org = factory.create(orgHandlerProvider.get()).parse(
|
||||
final Map<String, NamedResource> org = factory.create(orgHandlerProvider.get()).parse(
|
||||
from.getContent());
|
||||
|
||||
return new VCloudSession() {
|
||||
|
@ -86,7 +86,7 @@ public class ParseLoginResponseFromHeaders implements Function<HttpResponse, VCl
|
|||
}
|
||||
|
||||
@Org
|
||||
public Map<String, NamedLink> getOrgs() {
|
||||
public Map<String, NamedResource> getOrgs() {
|
||||
return org;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -23,13 +23,13 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.xml;
|
||||
|
||||
import static org.jclouds.rest.util.Utils.putNamedLink;
|
||||
import static org.jclouds.rest.util.Utils.putNamedResource;
|
||||
import static org.jclouds.vcloud.VCloudMediaType.ORG_XML;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.rest.domain.NamedLink;
|
||||
import org.jclouds.rest.domain.NamedResource;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
|
@ -38,22 +38,23 @@ import com.google.common.collect.Maps;
|
|||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class OrgListHandler extends ParseSax.HandlerWithResult<Map<String, NamedLink>> {
|
||||
public class OrgListHandler extends
|
||||
ParseSax.HandlerWithResult<Map<String, NamedResource>> {
|
||||
|
||||
private Map<String, NamedLink> org = Maps.newHashMap();
|
||||
private Map<String, NamedResource> org = Maps.newHashMap();
|
||||
|
||||
public Map<String, NamedLink> getResult() {
|
||||
public Map<String, NamedResource> getResult() {
|
||||
return org;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startElement(String uri, String localName, String qName, Attributes attributes)
|
||||
throws SAXException {
|
||||
public void startElement(String uri, String localName, String qName,
|
||||
Attributes attributes) throws SAXException {
|
||||
if (qName.equals("Org")) {
|
||||
int typeIndex = attributes.getIndex("type");
|
||||
if (typeIndex != -1) {
|
||||
if (attributes.getValue(typeIndex).equals(ORG_XML)) {
|
||||
putNamedLink(org, attributes);
|
||||
putNamedResource(org, attributes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ import java.lang.reflect.Method;
|
|||
import java.net.URI;
|
||||
|
||||
import javax.ws.rs.core.HttpHeaders;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.http.filters.BasicAuthentication;
|
||||
import org.jclouds.logging.Logger;
|
||||
|
@ -59,7 +58,7 @@ public class VCloudLoginTest extends RestClientTest<VCloudLogin> {
|
|||
GeneratedHttpRequest<VCloudLogin> httpMethod = processor.createRequest(method);
|
||||
|
||||
assertEquals(httpMethod.getRequestLine(), "POST http://localhost:8080/login HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod, HttpHeaders.ACCEPT + ": " + MediaType.APPLICATION_XML + "\n");
|
||||
assertHeadersEqual(httpMethod, HttpHeaders.ACCEPT + ": application/vnd.vmware.vcloud.organizationList+xml\n");
|
||||
assertEntityEquals(httpMethod, null);
|
||||
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseLoginResponseFromHeaders.class);
|
||||
|
|
|
@ -30,7 +30,6 @@ import java.lang.reflect.Method;
|
|||
import java.net.URI;
|
||||
|
||||
import javax.ws.rs.core.HttpHeaders;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.logging.Logger;
|
||||
|
@ -59,7 +58,7 @@ public class VCloudVersionsTest extends RestClientTest<VCloudVersions> {
|
|||
GeneratedHttpRequest<VCloudVersions> httpMethod = processor.createRequest(method);
|
||||
|
||||
assertEquals(httpMethod.getRequestLine(), "GET http://localhost:8080/versions HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod, HttpHeaders.ACCEPT + ": " + MediaType.APPLICATION_XML + "\n");
|
||||
assertHeadersEqual(httpMethod, HttpHeaders.ACCEPT + ": application/vnd.vmware.vcloud.vcloud+xml\n");
|
||||
assertEntityEquals(httpMethod, null);
|
||||
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
|
|
|
@ -44,7 +44,7 @@ import org.jclouds.http.handlers.DelegatingErrorHandler;
|
|||
import org.jclouds.http.handlers.DelegatingRetryHandler;
|
||||
import org.jclouds.http.handlers.RedirectionRetryHandler;
|
||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||
import org.jclouds.rest.domain.NamedLink;
|
||||
import org.jclouds.rest.domain.NamedResource;
|
||||
import org.jclouds.util.Jsr330;
|
||||
import org.jclouds.vcloud.VCloudLogin;
|
||||
import org.jclouds.vcloud.VCloudLogin.VCloudSession;
|
||||
|
@ -109,7 +109,7 @@ public class VCloudDiscoveryRestClientModuleTest {
|
|||
public VCloudSession get() throws InterruptedException, ExecutionException {
|
||||
return new VCloudSession() {
|
||||
|
||||
public Map<String, NamedLink> getOrgs() {
|
||||
public Map<String, NamedResource> getOrgs() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ import javax.ws.rs.core.HttpHeaders;
|
|||
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.jclouds.rest.domain.internal.NamedLinkImpl;
|
||||
import org.jclouds.rest.internal.NamedResourceImpl;
|
||||
import org.jclouds.vcloud.VCloudMediaType;
|
||||
import org.jclouds.vcloud.VCloudLogin.VCloudSession;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
|
@ -64,7 +64,7 @@ public class ParseLoginResponseFromHeadersTest extends BaseHandlerTest {
|
|||
"Content-Type: application/xml; charset=utf-8");
|
||||
VCloudSession reply = parser.apply(response);
|
||||
assertEquals(reply.getVCloudToken(), "9er4d061-4bff-48fa-84b1-5da7166764d2");
|
||||
assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new NamedLinkImpl(
|
||||
assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new NamedResourceImpl("48",
|
||||
"adrian@jclouds.org", VCloudMediaType.ORG_XML, URI
|
||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
|
||||
|
||||
|
|
|
@ -30,8 +30,8 @@ import java.net.URI;
|
|||
import java.util.Map;
|
||||
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.jclouds.rest.domain.NamedLink;
|
||||
import org.jclouds.rest.domain.internal.NamedLinkImpl;
|
||||
import org.jclouds.rest.domain.NamedResource;
|
||||
import org.jclouds.rest.internal.NamedResourceImpl;
|
||||
import org.jclouds.vcloud.VCloudMediaType;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -55,9 +55,9 @@ public class OrgListHandlerTest extends BaseHandlerTest {
|
|||
public void testApplyInputStream() {
|
||||
InputStream is = getClass().getResourceAsStream("/orglist.xml");
|
||||
|
||||
Map<String, NamedLink> result = factory.create(injector.getInstance(OrgListHandler.class))
|
||||
Map<String, NamedResource> result = factory.create(injector.getInstance(OrgListHandler.class))
|
||||
.parse(is);
|
||||
assertEquals(result, ImmutableMap.of("adrian@jclouds.org", new NamedLinkImpl(
|
||||
assertEquals(result, ImmutableMap.of("adrian@jclouds.org", new NamedResourceImpl("48",
|
||||
"adrian@jclouds.org", VCloudMediaType.ORG_XML, URI
|
||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue