From 260c23170b8de571850970ab6f170f42a428ac7e Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 12 Jan 2012 19:04:12 -0800 Subject: [PATCH] Issue 710:customize is not supported on vCloud 1.0 --- ...antiateVAppTemplateParamsToXmlPayload.java | 17 +------ ...IntoNameThenCustomizeDeployAndPowerOn.java | 1 - .../InstantiateVAppTemplateOptions.java | 23 +--------- ...ateVAppTemplateParamsToXmlPayloadTest.java | 45 ++----------------- .../InstantiateVAppTemplateOptionsTest.java | 14 ------ .../instantiationparams-customization.xml | 1 - 6 files changed, 6 insertions(+), 95 deletions(-) delete mode 100644 apis/vcloud/src/test/resources/instantiationparams-customization.xml diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java index 984d5bf6ce..9c531a9769 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java @@ -101,7 +101,6 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder boolean deploy = true; boolean powerOn = true; - Boolean customizeOnInstantiate = null; Set 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, @Nullable Boolean customizeOnInstantiate) + URI template, Iterable 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) { XMLBuilder networkConfigBuilder = instantiationParamsBuilder.e("NetworkConfigSection"); diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java index 6bb0948769..e98b88dbc1 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java @@ -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); diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java index 3be4d56f60..6212e5ddc7 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java @@ -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 */ diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java index c6dad9bc06..0aa1667708 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java @@ -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. of(options)).atLeastOnce(); - request.setPayload(expected); - - expect(template.getNetworkSection()).andReturn(net).atLeastOnce(); - expect(net.getNetworks()).andReturn( - ImmutableSet. 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 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); - - } } diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptionsTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptionsTest.java index 1971f316c0..e8b4943891 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptionsTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptionsTest.java @@ -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(); diff --git a/apis/vcloud/src/test/resources/instantiationparams-customization.xml b/apis/vcloud/src/test/resources/instantiationparams-customization.xml deleted file mode 100644 index 9df99619b8..0000000000 --- a/apis/vcloud/src/test/resources/instantiationparams-customization.xml +++ /dev/null @@ -1 +0,0 @@ -Configuration parameters for logical networksbridgedtrue \ No newline at end of file