Package org.jclouds.googlecomputeengine.features

Examples of org.jclouds.googlecomputeengine.features.FirewallApi



   protected void cleanUpNetworksAndFirewallsForGroup(final String groupName) {
      String resourceName = namingConvention.create().sharedNameForGroup(groupName);
      final Network network = api.getNetworkApiForProject(project.get()).get(resourceName);
      FirewallApi firewallApi = api.getFirewallApiForProject(project.get());
      Predicate<Firewall> firewallBelongsToNetwork = new Predicate<Firewall>() {
         @Override
         public boolean apply(Firewall input) {
            return input != null && input.getNetwork().equals(network.getSelfLink());
         }
      };

      Set<AtomicReference<Operation>> operations = Sets.newHashSet();
      for (Firewall firewall : firewallApi.list().concat().filter(firewallBelongsToNetwork)) {
         operations.add(new AtomicReference<Operation>(firewallApi.delete(firewall.getName())));
      }

      for (AtomicReference<Operation> operation : operations) {
         retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval,
                 MILLISECONDS).apply(operation);
View Full Code Here


    */
   private void getOrCreateFirewalls(GoogleComputeEngineTemplateOptions templateOptions, Network network,
                                     FirewallTagNamingConvention naming) {

      String projectName = userProject.get();
      FirewallApi firewallApi = api.getFirewallApiForProject(projectName);
      Set<AtomicReference<Operation>> operations = Sets.newHashSet();

      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


   protected void cleanUpNetworksAndFirewallsForGroup(final String groupName) {
      String resourceName = namingConvention.create().sharedNameForGroup(groupName);
      final Network network = api.getNetworkApiForProject(project.get()).get(resourceName);
      FirewallApi firewallApi = api.getFirewallApiForProject(project.get());
      Predicate<Firewall> firewallBelongsToNetwork = new Predicate<Firewall>() {
         @Override
         public boolean apply(Firewall input) {
            return input != null && input.getNetwork().equals(network.getSelfLink());
         }
      };

      Set<AtomicReference<Operation>> operations = Sets.newHashSet();
      for (Firewall firewall : firewallApi.list().concat().filter(firewallBelongsToNetwork)) {
         operations.add(new AtomicReference<Operation>(firewallApi.delete(firewall.getName())));
      }

      for (AtomicReference<Operation> operation : operations) {
         retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval,
                 MILLISECONDS).apply(operation);
View Full Code Here

    */
   private void getOrCreateFirewalls(GoogleComputeEngineTemplateOptions templateOptions, Network network,
                                     FirewallTagNamingConvention naming) {

      String projectName = userProject.get();
      FirewallApi firewallApi = api.getFirewallApiForProject(projectName);
      Set<AtomicReference<Operation>> operations = Sets.newHashSet();

      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 = new AtomicReference<Operation>(firewallApi.createInNetwork(
                    firewallOptions.getName(),
                    network.getSelfLink(),
                    firewallOptions));
            operations.add(operation);
         }
View Full Code Here

      };

      FirewallToIpPermission fwToPerm = new FirewallToIpPermission();

      GoogleComputeEngineApi api = createMock(GoogleComputeEngineApi.class);
      FirewallApi fwApi = createMock(FirewallApi.class);

      ListOptions options = new Builder().filter("network eq .*/jclouds-test");
      expect(api.getFirewallApiForProject(projectSupplier.get()))
              .andReturn(fwApi);
      expect(fwApi.list(options)).andReturn(PagedIterables.of(IterableWithMarkers.from(ImmutableSet.of(FirewallToIpPermissionTest.fwForTest()))));

      replay(api, fwApi);
      Network.Builder builder = Network.builder();

      builder.id("abcd");
View Full Code Here


   protected void cleanUpNetworksAndFirewallsForGroup(final String groupName) {
      String resourceName = namingConvention.create().sharedNameForGroup(groupName);
      final Network network = api.getNetworkApiForProject(project.get()).get(resourceName);
      FirewallApi firewallApi = api.getFirewallApiForProject(project.get());
      Predicate<Firewall> firewallBelongsToNetwork = new Predicate<Firewall>() {
         @Override
         public boolean apply(Firewall input) {
            return input != null && input.getNetwork().equals(network.getSelfLink());
         }
      };

      Set<AtomicReference<Operation>> operations = Sets.newHashSet();
      for (Firewall firewall : firewallApi.list().concat().filter(firewallBelongsToNetwork)) {
         operations.add(new AtomicReference<Operation>(firewallApi.delete(firewall.getName())));
      }

      for (AtomicReference<Operation> operation : operations) {
         retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval,
                 MILLISECONDS).apply(operation);
View Full Code Here

    */
   private void getOrCreateFirewalls(GoogleComputeEngineTemplateOptions templateOptions, Network network,
                                     FirewallTagNamingConvention naming) {

      String projectName = userProject.get();
      FirewallApi firewallApi = api.getFirewallApiForProject(projectName);
      Set<AtomicReference<Operation>> operations = Sets.newHashSet();

      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

TOP

Related Classes of org.jclouds.googlecomputeengine.features.FirewallApi

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.