{"action":"created","comment":{"url":"https://api.github.com/repos/RackHD/on-http/pulls/comments/51562130","id":51562130,"diff_hunk":"@@ -0,0 +1,145 @@\n+// Copyright 2016, EMC, Inc.\n+\n+'use strict';\n+\n+var injector = require('../../../index.js').injector;\n+var redfish = injector.get('Http.Api.Services.Redfish');\n+var waterline = injector.get('Services.Waterline');\n+var Promise = injector.get('Promise');\n+var _ = injector.get('_');\n+var moment = require('moment');\n+\n+module.exports = {\n+    taskServiceRoot: taskServiceRoot,\n+    listTasks: listTasks,\n+    getTask: getTask,\n+    getSystemTasks: getSystemTasks\n+};\n+\n+var dataFactory = function(identifier, dataName) {\n+    var statusMap = {\n+        'valid': 'Running',\n+        'succeeded': 'Completed',\n+        'cancelled': 'Killed',\n+        'failed':  'Exception'\n+    };\n+\n+    switch(dataName)  {\n+        case 'graphObjects':\n+            return Promise.map(waterline.graphobjects.find({}), function(graph) {\n+                    return { \n+                        state: statusMap[graph._status],\n+                        id: graph.id,\n+                        status: 'OK',\n+                        startTime: moment.utc(graph.createdAt).format(),\n+                        endTime: (graph._status !== 'valid') ? \n+                            moment.utc(graph.updatedAt).format() : \n+                            '',\n+                        name: graph.name,\n+                        systemId: graph.node\n+                    };\n+                });\n+    }\n+};\n+\n+function taskServiceRoot(req, res) {\n+    var options = {};\n+    options.basepath = req.swagger.operation.api.basePath;\n+    options.templateScope = ['global'];\n+    options.url = req.url;\n+    options.dateTime = moment.utc().format();\n+    options.systems = [];\n+\n+    Promise.all([ dataFactory('', 'graphObjects') ])\n+        .spread(function(graphs) {\n+            _.forEach(graphs, function(graph) {\n+                if (graph.systemId && -1 === options.systems.indexOf(graph.systemId))  {\n+                    options.systems.push(graph.systemId);\n+                }\n+            });\n+            options.graphs = graphs;\n+            return redfish.render('redfish.1.0.0.taskservice.1.0.0.json', \n+                 'TaskService.1.0.0.json#/definitions/TaskService',","path":"lib/api/redfish-1.0/task-service.js","position":62,"original_position":62,"commit_id":"6a919e3aedd843d0d08393e55c883d38a6746a16","original_commit_id":"04bc4cd835231e73de2ddc5435472d48fcc00e94","user":{"login":"yyscamper","id":511378,"avatar_url":"https://avatars.githubusercontent.com/u/511378?v=3","gravatar_id":"","url":"https://api.github.com/users/yyscamper","html_url":"https://github.com/yyscamper","followers_url":"https://api.github.com/users/yyscamper/followers","following_url":"https://api.github.com/users/yyscamper/following{/other_user}","gists_url":"https://api.github.com/users/yyscamper/gists{/gist_id}","starred_url":"https://api.github.com/users/yyscamper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yyscamper/subscriptions","organizations_url":"https://api.github.com/users/yyscamper/orgs","repos_url":"https://api.github.com/users/yyscamper/repos","events_url":"https://api.github.com/users/yyscamper/events{/privacy}","received_events_url":"https://api.github.com/users/yyscamper/received_events","type":"User","site_admin":false},"body":"I think @WangWinson 's concern here is if we move it from database to filesystem, it will be a way to reduce the RackHD footprint, I know some people is working on this. \r\n\r\nMeanwhile, put it into filesytem will get the dynamic loading feature, but our current database design only load templates one time when app runs, if we put a new template file (especially during debugging), we have to reboot the app to let the new template file takes effect.\r\n\r\nOf course, this discussion is not push you to change it in this PR, first we need a discussion, if agree, we can do it in another PR.\r\n\r\n","created_at":"2016-02-02T12:34:49Z","updated_at":"2016-02-02T12:34:49Z","html_url":"https://github.com/RackHD/on-http/pull/104#discussion_r51562130","pull_request_url":"https://api.github.com/repos/RackHD/on-http/pulls/104","_links":{"self":{"href":"https://api.github.com/repos/RackHD/on-http/pulls/comments/51562130"},"html":{"href":"https://github.com/RackHD/on-http/pull/104#discussion_r51562130"},"pull_request":{"href":"https://api.github.com/repos/RackHD/on-http/pulls/104"}}},"pull_request":{"url":"https://api.github.com/repos/RackHD/on-http/pulls/104","id":57448311,"html_url":"https://github.com/RackHD/on-http/pull/104","diff_url":"https://github.com/RackHD/on-http/pull/104.diff","patch_url":"https://github.com/RackHD/on-http/pull/104.patch","issue_url":"https://api.github.com/repos/RackHD/on-http/issues/104","number":104,"state":"open","locked":false,"title":"Redfish 1.0 /TaskService:","user":{"login":"zyoung51","id":13998687,"avatar_url":"https://avatars.githubusercontent.com/u/13998687?v=3","gravatar_id":"","url":"https://api.github.com/users/zyoung51","html_url":"https://github.com/zyoung51","followers_url":"https://api.github.com/users/zyoung51/followers","following_url":"https://api.github.com/users/zyoung51/following{/other_user}","gists_url":"https://api.github.com/users/zyoung51/gists{/gist_id}","starred_url":"https://api.github.com/users/zyoung51/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zyoung51/subscriptions","organizations_url":"https://api.github.com/users/zyoung51/orgs","repos_url":"https://api.github.com/users/zyoung51/repos","events_url":"https://api.github.com/users/zyoung51/events{/privacy}","received_events_url":"https://api.github.com/users/zyoung51/received_events","type":"User","site_admin":false},"body":"- Implement GET for the following endpoints:\r\n  - /TaskService\r\n  - /TaskService/Tasks\r\n  - /TaskService/Oem/Tasks/{nodeid}\r\n  - /TaskService/Tasks/{taskid}\r\n- Update redfish swagger definition\r\n- Add unittests","created_at":"2016-01-28T03:04:40Z","updated_at":"2016-02-02T12:34:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d770a27983d0e4921f1aefd3bc4ba5d94e188f7a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/RackHD/on-http/pulls/104/commits","review_comments_url":"https://api.github.com/repos/RackHD/on-http/pulls/104/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/104/comments","statuses_url":"https://api.github.com/repos/RackHD/on-http/statuses/6a919e3aedd843d0d08393e55c883d38a6746a16","head":{"label":"zyoung51:feature/redfish-taskservice-2","ref":"feature/redfish-taskservice-2","sha":"6a919e3aedd843d0d08393e55c883d38a6746a16","user":{"login":"zyoung51","id":13998687,"avatar_url":"https://avatars.githubusercontent.com/u/13998687?v=3","gravatar_id":"","url":"https://api.github.com/users/zyoung51","html_url":"https://github.com/zyoung51","followers_url":"https://api.github.com/users/zyoung51/followers","following_url":"https://api.github.com/users/zyoung51/following{/other_user}","gists_url":"https://api.github.com/users/zyoung51/gists{/gist_id}","starred_url":"https://api.github.com/users/zyoung51/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zyoung51/subscriptions","organizations_url":"https://api.github.com/users/zyoung51/orgs","repos_url":"https://api.github.com/users/zyoung51/repos","events_url":"https://api.github.com/users/zyoung51/events{/privacy}","received_events_url":"https://api.github.com/users/zyoung51/received_events","type":"User","site_admin":false},"repo":{"id":45706063,"name":"on-http","full_name":"zyoung51/on-http","owner":{"login":"zyoung51","id":13998687,"avatar_url":"https://avatars.githubusercontent.com/u/13998687?v=3","gravatar_id":"","url":"https://api.github.com/users/zyoung51","html_url":"https://github.com/zyoung51","followers_url":"https://api.github.com/users/zyoung51/followers","following_url":"https://api.github.com/users/zyoung51/following{/other_user}","gists_url":"https://api.github.com/users/zyoung51/gists{/gist_id}","starred_url":"https://api.github.com/users/zyoung51/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zyoung51/subscriptions","organizations_url":"https://api.github.com/users/zyoung51/orgs","repos_url":"https://api.github.com/users/zyoung51/repos","events_url":"https://api.github.com/users/zyoung51/events{/privacy}","received_events_url":"https://api.github.com/users/zyoung51/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/zyoung51/on-http","description":"","fork":true,"url":"https://api.github.com/repos/zyoung51/on-http","forks_url":"https://api.github.com/repos/zyoung51/on-http/forks","keys_url":"https://api.github.com/repos/zyoung51/on-http/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zyoung51/on-http/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zyoung51/on-http/teams","hooks_url":"https://api.github.com/repos/zyoung51/on-http/hooks","issue_events_url":"https://api.github.com/repos/zyoung51/on-http/issues/events{/number}","events_url":"https://api.github.com/repos/zyoung51/on-http/events","assignees_url":"https://api.github.com/repos/zyoung51/on-http/assignees{/user}","branches_url":"https://api.github.com/repos/zyoung51/on-http/branches{/branch}","tags_url":"https://api.github.com/repos/zyoung51/on-http/tags","blobs_url":"https://api.github.com/repos/zyoung51/on-http/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zyoung51/on-http/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zyoung51/on-http/git/refs{/sha}","trees_url":"https://api.github.com/repos/zyoung51/on-http/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zyoung51/on-http/statuses/{sha}","languages_url":"https://api.github.com/repos/zyoung51/on-http/languages","stargazers_url":"https://api.github.com/repos/zyoung51/on-http/stargazers","contributors_url":"https://api.github.com/repos/zyoung51/on-http/contributors","subscribers_url":"https://api.github.com/repos/zyoung51/on-http/subscribers","subscription_url":"https://api.github.com/repos/zyoung51/on-http/subscription","commits_url":"https://api.github.com/repos/zyoung51/on-http/commits{/sha}","git_commits_url":"https://api.github.com/repos/zyoung51/on-http/git/commits{/sha}","comments_url":"https://api.github.com/repos/zyoung51/on-http/comments{/number}","issue_comment_url":"https://api.github.com/repos/zyoung51/on-http/issues/comments{/number}","contents_url":"https://api.github.com/repos/zyoung51/on-http/contents/{+path}","compare_url":"https://api.github.com/repos/zyoung51/on-http/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zyoung51/on-http/merges","archive_url":"https://api.github.com/repos/zyoung51/on-http/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zyoung51/on-http/downloads","issues_url":"https://api.github.com/repos/zyoung51/on-http/issues{/number}","pulls_url":"https://api.github.com/repos/zyoung51/on-http/pulls{/number}","milestones_url":"https://api.github.com/repos/zyoung51/on-http/milestones{/number}","notifications_url":"https://api.github.com/repos/zyoung51/on-http/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zyoung51/on-http/labels{/name}","releases_url":"https://api.github.com/repos/zyoung51/on-http/releases{/id}","deployments_url":"https://api.github.com/repos/zyoung51/on-http/deployments","created_at":"2015-11-06T20:36:16Z","updated_at":"2016-01-28T14:00:54Z","pushed_at":"2016-02-01T19:55:07Z","git_url":"git://github.com/zyoung51/on-http.git","ssh_url":"git@github.com:zyoung51/on-http.git","clone_url":"https://github.com/zyoung51/on-http.git","svn_url":"https://github.com/zyoung51/on-http","homepage":null,"size":1771,"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":"ed4013aab58accaf57e0f559237924cd916c9dc0","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-01-31T09:01:04Z","pushed_at":"2016-02-02T10:08:09Z","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":2089,"stargazers_count":8,"watchers_count":8,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":31,"mirror_url":null,"open_issues_count":5,"forks":31,"open_issues":5,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/RackHD/on-http/pulls/104"},"html":{"href":"https://github.com/RackHD/on-http/pull/104"},"issue":{"href":"https://api.github.com/repos/RackHD/on-http/issues/104"},"comments":{"href":"https://api.github.com/repos/RackHD/on-http/issues/104/comments"},"review_comments":{"href":"https://api.github.com/repos/RackHD/on-http/pulls/104/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/104/commits"},"statuses":{"href":"https://api.github.com/repos/RackHD/on-http/statuses/6a919e3aedd843d0d08393e55c883d38a6746a16"}}}}