stubbed in firewall client

This commit is contained in:
Adrian Cole 2011-03-25 15:49:15 -07:00
parent bc7bc99d97
commit a453a060a8
8 changed files with 202 additions and 26 deletions

View File

@ -25,6 +25,7 @@ import org.jclouds.compute.domain.CIMOperatingSystem;
import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Delegate;
import org.jclouds.savvis.vpdc.domain.Resource; import org.jclouds.savvis.vpdc.domain.Resource;
import org.jclouds.savvis.vpdc.features.BrowsingAsyncClient; import org.jclouds.savvis.vpdc.features.BrowsingAsyncClient;
import org.jclouds.savvis.vpdc.features.FirewallAsyncClient;
import org.jclouds.savvis.vpdc.features.VMAsyncClient; import org.jclouds.savvis.vpdc.features.VMAsyncClient;
import org.jclouds.savvis.vpdc.internal.Org; import org.jclouds.savvis.vpdc.internal.Org;
@ -52,6 +53,12 @@ public interface VPDCAsyncClient {
@Delegate @Delegate
VMAsyncClient getVMClient(); VMAsyncClient getVMClient();
/**
* Provides asynchronous access to Firewall Operation features.
*/
@Delegate
FirewallAsyncClient getFirewallClient();
/** /**
* *
* @return a listing of all orgs that the current user has access to. * @return a listing of all orgs that the current user has access to.

View File

@ -27,6 +27,7 @@ import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Delegate;
import org.jclouds.savvis.vpdc.domain.Resource; import org.jclouds.savvis.vpdc.domain.Resource;
import org.jclouds.savvis.vpdc.features.BrowsingClient; import org.jclouds.savvis.vpdc.features.BrowsingClient;
import org.jclouds.savvis.vpdc.features.FirewallClient;
import org.jclouds.savvis.vpdc.features.VMClient; import org.jclouds.savvis.vpdc.features.VMClient;
/** /**
@ -52,6 +53,12 @@ public interface VPDCClient {
@Delegate @Delegate
VMClient getVMClient(); VMClient getVMClient();
/**
* Provides synchronous access to Firewall Operation features.
*/
@Delegate
FirewallClient getFirewallClient();
/** /**
* *
* @return a listing of all orgs that the current user has access to. * @return a listing of all orgs that the current user has access to.
@ -59,8 +66,8 @@ public interface VPDCClient {
Set<Resource> listOrgs(); Set<Resource> listOrgs();
/** /**
* predefined by default in the classpath resource * predefined by default in the classpath resource {@code
* {@code /savvis-symphonyvpdc/predefined_operatingsystems.json} * /savvis-symphonyvpdc/predefined_operatingsystems.json}
* *
* @return the operating systems that are predefined in the provider * @return the operating systems that are predefined in the provider
* @see <a href="https://api.sandbox.symphonyvpdc.savvis.net/doc/spec/api/addSingleVM.html" /> * @see <a href="https://api.sandbox.symphonyvpdc.savvis.net/doc/spec/api/addSingleVM.html" />

View File

@ -53,6 +53,8 @@ import org.jclouds.savvis.vpdc.domain.Resource;
import org.jclouds.savvis.vpdc.domain.internal.VCloudSession; import org.jclouds.savvis.vpdc.domain.internal.VCloudSession;
import org.jclouds.savvis.vpdc.features.BrowsingAsyncClient; import org.jclouds.savvis.vpdc.features.BrowsingAsyncClient;
import org.jclouds.savvis.vpdc.features.BrowsingClient; import org.jclouds.savvis.vpdc.features.BrowsingClient;
import org.jclouds.savvis.vpdc.features.FirewallAsyncClient;
import org.jclouds.savvis.vpdc.features.FirewallClient;
import org.jclouds.savvis.vpdc.features.VMAsyncClient; import org.jclouds.savvis.vpdc.features.VMAsyncClient;
import org.jclouds.savvis.vpdc.features.VMClient; import org.jclouds.savvis.vpdc.features.VMClient;
import org.jclouds.savvis.vpdc.handlers.VPDCErrorHandler; import org.jclouds.savvis.vpdc.handlers.VPDCErrorHandler;
@ -91,7 +93,7 @@ public class VPDCRestClientModule extends RestClientModule<VPDCClient, VPDCAsync
@org.jclouds.savvis.vpdc.internal.Org @org.jclouds.savvis.vpdc.internal.Org
@Singleton @Singleton
protected Set<org.jclouds.savvis.vpdc.domain.Resource> provideOrgs(Supplier<VCloudSession> cache, protected Set<org.jclouds.savvis.vpdc.domain.Resource> provideOrgs(Supplier<VCloudSession> cache,
@Named(PROPERTY_IDENTITY) String user) { @Named(PROPERTY_IDENTITY) String user) {
VCloudSession discovery = cache.get(); VCloudSession discovery = cache.get();
checkState(discovery.getOrgs().size() > 0, "No orgs present for user: " + user); checkState(discovery.getOrgs().size() > 0, "No orgs present for user: " + user);
return discovery.getOrgs(); return discovery.getOrgs();
@ -109,14 +111,15 @@ public class VPDCRestClientModule extends RestClientModule<VPDCClient, VPDCAsync
@Provides @Provides
@Singleton @Singleton
protected Predicate<String> successTester(Injector injector, protected Predicate<String> successTester(Injector injector,
@Named(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED) long completed) { @Named(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED) long completed) {
return new RetryablePredicate<String>(injector.getInstance(TaskSuccess.class), completed); return new RetryablePredicate<String>(injector.getInstance(TaskSuccess.class), completed);
} }
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()// public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
.put(BrowsingClient.class, BrowsingAsyncClient.class)// .put(BrowsingClient.class, BrowsingAsyncClient.class)//
.put(VMClient.class, VMAsyncClient.class)// .put(VMClient.class, VMAsyncClient.class)//
.build(); .put(FirewallClient.class, FirewallAsyncClient.class)//
.build();
public VPDCRestClientModule() { public VPDCRestClientModule() {
super(VPDCClient.class, VPDCAsyncClient.class, DELEGATE_MAP); super(VPDCClient.class, VPDCAsyncClient.class, DELEGATE_MAP);
@ -125,33 +128,31 @@ public class VPDCRestClientModule extends RestClientModule<VPDCClient, VPDCAsync
@Singleton @Singleton
@Provides @Provides
protected Set<CIMOperatingSystem> provideOperatingSystems(Json json, @Provider String providerName) protected Set<CIMOperatingSystem> provideOperatingSystems(Json json, @Provider String providerName)
throws IOException { throws IOException {
return json.fromJson( return json.fromJson(Strings2.toStringAndClose(getClass().getResourceAsStream(
Strings2.toStringAndClose(getClass().getResourceAsStream( "/" + providerName + "/predefined_operatingsystems.json")), new TypeLiteral<Set<CIMOperatingSystem>>() {
"/" + providerName + "/predefined_operatingsystems.json")), }.getType());
new TypeLiteral<Set<CIMOperatingSystem>>() {
}.getType());
} }
@Provides @Provides
@Singleton @Singleton
protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds, protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
final LoginAsyncClient login) { final LoginAsyncClient login) {
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<VCloudSession>(authException, seconds, return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<VCloudSession>(authException, seconds,
new Supplier<VCloudSession>() { new Supplier<VCloudSession>() {
@Override @Override
public VCloudSession get() { public VCloudSession get() {
try { try {
return login.login().get(10, TimeUnit.SECONDS); return login.login().get(10, TimeUnit.SECONDS);
} catch (Exception e) { } catch (Exception e) {
propagate(e); propagate(e);
assert false : e; assert false : e;
return null; return null;
}
} }
}
}); });
} }
@Override @Override

View File

@ -0,0 +1,39 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.savvis.vpdc.features;
import javax.ws.rs.Path;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.savvis.vpdc.filters.SetVCloudTokenCookie;
/**
* Provides access to Symphony VPDC resources via their REST API.
* <p/>
*
* @see <a href="https://api.sandbox.symphonyvpdc.savvis.net/doc/spec/api/index.html" />
* @author Adrian Cole
*/
@RequestFilters(SetVCloudTokenCookie.class)
@Path("v{jclouds.api-version}")
public interface FirewallAsyncClient {
}

View File

@ -0,0 +1,36 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.savvis.vpdc.features;
import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout;
/**
* Provides access to Symphony VPDC resources via their REST API.
* <p/>
*
* @see <a href="https://api.sandbox.symphonyvpdc.savvis.net/doc/spec/api/" />
* @author Adrian Cole
*/
@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS)
public interface FirewallClient {
}

