{"action":"created","comment":{"url":"https://api.github.com/repos/spinnaker/clouddriver/pulls/comments/70277329","id":70277329,"diff_hunk":"@@ -37,8 +42,64 @@ class OpenstackSecurityGroup implements SecurityGroup {\n   final Set<Rule> inboundRules\n   final Set<Rule> outboundRules\n \n+  @JsonIgnore\n   @Override\n   SecurityGroupSummary getSummary() {\n     new OpenstackSecurityGroupSummary(name: name, id: id)\n   }\n+\n+  static OpenstackSecurityGroup from(SecGroupExtension securityGroup, String accountName, String region) {\n+    new OpenstackSecurityGroup(id: securityGroup.id,\n+      accountName: accountName,\n+      region: region,\n+      name: securityGroup.name,\n+      description: securityGroup.description,\n+      inboundRules: buildInboundRules(securityGroup, accountName, region)\n+    )\n+  }\n+\n+  private static List<Rule> buildInboundRules(SecGroupExtension securityGroup, String accountName, String region) {\n+    securityGroup.rules.collect { rule ->\n+      // The Openstack4J library doesn't put a type on the rule, instead, it includes a range object with a null cidr\n+      rule.range?.cidr ? buildIpRangeRule(rule) : buildSecurityGroupRule(rule, accountName, region)\n+    }\n+  }\n+\n+  private static SecurityGroupRule buildSecurityGroupRule(SecGroupExtension.Rule rule, String accountName, String region) {\n+    def portRange = new Rule.PortRange(startPort: rule.fromPort, endPort: rule.toPort)\n+    def securityGroup = new OpenstackSecurityGroup(\n+      name: rule.group.name,\n+      type: OpenstackCloudProvider.ID,\n+      accountName: accountName,\n+      region: region\n+    )\n+    new SecurityGroupRule(protocol: rule.IPProtocol.value(),\n+      portRanges: [portRange] as SortedSet,\n+      securityGroup: securityGroup\n+    )\n+  }\n+\n+  private static IpRangeRule buildIpRangeRule(SecGroupExtension.Rule rule) {\n+    def portRange = new Rule.PortRange(startPort: rule.fromPort, endPort: rule.toPort)\n+    def addressableRange = buildAddressableRangeFromCidr(rule.range.cidr)\n+    new IpRangeRule(protocol: rule.IPProtocol.value(),\n+      portRanges: [portRange] as SortedSet,\n+      range: addressableRange\n+    )\n+  }\n+\n+  private static AddressableRange buildAddressableRangeFromCidr(String cidr) {\n+    if (!cidr) {\n+      return null\n+    }\n+\n+    def rangeParts = cidr.split('/') as List\n+\n+    // If the cidr just a single IP address, use 32 as the mask\n+    if (rangeParts.size() == 1) {","path":"clouddriver-openstack/src/main/groovy/com/netflix/spinnaker/clouddriver/openstack/model/OpenstackSecurityGroup.groovy","position":76,"original_position":76,"commit_id":"395d8299de875100bc7d5b0a3ee9482bbf66541b","original_commit_id":"395d8299de875100bc7d5b0a3ee9482bbf66541b","user":{"login":"lwander","id":4874941,"avatar_url":"https://avatars.githubusercontent.com/u/4874941?v=3","gravatar_id":"","url":"https://api.github.com/users/lwander","html_url":"https://github.com/lwander","followers_url":"https://api.github.com/users/lwander/followers","following_url":"https://api.github.com/users/lwander/following{/other_user}","gists_url":"https://api.github.com/users/lwander/gists{/gist_id}","starred_url":"https://api.github.com/users/lwander/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lwander/subscriptions","organizations_url":"https://api.github.com/users/lwander/orgs","repos_url":"https://api.github.com/users/lwander/repos","events_url":"https://api.github.com/users/lwander/events{/privacy}","received_events_url":"https://api.github.com/users/lwander/received_events","type":"User","site_admin":false},"body":"Sounds good","created_at":"2016-07-11T15:14:28Z","updated_at":"2016-07-11T15:14:28Z","html_url":"https://github.com/spinnaker/clouddriver/pull/750#discussion_r70277329","pull_request_url":"https://api.github.com/repos/spinnaker/clouddriver/pulls/750","_links":{"self":{"href":"https://api.github.com/repos/spinnaker/clouddriver/pulls/comments/70277329"},"html":{"href":"https://github.com/spinnaker/clouddriver/pull/750#discussion_r70277329"},"pull_request":{"href":"https://api.github.com/repos/spinnaker/clouddriver/pulls/750"}}},"pull_request":{"url":"https://api.github.com/repos/spinnaker/clouddriver/pulls/750","id":76966477,"html_url":"https://github.com/spinnaker/clouddriver/pull/750","diff_url":"https://github.com/spinnaker/clouddriver/pull/750.diff","patch_url":"https://github.com/spinnaker/clouddriver/pull/750.patch","issue_url":"https://api.github.com/repos/spinnaker/clouddriver/issues/750","number":750,"state":"open","locked":false,"title":"Added Openstack security group caching.","user":{"login":"varikin","id":14263,"avatar_url":"https://avatars.githubusercontent.com/u/14263?v=3","gravatar_id":"","url":"https://api.github.com/users/varikin","html_url":"https://github.com/varikin","followers_url":"https://api.github.com/users/varikin/followers","following_url":"https://api.github.com/users/varikin/following{/other_user}","gists_url":"https://api.github.com/users/varikin/gists{/gist_id}","starred_url":"https://api.github.com/users/varikin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/varikin/subscriptions","organizations_url":"https://api.github.com/users/varikin/orgs","repos_url":"https://api.github.com/users/varikin/repos","events_url":"https://api.github.com/users/varikin/events{/privacy}","received_events_url":"https://api.github.com/users/varikin/received_events","type":"User","site_admin":false},"body":"Closes spinnaker/spinnaker#969","created_at":"2016-07-11T14:46:35Z","updated_at":"2016-07-11T15:14:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0deaec279118b5ab9dfb21d4b4e9f2bf58663665","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/spinnaker/clouddriver/pulls/750/commits","review_comments_url":"https://api.github.com/repos/spinnaker/clouddriver/pulls/750/comments","review_comment_url":"https://api.github.com/repos/spinnaker/clouddriver/pulls/comments{/number}","comments_url":"https://api.github.com/repos/spinnaker/clouddriver/issues/750/comments","statuses_url":"https://api.github.com/repos/spinnaker/clouddriver/statuses/395d8299de875100bc7d5b0a3ee9482bbf66541b","head":{"label":"target:feature_security_group_caching","ref":"feature_security_group_caching","sha":"395d8299de875100bc7d5b0a3ee9482bbf66541b","user":{"login":"target","id":932489,"avatar_url":"https://avatars.githubusercontent.com/u/932489?v=3","gravatar_id":"","url":"https://api.github.com/users/target","html_url":"https://github.com/target","followers_url":"https://api.github.com/users/target/followers","following_url":"https://api.github.com/users/target/following{/other_user}","gists_url":"https://api.github.com/users/target/gists{/gist_id}","starred_url":"https://api.github.com/users/target/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/target/subscriptions","organizations_url":"https://api.github.com/users/target/orgs","repos_url":"https://api.github.com/users/target/repos","events_url":"https://api.github.com/users/target/events{/privacy}","received_events_url":"https://api.github.com/users/target/received_events","type":"Organization","site_admin":false},"repo":{"id":58946721,"name":"clouddriver","full_name":"target/clouddriver","owner":{"login":"target","id":932489,"avatar_url":"https://avatars.githubusercontent.com/u/932489?v=3","gravatar_id":"","url":"https://api.github.com/users/target","html_url":"https://github.com/target","followers_url":"https://api.github.com/users/target/followers","following_url":"https://api.github.com/users/target/following{/other_user}","gists_url":"https://api.github.com/users/target/gists{/gist_id}","starred_url":"https://api.github.com/users/target/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/target/subscriptions","organizations_url":"https://api.github.com/users/target/orgs","repos_url":"https://api.github.com/users/target/repos","events_url":"https://api.github.com/users/target/events{/privacy}","received_events_url":"https://api.github.com/users/target/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/target/clouddriver","description":"read and write operations across cloud providers","fork":true,"url":"https://api.github.com/repos/target/clouddriver","forks_url":"https://api.github.com/repos/target/clouddriver/forks","keys_url":"https://api.github.com/repos/target/clouddriver/keys{/key_id}","collaborators_url":"https://api.github.com/repos/target/clouddriver/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/target/clouddriver/teams","hooks_url":"https://api.github.com/repos/target/clouddriver/hooks","issue_events_url":"https://api.github.com/repos/target/clouddriver/issues/events{/number}","events_url":"https://api.github.com/repos/target/clouddriver/events","assignees_url":"https://api.github.com/repos/target/clouddriver/assignees{/user}","branches_url":"https://api.github.com/repos/target/clouddriver/branches{/branch}","tags_url":"https://api.github.com/repos/target/clouddriver/tags","blobs_url":"https://api.github.com/repos/target/clouddriver/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/target/clouddriver/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/target/clouddriver/git/refs{/sha}","trees_url":"https://api.github.com/repos/target/clouddriver/git/trees{/sha}","statuses_url":"https://api.github.com/repos/target/clouddriver/statuses/{sha}","languages_url":"https://api.github.com/repos/target/clouddriver/languages","stargazers_url":"https://api.github.com/repos/target/clouddriver/stargazers","contributors_url":"https://api.github.com/repos/target/clouddriver/contributors","subscribers_url":"https://api.github.com/repos/target/clouddriver/subscribers","subscription_url":"https://api.github.com/repos/target/clouddriver/subscription","commits_url":"https://api.github.com/repos/target/clouddriver/commits{/sha}","git_commits_url":"https://api.github.com/repos/target/clouddriver/git/commits{/sha}","comments_url":"https://api.github.com/repos/target/clouddriver/comments{/number}","issue_comment_url":"https://api.github.com/repos/target/clouddriver/issues/comments{/number}","contents_url":"https://api.github.com/repos/target/clouddriver/contents/{+path}","compare_url":"https://api.github.com/repos/target/clouddriver/compare/{base}...{head}","merges_url":"https://api.github.com/repos/target/clouddriver/merges","archive_url":"https://api.github.com/repos/target/clouddriver/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/target/clouddriver/downloads","issues_url":"https://api.github.com/repos/target/clouddriver/issues{/number}","pulls_url":"https://api.github.com/repos/target/clouddriver/pulls{/number}","milestones_url":"https://api.github.com/repos/target/clouddriver/milestones{/number}","notifications_url":"https://api.github.com/repos/target/clouddriver/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/target/clouddriver/labels{/name}","releases_url":"https://api.github.com/repos/target/clouddriver/releases{/id}","deployments_url":"https://api.github.com/repos/target/clouddriver/deployments","created_at":"2016-05-16T16:06:08Z","updated_at":"2016-05-16T16:06:14Z","pushed_at":"2016-07-11T14:40:57Z","git_url":"git://github.com/target/clouddriver.git","ssh_url":"git@github.com:target/clouddriver.git","clone_url":"https://github.com/target/clouddriver.git","svn_url":"https://github.com/target/clouddriver","homepage":null,"size":27273,"stargazers_count":0,"watchers_count":0,"language":"Groovy","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"spinnaker:master","ref":"master","sha":"48eb169faa588e089da8da2f0aedc6b3238ad2dd","user":{"login":"spinnaker","id":7634182,"avatar_url":"https://avatars.githubusercontent.com/u/7634182?v=3","gravatar_id":"","url":"https://api.github.com/users/spinnaker","html_url":"https://github.com/spinnaker","followers_url":"https://api.github.com/users/spinnaker/followers","following_url":"https://api.github.com/users/spinnaker/following{/other_user}","gists_url":"https://api.github.com/users/spinnaker/gists{/gist_id}","starred_url":"https://api.github.com/users/spinnaker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spinnaker/subscriptions","organizations_url":"https://api.github.com/users/spinnaker/orgs","repos_url":"https://api.github.com/users/spinnaker/repos","events_url":"https://api.github.com/users/spinnaker/events{/privacy}","received_events_url":"https://api.github.com/users/spinnaker/received_events","type":"Organization","site_admin":false},"repo":{"id":37556951,"name":"clouddriver","full_name":"spinnaker/clouddriver","owner":{"login":"spinnaker","id":7634182,"avatar_url":"https://avatars.githubusercontent.com/u/7634182?v=3","gravatar_id":"","url":"https://api.github.com/users/spinnaker","html_url":"https://github.com/spinnaker","followers_url":"https://api.github.com/users/spinnaker/followers","following_url":"https://api.github.com/users/spinnaker/following{/other_user}","gists_url":"https://api.github.com/users/spinnaker/gists{/gist_id}","starred_url":"https://api.github.com/users/spinnaker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spinnaker/subscriptions","organizations_url":"https://api.github.com/users/spinnaker/orgs","repos_url":"https://api.github.com/users/spinnaker/repos","events_url":"https://api.github.com/users/spinnaker/events{/privacy}","received_events_url":"https://api.github.com/users/spinnaker/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/spinnaker/clouddriver","description":"read and write operations across cloud providers","fork":false,"url":"https://api.github.com/repos/spinnaker/clouddriver","forks_url":"https://api.github.com/repos/spinnaker/clouddriver/forks","keys_url":"https://api.github.com/repos/spinnaker/clouddriver/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spinnaker/clouddriver/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spinnaker/clouddriver/teams","hooks_url":"https://api.github.com/repos/spinnaker/clouddriver/hooks","issue_events_url":"https://api.github.com/repos/spinnaker/clouddriver/issues/events{/number}","events_url":"https://api.github.com/repos/spinnaker/clouddriver/events","assignees_url":"https://api.github.com/repos/spinnaker/clouddriver/assignees{/user}","branches_url":"https://api.github.com/repos/spinnaker/clouddriver/branches{/branch}","tags_url":"https://api.github.com/repos/spinnaker/clouddriver/tags","blobs_url":"https://api.github.com/repos/spinnaker/clouddriver/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spinnaker/clouddriver/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spinnaker/clouddriver/git/refs{/sha}","trees_url":"https://api.github.com/repos/spinnaker/clouddriver/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spinnaker/clouddriver/statuses/{sha}","languages_url":"https://api.github.com/repos/spinnaker/clouddriver/languages","stargazers_url":"https://api.github.com/repos/spinnaker/clouddriver/stargazers","contributors_url":"https://api.github.com/repos/spinnaker/clouddriver/contributors","subscribers_url":"https://api.github.com/repos/spinnaker/clouddriver/subscribers","subscription_url":"https://api.github.com/repos/spinnaker/clouddriver/subscription","commits_url":"https://api.github.com/repos/spinnaker/clouddriver/commits{/sha}","git_commits_url":"https://api.github.com/repos/spinnaker/clouddriver/git/commits{/sha}","comments_url":"https://api.github.com/repos/spinnaker/clouddriver/comments{/number}","issue_comment_url":"https://api.github.com/repos/spinnaker/clouddriver/issues/comments{/number}","contents_url":"https://api.github.com/repos/spinnaker/clouddriver/contents/{+path}","compare_url":"https://api.github.com/repos/spinnaker/clouddriver/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spinnaker/clouddriver/merges","archive_url":"https://api.github.com/repos/spinnaker/clouddriver/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spinnaker/clouddriver/downloads","issues_url":"https://api.github.com/repos/spinnaker/clouddriver/issues{/number}","pulls_url":"https://api.github.com/repos/spinnaker/clouddriver/pulls{/number}","milestones_url":"https://api.github.com/repos/spinnaker/clouddriver/milestones{/number}","notifications_url":"https://api.github.com/repos/spinnaker/clouddriver/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spinnaker/clouddriver/labels{/name}","releases_url":"https://api.github.com/repos/spinnaker/clouddriver/releases{/id}","deployments_url":"https://api.github.com/repos/spinnaker/clouddriver/deployments","created_at":"2015-06-16T21:26:02Z","updated_at":"2016-07-08T19:16:29Z","pushed_at":"2016-07-11T14:46:35Z","git_url":"git://github.com/spinnaker/clouddriver.git","ssh_url":"git@github.com:spinnaker/clouddriver.git","clone_url":"https://github.com/spinnaker/clouddriver.git","svn_url":"https://github.com/spinnaker/clouddriver","homepage":null,"size":29323,"stargazers_count":55,"watchers_count":55,"language":"Groovy","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":82,"mirror_url":null,"open_issues_count":11,"forks":82,"open_issues":11,"watchers":55,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/spinnaker/clouddriver/pulls/750"},"html":{"href":"https://github.com/spinnaker/clouddriver/pull/750"},"issue":{"href":"https://api.github.com/repos/spinnaker/clouddriver/issues/750"},"comments":{"href":"https://api.github.com/repos/spinnaker/clouddriver/issues/750/comments"},"review_comments":{"href":"https://api.github.com/repos/spinnaker/clouddriver/pulls/750/comments"},"review_comment":{"href":"https://api.github.com/repos/spinnaker/clouddriver/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/spinnaker/clouddriver/pulls/750/commits"},"statuses":{"href":"https://api.github.com/repos/spinnaker/clouddriver/statuses/395d8299de875100bc7d5b0a3ee9482bbf66541b"}}}}
{"actor":{"display_login":"lwander"}}