From 2ff538813dd58ec38f07eb5eb72d607a4f6787f3 Mon Sep 17 00:00:00 2001 From: Jason King Date: Mon, 12 Dec 2011 15:14:15 +0000 Subject: [PATCH] Issue 695: Object graph for making a create virtual machine call. --- .../domain/network/DnsSettings.java | 121 ++++++++++ .../domain/network/LinuxCustomization.java | 120 ++++++++++ .../domain/network/NetworkAdapterSetting.java | 122 +++++++++++ .../network/NetworkAdapterSettings.java | 105 +++++++++ .../domain/network/NetworkSettings.java | 119 ++++++++++ .../domain/network/WindowsCustomization.java | 141 ++++++++++++ ...CreateOsTemplateVirtualMachineRequest.java | 207 ++++++++++++++++++ .../vm/CreateVirtualMachineRequest.java | 182 +++++++++++++++ 8 files changed, 1117 insertions(+) create mode 100644 sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/DnsSettings.java create mode 100644 sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/LinuxCustomization.java create mode 100644 sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/NetworkAdapterSetting.java create mode 100644 sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/NetworkAdapterSettings.java create mode 100644 sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/NetworkSettings.java create mode 100644 sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/WindowsCustomization.java create mode 100644 sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/CreateOsTemplateVirtualMachineRequest.java create mode 100644 sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/CreateVirtualMachineRequest.java diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/DnsSettings.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/DnsSettings.java new file mode 100644 index 0000000000..a1cdfa404f --- /dev/null +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/DnsSettings.java @@ -0,0 +1,121 @@ +/** + * 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.network; + +import org.jclouds.javax.annotation.Nullable; + +import javax.xml.bind.annotation.XmlElement; + +/** + * + * @author Jason King + */ +public class DnsSettings { + + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromDnsSettings(this); + } + + public static class Builder { + + private String primaryDns; + private String secondaryDns; + + /** + * @see org.jclouds.tmrk.enterprisecloud.domain.network.DnsSettings#getPrimaryDns + */ + public Builder primaryDns(String primaryDns) { + this.primaryDns = primaryDns; + return this; + } + + /** + * @see org.jclouds.tmrk.enterprisecloud.domain.network.DnsSettings#getSecondaryDns + */ + public Builder secondaryDns(String secondaryDns) { + this.secondaryDns = secondaryDns; + return this; + } + + public DnsSettings build() { + return new DnsSettings(primaryDns, secondaryDns); + } + + public Builder fromDnsSettings(DnsSettings in) { + return primaryDns(in.getPrimaryDns()).secondaryDns(in.getSecondaryDns()); + } + } + + @XmlElement(name = "PrimaryDns", required = false) + private String primaryDns; + + @XmlElement(name = "SecondaryDns", required = false) + private String secondaryDns; + + public DnsSettings(@Nullable String primaryDns, @Nullable String secondaryDns) { + this.primaryDns = primaryDns; + this.secondaryDns = secondaryDns; + } + + protected DnsSettings() { + //For JAXB + } + + @Nullable + public String getPrimaryDns() { + return primaryDns; + } + + @Nullable + public String getSecondaryDns() { + return secondaryDns; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + DnsSettings that = (DnsSettings) o; + + if (primaryDns != null ? !primaryDns.equals(that.primaryDns) : that.primaryDns != null) + return false; + if (secondaryDns != null ? !secondaryDns.equals(that.secondaryDns) : that.secondaryDns != null) + return false; + + return true; + } + + @Override + public int hashCode() { + int result = primaryDns != null ? primaryDns.hashCode() : 0; + result = 31 * result + (secondaryDns != null ? secondaryDns.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "[primaryDns="+ primaryDns +",secondaryDns="+ secondaryDns +"]"; + } +} \ No newline at end of file diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/LinuxCustomization.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/LinuxCustomization.java new file mode 100644 index 0000000000..0d4761201d --- /dev/null +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/LinuxCustomization.java @@ -0,0 +1,120 @@ +/** + * 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.network; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.tmrk.enterprisecloud.domain.internal.AnonymousResource; + +import javax.xml.bind.annotation.XmlElement; + +/** + * + * @author Jason King + */ +public class LinuxCustomization { + + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromLinuxCustomization(this); + } + + public static class Builder { + + private NetworkSettings networkSettings; + private AnonymousResource sshKey; + + /** + * @see org.jclouds.tmrk.enterprisecloud.domain.network.LinuxCustomization#getNetworkSettings + */ + public Builder networkSettings(NetworkSettings networkSettings) { + this.networkSettings = networkSettings; + return this; + } + + /** + * @see org.jclouds.tmrk.enterprisecloud.domain.network.LinuxCustomization#getSshKey + */ + public Builder sshKey(AnonymousResource sshKey) { + this.sshKey = sshKey; + return this; + } + + public LinuxCustomization build() { + return new LinuxCustomization(networkSettings, sshKey); + } + + public Builder fromLinuxCustomization(LinuxCustomization in) { + return networkSettings(in.getNetworkSettings()).sshKey(in.getSshKey()); + } + } + + @XmlElement(name = "NetworkSettings", required = false) + private NetworkSettings networkSettings; + + @XmlElement(name = "SshKey", required = false) + private AnonymousResource sshKey; + + public LinuxCustomization(@Nullable NetworkSettings networkSettings, @Nullable AnonymousResource sshKey) { + this.networkSettings = networkSettings; + this.sshKey = sshKey; + } + + private LinuxCustomization() { + //For JAXB + } + + public NetworkSettings getNetworkSettings() { + return networkSettings; + } + + public AnonymousResource getSshKey() { + return sshKey; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + LinuxCustomization that = (LinuxCustomization) o; + + if (networkSettings != null ? !networkSettings.equals(that.networkSettings) : that.networkSettings != null) + return false; + if (sshKey != null ? !sshKey.equals(that.sshKey) : that.sshKey != null) + return false; + + return true; + } + + @Override + public int hashCode() { + int result = networkSettings != null ? networkSettings.hashCode() : 0; + result = 31 * result + (sshKey != null ? sshKey.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "[networkSettings="+ networkSettings +",sshKey="+ sshKey +"]"; + } +} \ No newline at end of file diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/NetworkAdapterSetting.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/NetworkAdapterSetting.java new file mode 100644 index 0000000000..96e307b051 --- /dev/null +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/NetworkAdapterSetting.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.network; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.tmrk.enterprisecloud.domain.NamedResource; + +import javax.xml.bind.annotation.XmlElement; + +/** + * + * @author Jason King + */ +public class NetworkAdapterSetting { + + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromNetworkAdapterSetting(this); + } + + public static class Builder { + + private NamedResource network; + private String ipAddress; + + /** + * @see org.jclouds.tmrk.enterprisecloud.domain.network.NetworkAdapterSetting#getNetwork + */ + public Builder network(NamedResource network) { + this.network = network; + return this; + } + + /** + * @see org.jclouds.tmrk.enterprisecloud.domain.network.NetworkAdapterSetting#getIpAddress + */ + public Builder ipAddress(String ipAddress) { + this.ipAddress = ipAddress; + return this; + } + + public NetworkAdapterSetting build() { + return new NetworkAdapterSetting(ipAddress, network); + } + + public Builder fromNetworkAdapterSetting(NetworkAdapterSetting in) { + return ipAddress(in.getIpAddress()).network(in.getNetwork()); + } + } + + @XmlElement(name = "Network", required = false) + private NamedResource network; + + @XmlElement(name = "IpAddress", required = false) + private String ipAddress; + + public NetworkAdapterSetting(@Nullable String ipAddress, @Nullable NamedResource network) { + this.ipAddress = ipAddress; + this.network = network; + } + + protected NetworkAdapterSetting() { + //For JAXB + } + + @Nullable + public String getIpAddress() { + return ipAddress; + } + + @Nullable + public NamedResource getNetwork() { + return network; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + NetworkAdapterSetting that = (NetworkAdapterSetting) o; + + if (ipAddress != null ? !ipAddress.equals(that.ipAddress) : that.ipAddress != null) + return false; + if (network != null ? !network.equals(that.network) : that.network != null) + return false; + + return true; + } + + @Override + public int hashCode() { + int result = network != null ? network.hashCode() : 0; + result = 31 * result + (ipAddress != null ? ipAddress.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "[ipAddress="+ ipAddress +",network="+ network +"]"; + } +} \ No newline at end of file diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/NetworkAdapterSettings.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/NetworkAdapterSettings.java new file mode 100644 index 0000000000..ada4cfd429 --- /dev/null +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/NetworkAdapterSettings.java @@ -0,0 +1,105 @@ +/** + * 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.network; + +import com.google.common.collect.Sets; + +import javax.xml.bind.annotation.XmlElement; +import java.util.Collections; +import java.util.Set; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * + * @author Jason King + */ +public class NetworkAdapterSettings { + + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromNetworkAdapterSettings(this); + } + + public static class Builder { + + private Set adapters = Sets.newLinkedHashSet(); + + /** + * @see org.jclouds.tmrk.enterprisecloud.domain.network.NetworkAdapterSettings#getNetworkAdapterSettings() + */ + public Builder adapters(Set adapters) { + this.adapters = Sets.newLinkedHashSet(checkNotNull(adapters, "adapters")); + return this; + } + + public Builder addNetworkAdapterSetting(NetworkAdapterSetting adapter) { + adapters.add(checkNotNull(adapter, "adapter")); + return this; + } + + public NetworkAdapterSettings build() { + return new NetworkAdapterSettings(adapters); + } + + public Builder fromNetworkAdapterSettings(NetworkAdapterSettings in) { + return adapters(in.getNetworkAdapterSettings()); + } + } + + private NetworkAdapterSettings() { + //For JAXB and builder use + } + + private NetworkAdapterSettings(Set adapters) { + this.adapters = Sets.newLinkedHashSet(adapters); + } + + @XmlElement(name = "NetworkAdapter") + private Set adapters = Sets.newLinkedHashSet(); + + public Set getNetworkAdapterSettings() { + return Collections.unmodifiableSet(adapters); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + NetworkAdapterSettings that = (NetworkAdapterSettings) o; + + if (!adapters.equals(that.adapters)) return false; + + return true; + } + + @Override + public int hashCode() { + return adapters.hashCode(); + } + + public String toString() { + return "["+ adapters.toString()+"]"; + } +} diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/NetworkSettings.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/NetworkSettings.java new file mode 100644 index 0000000000..58bceae348 --- /dev/null +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/NetworkSettings.java @@ -0,0 +1,119 @@ +/** + * 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.network; + +import org.jclouds.javax.annotation.Nullable; + +import javax.xml.bind.annotation.XmlElement; + +/** + * + * @author Jason King + */ +public class NetworkSettings { + + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromNetworkAdapterSetting(this); + } + + public static class Builder { + + private NetworkAdapterSettings networkAdapterSettings; + private DnsSettings dnsSettings; + + /** + * @see org.jclouds.tmrk.enterprisecloud.domain.network.NetworkSettings#getNetworkAdapterSettings + */ + public Builder networkAdapterSettings(NetworkAdapterSettings networkAdapterSettings) { + this.networkAdapterSettings = networkAdapterSettings; + return this; + } + + /** + * @see org.jclouds.tmrk.enterprisecloud.domain.network.NetworkSettings#getDnsSettings + */ + public Builder dnsSettings(DnsSettings dnsSettings) { + this.dnsSettings = dnsSettings; + return this; + } + + public NetworkSettings build() { + return new NetworkSettings(networkAdapterSettings, dnsSettings); + } + + public Builder fromNetworkAdapterSetting(NetworkSettings in) { + return networkAdapterSettings(in.getNetworkAdapterSettings()).dnsSettings(in.getDnsSettings()); + } + } + + @XmlElement(name = "NetworkAdapterSettings", required = false) + private NetworkAdapterSettings networkAdapterSettings; + + @XmlElement(name = "DnsSettings", required = false) + private DnsSettings dnsSettings; + + public NetworkSettings(@Nullable NetworkAdapterSettings networkAdapterSettings, @Nullable DnsSettings dnsSettings) { + this.networkAdapterSettings = networkAdapterSettings; + this.dnsSettings = dnsSettings; + } + + protected NetworkSettings() { + //For JAXB + } + + public NetworkAdapterSettings getNetworkAdapterSettings() { + return networkAdapterSettings; + } + + public DnsSettings getDnsSettings() { + return dnsSettings; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + NetworkSettings that = (NetworkSettings) o; + + if (dnsSettings != null ? !dnsSettings.equals(that.dnsSettings) : that.dnsSettings != null) + return false; + if (networkAdapterSettings != null ? !networkAdapterSettings.equals(that.networkAdapterSettings) : that.networkAdapterSettings != null) + return false; + + return true; + } + + @Override + public int hashCode() { + int result = networkAdapterSettings != null ? networkAdapterSettings.hashCode() : 0; + result = 31 * result + (dnsSettings != null ? dnsSettings.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "[networkAdapterSettings="+ networkAdapterSettings +",dnsSettings="+ dnsSettings +"]"; + } +} \ No newline at end of file diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/WindowsCustomization.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/WindowsCustomization.java new file mode 100644 index 0000000000..9c40126e37 --- /dev/null +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/WindowsCustomization.java @@ -0,0 +1,141 @@ +/** + * 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.network; + +import org.jclouds.javax.annotation.Nullable; + +import javax.xml.bind.annotation.XmlElement; + +/** + * + * @author Jason King + */ +public class WindowsCustomization { + + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromLinuxCustomization(this); + } + + public static class Builder { + + private NetworkSettings networkSettings; + private String password; + private String licenseKey; + + /** + * @see org.jclouds.tmrk.enterprisecloud.domain.network.WindowsCustomization#getNetworkSettings + */ + public Builder networkSettings(NetworkSettings networkSettings) { + this.networkSettings = networkSettings; + return this; + } + + /** + * @see org.jclouds.tmrk.enterprisecloud.domain.network.WindowsCustomization#getPassword + */ + public Builder password(String password) { + this.password = password; + return this; + } + + /** + * @see org.jclouds.tmrk.enterprisecloud.domain.network.WindowsCustomization#getLicenseKey + */ + public Builder licenseKey(String licenseKey) { + this.licenseKey = licenseKey; + return this; + } + + public WindowsCustomization build() { + return new WindowsCustomization(networkSettings, password, licenseKey); + } + + public Builder fromLinuxCustomization(WindowsCustomization in) { + return networkSettings(in.getNetworkSettings()).password(in.getPassword()).licenseKey(in.getLicenseKey()); + } + } + + @XmlElement(name = "NetworkSettings", required = false) + private NetworkSettings networkSettings; + + @XmlElement(name = "Password", required = false) + private String password; + + @XmlElement(name = "LicenseKey", required = false) + private String licenseKey; + + public WindowsCustomization(@Nullable NetworkSettings networkSettings, @Nullable String password, @Nullable String licenseKey) { + this.networkSettings = networkSettings; + this.password = password; + this.licenseKey = licenseKey; + } + + private WindowsCustomization() { + //For JAXB + } + + public NetworkSettings getNetworkSettings() { + return networkSettings; + } + + public String getPassword() { + return password; + } + + public String getLicenseKey() { + return licenseKey; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + WindowsCustomization that = (WindowsCustomization) o; + + if (licenseKey != null ? !licenseKey.equals(that.licenseKey) : that.licenseKey != null) + return false; + if (networkSettings != null ? !networkSettings.equals(that.networkSettings) : that.networkSettings != null) + return false; + if (password != null ? !password.equals(that.password) : that.password != null) + return false; + + return true; + } + + @Override + public int hashCode() { + int result = networkSettings != null ? networkSettings.hashCode() : 0; + result = 31 * result + (password != null ? password.hashCode() : 0); + result = 31 * result + (licenseKey != null ? licenseKey.hashCode() : 0); + return result; + } + + @Override + public String toString() { + final String pw = password==null ? null : "*******"; + final String lic = licenseKey==null ? null : "*******"; + return "[networkSettings="+networkSettings+",password="+pw+",licenseKey="+lic+"]"; + } +} \ No newline at end of file diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/CreateOsTemplateVirtualMachineRequest.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/CreateOsTemplateVirtualMachineRequest.java new file mode 100644 index 0000000000..0d6c609429 --- /dev/null +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/CreateOsTemplateVirtualMachineRequest.java @@ -0,0 +1,207 @@ +/** + * 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.vm; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.tmrk.enterprisecloud.domain.LayoutRequest; +import org.jclouds.tmrk.enterprisecloud.domain.internal.ResourceCapacity; +import org.jclouds.tmrk.enterprisecloud.domain.network.LinuxCustomization; +import org.jclouds.tmrk.enterprisecloud.domain.network.WindowsCustomization; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.Set; + +/** + * + * @author Jason King + * + */ +@XmlRootElement(name = "CreateVirtualMachineRequest") +public class CreateOsTemplateVirtualMachineRequest extends CreateVirtualMachineRequest { + + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder toBuilder() { + return new Builder().fromCreateOsTemplateVirtualMachineRequest(this); + } + + public static class Builder extends CreateVirtualMachineRequest.Builder { + + private LinuxCustomization linuxCustomization; + private WindowsCustomization windowsCustomization; + private boolean poweredOn; + + /** + * @see org.jclouds.tmrk.enterprisecloud.domain.vm.CreateOsTemplateVirtualMachineRequest#getLinuxCustomization + */ + public Builder linuxCustomization(LinuxCustomization linuxCustomization) { + this.linuxCustomization = linuxCustomization; + return this; + } + + /** + * @see org.jclouds.tmrk.enterprisecloud.domain.vm.CreateOsTemplateVirtualMachineRequest#getWindowsCustomization + */ + public Builder windowsCustomization(WindowsCustomization windowsCustomization) { + this.windowsCustomization = windowsCustomization; + return this; + } + + + /** + * @see org.jclouds.tmrk.enterprisecloud.domain.vm.CreateOsTemplateVirtualMachineRequest#isPoweredOn + */ + public Builder poweredOn(boolean poweredOn) { + this.poweredOn = poweredOn; + return this; + } + + /** + * @see CreateVirtualMachineRequest#getName() + */ + public Builder name(String name) { + return Builder.class.cast(super.name(name)); + } + + /** + * @see CreateVirtualMachineRequest#getDescription() + */ + public Builder description(String description) { + return Builder.class.cast(super.description(description)); + } + + /** + * @see CreateVirtualMachineRequest#getProcessorCount() + */ + public Builder processorCount(int processorCount) { + return Builder.class.cast(super.processorCount(processorCount)); + } + + /** + * @see CreateVirtualMachineRequest#getMemory() + */ + public Builder memory(ResourceCapacity memory) { + return Builder.class.cast(super.memory(memory)); + } + + /** + * @see CreateVirtualMachineRequest#getLayout() + */ + public Builder layout(LayoutRequest layout) { + return Builder.class.cast(super.layout(layout)); + } + + /** + * @see CreateVirtualMachineRequest#getTags() + */ + public Builder tags(Set tags) { + return Builder.class.cast(super.tags(tags)); + } + + public Builder fromCreateVirtualMachineRequest(CreateVirtualMachineRequest request) { + return Builder.class.cast(super.fromCreateVirtualMachineRequest(request)); + } + + @Override + public CreateOsTemplateVirtualMachineRequest build() { + return new CreateOsTemplateVirtualMachineRequest(name, processorCount,memory, + description,layout,tags, + linuxCustomization,windowsCustomization,poweredOn); + } + + public Builder fromCreateOsTemplateVirtualMachineRequest(CreateOsTemplateVirtualMachineRequest in) { + return fromCreateVirtualMachineRequest(in) + .linuxCustomization(in.getLinuxCustomization()) + .windowsCustomization(in.getWindowsCustomization()) + .poweredOn(in.isPoweredOn()); + } + } + + @XmlElement(name = "LinuxCustomization", required = false) + private LinuxCustomization linuxCustomization; + + @XmlElement(name = "WindowsCustomization", required = false) + private WindowsCustomization windowsCustomization; + + @XmlElement(name = "PoweredOn", required = false) + private boolean poweredOn; + + + private CreateOsTemplateVirtualMachineRequest(String name, int processorCount, ResourceCapacity memory, + @Nullable String description,@Nullable LayoutRequest layout,@Nullable Set tags, + @Nullable LinuxCustomization linuxCustomization, @Nullable WindowsCustomization windowsCustomization, boolean poweredOn) { + super(name,processorCount,memory,description,layout,tags); + this.linuxCustomization = linuxCustomization; + this.windowsCustomization = windowsCustomization; + this.poweredOn = poweredOn; + } + + protected CreateOsTemplateVirtualMachineRequest() { + //For JAXB + } + + public LinuxCustomization getLinuxCustomization() { + return linuxCustomization; + } + + public WindowsCustomization getWindowsCustomization() { + return windowsCustomization; + } + + public boolean isPoweredOn() { + return poweredOn; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + CreateOsTemplateVirtualMachineRequest that = (CreateOsTemplateVirtualMachineRequest) o; + + if (poweredOn != that.poweredOn) return false; + if (linuxCustomization != null ? !linuxCustomization.equals(that.linuxCustomization) : that.linuxCustomization != null) + return false; + if (windowsCustomization != null ? !windowsCustomization.equals(that.windowsCustomization) : that.windowsCustomization != null) + return false; + + return true; + } + + @Override + public int hashCode() { + int result = linuxCustomization != null ? linuxCustomization.hashCode() : 0; + result = 31 * result + (windowsCustomization != null ? windowsCustomization.hashCode() : 0); + result = 31 * result + (poweredOn ? 1 : 0); + return result; + } + + @Override + public String string() { + return super.string()+", linuxCustomization="+linuxCustomization+", windowsCustomization="+windowsCustomization+", poweredOn="+poweredOn; + } +} \ No newline at end of file diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/CreateVirtualMachineRequest.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/CreateVirtualMachineRequest.java new file mode 100644 index 0000000000..35a156ccfb --- /dev/null +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/CreateVirtualMachineRequest.java @@ -0,0 +1,182 @@ +/** + * 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.vm; + +import com.google.common.collect.Sets; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.tmrk.enterprisecloud.domain.LayoutRequest; +import org.jclouds.tmrk.enterprisecloud.domain.internal.ResourceCapacity; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import java.util.Collections; +import java.util.Set; + +/** + * + * @author Jason King + * + */ +public class CreateVirtualMachineRequest> { + + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromCreateVirtualMachineRequest(this); + } + + public static class Builder> { + + protected String name; + protected String description; + protected int processorCount; + protected ResourceCapacity memory; + protected LayoutRequest layout; + protected Set tags = Sets.newLinkedHashSet(); + + /** + * @see CreateVirtualMachineRequest#getName() + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * @see CreateVirtualMachineRequest#getDescription() + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * @see CreateVirtualMachineRequest#getProcessorCount() + */ + public Builder processorCount(int processorCount) { + this.processorCount = processorCount; + return this; + } + + /** + * @see CreateVirtualMachineRequest#getMemory() + */ + public Builder memory(ResourceCapacity memory) { + this.memory = memory; + return this; + } + + /** + * @see CreateVirtualMachineRequest#getLayout() + */ + public Builder layout(LayoutRequest layout) { + this.layout = layout; + return this; + } + + /** + * @see CreateVirtualMachineRequest#getTags() + */ + public Builder tags(Set tags) { + this.tags = tags; + return this; + } + + public CreateVirtualMachineRequest build() { + return new CreateVirtualMachineRequest(name,processorCount,memory,description,layout,tags); + } + + public Builder fromCreateVirtualMachineRequest(CreateVirtualMachineRequest in) { + return name(in.getName()) + .processorCount(in.getProcessorCount()) + .memory(in.getMemory()) + .description(in.getDescription()) + .layout(in.getLayout()) + .tags(in.getTags()); + } + } + + @XmlAttribute(name = "name", required = true) + private String name; + + @XmlElement(name = "ProcessorCount", required = true) + private int processorCount; + + @XmlElement(name = "Memory", required = true) //Docs/Schema are contradictory - required + private ResourceCapacity memory; + + @XmlElement(name = "Layout", required = true) //Docs/Schema are contradictory - required + private LayoutRequest layout; + + @XmlElement(name = "Description", required = false) + private String description; + + @XmlElement(name = "Tags", required = true) //Might need empty element + private Set tags = Sets.newLinkedHashSet(); + + protected CreateVirtualMachineRequest(String name, int processorCount, ResourceCapacity memory, + @Nullable String description,@Nullable LayoutRequest layout,@Nullable Set tags) { + this.name = name; + this.description = description; + this.processorCount = processorCount; + this.memory = memory; + this.layout = layout; + this.tags = tags; + } + + protected CreateVirtualMachineRequest() { + //For JAXB + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + + public int getProcessorCount() { + return processorCount; + } + + public ResourceCapacity getMemory() { + return memory; + } + + public LayoutRequest getLayout() { + return layout; + } + + public Set getTags() { + return Collections.unmodifiableSet(tags); + } + + @Override + public String toString() { + return String.format("[%s]",string()); + } + + public String string() { + return "name="+name+", description="+description+", processorCount="+processorCount+", memory="+memory+", layout="+layout+", tags="+tags; + } +} \ No newline at end of file