brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] brooklyn-server pull request #276: (For Review) Effector for opening inbound...
Date Thu, 28 Jul 2016 08:52:24 GMT
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/276#discussion_r72585871
  
    --- Diff: locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/networking/NetworkingEffectors.java
---
    @@ -0,0 +1,80 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.brooklyn.location.jclouds.networking;
    +
    +import com.google.common.base.Optional;
    +import com.google.common.base.Preconditions;
    +import com.google.common.base.Predicates;
    +import com.google.common.collect.ImmutableList;
    +import com.google.common.collect.Iterables;
    +import com.google.common.collect.Range;
    +import com.google.common.reflect.TypeToken;
    +import org.apache.brooklyn.api.effector.Effector;
    +import org.apache.brooklyn.api.location.Location;
    +import org.apache.brooklyn.config.ConfigKey;
    +import org.apache.brooklyn.core.config.ConfigKeys;
    +import org.apache.brooklyn.core.effector.EffectorBody;
    +import org.apache.brooklyn.core.effector.Effectors;
    +import org.apache.brooklyn.location.jclouds.JcloudsMachineLocation;
    +import org.apache.brooklyn.util.collections.MutableList;
    +import org.apache.brooklyn.util.core.BrooklynNetworkUtils;
    +import org.apache.brooklyn.util.core.config.ConfigBag;
    +import org.apache.brooklyn.util.net.Cidr;
    +import org.jclouds.net.domain.IpPermission;
    +import org.jclouds.net.domain.IpProtocol;
    +
    +import java.util.List;
    +
    +public class NetworkingEffectors {
    +    public static final ConfigKey<List<String>> INBOUND_PORTS_EFFECTOR =
ConfigKeys.newConfigKey(new TypeToken<List<String>>() {}, "inbound.ports.effector",
    +            "Ports to open from the effector", ImmutableList.<String>of());
    +
    +    public static Effector<Void> openPortsInSecurityGroupEffector() {
    +        return Effectors.effector(Void.class, "openPortsInSecurityGroup")
    +                .parameter(INBOUND_PORTS_EFFECTOR)
    +                .description("Open ports in Cloud Security Group")
    +                .impl(new OpenPortsInSecurityGroupBody())
    +                .build();
    +    }
    +
    +    private static class OpenPortsInSecurityGroupBody extends EffectorBody<Void>
{
    +        @Override
    +        public Void call(ConfigBag parameters) {
    +            List<String> rawPortRules = parameters.get(INBOUND_PORTS_EFFECTOR);
    +            Preconditions.checkNotNull(rawPortRules, "ports cannot be null");
    +            MutableList.Builder<IpPermission> ipPermissionsBuilder = MutableList.builder();
    +            for (Range<Integer> portRule : BrooklynNetworkUtils.portRulesToRanges(rawPortRules).asRanges())
{
    +                ipPermissionsBuilder.add(
    +                        IpPermission.builder()
    +                                .ipProtocol(IpProtocol.TCP)
    --- End diff --
    
    We want this to support both UPD and TCP, so the effector to indicate which is required.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message