mirror of https://github.com/apache/jclouds.git
Issue 622:Unable to clone machine of Terremark VCloud Express
This commit is contained in:
parent
46c7822b4a
commit
92bcb2b822
|
@ -42,7 +42,7 @@ public class BindCloneVAppParamsToXmlPayload extends BindCloneParamsToXmlPayload
|
|||
@Inject
|
||||
public BindCloneVAppParamsToXmlPayload(BindToStringPayload stringBinder,
|
||||
@Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) {
|
||||
super(stringBinder, schema, schema);
|
||||
super(stringBinder, ns, schema);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1 +1 @@
|
|||
<CloneVAppParams xmlns="http://vcloud.safesecureweb.com/ns/vcloud.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" deploy="false" name="my-vapp" powerOn="false" xsi:schemaLocation="http://vcloud.safesecureweb.com/ns/vcloud.xsd http://vcloud.safesecureweb.com/ns/vcloud.xsd"><Source href="https://vcenterprise.bluelock.com/api/v1.0/vapp/4181" type="application/vnd.vmware.vcloud.vApp+xml"/></CloneVAppParams>
|
||||
<CloneVAppParams xmlns="http://www.vmware.com/vcloud/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" deploy="false" name="my-vapp" powerOn="false" xsi:schemaLocation="http://www.vmware.com/vcloud/v1 http://vcloud.safesecureweb.com/ns/vcloud.xsd"><Source href="https://vcenterprise.bluelock.com/api/v1.0/vapp/4181" type="application/vnd.vmware.vcloud.vApp+xml"/></CloneVAppParams>
|
|
@ -1 +1 @@
|
|||
<CloneVAppParams xmlns="http://vcloud.safesecureweb.com/ns/vcloud.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" deploy="true" name="new-linux-server" powerOn="true" xsi:schemaLocation="http://vcloud.safesecureweb.com/ns/vcloud.xsd http://vcloud.safesecureweb.com/ns/vcloud.xsd"><Description>The description of the new vApp</Description><Source href="https://vcenterprise.bluelock.com/api/v1.0/vapp/201" type="application/vnd.vmware.vcloud.vApp+xml"/></CloneVAppParams>
|
||||
<CloneVAppParams xmlns="http://www.vmware.com/vcloud/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" deploy="true" name="new-linux-server" powerOn="true" xsi:schemaLocation="http://www.vmware.com/vcloud/v1 http://vcloud.safesecureweb.com/ns/vcloud.xsd"><Description>The description of the new vApp</Description><Source href="https://vcenterprise.bluelock.com/api/v1.0/vapp/201" type="application/vnd.vmware.vcloud.vApp+xml"/></CloneVAppParams>
|
|
@ -1 +1 @@
|
|||
<CloneVAppParams xmlns="http://vcloud.safesecureweb.com/ns/vcloud.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" deploy="true" name="new-linux-server" powerOn="true" xsi:schemaLocation="http://vcloud.safesecureweb.com/ns/vcloud.xsd http://vcloud.safesecureweb.com/ns/vcloud.xsd"><Description>The description of the new vApp</Description><Source href="https://vcenterprise.bluelock.com/api/v1.0/vapp/201" type="application/vnd.vmware.vcloud.vApp+xml"/><IsSourceDelete>true</IsSourceDelete></CloneVAppParams>
|
||||
<CloneVAppParams xmlns="http://www.vmware.com/vcloud/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" deploy="true" name="new-linux-server" powerOn="true" xsi:schemaLocation="http://www.vmware.com/vcloud/v1 http://vcloud.safesecureweb.com/ns/vcloud.xsd"><Description>The description of the new vApp</Description><Source href="https://vcenterprise.bluelock.com/api/v1.0/vapp/201" type="application/vnd.vmware.vcloud.vApp+xml"/><IsSourceDelete>true</IsSourceDelete></CloneVAppParams>
|
|
@ -44,7 +44,7 @@ import org.jclouds.rest.annotations.RequestFilters;
|
|||
import org.jclouds.rest.annotations.ResponseParser;
|
||||
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||
import org.jclouds.vcloud.binders.BindCloneVAppParamsToXmlPayload;
|
||||
import org.jclouds.vcloud.binders.BindCloneVCloudExpressVAppParamsToXmlPayload;
|
||||
import org.jclouds.vcloud.binders.BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload;
|
||||
import org.jclouds.vcloud.domain.Catalog;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
|
@ -163,7 +163,7 @@ public interface VCloudExpressAsyncClient extends CommonVCloudAsyncClient {
|
|||
@Produces("application/vnd.vmware.vcloud.cloneVAppParams+xml")
|
||||
@Consumes(TASK_XML)
|
||||
@XMLResponseParser(TaskHandler.class)
|
||||
@MapBinder(BindCloneVAppParamsToXmlPayload.class)
|
||||
@MapBinder(BindCloneVCloudExpressVAppParamsToXmlPayload.class)
|
||||
ListenableFuture<? extends Task> cloneVAppInVDC(@EndpointParam URI vdc, @PayloadParam("vApp") URI toClone,
|
||||
@PayloadParam("newName") @ParamValidators(DnsNameValidator.class) String newName,
|
||||
CloneVAppOptions... options);
|
||||
|
|
|
@ -49,14 +49,14 @@ import com.jamesmurty.utils.XMLBuilder;
|
|||
*
|
||||
*/
|
||||
@Singleton
|
||||
public class BindCloneVAppParamsToXmlPayload implements MapBinder {
|
||||
public class BindCloneVCloudExpressVAppParamsToXmlPayload implements MapBinder {
|
||||
|
||||
protected final String ns;
|
||||
protected final String schema;
|
||||
private final BindToStringPayload stringBinder;
|
||||
|
||||
@Inject
|
||||
public BindCloneVAppParamsToXmlPayload(BindToStringPayload stringBinder,
|
||||
public BindCloneVCloudExpressVAppParamsToXmlPayload(BindToStringPayload stringBinder,
|
||||
@Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) {
|
||||
this.ns = ns;
|
||||
this.schema = schema;
|
||||
|
@ -93,7 +93,7 @@ public class BindCloneVAppParamsToXmlPayload implements MapBinder {
|
|||
XMLBuilder rootBuilder = buildRoot(newName, options.isDeploy(), options.isPowerOn());
|
||||
if (options.getDescription() != null)
|
||||
rootBuilder.e("Description").text(options.getDescription());
|
||||
rootBuilder.e("VApp").a("href", vApp).a("type", VCloudMediaType.VAPP_XML);
|
||||
rootBuilder.e("VApp").a("xmlns", ns).a("href", vApp).a("type", VCloudMediaType.VAPP_XML);
|
||||
Properties outputProperties = new Properties();
|
||||
outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
|
||||
return rootBuilder.asString(outputProperties);
|
|
@ -47,7 +47,7 @@ import com.google.inject.name.Names;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class BindCloneVAppParamsToXmlPayloadTest {
|
||||
public class BindCloneVCloudExpressVAppParamsToXmlPayloadTest {
|
||||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
|
||||
@Override
|
||||
|
@ -70,7 +70,7 @@ public class BindCloneVAppParamsToXmlPayloadTest {
|
|||
request.setPayload(expected);
|
||||
replay(request);
|
||||
|
||||
BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class);
|
||||
BindCloneVCloudExpressVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVCloudExpressVAppParamsToXmlPayload.class);
|
||||
|
||||
Map<String, String> map = Maps.newHashMap();
|
||||
map.put("newName", "new-linux-server");
|
||||
|
@ -88,7 +88,7 @@ public class BindCloneVAppParamsToXmlPayloadTest {
|
|||
request.setPayload(expected);
|
||||
replay(request);
|
||||
|
||||
BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class);
|
||||
BindCloneVCloudExpressVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVCloudExpressVAppParamsToXmlPayload.class);
|
||||
|
||||
Map<String, String> map = Maps.newHashMap();
|
||||
map.put("newName", "my-vapp");
|
|
@ -1,98 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 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.vcloud.binders;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.classextension.EasyMock.createMock;
|
||||
import static org.easymock.classextension.EasyMock.replay;
|
||||
import static org.easymock.classextension.EasyMock.verify;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
import org.jclouds.util.Strings2;
|
||||
import org.jclouds.vcloud.VCloudExpressPropertiesBuilder;
|
||||
import org.jclouds.vcloud.options.CloneVAppOptions;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.name.Names;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code BindCloneVAppParamsToXmlPayload}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class VCloudExpressBindCloneVAppParamsToXmlPayloadTest {
|
||||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
Properties props = new Properties();
|
||||
Names.bindProperties(binder(), checkNotNull(new VCloudExpressPropertiesBuilder(props).build(), "properties"));
|
||||
}
|
||||
});
|
||||
|
||||
public void testWithDescriptionDeployOn() throws IOException {
|
||||
String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/cloneVApp.xml"));
|
||||
|
||||
CloneVAppOptions options = new CloneVAppOptions().deploy().powerOn().withDescription(
|
||||
"The description of the new vApp");
|
||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||
expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes();
|
||||
expect(request.getArgs()).andReturn(ImmutableList.<Object>of( options)).atLeastOnce();
|
||||
request.setPayload(expected);
|
||||
replay(request);
|
||||
|
||||
BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class);
|
||||
|
||||
Map<String, String> map = Maps.newHashMap();
|
||||
map.put("newName", "new-linux-server");
|
||||
map.put("vApp", "https://vcloud.safesecureweb.com/api/v0.8/vapp/201");
|
||||
binder.bindToRequest(request, map);
|
||||
verify(request);
|
||||
}
|
||||
|
||||
public void testDefault() throws IOException {
|
||||
String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/cloneVApp-default.xml"));
|
||||
|
||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||
expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes();
|
||||
expect(request.getArgs()).andReturn(ImmutableList.<Object>of()).atLeastOnce();
|
||||
request.setPayload(expected);
|
||||
replay(request);
|
||||
|
||||
BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class);
|
||||
|
||||
Map<String, String> map = Maps.newHashMap();
|
||||
map.put("newName", "my-vapp");
|
||||
map.put("vApp", "https://vcloud.safesecureweb.com/api/v0.8/vapp/4181");
|
||||
binder.bindToRequest(request, map);
|
||||
verify(request);
|
||||
}
|
||||
}
|
|
@ -27,7 +27,7 @@ import javax.xml.parsers.FactoryConfigurationError;
|
|||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.jclouds.rest.binders.BindToStringPayload;
|
||||
import org.jclouds.vcloud.binders.BindCloneVAppParamsToXmlPayload;
|
||||
import org.jclouds.vcloud.binders.BindCloneVCloudExpressVAppParamsToXmlPayload;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.jamesmurty.utils.XMLBuilder;
|
||||
|
@ -38,7 +38,7 @@ import com.jamesmurty.utils.XMLBuilder;
|
|||
*
|
||||
*/
|
||||
@Singleton
|
||||
public class TerremarkBindCloneVAppParamsToXmlPayload extends BindCloneVAppParamsToXmlPayload {
|
||||
public class TerremarkBindCloneVAppParamsToXmlPayload extends BindCloneVCloudExpressVAppParamsToXmlPayload {
|
||||
|
||||
@Inject
|
||||
public TerremarkBindCloneVAppParamsToXmlPayload(BindToStringPayload stringBinder,
|
||||
|
|
Loading…
Reference in New Issue