diff --git a/src/main/java/cloud/dnation/jenkins/plugins/hetzner/HetznerCloudResourceManager.java b/src/main/java/cloud/dnation/jenkins/plugins/hetzner/HetznerCloudResourceManager.java index 2da1522..a67a326 100644 --- a/src/main/java/cloud/dnation/jenkins/plugins/hetzner/HetznerCloudResourceManager.java +++ b/src/main/java/cloud/dnation/jenkins/plugins/hetzner/HetznerCloudResourceManager.java @@ -29,6 +29,7 @@ import cloud.dnation.jenkins.plugins.hetzner.client.HetznerApi; import cloud.dnation.jenkins.plugins.hetzner.client.IdentifiableResource; import cloud.dnation.jenkins.plugins.hetzner.client.Meta; +import cloud.dnation.jenkins.plugins.hetzner.client.PublicNetRequest; import cloud.dnation.jenkins.plugins.hetzner.client.ServerDetail; import cloud.dnation.jenkins.plugins.hetzner.client.SshKeyDetail; import cloud.dnation.jenkins.plugins.hetzner.connect.ConnectivityType; @@ -241,6 +242,12 @@ public HetznerServerInfo createServer(HetznerServerAgent agent) { } else { networkId = getNetworkIdForLabelExpression(agent.getTemplate().getNetwork()); } + if (ct == ConnectivityType.PRIVATE) { + final PublicNetRequest pn = new PublicNetRequest(); + pn.setEnableIpv4(false); + pn.setEnableIpv6(false); + createServerRequest.setPublicNet(pn); + } createServerRequest.setNetworks(Lists.newArrayList(networkId)); } } diff --git a/src/main/java/cloud/dnation/jenkins/plugins/hetzner/connect/AbstractConnectivity.java b/src/main/java/cloud/dnation/jenkins/plugins/hetzner/connect/AbstractConnectivity.java index 95e53ad..465de79 100644 --- a/src/main/java/cloud/dnation/jenkins/plugins/hetzner/connect/AbstractConnectivity.java +++ b/src/main/java/cloud/dnation/jenkins/plugins/hetzner/connect/AbstractConnectivity.java @@ -16,14 +16,7 @@ package cloud.dnation.jenkins.plugins.hetzner.connect; import hudson.model.AbstractDescribableImpl; -import lombok.Getter; public abstract class AbstractConnectivity extends AbstractDescribableImpl { - - public AbstractConnectivity(ConnectivityType type) { - this.type = type; - } - - @Getter - protected final transient ConnectivityType type; + public abstract ConnectivityType getType(); } diff --git a/src/main/java/cloud/dnation/jenkins/plugins/hetzner/connect/Both.java b/src/main/java/cloud/dnation/jenkins/plugins/hetzner/connect/Both.java index d638ebf..2093e3c 100644 --- a/src/main/java/cloud/dnation/jenkins/plugins/hetzner/connect/Both.java +++ b/src/main/java/cloud/dnation/jenkins/plugins/hetzner/connect/Both.java @@ -19,13 +19,14 @@ import edu.umd.cs.findbugs.annotations.NonNull; import hudson.Extension; import hudson.model.Descriptor; +import lombok.NoArgsConstructor; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; +@NoArgsConstructor(onConstructor = @__({@DataBoundConstructor})) public class Both extends AbstractConnectivity{ - @DataBoundConstructor - public Both() { - super(ConnectivityType.BOTH); + public ConnectivityType getType() { + return ConnectivityType.BOTH; } @Extension diff --git a/src/main/java/cloud/dnation/jenkins/plugins/hetzner/connect/PrivateOnly.java b/src/main/java/cloud/dnation/jenkins/plugins/hetzner/connect/PrivateOnly.java index 7169324..30ef03b 100644 --- a/src/main/java/cloud/dnation/jenkins/plugins/hetzner/connect/PrivateOnly.java +++ b/src/main/java/cloud/dnation/jenkins/plugins/hetzner/connect/PrivateOnly.java @@ -19,15 +19,15 @@ import edu.umd.cs.findbugs.annotations.NonNull; import hudson.Extension; import hudson.model.Descriptor; +import lombok.NoArgsConstructor; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; +@NoArgsConstructor(onConstructor = @__({@DataBoundConstructor})) public class PrivateOnly extends AbstractConnectivity { - @DataBoundConstructor - public PrivateOnly() { - super(ConnectivityType.PRIVATE); + public ConnectivityType getType() { + return ConnectivityType.PRIVATE; } - @Extension @Symbol("private-only") public static final class DescriptorImpl extends Descriptor { diff --git a/src/main/java/cloud/dnation/jenkins/plugins/hetzner/connect/PublicOnly.java b/src/main/java/cloud/dnation/jenkins/plugins/hetzner/connect/PublicOnly.java index c97ad62..6c59384 100644 --- a/src/main/java/cloud/dnation/jenkins/plugins/hetzner/connect/PublicOnly.java +++ b/src/main/java/cloud/dnation/jenkins/plugins/hetzner/connect/PublicOnly.java @@ -19,13 +19,14 @@ import edu.umd.cs.findbugs.annotations.NonNull; import hudson.Extension; import hudson.model.Descriptor; +import lombok.NoArgsConstructor; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; -public class PublicOnly extends AbstractConnectivity{ - @DataBoundConstructor - public PublicOnly() { - super(ConnectivityType.PUBLIC); +@NoArgsConstructor(onConstructor = @__({@DataBoundConstructor})) +public class PublicOnly extends AbstractConnectivity { + public ConnectivityType getType() { + return ConnectivityType.PUBLIC; } @Extension