{"action":"created","comment":{"url":"https://api.github.com/repos/ClusterHQ/flocker/pulls/comments/27566198","id":27566198,"diff_hunk":"@@ -1308,6 +1311,572 @@ def test_discover_manifestation_paths(self):\n             self.successResultOf(d).paths)\n \n \n+class ApplicationNodeDeployerDiscoverNodeConfigurationTests(\n+        SynchronousTestCase):\n+    \"\"\"\n+    Tests for ``ApplicationNodeDeployer.discover_local_state``.\n+    \"\"\"\n+    def setUp(self):\n+        self.network = make_memory_network()\n+\n+    def test_discover_none(self):\n+        \"\"\"\n+        ``ApplicationNodeDeployer.discover_local_state`` returns an empty\n+        ``NodeState`` if there are no Docker containers on the host.\n+        \"\"\"\n+        fake_docker = FakeDockerClient(units={})\n+        api = ApplicationNodeDeployer(\n+            u'example.com',\n+            docker_client=fake_docker,\n+            network=self.network\n+        )\n+        d = api.discover_local_state(NodeState(hostname=u'example.com'))\n+\n+        self.assertEqual(NodeState(hostname=u'example.com',\n+                                   manifestations=None,\n+                                   paths=None),\n+                         self.successResultOf(d))\n+\n+    def test_discover_one(self):\n+        \"\"\"\n+        ``ApplicationNodeDeployer.discover_local_state`` returns ``NodeState``\n+        with a a list of running ``Application``\\ s; one for each active\n+        container.\n+        \"\"\"\n+        expected_application_name = u'site-example.com'\n+        unit = Unit(name=expected_application_name,\n+                    container_name=expected_application_name,\n+                    container_image=u\"flocker/wordpress:latest\",\n+                    activation_state=u'active')\n+        fake_docker = FakeDockerClient(units={expected_application_name: unit})\n+        application = Application(\n+            name=unit.name,\n+            image=DockerImage.from_string(unit.container_image)\n+        )\n+        api = ApplicationNodeDeployer(\n+            u'example.com',\n+            docker_client=fake_docker,\n+            network=self.network\n+        )\n+        d = api.discover_local_state(NodeState(hostname=u'example.com'))\n+\n+        self.assertEqual(NodeState(hostname=u'example.com',\n+                                   applications=[application],\n+                                   manifestations=None,\n+                                   paths=None),\n+                         self.successResultOf(d))\n+\n+    def test_discover_multiple(self):\n+        \"\"\"\n+        ``ApplicationNodeDeployer.discover_local_state`` returns a\n+        ``NodeState`` with a running ``Application`` for every active\n+        container on the host.\n+        \"\"\"\n+        unit1 = Unit(name=u'site-example.com',\n+                     container_name=u'site-example.com',\n+                     container_image=u'clusterhq/wordpress:latest',\n+                     activation_state=u'active')\n+        unit2 = Unit(name=u'site-example.net',\n+                     container_name=u'site-example.net',\n+                     container_image=u'clusterhq/wordpress:latest',\n+                     activation_state=u'active')\n+        units = {unit1.name: unit1, unit2.name: unit2}\n+\n+        fake_docker = FakeDockerClient(units=units)\n+        applications = [\n+            Application(\n+                name=unit.name,\n+                image=DockerImage.from_string(unit.container_image)\n+            ) for unit in units.values()\n+        ]\n+        api = ApplicationNodeDeployer(\n+            u'example.com',\n+            docker_client=fake_docker,\n+            network=self.network\n+        )\n+        d = api.discover_local_state(NodeState(hostname=u'example.com'))\n+\n+        self.assertItemsEqual(pset(applications),\n+                              self.successResultOf(d).applications)\n+\n+    def test_discover_application_with_environment(self):\n+        \"\"\"\n+        An ``Application`` with ``Environment`` objects is discovered from a\n+        ``Unit`` with ``Environment`` objects.\n+        \"\"\"\n+        environment_variables = (\n+            ('CUSTOM_ENV_A', 'a value'),\n+            ('CUSTOM_ENV_B', 'something else'),\n+        )","path":"flocker/node/test/test_deploy.py","position":320,"original_position":320,"commit_id":"a7150f4ac3b4f9c6b90630bdc1155bbebba08277","original_commit_id":"a7150f4ac3b4f9c6b90630bdc1155bbebba08277","user":{"login":"exarkun","id":254565,"avatar_url":"https://avatars.githubusercontent.com/u/254565?v=3","gravatar_id":"","url":"https://api.github.com/users/exarkun","html_url":"https://github.com/exarkun","followers_url":"https://api.github.com/users/exarkun/followers","following_url":"https://api.github.com/users/exarkun/following{/other_user}","gists_url":"https://api.github.com/users/exarkun/gists{/gist_id}","starred_url":"https://api.github.com/users/exarkun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exarkun/subscriptions","organizations_url":"https://api.github.com/users/exarkun/orgs","repos_url":"https://api.github.com/users/exarkun/repos","events_url":"https://api.github.com/users/exarkun/events{/privacy}","received_events_url":"https://api.github.com/users/exarkun/received_events","type":"User","site_admin":false},"body":"`b\"..\"`","created_at":"2015-04-01T12:59:32Z","updated_at":"2015-04-01T12:59:32Z","html_url":"https://github.com/ClusterHQ/flocker/pull/1247#discussion_r27566198","pull_request_url":"https://api.github.com/repos/ClusterHQ/flocker/pulls/1247","_links":{"self":{"href":"https://api.github.com/repos/ClusterHQ/flocker/pulls/comments/27566198"},"html":{"href":"https://github.com/ClusterHQ/flocker/pull/1247#discussion_r27566198"},"pull_request":{"href":"https://api.github.com/repos/ClusterHQ/flocker/pulls/1247"}}},"pull_request":{"url":"https://api.github.com/repos/ClusterHQ/flocker/pulls/1247","id":31954458,"html_url":"https://github.com/ClusterHQ/flocker/pull/1247","diff_url":"https://github.com/ClusterHQ/flocker/pull/1247.diff","patch_url":"https://github.com/ClusterHQ/flocker/pull/1247.patch","issue_url":"https://api.github.com/repos/ClusterHQ/flocker/issues/1247","number":1247,"state":"open","locked":false,"title":"[FLOC-1542] Split container discovery","user":{"login":"itamarst","id":3266662,"avatar_url":"https://avatars.githubusercontent.com/u/3266662?v=3","gravatar_id":"","url":"https://api.github.com/users/itamarst","html_url":"https://github.com/itamarst","followers_url":"https://api.github.com/users/itamarst/followers","following_url":"https://api.github.com/users/itamarst/following{/other_user}","gists_url":"https://api.github.com/users/itamarst/gists{/gist_id}","starred_url":"https://api.github.com/users/itamarst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/itamarst/subscriptions","organizations_url":"https://api.github.com/users/itamarst/orgs","repos_url":"https://api.github.com/users/itamarst/repos","events_url":"https://api.github.com/users/itamarst/events{/privacy}","received_events_url":"https://api.github.com/users/itamarst/received_events","type":"User","site_admin":false},"body":"Will be more readable once #1233 is merged (which can be done as soon as buildbot is green).","created_at":"2015-03-25T18:56:12Z","updated_at":"2015-04-01T12:59:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"565f98c901f2e70ab4ff5d46b6164b30e021d169","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ClusterHQ/flocker/pulls/1247/commits","review_comments_url":"https://api.github.com/repos/ClusterHQ/flocker/pulls/1247/comments","review_comment_url":"https://api.github.com/repos/ClusterHQ/flocker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ClusterHQ/flocker/issues/1247/comments","statuses_url":"https://api.github.com/repos/ClusterHQ/flocker/statuses/a7150f4ac3b4f9c6b90630bdc1155bbebba08277","head":{"label":"ClusterHQ:split-container-discovery-FLOC-1542","ref":"split-container-discovery-FLOC-1542","sha":"a7150f4ac3b4f9c6b90630bdc1155bbebba08277","user":{"login":"ClusterHQ","id":7913449,"avatar_url":"https://avatars.githubusercontent.com/u/7913449?v=3","gravatar_id":"","url":"https://api.github.com/users/ClusterHQ","html_url":"https://github.com/ClusterHQ","followers_url":"https://api.github.com/users/ClusterHQ/followers","following_url":"https://api.github.com/users/ClusterHQ/following{/other_user}","gists_url":"https://api.github.com/users/ClusterHQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ClusterHQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ClusterHQ/subscriptions","organizations_url":"https://api.github.com/users/ClusterHQ/orgs","repos_url":"https://api.github.com/users/ClusterHQ/repos","events_url":"https://api.github.com/users/ClusterHQ/events{/privacy}","received_events_url":"https://api.github.com/users/ClusterHQ/received_events","type":"Organization","site_admin":false},"repo":{"id":19248542,"name":"flocker","full_name":"ClusterHQ/flocker","owner":{"login":"ClusterHQ","id":7913449,"avatar_url":"https://avatars.githubusercontent.com/u/7913449?v=3","gravatar_id":"","url":"https://api.github.com/users/ClusterHQ","html_url":"https://github.com/ClusterHQ","followers_url":"https://api.github.com/users/ClusterHQ/followers","following_url":"https://api.github.com/users/ClusterHQ/following{/other_user}","gists_url":"https://api.github.com/users/ClusterHQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ClusterHQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ClusterHQ/subscriptions","organizations_url":"https://api.github.com/users/ClusterHQ/orgs","repos_url":"https://api.github.com/users/ClusterHQ/repos","events_url":"https://api.github.com/users/ClusterHQ/events{/privacy}","received_events_url":"https://api.github.com/users/ClusterHQ/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ClusterHQ/flocker","description":"Easily manage Docker containers & their data","fork":false,"url":"https://api.github.com/repos/ClusterHQ/flocker","forks_url":"https://api.github.com/repos/ClusterHQ/flocker/forks","keys_url":"https://api.github.com/repos/ClusterHQ/flocker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ClusterHQ/flocker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ClusterHQ/flocker/teams","hooks_url":"https://api.github.com/repos/ClusterHQ/flocker/hooks","issue_events_url":"https://api.github.com/repos/ClusterHQ/flocker/issues/events{/number}","events_url":"https://api.github.com/repos/ClusterHQ/flocker/events","assignees_url":"https://api.github.com/repos/ClusterHQ/flocker/assignees{/user}","branches_url":"https://api.github.com/repos/ClusterHQ/flocker/branches{/branch}","tags_url":"https://api.github.com/repos/ClusterHQ/flocker/tags","blobs_url":"https://api.github.com/repos/ClusterHQ/flocker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ClusterHQ/flocker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ClusterHQ/flocker/git/refs{/sha}","trees_url":"https://api.github.com/repos/ClusterHQ/flocker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ClusterHQ/flocker/statuses/{sha}","languages_url":"https://api.github.com/repos/ClusterHQ/flocker/languages","stargazers_url":"https://api.github.com/repos/ClusterHQ/flocker/stargazers","contributors_url":"https://api.github.com/repos/ClusterHQ/flocker/contributors","subscribers_url":"https://api.github.com/repos/ClusterHQ/flocker/subscribers","subscription_url":"https://api.github.com/repos/ClusterHQ/flocker/subscription","commits_url":"https://api.github.com/repos/ClusterHQ/flocker/commits{/sha}","git_commits_url":"https://api.github.com/repos/ClusterHQ/flocker/git/commits{/sha}","comments_url":"https://api.github.com/repos/ClusterHQ/flocker/comments{/number}","issue_comment_url":"https://api.github.com/repos/ClusterHQ/flocker/issues/comments{/number}","contents_url":"https://api.github.com/repos/ClusterHQ/flocker/contents/{+path}","compare_url":"https://api.github.com/repos/ClusterHQ/flocker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ClusterHQ/flocker/merges","archive_url":"https://api.github.com/repos/ClusterHQ/flocker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ClusterHQ/flocker/downloads","issues_url":"https://api.github.com/repos/ClusterHQ/flocker/issues{/number}","pulls_url":"https://api.github.com/repos/ClusterHQ/flocker/pulls{/number}","milestones_url":"https://api.github.com/repos/ClusterHQ/flocker/milestones{/number}","notifications_url":"https://api.github.com/repos/ClusterHQ/flocker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ClusterHQ/flocker/labels{/name}","releases_url":"https://api.github.com/repos/ClusterHQ/flocker/releases{/id}","created_at":"2014-04-28T18:02:14Z","updated_at":"2015-04-01T09:38:49Z","pushed_at":"2015-04-01T11:16:24Z","git_url":"git://github.com/ClusterHQ/flocker.git","ssh_url":"git@github.com:ClusterHQ/flocker.git","clone_url":"https://github.com/ClusterHQ/flocker.git","svn_url":"https://github.com/ClusterHQ/flocker","homepage":"https://clusterhq.com","size":46759,"stargazers_count":1314,"watchers_count":1314,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":66,"mirror_url":null,"open_issues_count":21,"forks":66,"open_issues":21,"watchers":1314,"default_branch":"master"}},"base":{"label":"ClusterHQ:master","ref":"master","sha":"23bcbb04fc2a891d8105d0306cc710997c2b1735","user":{"login":"ClusterHQ","id":7913449,"avatar_url":"https://avatars.githubusercontent.com/u/7913449?v=3","gravatar_id":"","url":"https://api.github.com/users/ClusterHQ","html_url":"https://github.com/ClusterHQ","followers_url":"https://api.github.com/users/ClusterHQ/followers","following_url":"https://api.github.com/users/ClusterHQ/following{/other_user}","gists_url":"https://api.github.com/users/ClusterHQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ClusterHQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ClusterHQ/subscriptions","organizations_url":"https://api.github.com/users/ClusterHQ/orgs","repos_url":"https://api.github.com/users/ClusterHQ/repos","events_url":"https://api.github.com/users/ClusterHQ/events{/privacy}","received_events_url":"https://api.github.com/users/ClusterHQ/received_events","type":"Organization","site_admin":false},"repo":{"id":19248542,"name":"flocker","full_name":"ClusterHQ/flocker","owner":{"login":"ClusterHQ","id":7913449,"avatar_url":"https://avatars.githubusercontent.com/u/7913449?v=3","gravatar_id":"","url":"https://api.github.com/users/ClusterHQ","html_url":"https://github.com/ClusterHQ","followers_url":"https://api.github.com/users/ClusterHQ/followers","following_url":"https://api.github.com/users/ClusterHQ/following{/other_user}","gists_url":"https://api.github.com/users/ClusterHQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ClusterHQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ClusterHQ/subscriptions","organizations_url":"https://api.github.com/users/ClusterHQ/orgs","repos_url":"https://api.github.com/users/ClusterHQ/repos","events_url":"https://api.github.com/users/ClusterHQ/events{/privacy}","received_events_url":"https://api.github.com/users/ClusterHQ/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ClusterHQ/flocker","description":"Easily manage Docker containers & their data","fork":false,"url":"https://api.github.com/repos/ClusterHQ/flocker","forks_url":"https://api.github.com/repos/ClusterHQ/flocker/forks","keys_url":"https://api.github.com/repos/ClusterHQ/flocker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ClusterHQ/flocker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ClusterHQ/flocker/teams","hooks_url":"https://api.github.com/repos/ClusterHQ/flocker/hooks","issue_events_url":"https://api.github.com/repos/ClusterHQ/flocker/issues/events{/number}","events_url":"https://api.github.com/repos/ClusterHQ/flocker/events","assignees_url":"https://api.github.com/repos/ClusterHQ/flocker/assignees{/user}","branches_url":"https://api.github.com/repos/ClusterHQ/flocker/branches{/branch}","tags_url":"https://api.github.com/repos/ClusterHQ/flocker/tags","blobs_url":"https://api.github.com/repos/ClusterHQ/flocker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ClusterHQ/flocker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ClusterHQ/flocker/git/refs{/sha}","trees_url":"https://api.github.com/repos/ClusterHQ/flocker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ClusterHQ/flocker/statuses/{sha}","languages_url":"https://api.github.com/repos/ClusterHQ/flocker/languages","stargazers_url":"https://api.github.com/repos/ClusterHQ/flocker/stargazers","contributors_url":"https://api.github.com/repos/ClusterHQ/flocker/contributors","subscribers_url":"https://api.github.com/repos/ClusterHQ/flocker/subscribers","subscription_url":"https://api.github.com/repos/ClusterHQ/flocker/subscription","commits_url":"https://api.github.com/repos/ClusterHQ/flocker/commits{/sha}","git_commits_url":"https://api.github.com/repos/ClusterHQ/flocker/git/commits{/sha}","comments_url":"https://api.github.com/repos/ClusterHQ/flocker/comments{/number}","issue_comment_url":"https://api.github.com/repos/ClusterHQ/flocker/issues/comments{/number}","contents_url":"https://api.github.com/repos/ClusterHQ/flocker/contents/{+path}","compare_url":"https://api.github.com/repos/ClusterHQ/flocker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ClusterHQ/flocker/merges","archive_url":"https://api.github.com/repos/ClusterHQ/flocker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ClusterHQ/flocker/downloads","issues_url":"https://api.github.com/repos/ClusterHQ/flocker/issues{/number}","pulls_url":"https://api.github.com/repos/ClusterHQ/flocker/pulls{/number}","milestones_url":"https://api.github.com/repos/ClusterHQ/flocker/milestones{/number}","notifications_url":"https://api.github.com/repos/ClusterHQ/flocker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ClusterHQ/flocker/labels{/name}","releases_url":"https://api.github.com/repos/ClusterHQ/flocker/releases{/id}","created_at":"2014-04-28T18:02:14Z","updated_at":"2015-04-01T09:38:49Z","pushed_at":"2015-04-01T11:16:24Z","git_url":"git://github.com/ClusterHQ/flocker.git","ssh_url":"git@github.com:ClusterHQ/flocker.git","clone_url":"https://github.com/ClusterHQ/flocker.git","svn_url":"https://github.com/ClusterHQ/flocker","homepage":"https://clusterhq.com","size":46759,"stargazers_count":1314,"watchers_count":1314,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":66,"mirror_url":null,"open_issues_count":21,"forks":66,"open_issues":21,"watchers":1314,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ClusterHQ/flocker/pulls/1247"},"html":{"href":"https://github.com/ClusterHQ/flocker/pull/1247"},"issue":{"href":"https://api.github.com/repos/ClusterHQ/flocker/issues/1247"},"comments":{"href":"https://api.github.com/repos/ClusterHQ/flocker/issues/1247/comments"},"review_comments":{"href":"https://api.github.com/repos/ClusterHQ/flocker/pulls/1247/comments"},"review_comment":{"href":"https://api.github.com/repos/ClusterHQ/flocker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ClusterHQ/flocker/pulls/1247/commits"},"statuses":{"href":"https://api.github.com/repos/ClusterHQ/flocker/statuses/a7150f4ac3b4f9c6b90630bdc1155bbebba08277"}}}}