{"action":"created","comment":{"url":"https://api.github.com/repos/RackHD/on-http/pulls/comments/59458159","id":59458159,"diff_hunk":"@@ -102,41 +102,80 @@ function profileApiServiceFactory(\n \n                 });\n             } else {\n-                return self.createNodeAndRunDiscovery(macAddresses);\n+                return self.createNodeAndRunDiscovery(macAddresses, options);\n             }\n         });\n     };\n \n-    ProfileApiService.prototype.runDiscovery = function(node) {\n+    ProfileApiService.prototype.runDiscovery = function(node, options) {\n         var self = this;\n+        var configuration;\n \n+        if (node.type === 'switch') {\n+            configuration = self.getSwitchDiscoveryConfiguration(node, options.switchVendor);\n+        } else {\n+            configuration = {\n+                name: 'Graph.SKU.Discovery',\n+                options: {\n+                    defaults: {\n+                        graphOptions: {\n+                            target: node.id\n+                        },\n+                        nodeId: node.id\n+                    }\n+                }\n+            };\n+        }\n+\n+        // The nested workflow holds the lock against the nodeId in this case,\n+        // so don't add it as a target to the outer workflow context\n+        return workflowApiService.createAndRunGraph(configuration, null)\n+        .then(function() {\n+            return self.waitForDiscoveryStart(node.id);\n+        })\n+        .then(function() {\n+            return node;\n+        });\n+    };\n+\n+    ProfileApiService.prototype.getSwitchDiscoveryConfiguration = function(node, vendor) {\n         var configuration = {\n-            name: 'Graph.SKU.Discovery',\n+            name: 'Graph.SKU.Switch.Discovery.Active',\n             options: {\n                 defaults: {\n                     graphOptions: {\n                         target: node.id\n                     },\n                     nodeId: node.id\n+                },\n+                'vendor-discovery-graph': {\n+                    graphName: null\n                 }\n             }\n         };\n \n-        return workflowApiService.createAndRunGraph(configuration)\n-        .then(function() {\n-            return self.waitForDiscoveryStart(node.id);\n-        })\n-        .then(function() {\n-            return node;\n-        });\n+        vendor = vendor.toLowerCase();\n+\n+        if (vendor === 'cisco') {","path":"lib/services/profiles-api-service.js","position":86,"original_position":86,"commit_id":"d2be2bbbc7a063d85dc1c414640f209d6e1ca748","original_commit_id":"d2be2bbbc7a063d85dc1c414640f209d6e1ca748","user":{"login":"pscharla","id":14006173,"avatar_url":"https://avatars.githubusercontent.com/u/14006173?v=3","gravatar_id":"","url":"https://api.github.com/users/pscharla","html_url":"https://github.com/pscharla","followers_url":"https://api.github.com/users/pscharla/followers","following_url":"https://api.github.com/users/pscharla/following{/other_user}","gists_url":"https://api.github.com/users/pscharla/gists{/gist_id}","starred_url":"https://api.github.com/users/pscharla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pscharla/subscriptions","organizations_url":"https://api.github.com/users/pscharla/orgs","repos_url":"https://api.github.com/users/pscharla/repos","events_url":"https://api.github.com/users/pscharla/events{/privacy}","received_events_url":"https://api.github.com/users/pscharla/received_events","type":"User","site_admin":false},"body":"That totally makes sense to me.  If I understand correctly, you are talking about doing something like this:\r\n\r\nif (vendor === 'cisco') {\r\n            configuration.options.switchvendor = 'cisco';\r\n        } else if (vendor === 'arista') {\r\n            configuration.options.switchvendor = 'arista'';\r\n        } else {\r\n\r\nThen we can collapse Graph.Switch.Discovery.Cisco.Poap, Graph.Switch.Discovery.Arista.Ztp, etc down to one common graph.  I think that means that we could collapse the deploy switch startup config graphs down too (i.e. deploy-cisco-nexus3000-switch-startup-config-graph.js).  The trick there may be if we need different startup config scripts or different catalog scripts between different flavors of switches from one vendor.  In that case we may need to get model number too and pass it down.","created_at":"2016-04-12T21:34:01Z","updated_at":"2016-04-12T21:34:01Z","html_url":"https://github.com/RackHD/on-http/pull/210#discussion_r59458159","pull_request_url":"https://api.github.com/repos/RackHD/on-http/pulls/210","_links":{"self":{"href":"https://api.github.com/repos/RackHD/on-http/pulls/comments/59458159"},"html":{"href":"https://github.com/RackHD/on-http/pull/210#discussion_r59458159"},"pull_request":{"href":"https://api.github.com/repos/RackHD/on-http/pulls/210"}}},"pull_request":{"url":"https://api.github.com/repos/RackHD/on-http/pulls/210","id":65720537,"html_url":"https://github.com/RackHD/on-http/pull/210","diff_url":"https://github.com/RackHD/on-http/pull/210.diff","patch_url":"https://github.com/RackHD/on-http/pull/210.patch","issue_url":"https://api.github.com/repos/RackHD/on-http/issues/210","number":210,"state":"open","locked":false,"title":"Enable network switch active discovery","user":{"login":"benbp","id":1020379,"avatar_url":"https://avatars.githubusercontent.com/u/1020379?v=3","gravatar_id":"","url":"https://api.github.com/users/benbp","html_url":"https://github.com/benbp","followers_url":"https://api.github.com/users/benbp/followers","following_url":"https://api.github.com/users/benbp/following{/other_user}","gists_url":"https://api.github.com/users/benbp/gists{/gist_id}","starred_url":"https://api.github.com/users/benbp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benbp/subscriptions","organizations_url":"https://api.github.com/users/benbp/orgs","repos_url":"https://api.github.com/users/benbp/repos","events_url":"https://api.github.com/users/benbp/events{/privacy}","received_events_url":"https://api.github.com/users/benbp/received_events","type":"User","site_admin":false},"body":"This PR includes changes made to enable active discovery of network switches (Cisco, Arista, etc.).\r\n\r\nThe bulk of the change is adding a new route to the southbound profiles api (/profiles/switch/:vendor), which enables us to use much of our existing discovery code but tailored for switches.\r\n\r\nThe taskrunner.py profile that has been added behaves in much the same way as the bootstrap.js template that we use for existing interaction with the discovery microkernel. This way we can re-use all the pre-existing linux-command job and task option data structures (via `downloadUrl`). The biggest difference is it only supports downloading other python scripts and running them, rather than shelling out bash commands (which isn't a very reliable or consistent approach across different switch environments).\r\n\r\nIn my experience pretty much all scripts support running python scripts within these bootstrap environments, so I figure that is a good common denominator to use across all switch vendors for discovery.\r\n\r\nFYI @dpasupathi\r\n\r\nRequires https://github.com/RackHD/on-tasks/pull/158, https://github.com/RackHD/on-taskgraph/pull/84 and https://github.com/RackHD/on-tftp/pull/34. \r\nhttps://github.com/RackHD/on-dhcp-proxy/pull/32 is relevant but not blocking.\r\n\r\n@RackHD/corecommitters @johren @pscharla @heckj @VulpesArtificem @zyoung51 ","created_at":"2016-04-08T00:20:43Z","updated_at":"2016-04-12T21:34:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"68d838262574d64d2315537f7cb61613966e643b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/RackHD/on-http/pulls/210/commits","review_comments_url":"https://api.github.com/repos/RackHD/on-http/pulls/210/comments","review_comment_url":"https://api.github.com/repos/RackHD/on-http/pulls/comments{/number}","comments_url":"https://api.github.com/repos/RackHD/on-http/issues/210/comments","statuses_url":"https://api.github.com/repos/RackHD/on-http/statuses/d2be2bbbc7a063d85dc1c414640f209d6e1ca748","head":{"label":"benbp:cisco-poap","ref":"cisco-poap","sha":"d2be2bbbc7a063d85dc1c414640f209d6e1ca748","user":{"login":"benbp","id":1020379,"avatar_url":"https://avatars.githubusercontent.com/u/1020379?v=3","gravatar_id":"","url":"https://api.github.com/users/benbp","html_url":"https://github.com/benbp","followers_url":"https://api.github.com/users/benbp/followers","following_url":"https://api.github.com/users/benbp/following{/other_user}","gists_url":"https://api.github.com/users/benbp/gists{/gist_id}","starred_url":"https://api.github.com/users/benbp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benbp/subscriptions","organizations_url":"https://api.github.com/users/benbp/orgs","repos_url":"https://api.github.com/users/benbp/repos","events_url":"https://api.github.com/users/benbp/events{/privacy}","received_events_url":"https://api.github.com/users/benbp/received_events","type":"User","site_admin":false},"repo":{"id":47728727,"name":"on-http","full_name":"benbp/on-http","owner":{"login":"benbp","id":1020379,"avatar_url":"https://avatars.githubusercontent.com/u/1020379?v=3","gravatar_id":"","url":"https://api.github.com/users/benbp","html_url":"https://github.com/benbp","followers_url":"https://api.github.com/users/benbp/followers","following_url":"https://api.github.com/users/benbp/following{/other_user}","gists_url":"https://api.github.com/users/benbp/gists{/gist_id}","starred_url":"https://api.github.com/users/benbp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benbp/subscriptions","organizations_url":"https://api.github.com/users/benbp/orgs","repos_url":"https://api.github.com/users/benbp/repos","events_url":"https://api.github.com/users/benbp/events{/privacy}","received_events_url":"https://api.github.com/users/benbp/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/benbp/on-http","description":"","fork":true,"url":"https://api.github.com/repos/benbp/on-http","forks_url":"https://api.github.com/repos/benbp/on-http/forks","keys_url":"https://api.github.com/repos/benbp/on-http/keys{/key_id}","collaborators_url":"https://api.github.com/repos/benbp/on-http/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/benbp/on-http/teams","hooks_url":"https://api.github.com/repos/benbp/on-http/hooks","issue_events_url":"https://api.github.com/repos/benbp/on-http/issues/events{/number}","events_url":"https://api.github.com/repos/benbp/on-http/events","assignees_url":"https://api.github.com/repos/benbp/on-http/assignees{/user}","branches_url":"https://api.github.com/repos/benbp/on-http/branches{/branch}","tags_url":"https://api.github.com/repos/benbp/on-http/tags","blobs_url":"https://api.github.com/repos/benbp/on-http/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/benbp/on-http/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/benbp/on-http/git/refs{/sha}","trees_url":"https://api.github.com/repos/benbp/on-http/git/trees{/sha}","statuses_url":"https://api.github.com/repos/benbp/on-http/statuses/{sha}","languages_url":"https://api.github.com/repos/benbp/on-http/languages","stargazers_url":"https://api.github.com/repos/benbp/on-http/stargazers","contributors_url":"https://api.github.com/repos/benbp/on-http/contributors","subscribers_url":"https://api.github.com/repos/benbp/on-http/subscribers","subscription_url":"https://api.github.com/repos/benbp/on-http/subscription","commits_url":"https://api.github.com/repos/benbp/on-http/commits{/sha}","git_commits_url":"https://api.github.com/repos/benbp/on-http/git/commits{/sha}","comments_url":"https://api.github.com/repos/benbp/on-http/comments{/number}","issue_comment_url":"https://api.github.com/repos/benbp/on-http/issues/comments{/number}","contents_url":"https://api.github.com/repos/benbp/on-http/contents/{+path}","compare_url":"https://api.github.com/repos/benbp/on-http/compare/{base}...{head}","merges_url":"https://api.github.com/repos/benbp/on-http/merges","archive_url":"https://api.github.com/repos/benbp/on-http/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/benbp/on-http/downloads","issues_url":"https://api.github.com/repos/benbp/on-http/issues{/number}","pulls_url":"https://api.github.com/repos/benbp/on-http/pulls{/number}","milestones_url":"https://api.github.com/repos/benbp/on-http/milestones{/number}","notifications_url":"https://api.github.com/repos/benbp/on-http/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/benbp/on-http/labels{/name}","releases_url":"https://api.github.com/repos/benbp/on-http/releases{/id}","deployments_url":"https://api.github.com/repos/benbp/on-http/deployments","created_at":"2015-12-10T00:56:30Z","updated_at":"2015-12-10T00:56:32Z","pushed_at":"2016-04-11T22:44:50Z","git_url":"git://github.com/benbp/on-http.git","ssh_url":"git@github.com:benbp/on-http.git","clone_url":"https://github.com/benbp/on-http.git","svn_url":"https://github.com/benbp/on-http","homepage":null,"size":2308,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"RackHD:master","ref":"master","sha":"f1851ce180053a4418fda82a2f2355d84cff812a","user":{"login":"RackHD","id":13982662,"avatar_url":"https://avatars.githubusercontent.com/u/13982662?v=3","gravatar_id":"","url":"https://api.github.com/users/RackHD","html_url":"https://github.com/RackHD","followers_url":"https://api.github.com/users/RackHD/followers","following_url":"https://api.github.com/users/RackHD/following{/other_user}","gists_url":"https://api.github.com/users/RackHD/gists{/gist_id}","starred_url":"https://api.github.com/users/RackHD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RackHD/subscriptions","organizations_url":"https://api.github.com/users/RackHD/orgs","repos_url":"https://api.github.com/users/RackHD/repos","events_url":"https://api.github.com/users/RackHD/events{/privacy}","received_events_url":"https://api.github.com/users/RackHD/received_events","type":"Organization","site_admin":false},"repo":{"id":41690081,"name":"on-http","full_name":"RackHD/on-http","owner":{"login":"RackHD","id":13982662,"avatar_url":"https://avatars.githubusercontent.com/u/13982662?v=3","gravatar_id":"","url":"https://api.github.com/users/RackHD","html_url":"https://github.com/RackHD","followers_url":"https://api.github.com/users/RackHD/followers","following_url":"https://api.github.com/users/RackHD/following{/other_user}","gists_url":"https://api.github.com/users/RackHD/gists{/gist_id}","starred_url":"https://api.github.com/users/RackHD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RackHD/subscriptions","organizations_url":"https://api.github.com/users/RackHD/orgs","repos_url":"https://api.github.com/users/RackHD/repos","events_url":"https://api.github.com/users/RackHD/events{/privacy}","received_events_url":"https://api.github.com/users/RackHD/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/RackHD/on-http","description":"","fork":false,"url":"https://api.github.com/repos/RackHD/on-http","forks_url":"https://api.github.com/repos/RackHD/on-http/forks","keys_url":"https://api.github.com/repos/RackHD/on-http/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RackHD/on-http/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RackHD/on-http/teams","hooks_url":"https://api.github.com/repos/RackHD/on-http/hooks","issue_events_url":"https://api.github.com/repos/RackHD/on-http/issues/events{/number}","events_url":"https://api.github.com/repos/RackHD/on-http/events","assignees_url":"https://api.github.com/repos/RackHD/on-http/assignees{/user}","branches_url":"https://api.github.com/repos/RackHD/on-http/branches{/branch}","tags_url":"https://api.github.com/repos/RackHD/on-http/tags","blobs_url":"https://api.github.com/repos/RackHD/on-http/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RackHD/on-http/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RackHD/on-http/git/refs{/sha}","trees_url":"https://api.github.com/repos/RackHD/on-http/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RackHD/on-http/statuses/{sha}","languages_url":"https://api.github.com/repos/RackHD/on-http/languages","stargazers_url":"https://api.github.com/repos/RackHD/on-http/stargazers","contributors_url":"https://api.github.com/repos/RackHD/on-http/contributors","subscribers_url":"https://api.github.com/repos/RackHD/on-http/subscribers","subscription_url":"https://api.github.com/repos/RackHD/on-http/subscription","commits_url":"https://api.github.com/repos/RackHD/on-http/commits{/sha}","git_commits_url":"https://api.github.com/repos/RackHD/on-http/git/commits{/sha}","comments_url":"https://api.github.com/repos/RackHD/on-http/comments{/number}","issue_comment_url":"https://api.github.com/repos/RackHD/on-http/issues/comments{/number}","contents_url":"https://api.github.com/repos/RackHD/on-http/contents/{+path}","compare_url":"https://api.github.com/repos/RackHD/on-http/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RackHD/on-http/merges","archive_url":"https://api.github.com/repos/RackHD/on-http/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RackHD/on-http/downloads","issues_url":"https://api.github.com/repos/RackHD/on-http/issues{/number}","pulls_url":"https://api.github.com/repos/RackHD/on-http/pulls{/number}","milestones_url":"https://api.github.com/repos/RackHD/on-http/milestones{/number}","notifications_url":"https://api.github.com/repos/RackHD/on-http/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RackHD/on-http/labels{/name}","releases_url":"https://api.github.com/repos/RackHD/on-http/releases{/id}","deployments_url":"https://api.github.com/repos/RackHD/on-http/deployments","created_at":"2015-08-31T17:29:08Z","updated_at":"2016-04-07T07:27:34Z","pushed_at":"2016-04-12T15:54:39Z","git_url":"git://github.com/RackHD/on-http.git","ssh_url":"git@github.com:RackHD/on-http.git","clone_url":"https://github.com/RackHD/on-http.git","svn_url":"https://github.com/RackHD/on-http","homepage":null,"size":2726,"stargazers_count":9,"watchers_count":9,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":39,"mirror_url":null,"open_issues_count":11,"forks":39,"open_issues":11,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/RackHD/on-http/pulls/210"},"html":{"href":"https://github.com/RackHD/on-http/pull/210"},"issue":{"href":"https://api.github.com/repos/RackHD/on-http/issues/210"},"comments":{"href":"https://api.github.com/repos/RackHD/on-http/issues/210/comments"},"review_comments":{"href":"https://api.github.com/repos/RackHD/on-http/pulls/210/comments"},"review_comment":{"href":"https://api.github.com/repos/RackHD/on-http/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/RackHD/on-http/pulls/210/commits"},"statuses":{"href":"https://api.github.com/repos/RackHD/on-http/statuses/d2be2bbbc7a063d85dc1c414640f209d6e1ca748"}}}}