View File

@ -0,0 +1,42 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.savvis.vpdc.features;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.Test;
import com.google.inject.TypeLiteral;
/**
* Tests annotation parsing of {@code FirewallAsyncClient}
*
* @author Adrian Cole
*/
@Test(groups = "unit")
public class FirewallAsyncClientTest extends BaseVPDCAsyncClientTest<FirewallAsyncClient> {
@Override
protected TypeLiteral<RestAnnotationProcessor<FirewallAsyncClient>> createTypeLiteral() {
return new TypeLiteral<RestAnnotationProcessor<FirewallAsyncClient>>() {
};
}
}

View File

@ -0,0 +1,44 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.savvis.vpdc.features;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test;
@Test(groups = "live")
public class FirewallClientLiveTest extends BaseVPDCClientLiveTest {
private FirewallClient client;
@Override
@BeforeGroups(groups = { "live" })
public void setupClient() {
super.setupClient();
client = context.getApi().getFirewallClient();
}
@AfterGroups(groups = "live")
protected void tearDown() {
//TODO cleanup resources
super.tearDown();
}
}

View File

@ -113,7 +113,7 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest {
// TODO: determine the sizes available in the VDC, for example there's // TODO: determine the sizes available in the VDC, for example there's
// a minimum size of boot disk, and also a preset combination of cpu count vs ram // a minimum size of boot disk, and also a preset combination of cpu count vs ram
Task task = client.addVMIntoVDC(billingSiteId, vpdcId, networkTierName, name, VMSpec.builder() Task task = client.addVMIntoVDC(billingSiteId, vpdcId, networkTierName, name, VMSpec.builder()
.operatingSystem(os).memoryInGig(2).build()); .operatingSystem(os).memoryInGig(2).addDataDrive("/data01", 25).build());
// make sure there's no error // make sure there's no error
assert task.getId() != null && task.getError() != null : task; assert task.getId() != null && task.getError() != null : task;