diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/ConfigurationOptionRange.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/ConfigurationOptionRange.java new file mode 100644 index 0000000000..8f21f44b8d --- /dev/null +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/ConfigurationOptionRange.java @@ -0,0 +1,134 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.tmrk.enterprisecloud.domain; + +import javax.xml.bind.annotation.XmlElement; + +/** + * + * @author Jason King + */ +public class ConfigurationOptionRange { + + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromConfigurationOptionRange(this); + } + + public static class Builder { + + private int minimum; + private int maximum; + private int stepFactor; + + /** + * @see org.jclouds.tmrk.enterprisecloud.domain.ConfigurationOptionRange#getMinimum + */ + public Builder minimum(int minimum) { + this.minimum = minimum; + return this; + } + + /** + * @see org.jclouds.tmrk.enterprisecloud.domain.ConfigurationOptionRange#getMaximum + */ + public Builder maximum(int maximum) { + this.maximum = maximum; + return this; + } + + /** + * @see org.jclouds.tmrk.enterprisecloud.domain.ConfigurationOptionRange#getStepFactor + */ + public Builder stepFactor(int stepFactor) { + this.stepFactor = stepFactor; + return this; + } + + public ConfigurationOptionRange build() { + return new ConfigurationOptionRange(minimum, maximum,stepFactor); + } + + public Builder fromConfigurationOptionRange(ConfigurationOptionRange in) { + return minimum(in.getMinimum()).maximum(in.getMaximum()).stepFactor(in.getStepFactor()); + } + } + + @XmlElement(name = "Minimum") + private int minimum; + + @XmlElement(name = "Maximum") + private int maximum; + + @XmlElement(name = "StepFactor") + private int stepFactor; + + private ConfigurationOptionRange(int minimum, int maximum, int stepFactor) { + this.minimum = minimum; + this.maximum = maximum; + this.stepFactor = stepFactor; + } + + private ConfigurationOptionRange() { + //For JAXB + } + + public int getMinimum() { + return minimum; + } + + public int getMaximum() { + return maximum; + } + + public int getStepFactor() { + return stepFactor; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ConfigurationOptionRange that = (ConfigurationOptionRange) o; + + if (maximum != that.maximum) return false; + if (minimum != that.minimum) return false; + if (stepFactor != that.stepFactor) return false; + + return true; + } + + @Override + public int hashCode() { + int result = minimum; + result = 31 * result + maximum; + result = 31 * result + stepFactor; + return result; + } + + @Override + public String toString() { + return "[minimum="+ minimum +", maximum="+ maximum +", stepFactor="+stepFactor+"]"; + } +} diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/CustomizationOption.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/CustomizationOption.java new file mode 100644 index 0000000000..2077cf8cdb --- /dev/null +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/CustomizationOption.java @@ -0,0 +1,167 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.tmrk.enterprisecloud.domain; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * + * @author Jason King + */ +public class CustomizationOption { + + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromConfigurationOptionRange(this); + } + + public static class Builder { + + private CustomizationType type; + private boolean canPowerOn; + private boolean passwordRequired; + private boolean sshKeyRequired; + + /** + * @see CustomizationOption#getType + */ + public Builder type(CustomizationType type) { + this.type = type; + return this; + } + + /** + * @see CustomizationOption#canPowerOn + */ + public Builder canPowerOn(boolean canPowerOn) { + this.canPowerOn = canPowerOn; + return this; + } + + /** + * @see CustomizationOption#isPasswordRequired() + */ + public Builder passwordRequired(boolean passwordRequired) { + this.passwordRequired = passwordRequired; + return this; + } + + /** + * @see CustomizationOption#isSshKeyRequired() + */ + public Builder sshKeyRequired(boolean sshKeyRequired) { + this.sshKeyRequired = sshKeyRequired; + return this; + } + + public CustomizationOption build() { + return new CustomizationOption(type, canPowerOn, passwordRequired,sshKeyRequired); + } + + public Builder fromConfigurationOptionRange(CustomizationOption in) { + return type(in.getType()).canPowerOn(in.canPowerOn()).passwordRequired(in.isPasswordRequired()).sshKeyRequired(in.isSshKeyRequired()); + } + } + + @XmlElement(name = "Type") + private CustomizationType type; + + @XmlElement(name = "CanPowerOn") + private boolean canPowerOn; + + @XmlElement(name = "PasswordRequired") + private boolean passwordRequired; + + @XmlElement(name = "SshKeyRequired") + private boolean sshKeyRequired; + + private CustomizationOption(CustomizationType type, boolean canPowerOn, boolean passwordRequired, boolean sshKeyRequired) { + this.type = checkNotNull(type,"type"); + this.canPowerOn = canPowerOn; + this.passwordRequired = passwordRequired; + this.sshKeyRequired = sshKeyRequired; + } + + private CustomizationOption() { + //For JAXB + } + + public CustomizationType getType() { + return type; + } + + public boolean canPowerOn() { + return canPowerOn; + } + + public boolean isPasswordRequired() { + return passwordRequired; + } + + public boolean isSshKeyRequired() { + return sshKeyRequired; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + CustomizationOption that = (CustomizationOption) o; + + if (canPowerOn != that.canPowerOn) return false; + if (passwordRequired != that.passwordRequired) return false; + if (sshKeyRequired != that.sshKeyRequired) return false; + if (type != that.type) return false; + + return true; + } + + @Override + public int hashCode() { + int result = type.hashCode(); + result = 31 * result + (canPowerOn ? 1 : 0); + result = 31 * result + (passwordRequired ? 1 : 0); + result = 31 * result + (sshKeyRequired ? 1 : 0); + return result; + } + + @Override + public String toString() { + return "[type="+type+", canPowerOn="+ canPowerOn +", passwordRequired="+ passwordRequired +", sshKeyRequired="+sshKeyRequired+"]"; + } + + @XmlEnum + public enum CustomizationType { + @XmlEnumValue("Linux") + LINUX, + + @XmlEnumValue("Windows") + WINDOWS; + } + +} diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/DiskConfigurationOption.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/DiskConfigurationOption.java new file mode 100644 index 0000000000..365df574ca --- /dev/null +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/DiskConfigurationOption.java @@ -0,0 +1,156 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.tmrk.enterprisecloud.domain.hardware; + +import javax.xml.bind.annotation.XmlElement; + +/** + * + * @author Jason King + */ +public class DiskConfigurationOption { + + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromConfigurationOptionRange(this); + } + + public static class Builder { + + private int minimum; + private int maximum; + private DiskConfigurationOptionRange systemDisk; + private DiskConfigurationOptionRange dataDisk; + + /** + * @see DiskConfigurationOption#getMinimum() + */ + public Builder minimum(int minimum) { + this.minimum = minimum; + return this; + } + + /** + * @see DiskConfigurationOption#getMaximum() + */ + public Builder maximum(int maximum) { + this.maximum = maximum; + return this; + } + + /** + * @see DiskConfigurationOption#getSystemDisk() + */ + public Builder systemDisk(DiskConfigurationOptionRange systemDisk) { + this.systemDisk = systemDisk; + return this; + } + + /** + * @see DiskConfigurationOption#getDataDisk() + */ + public Builder dataDisk(DiskConfigurationOptionRange dataDisk) { + this.dataDisk = dataDisk; + return this; + } + + public DiskConfigurationOption build() { + return new DiskConfigurationOption(minimum, maximum, systemDisk, dataDisk); + } + + public Builder fromConfigurationOptionRange(DiskConfigurationOption in) { + return minimum(in.getMinimum()).maximum(in.getMaximum()).systemDisk(in.getSystemDisk()).dataDisk(in.getDataDisk()); + } + } + + @XmlElement(name = "Minimum") + private int minimum; + + @XmlElement(name = "Maximum") + private int maximum; + + @XmlElement(name = "SystemDisk") + private DiskConfigurationOptionRange systemDisk; + + @XmlElement(name = "DataDisk") + private DiskConfigurationOptionRange dataDisk; + + private DiskConfigurationOption(int minimum, int maximum, DiskConfigurationOptionRange systemDisk, DiskConfigurationOptionRange dataDisk) { + this.minimum = minimum; + this.maximum = maximum; + this.systemDisk = systemDisk; + this.dataDisk = dataDisk; + } + + private DiskConfigurationOption() { + //For JAXB + } + + public int getMinimum() { + return minimum; + } + + public int getMaximum() { + return maximum; + } + + public DiskConfigurationOptionRange getSystemDisk() { + return systemDisk; + } + + public DiskConfigurationOptionRange getDataDisk() { + return dataDisk; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + DiskConfigurationOption that = (DiskConfigurationOption) o; + + if (maximum != that.maximum) return false; + if (minimum != that.minimum) return false; + if (dataDisk != null ? !dataDisk.equals(that.dataDisk) : that.dataDisk != null) + return false; + if (systemDisk != null ? !systemDisk.equals(that.systemDisk) : that.systemDisk != null) + return false; + + return true; + } + + @Override + public int hashCode() { + int result = minimum; + result = 31 * result + maximum; + result = 31 * result + (systemDisk != null ? systemDisk.hashCode() : 0); + result = 31 * result + (dataDisk != null ? dataDisk.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "[minimum="+minimum+", maximum="+ maximum +", systemDisk="+ systemDisk +", dataDisk="+dataDisk+"]"; + } + +} diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/DiskConfigurationOptionRange.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/DiskConfigurationOptionRange.java new file mode 100644 index 0000000000..4bfa1f5a63 --- /dev/null +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/DiskConfigurationOptionRange.java @@ -0,0 +1,122 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.tmrk.enterprisecloud.domain.hardware; + +import org.jclouds.tmrk.enterprisecloud.domain.ResourceCapacityRange; + +import javax.xml.bind.annotation.XmlElement; + +/** + * + * @author Jason King + */ +public class DiskConfigurationOptionRange { + + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromConfigurationOptionRange(this); + } + + public static class Builder { + + private ResourceCapacityRange resourceCapacityRange; + private double monthlyCost; + + /** + * @see DiskConfigurationOptionRange#getResourceCapacityRange + */ + public Builder resourceCapacityRange(ResourceCapacityRange resourceCapacityRange) { + this.resourceCapacityRange = resourceCapacityRange; + return this; + } + + /** + * @see DiskConfigurationOptionRange#getMonthlyCost() + */ + public Builder monthlyCost(double monthlyCost) { + this.monthlyCost = monthlyCost; + return this; + } + + + public DiskConfigurationOptionRange build() { + return new DiskConfigurationOptionRange(resourceCapacityRange, monthlyCost); + } + + public Builder fromConfigurationOptionRange(DiskConfigurationOptionRange in) { + return resourceCapacityRange(in.getResourceCapacityRange()).monthlyCost(in.getMonthlyCost()); + } + } + + @XmlElement(name = "ResourceCapacityRange") + private ResourceCapacityRange resourceCapacityRange; + + @XmlElement(name = "MonthlyCost") + private double monthlyCost; + + private DiskConfigurationOptionRange(ResourceCapacityRange resourceCapacityRange, double monthlyCost) { + this.resourceCapacityRange = resourceCapacityRange; + this.monthlyCost = monthlyCost; + } + + private DiskConfigurationOptionRange() { + //For JAXB + } + + public ResourceCapacityRange getResourceCapacityRange() { + return resourceCapacityRange; + } + + public double getMonthlyCost() { + return monthlyCost; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + DiskConfigurationOptionRange that = (DiskConfigurationOptionRange) o; + + if (Double.compare(that.monthlyCost, monthlyCost) != 0) return false; + if (resourceCapacityRange != null ? !resourceCapacityRange.equals(that.resourceCapacityRange) : that.resourceCapacityRange != null) + return false; + + return true; + } + + @Override + public int hashCode() { + int result; + long temp; + result = resourceCapacityRange != null ? resourceCapacityRange.hashCode() : 0; + temp = monthlyCost != +0.0d ? Double.doubleToLongBits(monthlyCost) : 0L; + result = 31 * result + (int) (temp ^ (temp >>> 32)); + return result; + } + + @Override + public String toString() { + return "[resourceCapacityRange="+resourceCapacityRange+", monthlyCost="+monthlyCost+"]"; + } +} diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/HardwareConfiguration.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/HardwareConfiguration.java index 6a00f781a9..c994bef5ad 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/HardwareConfiguration.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/HardwareConfiguration.java @@ -29,6 +29,7 @@ import org.jclouds.tmrk.enterprisecloud.domain.network.Nics; import org.jclouds.tmrk.enterprisecloud.domain.network.VirtualNic; import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; import java.net.URI; import java.util.Collections; import java.util.Map; @@ -40,6 +41,7 @@ import static com.google.common.base.Preconditions.checkNotNull; * * @author Jason King */ +@XmlRootElement(name = "HardwareConfiguration") public class HardwareConfiguration extends BaseResource { @SuppressWarnings("unchecked") diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachineConfigurationOptions.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachineConfigurationOptions.java index 261db65e9e..4078d2f6a7 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachineConfigurationOptions.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachineConfigurationOptions.java @@ -19,7 +19,8 @@ package org.jclouds.tmrk.enterprisecloud.domain.vm; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.tmrk.enterprisecloud.domain.ResourceCapacityRange; +import org.jclouds.tmrk.enterprisecloud.domain.*; +import org.jclouds.tmrk.enterprisecloud.domain.hardware.DiskConfigurationOption; import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource; import javax.xml.bind.annotation.XmlElement; @@ -48,8 +49,21 @@ public class VirtualMachineConfigurationOptions extends BaseResource { - //TODO There are additional fields + + protected ConfigurationOptionRange processor; protected ResourceCapacityRange memory; + protected DiskConfigurationOption disk; + protected ConfigurationOptionRange networkAdapter; + protected CustomizationOption customization; + //TODO ComputeMatrix field + + /** + * @see VirtualMachineConfigurationOptions#getProcessor + */ + public Builder processor(ConfigurationOptionRange processor) { + this.processor = processor; + return this; + } /** * @see VirtualMachineConfigurationOptions#getMemory @@ -59,13 +73,41 @@ public class VirtualMachineConfigurationOptions extends BaseResource getVirtualMachines(@EndpointParam URI uri); /** @@ -73,11 +75,20 @@ public interface VirtualMachineAsyncClient { ListenableFuture getAssignedIpAddresses(@EndpointParam URI uri); /** - * @see VirtualMachineClient#getVirtualMachineConfigurationOptions + * @see VirtualMachineClient#getConfigurationOptions */ @GET @Consumes("application/vnd.tmrk.cloud.virtualMachineConfigurationOptions") @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getVirtualMachineConfigurationOptions(@EndpointParam URI uri); + ListenableFuture getConfigurationOptions(@EndpointParam URI uri); + + /** + * @see VirtualMachineClient#getHardwareConfiguration + */ + @GET + @Consumes("application/vnd.tmrk.cloud.virtualMachineHardware") + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getHardwareConfiguration(@EndpointParam URI uri); } diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/features/VirtualMachineClient.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/features/VirtualMachineClient.java index 8734ee572c..a2680fc3ff 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/features/VirtualMachineClient.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/features/VirtualMachineClient.java @@ -19,6 +19,7 @@ package org.jclouds.tmrk.enterprisecloud.features; import org.jclouds.concurrent.Timeout; +import org.jclouds.tmrk.enterprisecloud.domain.hardware.HardwareConfiguration; import org.jclouds.tmrk.enterprisecloud.domain.network.AssignedIpAddresses; import org.jclouds.tmrk.enterprisecloud.domain.vm.VirtualMachine; import org.jclouds.tmrk.enterprisecloud.domain.vm.VirtualMachineConfigurationOptions; @@ -69,6 +70,14 @@ public interface VirtualMachineClient { * @param uri the uri for the configuration options. e.g. /cloudapi/ecloud/virtualmachines/{id}/configurationoptions * @return the configuration options */ - VirtualMachineConfigurationOptions getVirtualMachineConfigurationOptions(URI uri); + VirtualMachineConfigurationOptions getConfigurationOptions(URI uri); + + /** + * The Get Virtual Machines Hardware Configuration call returns information + * regarding the hardware configuration of a specified virtual machine in a compute pool. + * @param uri the uri for the hardware configuration e.g. /cloudapi/ecloud/virtualmachines/{id}/hardwareconfiguration + * @return + */ + HardwareConfiguration getHardwareConfiguration(URI uri); } diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/functions/ReturnEmptyVirtualMachinesOnNotFoundOr404.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/functions/ReturnEmptyVirtualMachinesOnNotFoundOr404.java new file mode 100644 index 0000000000..15864a0ac8 --- /dev/null +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/functions/ReturnEmptyVirtualMachinesOnNotFoundOr404.java @@ -0,0 +1,57 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.tmrk.enterprisecloud.functions; + +import com.google.common.base.Function; +import com.google.common.base.Throwables; +import com.google.common.collect.Iterables; +import org.jclouds.http.functions.ReturnTrueOn404; +import org.jclouds.rest.ResourceNotFoundException; +import org.jclouds.tmrk.enterprisecloud.domain.vm.VirtualMachines; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.util.Throwables2.propagateOrNull; + +/** + * + * @author Jason King + */ +@Singleton +public class ReturnEmptyVirtualMachinesOnNotFoundOr404 implements Function { + private final ReturnTrueOn404 rto404; + + @Inject + ReturnEmptyVirtualMachinesOnNotFoundOr404(ReturnTrueOn404 rto404) { + this.rto404 = checkNotNull(rto404, "rto404"); + } + + public Object apply(Exception from) { + Iterable throwables = Iterables.filter(Throwables.getCausalChain(from), + ResourceNotFoundException.class); + if (Iterables.size(throwables) >= 1) { + return VirtualMachines.builder().build(); + } else if (rto404.apply(from)) { + return VirtualMachines.builder().build(); + } + return VirtualMachines.class.cast(propagateOrNull(from)); + } +} diff --git a/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/features/VirtualMachineAsyncClientTest.java b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/features/VirtualMachineAsyncClientTest.java index 8ffcf2dbeb..8122981a11 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/features/VirtualMachineAsyncClientTest.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/features/VirtualMachineAsyncClientTest.java @@ -23,6 +23,7 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseXMLWithJAXB; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.internal.RestAnnotationProcessor; +import org.jclouds.tmrk.enterprisecloud.functions.ReturnEmptyVirtualMachinesOnNotFoundOr404; import org.testng.annotations.Test; import java.io.IOException; @@ -61,7 +62,7 @@ public class VirtualMachineAsyncClientTest extends BaseTerremarkEnterpriseCloudA assertPayloadEquals(httpRequest, null, null, false); assertResponseParserClassEquals(method, httpRequest, ParseXMLWithJAXB.class); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertExceptionParserClassEquals(method, ReturnEmptyVirtualMachinesOnNotFoundOr404.class); checkFilters(httpRequest); } @@ -80,8 +81,8 @@ public class VirtualMachineAsyncClientTest extends BaseTerremarkEnterpriseCloudA checkFilters(httpRequest); } - public void testGetVirtualMachineConfigurationOptions() throws SecurityException, NoSuchMethodException, IOException, URISyntaxException { - Method method = VirtualMachineAsyncClient.class.getMethod("getVirtualMachineConfigurationOptions", URI.class); + public void testGetConfigurationOptions() throws SecurityException, NoSuchMethodException, IOException, URISyntaxException { + Method method = VirtualMachineAsyncClient.class.getMethod("getConfigurationOptions", URI.class); HttpRequest httpRequest = processor.createRequest(method,new URI("/cloudapi/ecloud/virtualmachines/5504/configurationoptions")); assertRequestLineEquals(httpRequest, "GET https://services-beta.enterprisecloud.terremark.com/cloudapi/ecloud/virtualmachines/5504/configurationoptions HTTP/1.1"); @@ -94,6 +95,20 @@ public class VirtualMachineAsyncClientTest extends BaseTerremarkEnterpriseCloudA checkFilters(httpRequest); } + public void testGetHardwareConfiguration() throws SecurityException, NoSuchMethodException, IOException, URISyntaxException { + Method method = VirtualMachineAsyncClient.class.getMethod("getHardwareConfiguration", URI.class); + HttpRequest httpRequest = processor.createRequest(method,new URI("/cloudapi/ecloud/virtualmachines/5504/hardwareconfiguration")); + + assertRequestLineEquals(httpRequest, "GET https://services-beta.enterprisecloud.terremark.com/cloudapi/ecloud/virtualmachines/5504/hardwareconfiguration HTTP/1.1"); + assertNonPayloadHeadersEqual(httpRequest, "Accept: application/vnd.tmrk.cloud.virtualMachineHardware\nx-tmrk-version: 2011-07-01\n"); + assertPayloadEquals(httpRequest, null, null, false); + + assertResponseParserClassEquals(method, httpRequest, ParseXMLWithJAXB.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(httpRequest); + } + @Override protected TypeLiteral> createTypeLiteral() { return new TypeLiteral>() { diff --git a/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/features/VirtualMachineClientLiveTest.java b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/features/VirtualMachineClientLiveTest.java index d59642c1a8..89cc671f49 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/features/VirtualMachineClientLiveTest.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/features/VirtualMachineClientLiveTest.java @@ -19,6 +19,7 @@ package org.jclouds.tmrk.enterprisecloud.features; import com.google.common.collect.Iterables; +import org.jclouds.tmrk.enterprisecloud.domain.hardware.HardwareConfiguration; import org.jclouds.tmrk.enterprisecloud.domain.network.AssignedIpAddresses; import org.jclouds.tmrk.enterprisecloud.domain.network.DeviceNetwork; import org.jclouds.tmrk.enterprisecloud.domain.vm.VirtualMachine; @@ -30,9 +31,7 @@ import org.testng.annotations.Test; import java.net.URI; import java.util.Set; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; +import static org.testng.Assert.*; /** * Tests behavior of {@code VirtualMachineClient} @@ -53,27 +52,53 @@ public class VirtualMachineClientLiveTest extends BaseTerremarkEnterpriseCloudCl VirtualMachines virtualMachines = client.getVirtualMachines(new URI("/cloudapi/ecloud/virtualMachines/computePools/89")); for( VirtualMachine vm : virtualMachines.getVirtualMachines()) { VirtualMachine virtualMachine = client.getVirtualMachine(vm.getHref()); - assertNotNull(virtualMachine,"virtualMachine should not be null"); + assertNotNull(virtualMachine); assertEquals(virtualMachine.getStatus(),VirtualMachine.VirtualMachineStatus.DEPLOYED); } } + public void testGetVirtualMachinesWhenMissing() throws Exception { + VirtualMachines result = client.getVirtualMachines(new URI("/cloudapi/ecloud/virtualMachines/computePools/-1")); + assertEquals(result, VirtualMachines.builder().build()); + } + public void testGetVirtualMachine() throws Exception { VirtualMachine virtualMachine = client.getVirtualMachine(new URI("/cloudapi/ecloud/virtualMachines/5504")); assertNotNull(virtualMachine,"virtualMachine should not be null"); assertEquals(virtualMachine.getStatus(), VirtualMachine.VirtualMachineStatus.DEPLOYED); } + public void testGetVirtualMachineWhenMissing() throws Exception { + VirtualMachine virtualMachine = client.getVirtualMachine(new URI("/cloudapi/ecloud/virtualMachines/-1")); + assertNull(virtualMachine); + } + public void testGetAssignedIpAddresses() throws Exception { AssignedIpAddresses assignedIpAddresses = client.getAssignedIpAddresses(new URI("/cloudapi/ecloud/virtualMachines/5504/assignedips")); - assertNotNull(assignedIpAddresses,"assignedIpAddresses should not be null"); + assertNotNull(assignedIpAddresses); DeviceNetwork network = Iterables.getOnlyElement(assignedIpAddresses.getNetworks().getDeviceNetworks()); Set ipAddresses = network.getIpAddresses().getIpAddresses(); assertTrue(ipAddresses.size()>0, "vm has no assigned ip addresses"); } - public void testGetVirtualMachineConfigurationOptions() throws Exception { - VirtualMachineConfigurationOptions virtualMachineConfigurationOptions = client.getVirtualMachineConfigurationOptions(new URI("/cloudapi/ecloud/virtualmachines/5504/configurationoptions")); - assertNotNull(virtualMachineConfigurationOptions,"options should not be null"); + public void testGetAssignedIpAddressesWhenMissing() throws Exception { + AssignedIpAddresses assignedIpAddresses = client.getAssignedIpAddresses(new URI("/cloudapi/ecloud/virtualMachines/-1/assignedips")); + assertNull(assignedIpAddresses); } + + public void testGetConfigurationOptions() throws Exception { + VirtualMachineConfigurationOptions configurationOptions = client.getConfigurationOptions(new URI("/cloudapi/ecloud/virtualmachines/5504/configurationoptions")); + assertNotNull(configurationOptions); + } + + public void testGetHardwareConfiguration() throws Exception { + HardwareConfiguration hardwareConfiguration = client.getHardwareConfiguration(new URI("/cloudapi/ecloud/virtualmachines/5504/hardwareconfiguration")); + assertNotNull(hardwareConfiguration); + } + + public void testGetHardwareConfigurationWhenMissing() throws Exception { + HardwareConfiguration result = client.getHardwareConfiguration(new URI("/cloudapi/ecloud/virtualmachines/-1/hardwareconfiguration")); + assertNull(result); + } + } diff --git a/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/functions/ReturnEmptyVirtualMachinesOnNotFoundOr404Test.java b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/functions/ReturnEmptyVirtualMachinesOnNotFoundOr404Test.java new file mode 100644 index 0000000000..370687ca8d --- /dev/null +++ b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/functions/ReturnEmptyVirtualMachinesOnNotFoundOr404Test.java @@ -0,0 +1,66 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.tmrk.enterprisecloud.functions; + +import org.jclouds.http.HttpResponse; +import org.jclouds.http.HttpResponseException; +import org.jclouds.http.functions.ReturnTrueOn404; +import org.jclouds.rest.ResourceNotFoundException; +import org.jclouds.tmrk.enterprisecloud.domain.vm.VirtualMachines; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +/** + * + * @author Jason King + */ +@Test(groups = "unit", testName = "ReturnEmptyVirtualMachinesOnNotFoundOr404Test") +public class ReturnEmptyVirtualMachinesOnNotFoundOr404Test { + + private ReturnEmptyVirtualMachinesOnNotFoundOr404 function; + private VirtualMachines expected; + + @BeforeMethod + public void setUp() { + function = new ReturnEmptyVirtualMachinesOnNotFoundOr404(new ReturnTrueOn404()); + expected = VirtualMachines.builder().build(); + } + + public void testOn404() { + VirtualMachines expected = VirtualMachines.builder().build(); + assertEquals(function.apply(new HttpResponseException("response exception", null, new HttpResponse(404, "404 message", null))), expected); + } + + public void testOnNotFound() { + VirtualMachines expected = VirtualMachines.builder().build(); + assertEquals(function.apply(new ResourceNotFoundException()),expected); + } + + public void testOnNotFoundChained() { + VirtualMachines expected = VirtualMachines.builder().build(); + assertEquals(function.apply(new RuntimeException(new ResourceNotFoundException())),expected); + } + + @Test(expectedExceptions = HttpResponseException.class) + public void testOn500() { + function.apply(new HttpResponseException("response exception", null, new HttpResponse(500, "500 message", null))); + } +} diff --git a/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/xml/HardwareConfigurationJAXBParsingTest.java b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/xml/HardwareConfigurationJAXBParsingTest.java new file mode 100644 index 0000000000..63bf121c5a --- /dev/null +++ b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/xml/HardwareConfigurationJAXBParsingTest.java @@ -0,0 +1,142 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.tmrk.enterprisecloud.xml; + +import com.google.common.base.Function; +import com.google.common.collect.ImmutableSet; +import com.google.inject.AbstractModule; +import com.google.inject.Module; +import com.google.inject.Provides; +import org.jclouds.crypto.Crypto; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpResponse; +import org.jclouds.http.functions.ParseSax; +import org.jclouds.http.functions.ParseXMLWithJAXB; +import org.jclouds.logging.config.NullLoggingModule; +import org.jclouds.rest.AuthorizationException; +import org.jclouds.rest.BaseRestClientTest; +import org.jclouds.rest.RestContextSpec; +import org.jclouds.rest.internal.RestAnnotationProcessor; +import org.jclouds.tmrk.enterprisecloud.domain.hardware.HardwareConfiguration; +import org.jclouds.tmrk.enterprisecloud.domain.hardware.VirtualDisk; +import org.jclouds.tmrk.enterprisecloud.domain.internal.ResourceCapacity; +import org.jclouds.tmrk.enterprisecloud.domain.network.NetworkReference; +import org.jclouds.tmrk.enterprisecloud.domain.network.VirtualNic; +import org.jclouds.tmrk.enterprisecloud.features.VirtualMachineAsyncClient; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import javax.inject.Named; +import java.io.InputStream; +import java.lang.reflect.Method; +import java.net.URI; +import java.util.Set; + +import static org.jclouds.io.Payloads.newInputStreamPayload; +import static org.jclouds.rest.RestContextFactory.contextSpec; +import static org.jclouds.rest.RestContextFactory.createContextBuilder; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNotNull; + +/** + * Tests behavior of JAXB parsing for VirtualMachines + * @author Jason King + * + */ +public class HardwareConfigurationJAXBParsingTest extends BaseRestClientTest { + + @BeforeClass + void setupFactory() { + RestContextSpec contextSpec = contextSpec("test", "http://localhost:9999", "1", "", "userfoo", + "credentialFoo", String.class, Integer.class, + ImmutableSet. of(new MockModule(), new NullLoggingModule(), new AbstractModule() { + + @Override + protected void configure() {} + + @SuppressWarnings("unused") + @Provides + @Named("exception") + Set exception() { + throw new AuthorizationException(); + } + + })); + + injector = createContextBuilder(contextSpec).buildInjector(); + parserFactory = injector.getInstance(ParseSax.Factory.class); + crypto = injector.getInstance(Crypto.class); + } + + @Test(groups = "unit", testName = "HardwareConfigurationJAXBParsingTest") + public void testParse() throws Exception { + + Method method = VirtualMachineAsyncClient.class.getMethod("getHardwareConfiguration", URI.class); + HttpRequest request = factory(VirtualMachineAsyncClient.class).createRequest(method,new URI("/1")); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + + Function parser = (Function) RestAnnotationProcessor + .createResponseParser(parserFactory, injector, method, request); + + InputStream is = getClass().getResourceAsStream("/hardwareConfiguration.xml"); + HardwareConfiguration hardwareConfiguration = parser.apply(new HttpResponse(200, "ok", newInputStreamPayload(is))); + + assertHardwareConfiguration(hardwareConfiguration); + } + + private void assertHardwareConfiguration(HardwareConfiguration hardwareConfiguration) throws Exception { + assertEquals(1,hardwareConfiguration.getActions().size()); + assertEquals(1,hardwareConfiguration.getProcessorCount()); + ResourceCapacity memory = ResourceCapacity.builder().value(384).unit("MB").build(); + assertEquals(memory,hardwareConfiguration.getMemory()); + assertDisks(hardwareConfiguration.getVirtualDisks()); + assertNics(hardwareConfiguration.getVirtualNics()); + } + + private void assertDisks(Set disks) { + VirtualDisk disk = VirtualDisk.builder().index(0).name("Hard Disk 1") + .size(ResourceCapacity.builder().value(10).unit("GB").build()) + .build(); + + assertEquals(ImmutableSet.of(disk), disks); + } + + + private void assertNics(Set nics) throws Exception { + + assertEquals(1, nics.size()); + + NetworkReference network = NetworkReference.builder() + .href(new URI("/cloudapi/ecloud/networks/3936")) + .name("10.146.204.64/28") + .type("application/vnd.tmrk.cloud.network") + .networkType(NetworkReference.NetworkType.INTERNAL) + .build(); + + VirtualNic nic = VirtualNic.builder() + .macAddress("00:50:56:b8:00:58") + .name("Network adapter 1") + .network(network) + .unitNumber(7) + .build(); + assertEquals(nic,nics.iterator().next()); + } +} diff --git a/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/xml/VirtualMachineConfigurationOptionsJAXBParsingTest.java b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/xml/VirtualMachineConfigurationOptionsJAXBParsingTest.java index 0237be11d0..3897d1c1f6 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/xml/VirtualMachineConfigurationOptionsJAXBParsingTest.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/xml/VirtualMachineConfigurationOptionsJAXBParsingTest.java @@ -33,7 +33,9 @@ import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.BaseRestClientTest; import org.jclouds.rest.RestContextSpec; import org.jclouds.rest.internal.RestAnnotationProcessor; -import org.jclouds.tmrk.enterprisecloud.domain.ResourceCapacityRange; + import org.jclouds.tmrk.enterprisecloud.domain.*; +import org.jclouds.tmrk.enterprisecloud.domain.hardware.DiskConfigurationOption; +import org.jclouds.tmrk.enterprisecloud.domain.hardware.DiskConfigurationOptionRange; import org.jclouds.tmrk.enterprisecloud.domain.internal.ResourceCapacity; import org.jclouds.tmrk.enterprisecloud.domain.vm.VirtualMachineConfigurationOptions; import org.jclouds.tmrk.enterprisecloud.features.VirtualMachineAsyncClient; @@ -50,6 +52,8 @@ import static org.jclouds.io.Payloads.newInputStreamPayload; import static org.jclouds.rest.RestContextFactory.contextSpec; import static org.jclouds.rest.RestContextFactory.createContextBuilder; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; /** * Tests behavior of JAXB parsing for VirtualMachineConfigurationOptions @@ -85,7 +89,7 @@ public class VirtualMachineConfigurationOptionsJAXBParsingTest extends BaseRestC @Test public void testParseVirtualMachineWithJAXB() throws Exception { - Method method = VirtualMachineAsyncClient.class.getMethod("getVirtualMachineConfigurationOptions", URI.class); + Method method = VirtualMachineAsyncClient.class.getMethod("getConfigurationOptions", URI.class); HttpRequest request = factory(VirtualMachineAsyncClient.class).createRequest(method,new URI("/1")); assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); @@ -93,9 +97,19 @@ public class VirtualMachineConfigurationOptionsJAXBParsingTest extends BaseRestC .createResponseParser(parserFactory, injector, method, request); InputStream is = getClass().getResourceAsStream("/virtualMachineConfigurationOptions.xml"); - VirtualMachineConfigurationOptions virtualMachineConfigurationOptions = parser.apply(new HttpResponse(200, "ok", newInputStreamPayload(is))); + VirtualMachineConfigurationOptions configurationOptions = parser.apply(new HttpResponse(200, "ok", newInputStreamPayload(is))); - assertMemoryOptions(virtualMachineConfigurationOptions.getMemory()); + assertProcessorOptions(configurationOptions.getProcessor()); + assertMemoryOptions(configurationOptions.getMemory()); + assertDiskConfigurationOption(configurationOptions.getDisk()); + assertNetworkAdapterOptions(configurationOptions.getNetworkAdapter()); + assertCustomizationOption(configurationOptions.getCustomization()); + } + + private void assertProcessorOptions(ConfigurationOptionRange processor) { + assertEquals(processor.getMinimum(),1); + assertEquals(processor.getMaximum(),8); + assertEquals(processor.getStepFactor(),1); } private void assertMemoryOptions(ResourceCapacityRange memory) { @@ -103,4 +117,38 @@ public class VirtualMachineConfigurationOptionsJAXBParsingTest extends BaseRestC assertEquals(memory.getMaximumSize(), ResourceCapacity.builder().value(261120).unit("MB").build()); assertEquals(memory.getStepFactor(), ResourceCapacity.builder().value(4).unit("MB").build()); } + + private void assertNetworkAdapterOptions(ConfigurationOptionRange networkAdapter) { + assertEquals(networkAdapter.getMinimum(),1); + assertEquals(networkAdapter.getMaximum(),4); + assertEquals(networkAdapter.getStepFactor(),1); + } + + private void assertCustomizationOption(CustomizationOption customization) { + assertEquals(customization.getType(), CustomizationOption.CustomizationType.LINUX); + assertFalse(customization.canPowerOn()); + assertFalse(customization.isPasswordRequired()); + assertTrue(customization.isSshKeyRequired()); + } + + private void assertDiskConfigurationOption(DiskConfigurationOption diskConfigurationOption) { + assertEquals(diskConfigurationOption.getMinimum(),1); + assertEquals(diskConfigurationOption.getMaximum(), 15); + + ResourceCapacityRange systemDiskRange = ResourceCapacityRange.builder() + .minimumSize(ResourceCapacity.builder().value(1).unit("GB").build()) + .maximumSize(ResourceCapacity.builder().value(512).unit("GB").build()) + .stepFactor(ResourceCapacity.builder().value(1).unit("GB").build()) + .build(); + assertEquals(diskConfigurationOption.getSystemDisk(), DiskConfigurationOptionRange.builder().resourceCapacityRange(systemDiskRange).monthlyCost(0).build()); + + ResourceCapacityRange dataDiskRange = ResourceCapacityRange.builder() + .minimumSize(ResourceCapacity.builder().value(1).unit("GB").build()) + .maximumSize(ResourceCapacity.builder().value(512).unit("GB").build()) + .stepFactor(ResourceCapacity.builder().value(2).unit("GB").build()) + .build(); + + assertEquals(diskConfigurationOption.getDataDisk(), DiskConfigurationOptionRange.builder().resourceCapacityRange(dataDiskRange).monthlyCost(0).build()); + } + } diff --git a/sandbox-providers/tmrk-enterprisecloud/src/test/resources/hardwareConfiguration.xml b/sandbox-providers/tmrk-enterprisecloud/src/test/resources/hardwareConfiguration.xml new file mode 100644 index 0000000000..2eb8996f00 --- /dev/null +++ b/sandbox-providers/tmrk-enterprisecloud/src/test/resources/hardwareConfiguration.xml @@ -0,0 +1,37 @@ + + + + + 1 + + MB + 384 + + + + 0 + + GB + 10 + + Hard Disk 1 + + + + + 7 + Network adapter 1 + 00:50:56:b8:00:58 + + Internal + + + + \ No newline at end of file diff --git a/sandbox-providers/tmrk-enterprisecloud/src/test/resources/virtualMachineConfigurationOptions.xml b/sandbox-providers/tmrk-enterprisecloud/src/test/resources/virtualMachineConfigurationOptions.xml index a566b12a97..56215ee957 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/test/resources/virtualMachineConfigurationOptions.xml +++ b/sandbox-providers/tmrk-enterprisecloud/src/test/resources/virtualMachineConfigurationOptions.xml @@ -53,7 +53,7 @@ GB - 1 + 2 0