{"action":"created","comment":{"url":"https://api.github.com/repos/apache/brooklyn-server/pulls/comments/74433004","id":74433004,"diff_hunk":"@@ -0,0 +1,172 @@\n+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements.  See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership.  The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License.  You may obtain a copy of the License at\n+ *\n+ *     http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied.  See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+package org.apache.brooklyn.location.jclouds.networking;\n+\n+import java.util.List;\n+\n+import javax.annotation.Nullable;\n+\n+import org.apache.brooklyn.location.jclouds.BasicJcloudsLocationCustomizer;\n+import org.apache.brooklyn.location.jclouds.JcloudsLocation;\n+import org.apache.brooklyn.location.jclouds.JcloudsMachineLocation;\n+import org.apache.brooklyn.util.core.BrooklynNetworkUtils;\n+import org.apache.brooklyn.util.net.Cidr;\n+import org.jclouds.compute.ComputeService;\n+import org.jclouds.compute.domain.Template;\n+import org.jclouds.compute.options.TemplateOptions;\n+import org.jclouds.net.domain.IpPermission;\n+import org.jclouds.net.domain.IpProtocol;\n+\n+import com.google.common.base.Function;\n+import com.google.common.base.Strings;\n+import com.google.common.base.Suppliers;\n+import com.google.common.collect.FluentIterable;\n+import com.google.common.collect.Range;\n+import com.google.common.collect.RangeSet;\n+\n+/**\n+ * Configures a shared security group on Jclouds locations\n+ * <p>\n+ * Is based on {@link JcloudsLocationSecurityGroupCustomizer} but can be instantiated\n+ * in yaml e.g.\n+ * <p>\n+ * services:\n+ * - type: org.apache.brooklyn.entity.software.base.EmptySoftwareProcess\n+ * brooklyn.config:\n+ * provisioning.properties:\n+ * customizers:\n+ * - $brooklyn:object:\n+ * type: org.apache.brooklyn.location.jclouds.networking.SharedLocationSecurityGroupCustomizer\n+ * object.fields: {locationName: \"test\", portRanges: [\"900-910\",\"915\", \"22\"], cidr: \"82.40.153.101/24\"}\n+ */\n+public class SharedLocationSecurityGroupCustomizer extends BasicJcloudsLocationCustomizer {\n+\n+    private String locationName = null;\n+\n+    private List<String> portRanges = null;\n+\n+    private String cidr = null;\n+\n+    /**\n+     * We track inbound ports from the template to open them once we've created the new\n+     * security groups\n+     */\n+    private int[] inboundPorts;\n+\n+    /**\n+     * The location name is appended to the name of the shared SG - use if you need distinct shared SGs within the same location\n+     *\n+     * @param locationName appended to the name of the SG\n+     */\n+    public void setLocationName(String locationName) {\n+        this.locationName = locationName;\n+    }\n+\n+    /**\n+     * Extra ports to be opened on the entities in the SG\n+     *\n+     * @param portRanges\n+     */\n+    public void setPortRanges(List<String> portRanges) {\n+        this.portRanges = portRanges;\n+    }\n+\n+    /**\n+     * Set to restict the range that the ports that are to be opened can be accessed from\n+     *\n+     * @param cidr\n+     */\n+    public void setCidr(String cidr) {\n+        this.cidr = cidr;\n+    }\n+\n+    @Override\n+    public void customize(JcloudsLocation location, ComputeService computeService, TemplateOptions templateOptions) {\n+        super.customize(location, computeService, templateOptions);\n+        inboundPorts = templateOptions.getInboundPorts();\n+    }\n+\n+    @Override\n+    public void customize(JcloudsLocation location, ComputeService computeService, Template template) {","path":"locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/networking/SharedLocationSecurityGroupCustomizer.java","position":106,"original_position":106,"commit_id":"304a79ab18f57e446d0134de01de2cec7580ef3f","original_commit_id":"304a79ab18f57e446d0134de01de2cec7580ef3f","user":{"login":"neykov","id":3612111,"avatar_url":"https://avatars.githubusercontent.com/u/3612111?v=3","gravatar_id":"","url":"https://api.github.com/users/neykov","html_url":"https://github.com/neykov","followers_url":"https://api.github.com/users/neykov/followers","following_url":"https://api.github.com/users/neykov/following{/other_user}","gists_url":"https://api.github.com/users/neykov/gists{/gist_id}","starred_url":"https://api.github.com/users/neykov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neykov/subscriptions","organizations_url":"https://api.github.com/users/neykov/orgs","repos_url":"https://api.github.com/users/neykov/repos","events_url":"https://api.github.com/users/neykov/events{/privacy}","received_events_url":"https://api.github.com/users/neykov/received_events","type":"User","site_admin":false},"body":"Nit: One would usually override one or the other method (above one and this one) - they are called in succession with the above one being just a convenience, see https://github.com/apache/brooklyn-server/blob/master/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java#L1540-L1541.","created_at":"2016-08-11T14:31:43Z","updated_at":"2016-08-11T14:31:43Z","html_url":"https://github.com/apache/brooklyn-server/pull/292#discussion_r74433004","pull_request_url":"https://api.github.com/repos/apache/brooklyn-server/pulls/292","_links":{"self":{"href":"https://api.github.com/repos/apache/brooklyn-server/pulls/comments/74433004"},"html":{"href":"https://github.com/apache/brooklyn-server/pull/292#discussion_r74433004"},"pull_request":{"href":"https://api.github.com/repos/apache/brooklyn-server/pulls/292"}}},"pull_request":{"url":"https://api.github.com/repos/apache/brooklyn-server/pulls/292","id":80448506,"html_url":"https://github.com/apache/brooklyn-server/pull/292","diff_url":"https://github.com/apache/brooklyn-server/pull/292.diff","patch_url":"https://github.com/apache/brooklyn-server/pull/292.patch","issue_url":"https://api.github.com/repos/apache/brooklyn-server/issues/292","number":292,"state":"open","locked":false,"title":"Shared location customizer","user":{"login":"duncangrant","id":770352,"avatar_url":"https://avatars.githubusercontent.com/u/770352?v=3","gravatar_id":"","url":"https://api.github.com/users/duncangrant","html_url":"https://github.com/duncangrant","followers_url":"https://api.github.com/users/duncangrant/followers","following_url":"https://api.github.com/users/duncangrant/following{/other_user}","gists_url":"https://api.github.com/users/duncangrant/gists{/gist_id}","starred_url":"https://api.github.com/users/duncangrant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duncangrant/subscriptions","organizations_url":"https://api.github.com/users/duncangrant/orgs","repos_url":"https://api.github.com/users/duncangrant/repos","events_url":"https://api.github.com/users/duncangrant/events{/privacy}","received_events_url":"https://api.github.com/users/duncangrant/received_events","type":"User","site_admin":false},"body":"A location customizer that creates a single shared security group for each entity it is applied to as well as an individual entity.  The shared entity allows full tcp and udp traffic within members of the group.\r\n\r\nThis PR includes 85c65ed078060cd01f74732b7cc4bddef8a58006 from @bostko 's #276.\r\n\r\nThe implementation use the JcloudsLocationSecurityGroupCustomizer but has a no arg constructor so can be used in yaml.","created_at":"2016-08-08T13:13:05Z","updated_at":"2016-08-11T14:31:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e2df8b304f3a4c5f75815efa9829a4ba0db64df3","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/brooklyn-server/pulls/292/commits","review_comments_url":"https://api.github.com/repos/apache/brooklyn-server/pulls/292/comments","review_comment_url":"https://api.github.com/repos/apache/brooklyn-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/brooklyn-server/issues/292/comments","statuses_url":"https://api.github.com/repos/apache/brooklyn-server/statuses/304a79ab18f57e446d0134de01de2cec7580ef3f","head":{"label":"duncangrant:extra-customizer","ref":"extra-customizer","sha":"304a79ab18f57e446d0134de01de2cec7580ef3f","user":{"login":"duncangrant","id":770352,"avatar_url":"https://avatars.githubusercontent.com/u/770352?v=3","gravatar_id":"","url":"https://api.github.com/users/duncangrant","html_url":"https://github.com/duncangrant","followers_url":"https://api.github.com/users/duncangrant/followers","following_url":"https://api.github.com/users/duncangrant/following{/other_user}","gists_url":"https://api.github.com/users/duncangrant/gists{/gist_id}","starred_url":"https://api.github.com/users/duncangrant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duncangrant/subscriptions","organizations_url":"https://api.github.com/users/duncangrant/orgs","repos_url":"https://api.github.com/users/duncangrant/repos","events_url":"https://api.github.com/users/duncangrant/events{/privacy}","received_events_url":"https://api.github.com/users/duncangrant/received_events","type":"User","site_admin":false},"repo":{"id":58385058,"name":"brooklyn-server","full_name":"duncangrant/brooklyn-server","owner":{"login":"duncangrant","id":770352,"avatar_url":"https://avatars.githubusercontent.com/u/770352?v=3","gravatar_id":"","url":"https://api.github.com/users/duncangrant","html_url":"https://github.com/duncangrant","followers_url":"https://api.github.com/users/duncangrant/followers","following_url":"https://api.github.com/users/duncangrant/following{/other_user}","gists_url":"https://api.github.com/users/duncangrant/gists{/gist_id}","starred_url":"https://api.github.com/users/duncangrant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duncangrant/subscriptions","organizations_url":"https://api.github.com/users/duncangrant/orgs","repos_url":"https://api.github.com/users/duncangrant/repos","events_url":"https://api.github.com/users/duncangrant/events{/privacy}","received_events_url":"https://api.github.com/users/duncangrant/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/duncangrant/brooklyn-server","description":"Mirror of Apache Brooklyn server","fork":true,"url":"https://api.github.com/repos/duncangrant/brooklyn-server","forks_url":"https://api.github.com/repos/duncangrant/brooklyn-server/forks","keys_url":"https://api.github.com/repos/duncangrant/brooklyn-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/duncangrant/brooklyn-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/duncangrant/brooklyn-server/teams","hooks_url":"https://api.github.com/repos/duncangrant/brooklyn-server/hooks","issue_events_url":"https://api.github.com/repos/duncangrant/brooklyn-server/issues/events{/number}","events_url":"https://api.github.com/repos/duncangrant/brooklyn-server/events","assignees_url":"https://api.github.com/repos/duncangrant/brooklyn-server/assignees{/user}","branches_url":"https://api.github.com/repos/duncangrant/brooklyn-server/branches{/branch}","tags_url":"https://api.github.com/repos/duncangrant/brooklyn-server/tags","blobs_url":"https://api.github.com/repos/duncangrant/brooklyn-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/duncangrant/brooklyn-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/duncangrant/brooklyn-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/duncangrant/brooklyn-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/duncangrant/brooklyn-server/statuses/{sha}","languages_url":"https://api.github.com/repos/duncangrant/brooklyn-server/languages","stargazers_url":"https://api.github.com/repos/duncangrant/brooklyn-server/stargazers","contributors_url":"https://api.github.com/repos/duncangrant/brooklyn-server/contributors","subscribers_url":"https://api.github.com/repos/duncangrant/brooklyn-server/subscribers","subscription_url":"https://api.github.com/repos/duncangrant/brooklyn-server/subscription","commits_url":"https://api.github.com/repos/duncangrant/brooklyn-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/duncangrant/brooklyn-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/duncangrant/brooklyn-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/duncangrant/brooklyn-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/duncangrant/brooklyn-server/contents/{+path}","compare_url":"https://api.github.com/repos/duncangrant/brooklyn-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/duncangrant/brooklyn-server/merges","archive_url":"https://api.github.com/repos/duncangrant/brooklyn-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/duncangrant/brooklyn-server/downloads","issues_url":"https://api.github.com/repos/duncangrant/brooklyn-server/issues{/number}","pulls_url":"https://api.github.com/repos/duncangrant/brooklyn-server/pulls{/number}","milestones_url":"https://api.github.com/repos/duncangrant/brooklyn-server/milestones{/number}","notifications_url":"https://api.github.com/repos/duncangrant/brooklyn-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/duncangrant/brooklyn-server/labels{/name}","releases_url":"https://api.github.com/repos/duncangrant/brooklyn-server/releases{/id}","deployments_url":"https://api.github.com/repos/duncangrant/brooklyn-server/deployments","created_at":"2016-05-09T14:56:51Z","updated_at":"2016-05-09T14:57:00Z","pushed_at":"2016-08-08T13:09:51Z","git_url":"git://github.com/duncangrant/brooklyn-server.git","ssh_url":"git@github.com:duncangrant/brooklyn-server.git","clone_url":"https://github.com/duncangrant/brooklyn-server.git","svn_url":"https://github.com/duncangrant/brooklyn-server","homepage":null,"size":30693,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"ddb6acc9238d0ea6fe2a02016d2983d089aacdba","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":47246081,"name":"brooklyn-server","full_name":"apache/brooklyn-server","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/brooklyn-server","description":"Mirror of Apache Brooklyn server","fork":false,"url":"https://api.github.com/repos/apache/brooklyn-server","forks_url":"https://api.github.com/repos/apache/brooklyn-server/forks","keys_url":"https://api.github.com/repos/apache/brooklyn-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/brooklyn-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/brooklyn-server/teams","hooks_url":"https://api.github.com/repos/apache/brooklyn-server/hooks","issue_events_url":"https://api.github.com/repos/apache/brooklyn-server/issues/events{/number}","events_url":"https://api.github.com/repos/apache/brooklyn-server/events","assignees_url":"https://api.github.com/repos/apache/brooklyn-server/assignees{/user}","branches_url":"https://api.github.com/repos/apache/brooklyn-server/branches{/branch}","tags_url":"https://api.github.com/repos/apache/brooklyn-server/tags","blobs_url":"https://api.github.com/repos/apache/brooklyn-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/brooklyn-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/brooklyn-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/brooklyn-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/brooklyn-server/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/brooklyn-server/languages","stargazers_url":"https://api.github.com/repos/apache/brooklyn-server/stargazers","contributors_url":"https://api.github.com/repos/apache/brooklyn-server/contributors","subscribers_url":"https://api.github.com/repos/apache/brooklyn-server/subscribers","subscription_url":"https://api.github.com/repos/apache/brooklyn-server/subscription","commits_url":"https://api.github.com/repos/apache/brooklyn-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/brooklyn-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/brooklyn-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/brooklyn-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/brooklyn-server/contents/{+path}","compare_url":"https://api.github.com/repos/apache/brooklyn-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/brooklyn-server/merges","archive_url":"https://api.github.com/repos/apache/brooklyn-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/brooklyn-server/downloads","issues_url":"https://api.github.com/repos/apache/brooklyn-server/issues{/number}","pulls_url":"https://api.github.com/repos/apache/brooklyn-server/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/brooklyn-server/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/brooklyn-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/brooklyn-server/labels{/name}","releases_url":"https://api.github.com/repos/apache/brooklyn-server/releases{/id}","deployments_url":"https://api.github.com/repos/apache/brooklyn-server/deployments","created_at":"2015-12-02T08:00:06Z","updated_at":"2016-05-30T11:46:29Z","pushed_at":"2016-08-11T13:59:28Z","git_url":"git://github.com/apache/brooklyn-server.git","ssh_url":"git@github.com:apache/brooklyn-server.git","clone_url":"https://github.com/apache/brooklyn-server.git","svn_url":"https://github.com/apache/brooklyn-server","homepage":null,"size":30987,"stargazers_count":10,"watchers_count":10,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":35,"mirror_url":"git://git.apache.org/brooklyn-server.git","open_issues_count":20,"forks":35,"open_issues":20,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/brooklyn-server/pulls/292"},"html":{"href":"https://github.com/apache/brooklyn-server/pull/292"},"issue":{"href":"https://api.github.com/repos/apache/brooklyn-server/issues/292"},"comments":{"href":"https://api.github.com/repos/apache/brooklyn-server/issues/292/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/brooklyn-server/pulls/292/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/brooklyn-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/brooklyn-server/pulls/292/commits"},"statuses":{"href":"https://api.github.com/repos/apache/brooklyn-server/statuses/304a79ab18f57e446d0134de01de2cec7580ef3f"}}}}
{"actor":{"display_login":"neykov"}}