Package io.fabric8.service.jclouds.firewall

Examples of io.fabric8.service.jclouds.firewall.FirewallManager


* Parses the example JSON
*/
public class ParseServiceTest {
    @Test
    public void testParseFabric8MQService() throws Exception {
        ServiceSchema service = assertParseTestFile("fmq-service.json", ServiceSchema.class);
        Integer port = service.getPort();
        assertNotNull("port", port);
        IntOrString containerPort = service.getContainerPort();
        assertNotNull("containerPort", containerPort);

        String json = KubernetesHelper.toJson(service);
        System.out.println("Got JSON: " + json);
    }
View Full Code Here


          try {
            // TODO replace with better JmxTemplate reusing the
            // Connection!!!
            JMXConnector connector = null; // TODO: find out how to improve -->  connectionWrapper.getConnector();
            if (connector == null) {
              connector = new LocalJMXConnector(connection);
            }
            Object answer = callback.doWithJmxConnector(connector);
            answerHolder[0] = answer;
          } catch (Exception e) {
            Activator.getLogger().warning("Failed to connect to JMX: " + e, e);
View Full Code Here

          try {
            // TODO replace with better JmxTemplate reusing the
            // Connection!!!
            JMXConnector connector = null; //TODO: find out how to improve -->  connectionWrapper.getConnector();
            if (connector == null) {
              connector = new LocalJMXConnector(connection);
            }
            Object answer = callback.doWithJmxConnector(connector);
            answerHolder[0] = answer;
          } catch (Exception e) {
            throw new RuntimeException(e);
View Full Code Here

          CreateJCloudsContainerOptions opts = args.withUser(args.getUser(), args.getPassword(), "admin").build();

          FabricPlugin.getLogger().debug("Compute Service: " + opts.getComputeService());

          // finally create the image
          final CreateJCloudsContainerMetadata metadata = provider.create(opts, new CreationStateListener() {
            @Override
            public void onStateChange(String message) {
              monitor.subTask(message);
            }
          });

          // on failure we don't add the cloud image to the navigator
          Throwable failure = metadata.getFailure();
          if (failure != null) {
            return new Status(Status.ERROR, FabricPlugin.PLUGIN_ID, "Failed to create Fabric: " + fabricName, failure);
          }

          // now extract the public IP from the meta data
          final StringBuilder urisBuilder = new StringBuilder();
          for(String address:metadata.getPublicAddresses()) {
            urisBuilder.append(address).append(",");
          }

          final CreateJCloudsContainerOptions.Builder arguments = args;
          Viewers.async(new Runnable() {
View Full Code Here

          args = args.computeService(computeClient);

          FabricPlugin.getLogger().debug("Creating Jclouds provider type: " + providerName);

            // we need to set the fabric user , pw and role in that way, otherwise the user is not created
          CreateJCloudsContainerOptions opts = args.withUser(args.getUser(), args.getPassword(), "admin").build();

          FabricPlugin.getLogger().debug("Compute Service: " + opts.getComputeService());

          // finally create the image
          final CreateJCloudsContainerMetadata metadata = provider.create(opts, new CreationStateListener() {
            @Override
            public void onStateChange(String message) {
View Full Code Here

            NovaFirewallSupport novafw = new NovaFirewallSupport();
            novafw.activateComponent();
            firewallManagerFactory.bindFirewallSupport(novafw);
           
          // create and activate provider
          JcloudsContainerProvider provider = new JcloudsContainerProvider();
          provider.activateComponent();
            provider.bindFirewallManagerFactory(firewallManagerFactory);

            // get and set the provider name
          String providerName = args.getProviderName();
          args = args.contextName(providerName);

          // create and set the compute service
          ComputeService computeClient = CloudDetails.createComputeService(getSelectedCloud());
          args = args.computeService(computeClient);

          FabricPlugin.getLogger().debug("Creating Jclouds provider type: " + providerName);

            // we need to set the fabric user , pw and role in that way, otherwise the user is not created
          CreateJCloudsContainerOptions opts = args.withUser(args.getUser(), args.getPassword(), "admin").build();

          FabricPlugin.getLogger().debug("Compute Service: " + opts.getComputeService());

          // finally create the image
          final CreateJCloudsContainerMetadata metadata = provider.create(opts, new CreationStateListener() {
            @Override
            public void onStateChange(String message) {
              monitor.subTask(message);
            }
          });
View Full Code Here

        options.getSystemProperties().put(ContainerProviderUtils.ADDRESSES_PROPERTY_KEY, addresses);
        options.getMetadataMap().put(containerName, jCloudsContainerMetadata);

        //Setup firwall for node
        try {
            FirewallManager firewallManager = firewallManagerFactory.getFirewallManager(computeService);
            if (firewallManager.isSupported()) {
                listener.onStateChange("Configuring firewall.");
                String source = getOriginatingIp();

                Rule httpRule = Rule.create().source("0.0.0.0/0").destination(nodeMetadata).port(8181);
                firewallManager.addRules(httpRule);

                if (source != null) {
                    Rule jmxRule = Rule.create().source(source).destination(nodeMetadata).ports(44444, 1099);
                    Rule sshRule = Rule.create().source(source).destination(nodeMetadata).port(8101);
                    Rule zookeeperRule = Rule.create().source(source).destination(nodeMetadata).port(2181);
                    firewallManager.addRules(jmxRule, sshRule, zookeeperRule);
                }
                //We do add the target node public address to the firewall rules, as a way to make things easier in cases
                //where firewall configuration is shared among nodes of the same groups, e.g. EC2.
                if (!Strings.isNullOrEmpty(publicAddress)) {
                    Rule zookeeperFromTargetRule = Rule.create().source(publicAddress + "/32").destination(nodeMetadata).port(2181);
                    firewallManager.addRule(zookeeperFromTargetRule);
                }
            } else {
                listener.onStateChange(String.format("Skipping firewall configuration. Not supported for provider %s", options.getProviderName()));
            }
        } catch (FirewallNotSupportedOnProviderException e) {
View Full Code Here

        assertValid();
        ApiFirewallSupport firewallSupport = findApiFirewallSupport(computeService);
        if (firewallSupport == null) {
            throw new FirewallNotSupportedOnProviderException("Service is currently not supported for firewall operations");
        }
        FirewallManager firewallManager = new FirewallManager(computeService, firewallSupport);
        return firewallManager;
    }
View Full Code Here

            if (computeService == null) {
                return null;

            }
            Set<String> sourceCidrs = collectCirds();
            FirewallManager firewallManager = firewallManagerFactory.getFirewallManager(computeService);

            NodeMetadata node = null;

            if (!Strings.isNullOrEmpty(targetContainerName) && getCurator().getZookeeperClient().isConnected() && fabricService != null) {
               CreateJCloudsContainerMetadata metadata = getContainerCloudMetadata(targetContainerName);
               if (metadata != null && !Strings.isNullOrEmpty(metadata.getNodeId())) {
                   targetNodeId = metadata.getNodeId();
               }
            }

            if (!Strings.isNullOrEmpty(targetNodeId)) {
              node = computeService.getNodeMetadata(targetNodeId);
            }

            if (node == null) {
                System.err.println("Could not find target node. Make sure you specified either --target-node-id or --target-container using a valid cloud container.");
                return null;
            }
            if (flush) {
                firewallManager.addRule(Rule.create().destination(node).flush());
                return null;
            }
            for (String cidr : sourceCidrs) {
                Rule rule = Rule.create().destination(node).source(cidr);

                if (port != null && port.length > 0) {
                    rule = rule.ports(port);
                }
                if (revoke) {
                    firewallManager.addRule(rule.revoke());
                } else {
                    firewallManager.addRule(rule);
                }
            }
        }
        return null;
    }
View Full Code Here

          FabricPlugin.getLogger().debug("Create cloud fabric: " + fabricName + " container: " + agentName);

          // create and activate firewall manager
          FirewallManagerFactoryImpl firewallManagerFactory = new FirewallManagerFactoryImpl();
          firewallManagerFactory.activateComponent();
          Ec2FirewallSupport ec2fw = new Ec2FirewallSupport();
          ec2fw.activateComponent();
            firewallManagerFactory.bindFirewallSupport(ec2fw);
            NovaFirewallSupport novafw = new NovaFirewallSupport();
            novafw.activateComponent();
            firewallManagerFactory.bindFirewallSupport(novafw);
           
View Full Code Here

TOP

Related Classes of io.fabric8.service.jclouds.firewall.FirewallManager

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.