Package org.jclouds.googlecomputeengine.options

Examples of org.jclouds.googlecomputeengine.options.FirewallOptions


   }

   @Test(groups = "live", dependsOnMethods = "testUpdateFirewall")
   public void testPatchFirewall() {

      FirewallOptions firewall = new FirewallOptions()
              .name(FIREWALL_NAME)
              .network(getNetworkUrl(userProject.get(), FIREWALL_NETWORK_NAME))
              .allowedRules(ImmutableSet.of(
                      Firewall.Rule.builder()
                              .IpProtocol(IpProtocol.TCP)
View Full Code Here


   }

   @Test(groups = "live", dependsOnMethods = "testPatchFirewall")
   public void testGetFirewall() {

      FirewallOptions patchedFirewall = new FirewallOptions()
              .name(FIREWALL_NAME)
              .network(getNetworkUrl(userProject.get(), FIREWALL_NETWORK_NAME))
              .allowedRules(ImmutableSet.of(
                      Firewall.Rule.builder()
                              .IpProtocol(IpProtocol.TCP)
View Full Code Here

      FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
              TOKEN_RESPONSE, request, insertFirewallResponse).getFirewallApiForProject("myproject");

      assertEquals(api.createInNetwork("myfw", URI.create("https://www.googleapis" +
              ".com/compute/v1/projects/myproject/global/networks/default"),
              new FirewallOptions()
                      .addAllowedRule(Firewall.Rule.builder()
                              .IpProtocol(IpProtocol.TCP)
                              .addPort(22)
                              .addPortRange(23, 24).build())
                      .addSourceTag("tag1")
View Full Code Here

      FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
              TOKEN_RESPONSE, update,
              updateFirewallResponse).getFirewallApiForProject("myproject");

      assertEquals(api.update("myfw",
              new FirewallOptions()
                      .name("myfw")
                      .network(URI.create("https://www.googleapis" +
                              ".com/compute/v1/projects/myproject/global/networks/default"))
                      .addAllowedRule(Firewall.Rule.builder()
                              .IpProtocol(IpProtocol.TCP)
View Full Code Here

      FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
              TOKEN_RESPONSE, update,
              updateFirewallResponse).getFirewallApiForProject("myproject");

      assertEquals(api.patch("myfw",
              new FirewallOptions()
                      .name("myfw")
                      .network(URI.create("https://www.googleapis" +
                              ".com/compute/v1/projects/myproject/global/networks/default"))
                      .addAllowedRule(Firewall.Rule.builder()
                              .IpProtocol(IpProtocol.TCP)
View Full Code Here

   /**
    * {@inheritDoc}
    */
   @Override
   public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
      FirewallOptions options = (FirewallOptions) checkNotNull(postParams.get("options"), "firewallOptions");
      String name = (String) checkNotNull(postParams.get("name"), "name");
      URI network = (URI) checkNotNull(postParams.get("network"), "network");
      options.name(name);
      options.network(network);
      return bindToRequest(request, options);
   }
View Full Code Here

      for (Integer port : templateOptions.getInboundPorts()) {
         String name = naming.name(port);
         Firewall firewall = firewallApi.get(name);
         if (firewall == null) {
            ImmutableSet<Firewall.Rule> rules = ImmutableSet.of(Firewall.Rule.permitTcpRule(port), Firewall.Rule.permitUdpRule(port));
            FirewallOptions firewallOptions = new FirewallOptions()
                    .name(name)
                    .network(network.getSelfLink())
                    .allowedRules(rules)
                    .sourceTags(templateOptions.getTags())
                    .sourceRanges(of(DEFAULT_INTERNAL_NETWORK_RANGE, EXTERIOR_RANGE))
                    .targetTags(ImmutableSet.of(name));
            AtomicReference<Operation> operation = Atomics.newReference(firewallApi.createInNetwork(
                    firewallOptions.getName(),
                    network.getSelfLink(),
                    firewallOptions));
            operations.add(operation);
         }
      }
View Full Code Here

      if (api.getFirewallApiForProject(userProject.get()).list(options).concat().anyMatch(providesIpPermission(ipPermission))) {
         // Permission already exists.
         return group;
      }

      FirewallOptions fwOptions = new FirewallOptions();
      String uniqueFwName = namingConvention.createWithoutPrefix().uniqueNameForGroup(group.getName());
      fwOptions.name(uniqueFwName);
      fwOptions.network(group.getUri());
      if (!ipPermission.getGroupIds().isEmpty()) {
         fwOptions.sourceTags(ipPermission.getGroupIds());
      }
      if (!ipPermission.getCidrBlocks().isEmpty()) {
         fwOptions.sourceRanges(ipPermission.getCidrBlocks());
      }
      Firewall.Rule.Builder ruleBuilder = Firewall.Rule.builder();
      ruleBuilder.IpProtocol(ipPermission.getIpProtocol());
      if (ipPermission.getToPort() > 0) {
         ruleBuilder.addPortRange(ipPermission.getFromPort(), ipPermission.getToPort());
      }
      fwOptions.addAllowedRule(ruleBuilder.build());

      AtomicReference<Operation> operation = Atomics.newReference(api.getFirewallApiForProject(userProject
              .get()).createInNetwork(
              uniqueFwName,
              group.getUri(),
View Full Code Here

TOP

Related Classes of org.jclouds.googlecomputeengine.options.FirewallOptions

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.