diff --git a/providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/compute/strategy/VPDCComputeServiceAdapter.java b/providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/compute/strategy/VPDCComputeServiceAdapter.java index acb680b955..37a133747f 100644 --- a/providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/compute/strategy/VPDCComputeServiceAdapter.java +++ b/providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/compute/strategy/VPDCComputeServiceAdapter.java @@ -1,3 +1,22 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * 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.compute.strategy; import static com.google.common.base.Preconditions.checkNotNull; @@ -8,7 +27,6 @@ import java.net.URI; import java.util.Map; import java.util.concurrent.TimeUnit; -import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; @@ -34,6 +52,7 @@ import com.google.common.base.Predicate; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.ImmutableSet.Builder; +import com.google.inject.Inject; ; @@ -46,16 +65,16 @@ import com.google.common.collect.ImmutableSet.Builder; public class VPDCComputeServiceAdapter implements ComputeServiceAdapter { private final VPDCClient client; private final RetryablePredicate taskTester; - private final String email; + @Inject(optional = true) + @Named(PROPERTY_VPDC_VDC_EMAIL) + String email; @Inject - public VPDCComputeServiceAdapter(VPDCClient client, TaskSuccess taskSuccess, - @Named(PROPERTY_VPDC_VDC_EMAIL) String email) { + public VPDCComputeServiceAdapter(VPDCClient client, TaskSuccess taskSuccess) { this.client = checkNotNull(client, "client"); // TODO: parameterize this.taskTester = new RetryablePredicate(checkNotNull(taskSuccess, "taskSuccess"), 650, 10, TimeUnit.SECONDS); - this.email = email; } @Override @@ -136,7 +155,8 @@ public class VPDCComputeServiceAdapter implements ComputeServiceAdapter addVMIntoVDC(@EndpointParam URI vpdc, @PayloadParam("networkName") String networkTierName, + @PayloadParam("name") String vAppName, VMSpec spec); + /** * @see VMClient#removeVMFromVDC */ diff --git a/providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/features/VMClient.java b/providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/features/VMClient.java index 133998c96a..6f869b688d 100644 --- a/providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/features/VMClient.java +++ b/providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/features/VMClient.java @@ -52,6 +52,14 @@ public interface VMClient { */ Task addVMIntoVDC(String billingSiteId, String vpdcId, String networkTierName, String name, VMSpec spec); + /** + * + * @param vpdc + * href of the vpdc + * @see #addVMIntoVDC + */ + Task addVMIntoVDC(URI vpdc, String networkTierName, String name, VMSpec spec); + /** * Remove a VM *

diff --git a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMAsyncClientTest.java b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMAsyncClientTest.java index 1067daefab..99be9abc48 100644 --- a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMAsyncClientTest.java +++ b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMAsyncClientTest.java @@ -49,6 +49,37 @@ import com.google.inject.TypeLiteral; @Test(groups = "unit") public class VMAsyncClientTest extends BaseVPDCAsyncClientTest { + public void testAddVMIntoVDCURI() throws SecurityException, NoSuchMethodException, IOException { + Method method = VMAsyncClient.class + .getMethod("addVMIntoVDC", URI.class, String.class, String.class, VMSpec.class); + + CIMOperatingSystem os = Iterables.find(injector.getInstance(Key.get(new TypeLiteral>() { + })), new Predicate() { + + @Override + public boolean apply(CIMOperatingSystem arg0) { + return arg0.getOsType() == OSType.RHEL_64; + } + + }); + + HttpRequest request = processor.createRequest(method, URI + .create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/11/vdc/22"), "VM Tier01", "DemoHost-1", + VMSpec.builder().operatingSystem(os).build()); + + assertRequestLineEquals(request, + "GET https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/11/vdc/22/vApp/ HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/vm-default.xml")), + "application/xml", false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TaskHandler.class); + assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class); + + checkFilters(request); + } + public void testAddVMIntoVDC() throws SecurityException, NoSuchMethodException, IOException { Method method = VMAsyncClient.class.getMethod("addVMIntoVDC", String.class, String.class, String.class, String.class, VMSpec.class);