/** * Adds a firewall rule to the default network so that we can connect to our clients externally. */ private void createFirewall() throws IOException { Firewall firewallRule = new Firewall() .setName("cloud-loadtest-framework-firewall-rule") .setDescription("A firewall rule to allow the driver to coordinate load test instances.") .setAllowed(ImmutableList.of( new Firewall.Allowed() .setIPProtocol("tcp") .setPorts(Collections.singletonList("5000")))); try { compute.firewalls().insert(projectName, firewallRule).execute(); } catch (GoogleJsonResponseException e) { if (e.getStatusCode() != ALREADY_EXISTS) { throw e; } compute.firewalls() .update(projectName, "cloud-loadtest-framework-firewall-rule", firewallRule).execute(); } }
.setNetwork(networkUrl) .setAllowed(Collections.singletonList(allowSsh)) .setName(networkName + "-allow-ssh") .setSourceRanges(Collections.singletonList("0.0.0.0/0")); .setNetwork(networkUrl) .setAllowed(allowInteral) .setName(networkName + "-allow-internal") .setSourceRanges(Collections.singletonList("10.0.0.0/8"));
.setNetwork(networkUrl) .setAllowed(Collections.singletonList(allowSsh)) .setName(networkName + "-allow-ssh") .setSourceRanges(Collections.singletonList("0.0.0.0/0")); .setNetwork(networkUrl) .setAllowed(allowInteral) .setName(networkName + "-allow-internal") .setSourceRanges(Collections.singletonList("10.0.0.0/8"));