-
Notifications
You must be signed in to change notification settings - Fork 77
refactor southbound templates api #374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor southbound templates api #374
Conversation
spec/lib/task-spec.js
Outdated
| expect(task.options.fileServer).to.equal(fileServerUri); | ||
| expect(task.options.baseRoute).to.equal(server + '/api/current'); | ||
| expect(task.options.templatesRoute).to.equal(server + '/api/current/templates'); | ||
| expect(task.options.templatesRoute).to.equal(server + '/api/current/nodes/testtarget/templates'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long.
lib/task.js
Outdated
| self.renderContext.api.lookups = self.renderContext.api.base + '/lookups'; | ||
| self.renderContext.api.files = self.renderContext.api.base + '/files'; | ||
| self.renderContext.api.nodes = self.renderContext.api.base + '/nodes'; | ||
| self.renderContext.api.templates = self.renderContext.api.nodes + '/' + self.nodeId + '/templates'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long.
|
:+0: , sounds functional good. |
f9034fc to
6aa98af
Compare
| var positiveSetParamCommand = { | ||
| 'commands[1]': 'touch foo.txt', //allow duplicated command | ||
| 'commands[1].downloadUrl': ['/foo', '/foo123/123/bar'], | ||
| 'commands[1].downloadUrl': ['http://abc.com/foo', 'http://10.0.0.1:8080/foo123/123/bar', 'www.abc.com/abc'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long.
|
BUILD on-tasks #1751 : UNSTABLE
|
6aa98af to
73dfa97
Compare
| }); | ||
| expect(builtCommands[2]).to.deep.equal({ | ||
| cmd: 'runSomething', downloadUrl: 'api/downloadScript' | ||
| cmd: 'runSomething', downloadUrl: 'http://10.0.0.1:8080/api/downloadScript?nodeId={{context.target}}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long.
| }, | ||
| { | ||
| command: 'runSomething', downloadUrl: 'api/downloadScript' | ||
| command: 'runSomething', downloadUrl: 'http://10.0.0.1:8080/api/downloadScript?nodeId={{context.target}}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long.
lib/task-data/tasks/install-esx.js
Outdated
| rackhdCallbackScript: 'esx.rackhdcallback', | ||
| esxBootConfigTemplate: 'esx-boot-cfg', | ||
| esxBootConfigTemplateUri: '{{api.templates}}/{{options.esxBootConfigTemplate}}', | ||
| esxBootConfigTemplateUri: '{{api.templates}}/{{options.esxBootConfigTemplate}}?nodeId={{context.target}}', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long.
lib/jobs/secure-erase-drive.js
Outdated
|
|
||
| // add script's url in the first command | ||
| this.commands[0].downloadUrl = '/api/current/templates/secure_erase.py'; | ||
| this.commands[0].downloadUrl = '{{api.templates}}/secure_erase.py?nodeId={{context.target}}'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long.
|
BUILD on-tasks #1754 : UNSTABLE
BUILD smoke-test #3816 Error Logs ▼Test Name: test_list_simple_storage Error Details: (404) Reason: Not Found HTTP response headers: HTTPHeaderDict({'Content-Length': '742', 'X-Powered-By': 'Express', 'Connection': 'keep-alive', 'ETag': 'W/"2e6-R1p0eb9wQS2jPLEGXhEJyA"', 'Date': 'Mon, 21 Nov 2016 10:09:59 GMT', 'Access-Control-Allow-Origin': '*', 'Content-Type': 'application/json; charset=utf-8'}) HTTP response body: {"error":{"code":"Base.1.0.GeneralError","message":"A general error has occurred. See ExtendedInfo for more information.","@Message.ExtendedInfo":[{"@odata.type":"#Message.1.0.0.Message","MessageId":"Base.1.0.Messages.InvalidObject","Description":"Indicates that the object in question is invalid according to the implementation. Examples include a firmware update malformed URI.","Message":"The object at %1 is invalid.","Resolution":"Either the object is malformed or the URI is not correct. Correct the condition and resubmit the request if it failed.","Severity":"Critical"},{"MessageId":"RackHD.1.0.DetailedErrorMessage","Message":"No Catalogs Found for Source (smart).","Description":"Contains the detailed error message contents"}]}}Stack Trace: Traceback (most recent call last): Test Name: test_catalogs |
brianparry
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
@lanchongyizu I think it would be best to have @anhou or @yyscamper work with you to merge this to make sure all the dependencies are covered. |
|
@lanchongyizu if this PR had dependency with PR RackHD/on-http#531, at least the depenency PR test should pass. |
|
@lanchongyizu: Forgot to mention you, this description should be changed since now the downloadUrl is full path not relative path:
|
| "description": "Specify the download URL (relative to RackHD southbound API server) if the command needs to download some data or script from RackHD before execution", | ||
| "type": "string", | ||
| "pattern": "^/[a-zA-Z0-9+-.#?=\\\/]+" | ||
| "minLength": 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to keep the pattern and check downloadurl against a valid http URL pattern. There are talks/PRs around changing relative URI to fullpath URL and this check will help people catch errors if a legacy relative URI is used.
Ref: https://github.com/RackHD/RackHD/issues/489#issuecomment-262570418
| { | ||
| command: 'sudo node get_driveid.js', | ||
| downloadUrl: '/api/current/templates/get_driveid.js' | ||
| downloadUrl: '{{api.templates}}/get_driveid.js?nodeId={{context.target}}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A picky style suggestion. It's more like we leave spaces around(before and after) the render elements, like following example. In this PR, there are no spaces between api.templates and the surrounding {{ }}.
You can decide yourself on whether to change it or not.
lib/graphs/discovery-sku-graph.js
14: nodeIds: [ "{{ options.nodeId }}" ]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check with https://github.com/RackHD/on-tasks/blob/master/lib/task-data/tasks/install-centos.js#L14.
Thanks.
lib/task-data/tasks/catalog-smart.js
Outdated
| { | ||
| command: 'sudo bash get_smart.sh', | ||
| downloadUrl: '/api/current/templates/get_smart.sh' | ||
| downloadUrl: '{{api.templates}}/get_smart.sh?nodeId={{context.target}}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This suggestion has gone beyond this PR, but {{ context.target }} gives people unclear hint that is actually referring to a node ID. something like ?nodeId={{context.nodeId}}' or ?nodeId={{ tasks.nodeID}}' would make the code more readable and less error-prong.
Agreed? @yyscamper @anhou . If yes, this would generate a follow up refactor task.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just find the refactor has already been done in master, so please update {{context.target}} to {{nodeId}}
Ref: https://github.com/RackHD/on-http/blob/master/lib/services/swagger-api-service.js#L346
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work for task rendering, but only for templates and profiles rendering.
Thanks.
cgx027
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+0, I would suggest to add a schema pattern check against downloadUrl.
73dfa97 to
37123fb
Compare
| var positiveSetParamCommand = { | ||
| 'commands[1]': 'touch foo.txt', //allow duplicated command | ||
| 'commands[1].downloadUrl': ['/foo', '/foo123/123/bar'], | ||
| 'commands[1].downloadUrl': ['http://abc.com/foo', 'http://10.0.0.1:8080/foo123/123/bar?nodeId={{context.target}}', 'www.abc.com/abc'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long.
|
BUILD on-tasks #1756 : FAILURE
|
37123fb to
f03c597
Compare
| { | ||
| command: 'sudo ./remove_bmc_credentials.sh', | ||
| downloadUrl: '/api/current/templates/remove_bmc_credentials.sh' | ||
| downloadUrl: '{{ api.templates }}/remove_bmc_credentials.sh?nodeId={{ task.nodeId }}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long.
| profile: 'install-ubuntu.ipxe', | ||
| installScript: 'ubuntu-preseed', | ||
| installScriptUri: '{{api.templates}}/{{options.installScript}}', | ||
| installScriptUri: '{{ api.templates }}/{{ options.installScript }}?nodeId={{ task.nodeId }}', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long.
| profile: 'install-suse.ipxe', | ||
| installScript: 'suse-autoinst.xml', | ||
| installScriptUri: '{{api.templates}}/{{options.installScript}}', | ||
| installScriptUri: '{{ api.templates }}/{{ options.installScript }}?nodeId={{ task.nodeId }}', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long.
| profile: 'install-photon-os.ipxe', | ||
| installScript: 'photon-os-ks', | ||
| installScriptUri: '{{api.templates}}/{{options.installScript}}', | ||
| installScriptUri: '{{ api.templates }}/{{ options.installScript }}?nodeId={{ task.nodeId }}', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long.
| profile: 'install-esx.ipxe', | ||
| installScript: 'esx-ks', | ||
| installScriptUri: '{{api.templates}}/{{options.installScript}}', | ||
| installScriptUri: '{{ api.templates }}/{{ options.installScript }}?nodeId={{ task.nodeId }}', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long.
| profile: 'install-coreos.ipxe', | ||
| installScript: 'install-coreos.sh', | ||
| installScriptUri: '{{api.templates}}/{{options.installScript}}', | ||
| installScriptUri: '{{ api.templates }}/{{ options.installScript }}?nodeId={{ task.nodeId }}', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long.
| profile: 'install-centos.ipxe', | ||
| installScript: 'centos-ks', | ||
| installScriptUri: '{{api.templates}}/{{options.installScript}}', | ||
| installScriptUri: '{{ api.templates }}/{{ options.installScript }}?nodeId={{ task.nodeId }}', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long.
|
BUILD on-tasks #1760 : UNSTABLE
BUILD smoke-test #3843 Error Logs ▼Test Name: test_list_simple_storage Error Details: (404) Reason: Not Found HTTP response headers: HTTPHeaderDict({'Content-Length': '742', 'X-Powered-By': 'Express', 'Connection': 'keep-alive', 'ETag': 'W/"2e6-R1p0eb9wQS2jPLEGXhEJyA"', 'Date': 'Sun, 27 Nov 2016 14:01:27 GMT', 'Access-Control-Allow-Origin': '*', 'Content-Type': 'application/json; charset=utf-8'}) HTTP response body: {"error":{"code":"Base.1.0.GeneralError","message":"A general error has occurred. See ExtendedInfo for more information.","@Message.ExtendedInfo":[{"@odata.type":"#Message.1.0.0.Message","MessageId":"Base.1.0.Messages.InvalidObject","Description":"Indicates that the object in question is invalid according to the implementation. Examples include a firmware update malformed URI.","Message":"The object at %1 is invalid.","Resolution":"Either the object is malformed or the URI is not correct. Correct the condition and resubmit the request if it failed.","Severity":"Critical"},{"MessageId":"RackHD.1.0.DetailedErrorMessage","Message":"No Catalogs Found for Source (smart).","Description":"Contains the detailed error message contents"}]}}Stack Trace: Traceback (most recent call last): Test Name: test_catalogs BUILD unit-tests #10188 Error Logs ▼Test Name: Graph Library should validate all existing graphs not requiring user input for null values Error Details: Value does not exist for task.nodeId Stack Trace: TemplateRenderError: Value does not exist for task.nodeId at Task.renderString (node_modules/on-tasks/lib/task.js:214:19) at node_modules/on-tasks/lib/task.js:262:37 at arrayMap (node_modules/lodash/index.js:1406:25) at Function.map (node_modules/lodash/index.js:6710:14) at Task.render (node_modules/on-tasks/lib/task.js:254:18) at Task.renderOptions (node_modules/on-tasks/lib/task.js:273:25) at node_modules/on-tasks/lib/task.js:276:31 at node_modules/lodash/index.js:10033:16 at node_modules/lodash/index.js:3073:15 at baseForOwn (node_modules/lodash/index.js:2046:14) at Function.transform (node_modules/lodash/index.js:10032:39) at Task.renderOptions (node_modules/on-tasks/lib/task.js:275:22) at node_modules/on-tasks/lib/task.js:276:31 at node_modules/lodash/index.js:10033:16 at arrayEach (node_modules/lodash/index.js:1289:13) at Function.transform (node_modules/lodash/index.js:10032:39) at Task.renderOptions (node_modules/on-tasks/lib/task.js:275:22) at node_modules/on-tasks/lib/task.js:276:31 at node_modules/lodash/index.js:10033:16 at node_modules/lodash/index.js:3073:15 at baseForOwn (node_modules/lodash/index.js:2046:14) at Function.transform (node_modules/lodash/index.js:10032:39) at Task.renderOptions (node_modules/on-tasks/lib/task.js:275:22) at Task.renderOwnOptions (node_modules/on-tasks/lib/task.js:282:29) at node_modules/on-tasks/lib/task.js:180:22 at Object.finallyHandler (node_modules/on-core/node_modules/bluebird/js/main/finally.js:39:23) at Object.tryCatcher (node_modules/on-core/node_modules/bluebird/js/main/util.js:26:23) at Promise._settlePromiseFromHandler (node_modules/on-core/node_modules/bluebird/js/main/promise.js:510:31) at Promise._settlePromiseAt (node_modules/on-core/node_modules/bluebird/js/main/promise.js:584:18) at Async._drainQueue (node_modules/on-core/node_modules/bluebird/js/main/async.js:128:12) at Async._drainQueues (node_modules/on-core/node_modules/bluebird/js/main/async.js:133:10) at Immediate.Async.drainQueues [as _onImmediate] (node_modules/on-core/node_modules/bluebird/js/main/async.js:15:14)BUILD on-taskgraph #1736 Error Logs ▼Test Name: Graph Library should validate all existing graphs not requiring user input for null values Error Details: Value does not exist for task.nodeId Stack Trace: TemplateRenderError: Value does not exist for task.nodeId at Task.renderString (node_modules/on-tasks/lib/task.js:214:19) at node_modules/on-tasks/lib/task.js:262:37 at arrayMap (node_modules/lodash/index.js:1406:25) at Function.map (node_modules/lodash/index.js:6710:14) at Task.render (node_modules/on-tasks/lib/task.js:254:18) at Task.renderOptions (node_modules/on-tasks/lib/task.js:273:25) at node_modules/on-tasks/lib/task.js:276:31 at node_modules/lodash/index.js:10033:16 at node_modules/lodash/index.js:3073:15 at baseForOwn (node_modules/lodash/index.js:2046:14) at Function.transform (node_modules/lodash/index.js:10032:39) at Task.renderOptions (node_modules/on-tasks/lib/task.js:275:22) at node_modules/on-tasks/lib/task.js:276:31 at node_modules/lodash/index.js:10033:16 at arrayEach (node_modules/lodash/index.js:1289:13) at Function.transform (node_modules/lodash/index.js:10032:39) at Task.renderOptions (node_modules/on-tasks/lib/task.js:275:22) at node_modules/on-tasks/lib/task.js:276:31 at node_modules/lodash/index.js:10033:16 at node_modules/lodash/index.js:3073:15 at baseForOwn (node_modules/lodash/index.js:2046:14) at Function.transform (node_modules/lodash/index.js:10032:39) at Task.renderOptions (node_modules/on-tasks/lib/task.js:275:22) at Task.renderOwnOptions (node_modules/on-tasks/lib/task.js:282:29) at node_modules/on-tasks/lib/task.js:180:22 at Object.finallyHandler (node_modules/on-core/node_modules/bluebird/js/main/finally.js:39:23) at Object.tryCatcher (node_modules/on-core/node_modules/bluebird/js/main/util.js:26:23) at Promise._settlePromiseFromHandler (node_modules/on-core/node_modules/bluebird/js/main/promise.js:510:31) at Promise._settlePromiseAt (node_modules/on-core/node_modules/bluebird/js/main/promise.js:584:18) at Async._drainQueue (node_modules/on-core/node_modules/bluebird/js/main/async.js:128:12) at Async._drainQueues (node_modules/on-core/node_modules/bluebird/js/main/async.js:133:10) at Immediate.Async.drainQueues [as _onImmediate] (node_modules/on-core/node_modules/bluebird/js/main/async.js:15:14) |
It's related with RackHD/on-http#531.
@RackHD/corecommitters @panpan0000 @iceiilin @keedya @johren