diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/binders/BindCreateVirtualMachineKeyToXmlPayload.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/binders/BindCreateVirtualMachineKeyToXmlPayload.java
index 700cc1de37..3ed7c374ad 100644
--- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/binders/BindCreateVirtualMachineKeyToXmlPayload.java
+++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/binders/BindCreateVirtualMachineKeyToXmlPayload.java
@@ -24,9 +24,7 @@ import org.jclouds.rest.Binder;
import org.jclouds.rest.binders.BindToStringPayload;
import org.jclouds.tmrk.enterprisecloud.domain.NamedResource;
import org.jclouds.tmrk.enterprisecloud.domain.layout.LayoutRequest;
-import org.jclouds.tmrk.enterprisecloud.domain.network.LinuxCustomization;
-import org.jclouds.tmrk.enterprisecloud.domain.network.NetworkAdapterSetting;
-import org.jclouds.tmrk.enterprisecloud.domain.network.WindowsCustomization;
+import org.jclouds.tmrk.enterprisecloud.domain.network.*;
import org.jclouds.tmrk.enterprisecloud.domain.vm.CreateVirtualMachine;
import javax.inject.Inject;
@@ -135,14 +133,17 @@ public class BindCreateVirtualMachineKeyToXmlPayload implements Binder {
in = in.e("LinuxCustomization")
.e("NetworkSettings")
.e("NetworkAdapterSettings");
+
for(NetworkAdapterSetting setting:linuxCustomization.getNetworkSettings().getNetworkAdapterSettings().getNetworkAdapterSettings()) {
in = networkAdapterSetting(in,setting);
}
- //TODO DNS Settings
+ in = in.up();
+ in = dnsSettings(in, linuxCustomization.getNetworkSettings().getDnsSettings());
+
String href = linuxCustomization.getSshKey().getHref().toString();
String type = linuxCustomization.getSshKey().getType();
- return in.up().up().e("SshKey").a("href",href).a("type",type).up().up();
+ return in.up().e("SshKey").a("href",href).a("type",type).up().up();
}
private XMLBuilder networkAdapterSetting(XMLBuilder builder, NetworkAdapterSetting setting) {
@@ -155,6 +156,18 @@ public class BindCreateVirtualMachineKeyToXmlPayload implements Binder {
return builder;
}
+ private XMLBuilder dnsSettings(XMLBuilder in, DnsSettings dnsSettings) {
+ if(dnsSettings==null)return in;
+ final String primary = dnsSettings.getPrimaryDns();
+ final String secondary = dnsSettings.getSecondaryDns();
+
+ in = in.e("DnsSettings").e("PrimaryDns").t(primary).up();
+ if(secondary!=null && !secondary.isEmpty()) {
+ in = in.e("SecondaryDns").t(secondary).up();
+ }
+ return in.up();
+ }
+
private XMLBuilder windowsCustomization(XMLBuilder builder, CreateVirtualMachine vmData) {
WindowsCustomization windowsCustomization = vmData.getWindowsCustomization();
if(windowsCustomization==null) return builder;
diff --git a/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/binders/BindCreateVirtualMachineKeyToXmlPayloadTest.java b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/binders/BindCreateVirtualMachineKeyToXmlPayloadTest.java
index 7771c60112..b94e71e54d 100644
--- a/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/binders/BindCreateVirtualMachineKeyToXmlPayloadTest.java
+++ b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/binders/BindCreateVirtualMachineKeyToXmlPayloadTest.java
@@ -26,10 +26,7 @@ import org.jclouds.http.HttpRequest;
import org.jclouds.tmrk.enterprisecloud.domain.NamedResource;
import org.jclouds.tmrk.enterprisecloud.domain.internal.ResourceCapacity;
import org.jclouds.tmrk.enterprisecloud.domain.layout.LayoutRequest;
-import org.jclouds.tmrk.enterprisecloud.domain.network.LinuxCustomization;
-import org.jclouds.tmrk.enterprisecloud.domain.network.NetworkAdapterSetting;
-import org.jclouds.tmrk.enterprisecloud.domain.network.NetworkAdapterSettings;
-import org.jclouds.tmrk.enterprisecloud.domain.network.NetworkSettings;
+import org.jclouds.tmrk.enterprisecloud.domain.network.*;
import org.jclouds.tmrk.enterprisecloud.domain.vm.CreateVirtualMachine;
import org.testng.annotations.Test;
@@ -67,6 +64,10 @@ public class BindCreateVirtualMachineKeyToXmlPayloadTest {
"10.146.204.68" +
"" +
"" +
+ "" +
+ "1.2.3.4" +
+ "5.6.7.8" +
+ "" +
"" +
"" +
"" +
@@ -102,7 +103,9 @@ public class BindCreateVirtualMachineKeyToXmlPayloadTest {
NetworkAdapterSettings adapterSettings = NetworkAdapterSettings.builder()
.addNetworkAdapterSetting(adapterSetting).build();
- NetworkSettings networkSettings = NetworkSettings.builder().networkAdapterSettings(adapterSettings).build();
+ NetworkSettings networkSettings = NetworkSettings.builder().networkAdapterSettings(adapterSettings)
+ .dnsSettings(DnsSettings.builder().primaryDns("1.2.3.4").secondaryDns("5.6.7.8").build())
+ .build();
LinuxCustomization linuxCustomization = LinuxCustomization.builder()
.sshKey(sshKey)