mirror of https://github.com/apache/jclouds.git
stubbed in firewall client
This commit is contained in:
parent
bc7bc99d97
commit
a453a060a8
|
@ -25,6 +25,7 @@ import org.jclouds.compute.domain.CIMOperatingSystem;
|
|||
import org.jclouds.rest.annotations.Delegate;
|
||||
import org.jclouds.savvis.vpdc.domain.Resource;
|
||||
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.internal.Org;
|
||||
|
||||
|
@ -52,6 +53,12 @@ public interface VPDCAsyncClient {
|
|||
@Delegate
|
||||
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.
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.jclouds.concurrent.Timeout;
|
|||
import org.jclouds.rest.annotations.Delegate;
|
||||
import org.jclouds.savvis.vpdc.domain.Resource;
|
||||
import org.jclouds.savvis.vpdc.features.BrowsingClient;
|
||||
import org.jclouds.savvis.vpdc.features.FirewallClient;
|
||||
import org.jclouds.savvis.vpdc.features.VMClient;
|
||||
|
||||
/**
|
||||
|
@ -52,6 +53,12 @@ public interface VPDCClient {
|
|||
@Delegate
|
||||
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.
|
||||
|
@ -59,8 +66,8 @@ public interface VPDCClient {
|
|||
Set<Resource> listOrgs();
|
||||
|
||||
/**
|
||||
* predefined by default in the classpath resource
|
||||
* {@code /savvis-symphonyvpdc/predefined_operatingsystems.json}
|
||||
* predefined by default in the classpath resource {@code
|
||||
* /savvis-symphonyvpdc/predefined_operatingsystems.json}
|
||||
*
|
||||
* @return the operating systems that are predefined in the provider
|
||||
* @see <a href="https://api.sandbox.symphonyvpdc.savvis.net/doc/spec/api/addSingleVM.html" />
|
||||
|
|
|
@ -53,6 +53,8 @@ import org.jclouds.savvis.vpdc.domain.Resource;
|
|||
import org.jclouds.savvis.vpdc.domain.internal.VCloudSession;
|
||||
import org.jclouds.savvis.vpdc.features.BrowsingAsyncClient;
|
||||
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.VMClient;
|
||||
import org.jclouds.savvis.vpdc.handlers.VPDCErrorHandler;
|
||||
|
@ -91,7 +93,7 @@ public class VPDCRestClientModule extends RestClientModule<VPDCClient, VPDCAsync
|
|||
@org.jclouds.savvis.vpdc.internal.Org
|
||||
@Singleton
|
||||
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();
|
||||
checkState(discovery.getOrgs().size() > 0, "No orgs present for user: " + user);
|
||||
return discovery.getOrgs();
|
||||
|
@ -109,14 +111,15 @@ public class VPDCRestClientModule extends RestClientModule<VPDCClient, VPDCAsync
|
|||
@Provides
|
||||
@Singleton
|
||||
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);
|
||||
}
|
||||
|
||||
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
|
||||
.put(BrowsingClient.class, BrowsingAsyncClient.class)//
|
||||
.put(VMClient.class, VMAsyncClient.class)//
|
||||
.build();
|
||||
.put(BrowsingClient.class, BrowsingAsyncClient.class)//
|
||||
.put(VMClient.class, VMAsyncClient.class)//
|
||||
.put(FirewallClient.class, FirewallAsyncClient.class)//
|
||||
.build();
|
||||
|
||||
public VPDCRestClientModule() {
|
||||
super(VPDCClient.class, VPDCAsyncClient.class, DELEGATE_MAP);
|
||||
|
@ -125,33 +128,31 @@ public class VPDCRestClientModule extends RestClientModule<VPDCClient, VPDCAsync
|
|||
@Singleton
|
||||
@Provides
|
||||
protected Set<CIMOperatingSystem> provideOperatingSystems(Json json, @Provider String providerName)
|
||||
throws IOException {
|
||||
return json.fromJson(
|
||||
Strings2.toStringAndClose(getClass().getResourceAsStream(
|
||||
"/" + providerName + "/predefined_operatingsystems.json")),
|
||||
new TypeLiteral<Set<CIMOperatingSystem>>() {
|
||||
}.getType());
|
||||
throws IOException {
|
||||
return json.fromJson(Strings2.toStringAndClose(getClass().getResourceAsStream(
|
||||
"/" + providerName + "/predefined_operatingsystems.json")), new TypeLiteral<Set<CIMOperatingSystem>>() {
|
||||
}.getType());
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
||||
final LoginAsyncClient login) {
|
||||
final LoginAsyncClient login) {
|
||||
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<VCloudSession>(authException, seconds,
|
||||
new Supplier<VCloudSession>() {
|
||||
new Supplier<VCloudSession>() {
|
||||
|
||||
@Override
|
||||
public VCloudSession get() {
|
||||
try {
|
||||
return login.login().get(10, TimeUnit.SECONDS);
|
||||
} catch (Exception e) {
|
||||
propagate(e);
|
||||
assert false : e;
|
||||
return null;
|
||||
@Override
|
||||
public VCloudSession get() {
|
||||
try {
|
||||
return login.login().get(10, TimeUnit.SECONDS);
|
||||
} catch (Exception e) {
|
||||
propagate(e);
|
||||
assert false : e;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
||||
}
|
|
@ -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 {
|
||||
|
||||
}
|
|
@ -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>>() {
|
||||
};
|
||||
}
|
||||
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -113,7 +113,7 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest {
|
|||
// 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
|
||||
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
|
||||
assert task.getId() != null && task.getError() != null : task;
|
||||
|
|
Loading…
Reference in New Issue