{"action":"created","comment":{"url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/pulls/comments/59685974","id":59685974,"diff_hunk":"@@ -39,6 +41,286 @@ def _wait_for_execution(self, execution, timeout=900):\n                 return execution\n             time.sleep(3)\n \n+    @staticmethod\n+    def assert_equal_dictionaries(self, d1, d2, exceptions=()):\n+        for k, v in d1.iteritems():\n+            if k not in exceptions:\n+                self.assertEquals(d2[k], v,\n+                                  'The nodes differed on {0}. {1}!={2}'\n+                                  .format(k, d1[k], d2[k]))\n+\n+    def _assert_relationship(self, relationships, target,\n+                             expected_type=None, exists=True):\n+        \"\"\"\n+        assert that a node/node instance has a specific relationship\n+        :param relationships: node/node instance relationships list\n+        :param target: target name (node id, not instance id)\n+        :param expected_type: expected relationship type\n+        \"\"\"\n+        expected_type = expected_type or 'cloudify.relationships.contained_in'\n+        error_msg = 'relationship of target \"{0}\" ' \\\n+                    'and type \"{1}\" is missing'.format(target, expected_type)\n+\n+        for relationship in relationships:\n+            relationship_type = relationship['type']\n+            relationship_target = (relationship.get('target_name') or\n+                                   relationship.get('target_id'))\n+\n+            if (relationship_type == expected_type and\n+                    relationship_target == target):\n+                if not exists:\n+                    self.fail(error_msg)\n+                return\n+\n+        if exists:\n+            self.fail(error_msg.format(target, expected_type))\n+\n+    def _deploy_and_get_modified_bp_path(self, bp_name):\n+\n+        base_bp = '{0}_base.yaml'.format(bp_name)\n+        modified_bp = '{0}_modification.yaml'.format(bp_name)\n+\n+        base_bp_path = \\\n+            resource(os.path.join(blueprints_base_path, base_bp))\n+        deployment, _ = deploy(base_bp_path)\n+        modified_bp_path = \\\n+            resource(os.path.join(blueprints_base_path, modified_bp))\n+\n+        return deployment, modified_bp_path\n+\n+    def test_add_relationship(self):\n+        deployment, modified_bp_path = \\\n+            self._deploy_and_get_modified_bp_path('dep_up_add_relationship')\n+\n+        dep_update = \\\n+            self.client.deployment_updates.stage(deployment.id,\n+                                                 modified_bp_path)\n+\n+        self.client.deployment_updates.add(\n+                dep_update.id,\n+                entity_type='relationship',\n+                entity_id='node_templates:site2-node_templates:site1')\n+\n+        self.client.deployment_updates.commit(dep_update.id)\n+\n+        # assert that 'update' workflow was executed\n+        executions = \\\n+            self.client.executions.list(deployment_id=deployment.id,\n+                                        workflow_id='update')\n+        execution = self._wait_for_execution(executions[0])\n+        self.assertEquals('terminated', execution['status'],\n+                          execution.error)\n+\n+        # Get all related and affected nodes and node instances\n+        related_nodes = \\\n+            self.client.nodes.list(deployment_id=deployment.id,\n+                                   node_id='site0')\n+        related_node_instances = \\\n+            self.client.node_instances.list(deployment_id=deployment.id,\n+                                            node_id='site0')\n+        target_nodes = self.client.nodes.list(deployment_id=deployment.id,\n+                                              node_id='site1')\n+        target_node_instances = \\\n+            self.client.node_instances.list(deployment_id=deployment.id,\n+                                            node_id='site1')\n+        source_nodes = \\\n+            self.client.nodes.list(deployment_id=deployment.id,\n+                                   node_id='site2')\n+        source_node_instances = \\\n+            self.client.node_instances.list(deployment_id=deployment.id,\n+                                            node_id='site2')\n+\n+        # Check that there is only 1 from each\n+        self.assertEquals(1, len(related_nodes))\n+        self.assertEquals(1, len(related_node_instances))\n+        self.assertEquals(1, len(target_nodes))\n+        self.assertEquals(1, len(target_node_instances))\n+        self.assertEquals(1, len(source_nodes))\n+        self.assertEquals(1, len(source_node_instances))\n+\n+        # get the nodes and node instances\n+        # TODO: check that the other nodes/node_instances haven't changed\n+        related_node = related_nodes[0]                                         # NOQA\n+        related_node_instance = related_node_instances[0]                       # NOQA\n+        target_node = target_nodes[0]                                           # NOQA\n+        target_node_instance = target_node_instances[0]\n+        source_node = source_nodes[0]\n+        source_node_instance = source_node_instances[0]\n+\n+        # assert there are 2 relationships total\n+        self.assertEquals(2, len(source_node.relationships))\n+        self.assertEquals(2, len(source_node_instance.relationships))\n+\n+        # check the relationship between site2 and site0 is intact\n+        self._assert_relationship(\n+                source_node_instance.relationships,\n+                target='site0',\n+                expected_type='cloudify.relationships.connected_to')\n+        self._assert_relationship(\n+                source_node.relationships,\n+                target='site0',\n+                expected_type='cloudify.relationships.connected_to')\n+\n+        # check the new relationship between site2 and site1 is in place","path":"tests/workflow_tests/test_deployment_update.py","position":133,"original_position":133,"commit_id":"cb7ebc0771dbb5c47bbae01a23de522656eb6123","original_commit_id":"cb7ebc0771dbb5c47bbae01a23de522656eb6123","user":{"login":"max-orlov","id":9050974,"avatar_url":"https://avatars.githubusercontent.com/u/9050974?v=3","gravatar_id":"","url":"https://api.github.com/users/max-orlov","html_url":"https://github.com/max-orlov","followers_url":"https://api.github.com/users/max-orlov/followers","following_url":"https://api.github.com/users/max-orlov/following{/other_user}","gists_url":"https://api.github.com/users/max-orlov/gists{/gist_id}","starred_url":"https://api.github.com/users/max-orlov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/max-orlov/subscriptions","organizations_url":"https://api.github.com/users/max-orlov/orgs","repos_url":"https://api.github.com/users/max-orlov/repos","events_url":"https://api.github.com/users/max-orlov/events{/privacy}","received_events_url":"https://api.github.com/users/max-orlov/received_events","type":"User","site_admin":false},"body":"check comments for site num shifting","created_at":"2016-04-14T09:17:19Z","updated_at":"2016-04-14T09:17:19Z","html_url":"https://github.com/cloudify-cosmo/cloudify-manager/pull/421#discussion_r59685974","pull_request_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/pulls/421","_links":{"self":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/pulls/comments/59685974"},"html":{"href":"https://github.com/cloudify-cosmo/cloudify-manager/pull/421#discussion_r59685974"},"pull_request":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/pulls/421"}}},"pull_request":{"url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/pulls/421","id":62413175,"html_url":"https://github.com/cloudify-cosmo/cloudify-manager/pull/421","diff_url":"https://github.com/cloudify-cosmo/cloudify-manager/pull/421.diff","patch_url":"https://github.com/cloudify-cosmo/cloudify-manager/pull/421.patch","issue_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/issues/421","number":421,"state":"open","locked":false,"title":"Cfy 5036 support for relationship types update","user":{"login":"max-orlov","id":9050974,"avatar_url":"https://avatars.githubusercontent.com/u/9050974?v=3","gravatar_id":"","url":"https://api.github.com/users/max-orlov","html_url":"https://github.com/max-orlov","followers_url":"https://api.github.com/users/max-orlov/followers","following_url":"https://api.github.com/users/max-orlov/following{/other_user}","gists_url":"https://api.github.com/users/max-orlov/gists{/gist_id}","starred_url":"https://api.github.com/users/max-orlov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/max-orlov/subscriptions","organizations_url":"https://api.github.com/users/max-orlov/orgs","repos_url":"https://api.github.com/users/max-orlov/repos","events_url":"https://api.github.com/users/max-orlov/events{/privacy}","received_events_url":"https://api.github.com/users/max-orlov/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-03-10T16:09:51Z","updated_at":"2016-04-14T09:17:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"34187f7083ad1e7154f4a45d3684c6cb3213f1c8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/pulls/421/commits","review_comments_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/pulls/421/comments","review_comment_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/issues/421/comments","statuses_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/statuses/cb7ebc0771dbb5c47bbae01a23de522656eb6123","head":{"label":"cloudify-cosmo:CFY-5036-Support-for-relationship-types-update","ref":"CFY-5036-Support-for-relationship-types-update","sha":"cb7ebc0771dbb5c47bbae01a23de522656eb6123","user":{"login":"cloudify-cosmo","id":6260555,"avatar_url":"https://avatars.githubusercontent.com/u/6260555?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudify-cosmo","html_url":"https://github.com/cloudify-cosmo","followers_url":"https://api.github.com/users/cloudify-cosmo/followers","following_url":"https://api.github.com/users/cloudify-cosmo/following{/other_user}","gists_url":"https://api.github.com/users/cloudify-cosmo/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudify-cosmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudify-cosmo/subscriptions","organizations_url":"https://api.github.com/users/cloudify-cosmo/orgs","repos_url":"https://api.github.com/users/cloudify-cosmo/repos","events_url":"https://api.github.com/users/cloudify-cosmo/events{/privacy}","received_events_url":"https://api.github.com/users/cloudify-cosmo/received_events","type":"Organization","site_admin":false},"repo":{"id":18326574,"name":"cloudify-manager","full_name":"cloudify-cosmo/cloudify-manager","owner":{"login":"cloudify-cosmo","id":6260555,"avatar_url":"https://avatars.githubusercontent.com/u/6260555?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudify-cosmo","html_url":"https://github.com/cloudify-cosmo","followers_url":"https://api.github.com/users/cloudify-cosmo/followers","following_url":"https://api.github.com/users/cloudify-cosmo/following{/other_user}","gists_url":"https://api.github.com/users/cloudify-cosmo/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudify-cosmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudify-cosmo/subscriptions","organizations_url":"https://api.github.com/users/cloudify-cosmo/orgs","repos_url":"https://api.github.com/users/cloudify-cosmo/repos","events_url":"https://api.github.com/users/cloudify-cosmo/events{/privacy}","received_events_url":"https://api.github.com/users/cloudify-cosmo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cloudify-cosmo/cloudify-manager","description":"Cloudify's manager related code","fork":false,"url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager","forks_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/forks","keys_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/teams","hooks_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/hooks","issue_events_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/issues/events{/number}","events_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/events","assignees_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/assignees{/user}","branches_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/branches{/branch}","tags_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/tags","blobs_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/git/refs{/sha}","trees_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/statuses/{sha}","languages_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/languages","stargazers_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/stargazers","contributors_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/contributors","subscribers_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/subscribers","subscription_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/subscription","commits_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/commits{/sha}","git_commits_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/git/commits{/sha}","comments_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/comments{/number}","issue_comment_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/issues/comments{/number}","contents_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/contents/{+path}","compare_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/merges","archive_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/downloads","issues_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/issues{/number}","pulls_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/pulls{/number}","milestones_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/milestones{/number}","notifications_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/labels{/name}","releases_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/releases{/id}","deployments_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/deployments","created_at":"2014-04-01T11:06:47Z","updated_at":"2016-04-08T02:13:10Z","pushed_at":"2016-04-14T08:49:39Z","git_url":"git://github.com/cloudify-cosmo/cloudify-manager.git","ssh_url":"git@github.com:cloudify-cosmo/cloudify-manager.git","clone_url":"https://github.com/cloudify-cosmo/cloudify-manager.git","svn_url":"https://github.com/cloudify-cosmo/cloudify-manager","homepage":null,"size":13282,"stargazers_count":22,"watchers_count":22,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":26,"mirror_url":null,"open_issues_count":14,"forks":26,"open_issues":14,"watchers":22,"default_branch":"master"}},"base":{"label":"cloudify-cosmo:CFY-4929-depup","ref":"CFY-4929-depup","sha":"8315729e337d59f28c8454c873045da6de43ab20","user":{"login":"cloudify-cosmo","id":6260555,"avatar_url":"https://avatars.githubusercontent.com/u/6260555?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudify-cosmo","html_url":"https://github.com/cloudify-cosmo","followers_url":"https://api.github.com/users/cloudify-cosmo/followers","following_url":"https://api.github.com/users/cloudify-cosmo/following{/other_user}","gists_url":"https://api.github.com/users/cloudify-cosmo/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudify-cosmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudify-cosmo/subscriptions","organizations_url":"https://api.github.com/users/cloudify-cosmo/orgs","repos_url":"https://api.github.com/users/cloudify-cosmo/repos","events_url":"https://api.github.com/users/cloudify-cosmo/events{/privacy}","received_events_url":"https://api.github.com/users/cloudify-cosmo/received_events","type":"Organization","site_admin":false},"repo":{"id":18326574,"name":"cloudify-manager","full_name":"cloudify-cosmo/cloudify-manager","owner":{"login":"cloudify-cosmo","id":6260555,"avatar_url":"https://avatars.githubusercontent.com/u/6260555?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudify-cosmo","html_url":"https://github.com/cloudify-cosmo","followers_url":"https://api.github.com/users/cloudify-cosmo/followers","following_url":"https://api.github.com/users/cloudify-cosmo/following{/other_user}","gists_url":"https://api.github.com/users/cloudify-cosmo/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudify-cosmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudify-cosmo/subscriptions","organizations_url":"https://api.github.com/users/cloudify-cosmo/orgs","repos_url":"https://api.github.com/users/cloudify-cosmo/repos","events_url":"https://api.github.com/users/cloudify-cosmo/events{/privacy}","received_events_url":"https://api.github.com/users/cloudify-cosmo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cloudify-cosmo/cloudify-manager","description":"Cloudify's manager related code","fork":false,"url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager","forks_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/forks","keys_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/teams","hooks_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/hooks","issue_events_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/issues/events{/number}","events_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/events","assignees_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/assignees{/user}","branches_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/branches{/branch}","tags_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/tags","blobs_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/git/refs{/sha}","trees_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/statuses/{sha}","languages_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/languages","stargazers_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/stargazers","contributors_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/contributors","subscribers_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/subscribers","subscription_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/subscription","commits_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/commits{/sha}","git_commits_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/git/commits{/sha}","comments_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/comments{/number}","issue_comment_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/issues/comments{/number}","contents_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/contents/{+path}","compare_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/merges","archive_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/downloads","issues_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/issues{/number}","pulls_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/pulls{/number}","milestones_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/milestones{/number}","notifications_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/labels{/name}","releases_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/releases{/id}","deployments_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/deployments","created_at":"2014-04-01T11:06:47Z","updated_at":"2016-04-08T02:13:10Z","pushed_at":"2016-04-14T08:49:39Z","git_url":"git://github.com/cloudify-cosmo/cloudify-manager.git","ssh_url":"git@github.com:cloudify-cosmo/cloudify-manager.git","clone_url":"https://github.com/cloudify-cosmo/cloudify-manager.git","svn_url":"https://github.com/cloudify-cosmo/cloudify-manager","homepage":null,"size":13282,"stargazers_count":22,"watchers_count":22,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":26,"mirror_url":null,"open_issues_count":14,"forks":26,"open_issues":14,"watchers":22,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/pulls/421"},"html":{"href":"https://github.com/cloudify-cosmo/cloudify-manager/pull/421"},"issue":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/issues/421"},"comments":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/issues/421/comments"},"review_comments":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/pulls/421/comments"},"review_comment":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/pulls/421/commits"},"statuses":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/statuses/cb7ebc0771dbb5c47bbae01a23de522656eb6123"}}}}