Issue 710:customize is not supported on vCloud 1.0

This commit is contained in:
Adrian Cole 2012-01-12 19:04:12 -08:00
parent ef7e0a46e2
commit 260c23170b
6 changed files with 6 additions and 95 deletions

View File

@ -101,7 +101,6 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
boolean deploy = true;
boolean powerOn = true;
Boolean customizeOnInstantiate = null;
Set<NetworkConfig> networkConfig = null;
@ -116,7 +115,6 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
networknetworkConfigDecorator));
deploy = ifNullDefaultTo(options.shouldDeploy(), deploy);
powerOn = ifNullDefaultTo(options.shouldPowerOn(), powerOn);
customizeOnInstantiate = options.shouldCustomizeOnInstantiate();
}
if (networkConfig == null)
@ -125,8 +123,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
try {
return stringBinder.bindToRequest(
request,
generateXml(name, options.getDescription(), deploy, powerOn, template, networkConfig,
customizeOnInstantiate));
generateXml(name, options.getDescription(), deploy, powerOn, template, networkConfig));
} catch (ParserConfigurationException e) {
throw new RuntimeException(e);
} catch (FactoryConfigurationError e) {
@ -202,14 +199,13 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
}
protected String generateXml(String name, @Nullable String description, boolean deploy, boolean powerOn,
URI template, Iterable<NetworkConfig> networkConfig, @Nullable Boolean customizeOnInstantiate)
URI template, Iterable<NetworkConfig> networkConfig)
throws ParserConfigurationException, FactoryConfigurationError, TransformerException {
XMLBuilder rootBuilder = buildRoot(name).a("deploy", deploy + "").a("powerOn", powerOn + "");
if (description != null)
rootBuilder.e("Description").t(description);
XMLBuilder instantiationParamsBuilder = rootBuilder.e("InstantiationParams");
addNetworkConfig(instantiationParamsBuilder, networkConfig);
addCustomizationConfig(instantiationParamsBuilder, customizeOnInstantiate);
rootBuilder.e("Source").a("href", template.toASCIIString());
rootBuilder.e("AllEULAsAccepted").t("true");
@ -218,15 +214,6 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
return rootBuilder.asString(outputProperties);
}
protected void addCustomizationConfig(XMLBuilder instantiationParamsBuilder, Boolean customizeOnInstantiate) {
if (customizeOnInstantiate != null) {
// XMLBuilder customizationSectionBuilder =
// instantiationParamsBuilder.e("CustomizationSection");
// customizationSectionBuilder.e("ovf:Info").t("VApp template customization section");
// customizationSectionBuilder.e("CustomizeOnInstantiate").t(customizeOnInstantiate.toString());
}
}
protected void addNetworkConfig(XMLBuilder instantiationParamsBuilder,
Iterable<NetworkConfig> networkConfig) {
XMLBuilder networkConfigBuilder = instantiationParamsBuilder.e("NetworkConfigSection");

View File

@ -79,7 +79,6 @@ public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployA
.getIpAddressAllocationMode();
options.description(VCloudTemplateOptions.class.cast(template.getOptions()).getDescription());
options.customizeOnInstantiate(false);
options.deploy(false);
options.powerOn(false);

View File

@ -88,16 +88,7 @@ public class InstantiateVAppTemplateOptions {
this.block = block;
return this;
}
/**
* If true, then customization is executed for all children that include a
* GuestCustomizationSection.
*/
public InstantiateVAppTemplateOptions customizeOnInstantiate(boolean customizeOnInstantiate) {
this.customizeOnInstantiate = customizeOnInstantiate;
return this;
}
/**
* {@networkConfig VAppTemplate}s have internal networks that can be
* connected in order to access the internet or other external networks.
@ -123,10 +114,6 @@ public class InstantiateVAppTemplateOptions {
return networkConfig;
}
public Boolean shouldCustomizeOnInstantiate() {
return customizeOnInstantiate;
}
public static class Builder {
/**
@ -161,14 +148,6 @@ public class InstantiateVAppTemplateOptions {
return options.powerOn(powerOn);
}
/**
* @see InstantiateVAppTemplateOptions#customizeOnInstantiate
*/
public static InstantiateVAppTemplateOptions customizeOnInstantiate(Boolean customizeOnInstantiate) {
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
return options.customizeOnInstantiate(customizeOnInstantiate);
}
/**
* @see InstantiateVAppTemplateOptions#addNetworkConfig
*/

View File

@ -19,12 +19,11 @@
package org.jclouds.vcloud.binders;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.easymock.EasyMock.createMock;
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 static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.addNetworkConfig;
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.customizeOnInstantiate;
import java.io.IOException;
import java.net.URI;
@ -235,42 +234,4 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
binder.bindToRequest(request, map);
verify(request);
}
public void testWithCustomization() throws IOException {
URI templateUri = URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3");
VAppTemplate template = createMock(VAppTemplate.class);
VCloudNetworkSection net = createMock(VCloudNetworkSection.class);
InstantiateVAppTemplateOptions options = customizeOnInstantiate(true);
String expected = Strings2.toStringAndClose(getClass().getResourceAsStream(
"/instantiationparams-customization.xml"));
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);
expect(template.getNetworkSection()).andReturn(net).atLeastOnce();
expect(net.getNetworks()).andReturn(
ImmutableSet.<org.jclouds.ovf.Network> of(new org.jclouds.ovf.Network("vAppNet-vApp Internal", null)));
replay(request);
replay(template);
replay(net);
BindInstantiateVAppTemplateParamsToXmlPayload binder = createInjector(templateUri, template).getInstance(
BindInstantiateVAppTemplateParamsToXmlPayload.class);
Map<String, String> map = Maps.newHashMap();
map.put("name", "my-vapp");
map.put("template", "https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3");
binder.bindToRequest(request, map);
verify(request);
verify(template);
verify(net);
}
}

View File

@ -19,7 +19,6 @@
package org.jclouds.vcloud.options;
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.addNetworkConfig;
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.customizeOnInstantiate;
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.description;
import static org.testng.Assert.assertEquals;
@ -62,19 +61,6 @@ public class InstantiateVAppTemplateOptionsTest {
assertEquals(Iterables.get(options.getNetworkConfig(), 0).getFenceMode(), FenceMode.BRIDGED);
}
@Test
public void testCustomizeOnInstantiate() {
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
options.customizeOnInstantiate(true);
assertEquals(options.shouldCustomizeOnInstantiate(), new Boolean(true));
}
@Test
public void testCustomizeOnInstantiateStatic() {
InstantiateVAppTemplateOptions options = customizeOnInstantiate(true);
assertEquals(options.shouldCustomizeOnInstantiate(), new Boolean(true));
}
@Test
public void testDescription() {
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();

View File

@ -1 +0,0 @@
<InstantiateVAppTemplateParams xmlns="http://www.vmware.com/vcloud/v1" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" deploy="true" name="my-vapp" powerOn="true"><InstantiationParams><NetworkConfigSection><ovf:Info>Configuration parameters for logical networks</ovf:Info><NetworkConfig networkName="vAppNet-vApp Internal"><Configuration><ParentNetwork href="https://vcenterprise.bluelock.com/api/v1.0/network/1990"/><FenceMode>bridged</FenceMode></Configuration></NetworkConfig></NetworkConfigSection></InstantiationParams><Source href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"/><AllEULAsAccepted>true</AllEULAsAccepted></InstantiateVAppTemplateParams>