-
Notifications
You must be signed in to change notification settings - Fork 77
refactor southbound templates api #531
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 #531
Conversation
spec/lib/api/1.1/nodes-spec.js
Outdated
| var configuration; | ||
| var templates; | ||
| var taskProtocol; | ||
| var commonApiPresenter; |
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.
'commonApiPresenter' is defined but never used.
lib/api/1.1/southbound/nodes.js
Outdated
| * @api {get} /api/1.1/nodes/:indentifier/templates/:templateName GET /:indentifier/templates/:templateName | ||
| * @apiVersion 1.1.0 | ||
| * @apiDescription used internally by the system -- will NOT the template with the | ||
| * <code>templateName</code>, use /api/current/templates/library |
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/api/1.1/southbound/nodes.js
Outdated
| var router = express.Router(); | ||
|
|
||
| /** | ||
| * @api {get} /api/1.1/nodes/:indentifier/templates/:templateName GET /:indentifier/templates/:templateName |
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.
|
jenkins: depends on RackHD/on-tasks#374 RackHD/on-taskgraph#187 |
46691a8 to
19baff4
Compare
|
test this please A new setup vmslave took the test task unexpected, now has been fixed |
19baff4 to
c6fa250
Compare
c6fa250 to
c21bac2
Compare
|
test this please. |
|
test this please |
c4e901c to
b786882
Compare
|
@keedya Would you mind taking a look through this? I know you had some similar ideas about using nodeId in place of a lookup. |
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 Changes look good, but we need to make sure that functional and regression tests pass before merging. Please work with @anhou and @yyscamper to coordinate the merge. |
|
looks good 👍 |
lib/api/2.0/templates.js
Outdated
| ]); | ||
| }) | ||
| .spread(function(workflow, node) { | ||
| var nodeId = req.swagger.query.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.
some suggestion on follow-up work (not a must-to-have for this PR):
- We had talked the unique identifier can be either of nodeId or mac or board-serial-number or something else, so I think there would be a function to handle all of these identifier.
- Now your work only touches the /templates API, in future when touching more and more southbound APIs, you need to take care of reducing the code duplication. How to get the unique identifier (not only nodeId) from request should be some code code that shared by all southbound APIs or even should be configured in swagger as a fitting to let it works automatically.
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.
We have created story https://www.pivotaltracker.com/story/show/134938873 to follow the suggestions.
Thanks.
spec/lib/api/2.0/templates-spec.js
Outdated
| this.sandbox.stub(swagger, 'makeRenderableOptions').resolves({}); | ||
| taskProtocol.requestProperties.resolves({}); | ||
| return helper.request().get('/api/2.0/templates/123') | ||
| return helper.request().get('/api/2.0/templates/123?nodeId=123') |
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 add a negative test case to prove the API will fail if missing 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.
Done, thanks.
yyscamper
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.
+1 after adding a negative test case.
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.
Looks good 👍
|
@yyscamper Currently, the Jenkins-Dependency-PR can't work properly. |
48bf699 to
27f8016
Compare
|
test this please. |
|
@brianparry OK, thanks for your review. |
4a4f468 to
2611de0
Compare
|
test this please. |
2611de0 to
29b2f64
Compare
| 'use strict'; | ||
|
|
||
| var di = require('di'), | ||
| ejs = require('ejs'); |
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.
'ejs' is defined but never used.
| nodeApiService | ||
| ) { | ||
|
|
||
| var logger = Logger.initialize(templateApiServiceFactory); |
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.
'logger' is defined but never used.
lib/services/nodes-api-service.js
Outdated
| */ | ||
| NodeApiService.prototype.getNodeByIdentifier = function(identifier) { | ||
| return waterline.nodes.findByIdentifier(identifier); | ||
| } |
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.
Missing semicolon.
f53cc4d to
eac0ad4
Compare
|
@lanchongyizu Very appreciate you updated the PR description following the template, which makes people to understand what been done clearly. Awesome~~ |
…emplates/:name?macs=:macs * make option downloadUrl to use FULL PATH * remove postLookup() in esx-ks
eac0ad4 to
71cc464
Compare
|
BUILD on-http #2890 : UNSTABLE
BUILD smoke-test #3858 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': 'Tue, 29 Nov 2016 08:50:00 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 |
|
test this please. |
|
BUILD on-http #2891 : UNSTABLE
BUILD smoke-test #3859 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': 'Tue, 29 Nov 2016 10:13:03 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 |
Background
Currently, RackHD is heavily coupled with and dependent on lookups, especially the 1 to 1 relationship between MAC and IP, which causes the static IP problems and maybe other problems.
There are two kinds of relationships between MAC and IP, which should be taken into consideration now.
When the nodeId assigned, we can use it to identify the node rather than depend on lookups, since the latter introduces more complexity into lookups.
Also, MACAddress and maybe serial board number can be as identifiers.
Implementation
Thereafter, the PRs
are to refactor
/templates/:nameto
Additional work:
Test
I have tested the PRs by successfully installing below OSes which would be functionally equal to Regression Test.
Note: For Windows Server 2012, you should regenerate a new WinPE image.
@RackHD/corecommitters @panpan0000 @iceiilin @keedya @johren