{"action":"created","comment":{"url":"https://api.github.com/repos/allegro/ralph_pricing/pulls/comments/77631037","id":77631037,"diff_hunk":"@@ -0,0 +1,190 @@\n+# -*- coding: utf-8 -*-\n+\n+from __future__ import absolute_import\n+from __future__ import division\n+from __future__ import print_function\n+from __future__ import unicode_literals\n+\n+import datetime\n+import logging\n+\n+from ralph_scrooge.models import (\n+    PRICING_OBJECT_TYPES,\n+    PricingObject,\n+    PricingObjectModel,\n+    ServiceEnvironment,\n+    VIPInfo,\n+)\n+from ralph_scrooge.plugins.collect._exceptions import (\n+    UnknownServiceEnvironmentNotConfiguredError,\n+)\n+from ralph_scrooge.plugins.collect.utils import get_unknown_service_env\n+\n+from pyhermes.decorators import subscriber\n+\n+logger = logging.getLogger(__name__)\n+\n+\n+def validate_vip_event_data(data):\n+    \"\"\"Performs some basic sanity checks (e.g. missing values) on the incoming\n+    event data. Returns list of errors (if any).\n+\n+    This function is copied from Ralph3 (data_center.subscribers), with slight\n+    modifications.\n+    \"\"\"\n+    id = data['id']\n+    name = data['name']\n+    ip = data['ip']\n+    port = data['port']\n+    protocol = data['protocol']\n+    service = data['service']\n+    if service:\n+        service_uid = service.get('uid')\n+    else:\n+        service_uid = None\n+    environment = data['environment']\n+    lb_type = data['load_balancer_type']\n+    errors = []\n+\n+    if not id:\n+        err = 'missing id'\n+        errors.append(err)\n+    if not name:\n+        err = 'missing name'\n+        errors.append(err)\n+    if not ip:\n+        err = 'missing IP address'\n+        # unlike in Ralph3, we don't check if such address is valid!\n+        errors.append(err)\n+    if not port or port < 1024 or port > 49151:\n+        err = 'invalid port \"{}\"'.format(port)\n+        errors.append(err)\n+    if not protocol:\n+        err = 'missing protocol'\n+        errors.append(err)\n+    if not service_uid:\n+        err = 'missing service UID'\n+        errors.append(err)\n+    if not environment:\n+        err = 'missing environment'\n+        errors.append(err)\n+    if not lb_type:\n+        err = 'missing load_balancer_type'\n+        errors.append(err)\n+    return errors\n+\n+\n+def normalize_lb_type(lb_type):\n+    # XXX(xor-xor): What about standarizing these names between external","path":"src/ralph_scrooge/plugins/subscribers/ralph3_vip.py","position":78,"original_position":78,"commit_id":"e03c076303f418e9d0a478bfd0914c9958376508","original_commit_id":"e03c076303f418e9d0a478bfd0914c9958376508","user":{"login":"mkurek","id":107437,"avatar_url":"https://avatars.githubusercontent.com/u/107437?v=3","gravatar_id":"","url":"https://api.github.com/users/mkurek","html_url":"https://github.com/mkurek","followers_url":"https://api.github.com/users/mkurek/followers","following_url":"https://api.github.com/users/mkurek/following{/other_user}","gists_url":"https://api.github.com/users/mkurek/gists{/gist_id}","starred_url":"https://api.github.com/users/mkurek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkurek/subscriptions","organizations_url":"https://api.github.com/users/mkurek/orgs","repos_url":"https://api.github.com/users/mkurek/repos","events_url":"https://api.github.com/users/mkurek/events{/privacy}","received_events_url":"https://api.github.com/users/mkurek/received_events","type":"User","site_admin":false},"body":"i'd store it in settings","created_at":"2016-09-06T13:13:26Z","updated_at":"2016-09-06T13:13:26Z","html_url":"https://github.com/allegro/ralph_pricing/pull/495#discussion_r77631037","pull_request_url":"https://api.github.com/repos/allegro/ralph_pricing/pulls/495","_links":{"self":{"href":"https://api.github.com/repos/allegro/ralph_pricing/pulls/comments/77631037"},"html":{"href":"https://github.com/allegro/ralph_pricing/pull/495#discussion_r77631037"},"pull_request":{"href":"https://api.github.com/repos/allegro/ralph_pricing/pulls/495"}}},"pull_request":{"url":"https://api.github.com/repos/allegro/ralph_pricing/pulls/495","id":84109974,"html_url":"https://github.com/allegro/ralph_pricing/pull/495","diff_url":"https://github.com/allegro/ralph_pricing/pull/495.diff","patch_url":"https://github.com/allegro/ralph_pricing/pull/495.patch","issue_url":"https://api.github.com/repos/allegro/ralph_pricing/issues/495","number":495,"state":"open","locked":false,"title":"[switch to R3] Add ralph3_vip plugin.","user":{"login":"xor-xor","id":2082842,"avatar_url":"https://avatars.githubusercontent.com/u/2082842?v=3","gravatar_id":"","url":"https://api.github.com/users/xor-xor","html_url":"https://github.com/xor-xor","followers_url":"https://api.github.com/users/xor-xor/followers","following_url":"https://api.github.com/users/xor-xor/following{/other_user}","gists_url":"https://api.github.com/users/xor-xor/gists{/gist_id}","starred_url":"https://api.github.com/users/xor-xor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xor-xor/subscriptions","organizations_url":"https://api.github.com/users/xor-xor/orgs","repos_url":"https://api.github.com/users/xor-xor/repos","events_url":"https://api.github.com/users/xor-xor/events{/privacy}","received_events_url":"https://api.github.com/users/xor-xor/received_events","type":"User","site_admin":false},"body":"**Preview only! Do no merge it yet!**\r\n\r\nThis PR provides a new plugin for VIPs, which is kind of different than the rest, because it is more of a view than a plugin launched from comand line. It basically provides a dedicated endpoint, subscribes it to `refreshVipEvent` in Hermes and processes received data in real time, so in contrast to \"normal\" plugins, there's no distinction when it starts/finishes.\r\n\r\nIt also makes `get_unknown_service_env` function more generic, and moves it  to `plugins.collect.utils` (from `ralph3_asset` plugin).","created_at":"2016-09-06T12:05:35Z","updated_at":"2016-09-06T13:13:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6760809dfb2c5c03f271333eebbfc97800129360","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/allegro/ralph_pricing/pulls/495/commits","review_comments_url":"https://api.github.com/repos/allegro/ralph_pricing/pulls/495/comments","review_comment_url":"https://api.github.com/repos/allegro/ralph_pricing/pulls/comments{/number}","comments_url":"https://api.github.com/repos/allegro/ralph_pricing/issues/495/comments","statuses_url":"https://api.github.com/repos/allegro/ralph_pricing/statuses/e03c076303f418e9d0a478bfd0914c9958376508","head":{"label":"xor-xor:vip-plugin","ref":"vip-plugin","sha":"e03c076303f418e9d0a478bfd0914c9958376508","user":{"login":"xor-xor","id":2082842,"avatar_url":"https://avatars.githubusercontent.com/u/2082842?v=3","gravatar_id":"","url":"https://api.github.com/users/xor-xor","html_url":"https://github.com/xor-xor","followers_url":"https://api.github.com/users/xor-xor/followers","following_url":"https://api.github.com/users/xor-xor/following{/other_user}","gists_url":"https://api.github.com/users/xor-xor/gists{/gist_id}","starred_url":"https://api.github.com/users/xor-xor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xor-xor/subscriptions","organizations_url":"https://api.github.com/users/xor-xor/orgs","repos_url":"https://api.github.com/users/xor-xor/repos","events_url":"https://api.github.com/users/xor-xor/events{/privacy}","received_events_url":"https://api.github.com/users/xor-xor/received_events","type":"User","site_admin":false},"repo":{"id":64742322,"name":"ralph_pricing","full_name":"xor-xor/ralph_pricing","owner":{"login":"xor-xor","id":2082842,"avatar_url":"https://avatars.githubusercontent.com/u/2082842?v=3","gravatar_id":"","url":"https://api.github.com/users/xor-xor","html_url":"https://github.com/xor-xor","followers_url":"https://api.github.com/users/xor-xor/followers","following_url":"https://api.github.com/users/xor-xor/following{/other_user}","gists_url":"https://api.github.com/users/xor-xor/gists{/gist_id}","starred_url":"https://api.github.com/users/xor-xor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xor-xor/subscriptions","organizations_url":"https://api.github.com/users/xor-xor/orgs","repos_url":"https://api.github.com/users/xor-xor/repos","events_url":"https://api.github.com/users/xor-xor/events{/privacy}","received_events_url":"https://api.github.com/users/xor-xor/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/xor-xor/ralph_pricing","description":"A pricing module for Ralph","fork":true,"url":"https://api.github.com/repos/xor-xor/ralph_pricing","forks_url":"https://api.github.com/repos/xor-xor/ralph_pricing/forks","keys_url":"https://api.github.com/repos/xor-xor/ralph_pricing/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xor-xor/ralph_pricing/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xor-xor/ralph_pricing/teams","hooks_url":"https://api.github.com/repos/xor-xor/ralph_pricing/hooks","issue_events_url":"https://api.github.com/repos/xor-xor/ralph_pricing/issues/events{/number}","events_url":"https://api.github.com/repos/xor-xor/ralph_pricing/events","assignees_url":"https://api.github.com/repos/xor-xor/ralph_pricing/assignees{/user}","branches_url":"https://api.github.com/repos/xor-xor/ralph_pricing/branches{/branch}","tags_url":"https://api.github.com/repos/xor-xor/ralph_pricing/tags","blobs_url":"https://api.github.com/repos/xor-xor/ralph_pricing/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xor-xor/ralph_pricing/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xor-xor/ralph_pricing/git/refs{/sha}","trees_url":"https://api.github.com/repos/xor-xor/ralph_pricing/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xor-xor/ralph_pricing/statuses/{sha}","languages_url":"https://api.github.com/repos/xor-xor/ralph_pricing/languages","stargazers_url":"https://api.github.com/repos/xor-xor/ralph_pricing/stargazers","contributors_url":"https://api.github.com/repos/xor-xor/ralph_pricing/contributors","subscribers_url":"https://api.github.com/repos/xor-xor/ralph_pricing/subscribers","subscription_url":"https://api.github.com/repos/xor-xor/ralph_pricing/subscription","commits_url":"https://api.github.com/repos/xor-xor/ralph_pricing/commits{/sha}","git_commits_url":"https://api.github.com/repos/xor-xor/ralph_pricing/git/commits{/sha}","comments_url":"https://api.github.com/repos/xor-xor/ralph_pricing/comments{/number}","issue_comment_url":"https://api.github.com/repos/xor-xor/ralph_pricing/issues/comments{/number}","contents_url":"https://api.github.com/repos/xor-xor/ralph_pricing/contents/{+path}","compare_url":"https://api.github.com/repos/xor-xor/ralph_pricing/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xor-xor/ralph_pricing/merges","archive_url":"https://api.github.com/repos/xor-xor/ralph_pricing/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xor-xor/ralph_pricing/downloads","issues_url":"https://api.github.com/repos/xor-xor/ralph_pricing/issues{/number}","pulls_url":"https://api.github.com/repos/xor-xor/ralph_pricing/pulls{/number}","milestones_url":"https://api.github.com/repos/xor-xor/ralph_pricing/milestones{/number}","notifications_url":"https://api.github.com/repos/xor-xor/ralph_pricing/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xor-xor/ralph_pricing/labels{/name}","releases_url":"https://api.github.com/repos/xor-xor/ralph_pricing/releases{/id}","deployments_url":"https://api.github.com/repos/xor-xor/ralph_pricing/deployments","created_at":"2016-08-02T09:12:33Z","updated_at":"2016-08-02T09:12:34Z","pushed_at":"2016-09-06T11:49:26Z","git_url":"git://github.com/xor-xor/ralph_pricing.git","ssh_url":"git@github.com:xor-xor/ralph_pricing.git","clone_url":"https://github.com/xor-xor/ralph_pricing.git","svn_url":"https://github.com/xor-xor/ralph_pricing","homepage":null,"size":5249,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"allegro:develop","ref":"develop","sha":"7290816680cba82761b08072afc3cac4d7e3711f","user":{"login":"allegro","id":562236,"avatar_url":"https://avatars.githubusercontent.com/u/562236?v=3","gravatar_id":"","url":"https://api.github.com/users/allegro","html_url":"https://github.com/allegro","followers_url":"https://api.github.com/users/allegro/followers","following_url":"https://api.github.com/users/allegro/following{/other_user}","gists_url":"https://api.github.com/users/allegro/gists{/gist_id}","starred_url":"https://api.github.com/users/allegro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allegro/subscriptions","organizations_url":"https://api.github.com/users/allegro/orgs","repos_url":"https://api.github.com/users/allegro/repos","events_url":"https://api.github.com/users/allegro/events{/privacy}","received_events_url":"https://api.github.com/users/allegro/received_events","type":"Organization","site_admin":false},"repo":{"id":9495095,"name":"ralph_pricing","full_name":"allegro/ralph_pricing","owner":{"login":"allegro","id":562236,"avatar_url":"https://avatars.githubusercontent.com/u/562236?v=3","gravatar_id":"","url":"https://api.github.com/users/allegro","html_url":"https://github.com/allegro","followers_url":"https://api.github.com/users/allegro/followers","following_url":"https://api.github.com/users/allegro/following{/other_user}","gists_url":"https://api.github.com/users/allegro/gists{/gist_id}","starred_url":"https://api.github.com/users/allegro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allegro/subscriptions","organizations_url":"https://api.github.com/users/allegro/orgs","repos_url":"https://api.github.com/users/allegro/repos","events_url":"https://api.github.com/users/allegro/events{/privacy}","received_events_url":"https://api.github.com/users/allegro/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/allegro/ralph_pricing","description":"A pricing module for Ralph","fork":false,"url":"https://api.github.com/repos/allegro/ralph_pricing","forks_url":"https://api.github.com/repos/allegro/ralph_pricing/forks","keys_url":"https://api.github.com/repos/allegro/ralph_pricing/keys{/key_id}","collaborators_url":"https://api.github.com/repos/allegro/ralph_pricing/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/allegro/ralph_pricing/teams","hooks_url":"https://api.github.com/repos/allegro/ralph_pricing/hooks","issue_events_url":"https://api.github.com/repos/allegro/ralph_pricing/issues/events{/number}","events_url":"https://api.github.com/repos/allegro/ralph_pricing/events","assignees_url":"https://api.github.com/repos/allegro/ralph_pricing/assignees{/user}","branches_url":"https://api.github.com/repos/allegro/ralph_pricing/branches{/branch}","tags_url":"https://api.github.com/repos/allegro/ralph_pricing/tags","blobs_url":"https://api.github.com/repos/allegro/ralph_pricing/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/allegro/ralph_pricing/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/allegro/ralph_pricing/git/refs{/sha}","trees_url":"https://api.github.com/repos/allegro/ralph_pricing/git/trees{/sha}","statuses_url":"https://api.github.com/repos/allegro/ralph_pricing/statuses/{sha}","languages_url":"https://api.github.com/repos/allegro/ralph_pricing/languages","stargazers_url":"https://api.github.com/repos/allegro/ralph_pricing/stargazers","contributors_url":"https://api.github.com/repos/allegro/ralph_pricing/contributors","subscribers_url":"https://api.github.com/repos/allegro/ralph_pricing/subscribers","subscription_url":"https://api.github.com/repos/allegro/ralph_pricing/subscription","commits_url":"https://api.github.com/repos/allegro/ralph_pricing/commits{/sha}","git_commits_url":"https://api.github.com/repos/allegro/ralph_pricing/git/commits{/sha}","comments_url":"https://api.github.com/repos/allegro/ralph_pricing/comments{/number}","issue_comment_url":"https://api.github.com/repos/allegro/ralph_pricing/issues/comments{/number}","contents_url":"https://api.github.com/repos/allegro/ralph_pricing/contents/{+path}","compare_url":"https://api.github.com/repos/allegro/ralph_pricing/compare/{base}...{head}","merges_url":"https://api.github.com/repos/allegro/ralph_pricing/merges","archive_url":"https://api.github.com/repos/allegro/ralph_pricing/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/allegro/ralph_pricing/downloads","issues_url":"https://api.github.com/repos/allegro/ralph_pricing/issues{/number}","pulls_url":"https://api.github.com/repos/allegro/ralph_pricing/pulls{/number}","milestones_url":"https://api.github.com/repos/allegro/ralph_pricing/milestones{/number}","notifications_url":"https://api.github.com/repos/allegro/ralph_pricing/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/allegro/ralph_pricing/labels{/name}","releases_url":"https://api.github.com/repos/allegro/ralph_pricing/releases{/id}","deployments_url":"https://api.github.com/repos/allegro/ralph_pricing/deployments","created_at":"2013-04-17T10:30:06Z","updated_at":"2016-05-06T19:28:53Z","pushed_at":"2016-09-06T12:05:35Z","git_url":"git://github.com/allegro/ralph_pricing.git","ssh_url":"git@github.com:allegro/ralph_pricing.git","clone_url":"https://github.com/allegro/ralph_pricing.git","svn_url":"https://github.com/allegro/ralph_pricing","homepage":null,"size":6295,"stargazers_count":7,"watchers_count":7,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":14,"forks":17,"open_issues":14,"watchers":7,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/allegro/ralph_pricing/pulls/495"},"html":{"href":"https://github.com/allegro/ralph_pricing/pull/495"},"issue":{"href":"https://api.github.com/repos/allegro/ralph_pricing/issues/495"},"comments":{"href":"https://api.github.com/repos/allegro/ralph_pricing/issues/495/comments"},"review_comments":{"href":"https://api.github.com/repos/allegro/ralph_pricing/pulls/495/comments"},"review_comment":{"href":"https://api.github.com/repos/allegro/ralph_pricing/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/allegro/ralph_pricing/pulls/495/commits"},"statuses":{"href":"https://api.github.com/repos/allegro/ralph_pricing/statuses/e03c076303f418e9d0a478bfd0914c9958376508"}}}}
{"actor":{"display_login":"mkurek"}}