-
Notifications
You must be signed in to change notification settings - Fork 77
Add obm setting while posting a new node #524
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
Conversation
| helper.di.simpleWrapper(messenger, 'Services.Messenger'), | ||
| helper.di.simpleWrapper(rx,'Rx'), | ||
| helper.di.requireWrapper('node-cache', 'node-cache') | ||
| helper.di.requireWrapper('node-cache', 'node-cache', undefined, __dirname) |
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.
If without this change, the unit-test will always fail due to following error:
1) UPnP Service "before all" hook:
Error: dihelper incapable of finding specified file for require filename:node-cache, directories:(/home/rackhd/src/on-core/spec, /home/rackhd/src/on-core/lib)
at _require (/home/rackhd/src/on-core/lib/di.js:492:13)
at Object.requireWrapper (/home/rackhd/src/on-core/lib/di.js:518:13)
at Context.<anonymous> (spec/lib/services/upnp-service-spec.js:49:23)
|
👍 |
|
@yyscamper Please see my comment under RackHD/RackHD#483 |
| return waterline.nodes.create(body); | ||
| }).tap(function(node) { | ||
| return eventsProtocol.publishNodeEvent(node, 'added'); | ||
| }).tap(function(node) { |
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 does not look right to me. We dont have obmSettings anymore. They come up as obms. @brianparry - to keep me honest here.
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.
@srinia6: I examined the schema for POST /nodes (see https://github.com/RackHD/on-http/blob/master/static/monorail-2.0.yaml#L83), it doesn't tell how to specify the obm when manually adding a node.
And by looking at the rest code of postNode function, you will it still use the obmSettings (see https://github.com/yyscamper/on-http/blob/b31f6b199676172de8ddb37c0504de6df1cac197/lib/services/nodes-api-service.js#L308).
Anyway, we always need a way to let user specify the obm while manually adding a node, previously the obm document is bind with node, so it's pretty straightforward, now the obm is moved out, the situation is a little hard. If let user manually add the obm before creating node, but you don't know the node id; If bind obm document with node, then there is some what mismatch with our internal structure.
So @srinia6 @brianparry : What's your preference for how to specify the obm while adding a node?
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.
@yyscamper The line you've referenced in nodes-api-service is a bug. node.obmSettings will always be undefined. A separate query to the obms collection is required to get the obms associated with that node. The autoDiscover case is one that we missed when refactoring obms, and I think this is a reasonable approach to deal with it. I think we should change the property in the body from obmSettings to obms though. This will match the name of the collection and the way this is displayed in the view.
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.
body.obmSettings does not exists in the API 2.0, and the proposed changes are now handled via obms route and/or node/id/obms route. Your code needs to be re-visited.
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.
Overall 👍 but I think we need to make some changes to the schema for request validation.
| return waterline.nodes.create(body); | ||
| }).tap(function(node) { | ||
| return eventsProtocol.publishNodeEvent(node, 'added'); | ||
| }).tap(function(node) { |
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.
@yyscamper The line you've referenced in nodes-api-service is a bug. node.obmSettings will always be undefined. A separate query to the obms collection is required to get the obms associated with that node. The autoDiscover case is one that we missed when refactoring obms, and I think this is a reasonable approach to deal with it. I think we should change the property in the body from obmSettings to obms though. This will match the name of the collection and the way this is displayed in the view.
lib/services/nodes-api-service.js
Outdated
| NodeApiService.prototype.postNode = function(body) { | ||
| return Promise.resolve().then(function() { | ||
| return Promise.try (function() { | ||
| assert.string(body.type, 'node type is required'); |
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.
@yyscamper This should be handled in the schema; we should be adding type to the list of required properties: https://github.com/RackHD/on-http/blob/master/static/schemas/2.0/node.2.0.json#L54. You shouldn't need to validate the type since we have a enum in the schema with all node types. The new obms request option should be added to the nodes schema as an array of objects. The tricky part here is that we should be referencing the obm schema (https://github.com/RackHD/on-http/tree/master/static/schemas/obms) here to validate the obms themselves.
|
@brianparry : Your comment has been resolved. Actually this is more difficult that I thought to move the validation code into schema. The challenge is: So my solution is: |
|
BUILD on-http #2820 : UNSTABLE
|
f5a2205 to
fcbc3af
Compare
|
@brianparry : As we talked last week. I have removed the newly created obm schema, as a follow-up, the schema validation need to be moved into the swagger fitting. Please review this PR, whether this is OK or not. |
This is a part of fix for https://github.com/RackHD/RackHD/issues/483
Root cause: After the obm is moved to a standalone model, we forget to add the obm setting while posting a new node, so some node catalog job will fail.
BTW: the unit-test error due to the node-cache is fixed as well in my PR.
@RackHD/corecommitters @iceiilin @cgx027 @pengz1 @manfrednde