-
Notifications
You must be signed in to change notification settings - Fork 77
Ssh obm service #505
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
Ssh obm service #505
Conversation
|
@RackHD/corecommitters please review. |
lib/api/1.1/northbound/nodes.js
Outdated
| password: 'REDACTED' | ||
| }; | ||
| } else { | ||
| delete node['sshSettings']; |
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.
['sshSettings'] is better written in dot notation.
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.
ignoring this.
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.
it's recommended style also keep consistent with other codes
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
| .then(function (newNode) { | ||
| return eventsProtocol.publishNodeAttrEvent(oldNode, newNode, 'ibms'); | ||
| }) | ||
| .catch(function (error) { |
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.
'error' is defined but never used.
| .then(function(newNode) { | ||
| return eventsProtocol.publishNodeAttrEvent(oldNode, newNode, 'ibms'); | ||
| }) | ||
| .catch(function (error) { |
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.
'error' is defined but never used.
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 It's probably worth appending error.message to your base error message.
|
@RackHD/corecommitters - the unit test failures are due to on-core dependency. |
|
FYI the unit-test failure is due to on-core dependency. |
| var ibmsPatchById = controller( function(req) { | ||
| var ibmId = req.swagger.params.identifier.value; | ||
| var values = req.swagger.params.body.value; | ||
| return waterline.ibms.needByIdentifier(ibmId) |
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.
duplicated codes, it also exists in some other places for ibm and obm. two places will be maintained, and easy to miss something if one place is changed. it needs some optimization, or move the common codes to /lib/services/xxxx. maybe it also could be waterline.[xxx].needByxxxx().
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.
@anhou : I can create a ibm service and move the code for Patch and Delete. But the obm calls the obms waterline collection and ibms calls its own collection. Trying to think if thats what you meant? And not sure what you mean if one place changes ? They are 2 different collections that inherit from base class under on-core/models.
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.
@anhou @srinia6 The duplicated code is in ibmsGet, ibmsPut, ibmsGetById, and ibmsGetAll. These are all basically one-liners, does it really make sense to create another layer of abstraction for this? The two verbs with some substance to them (patch and delete) are not common anyway. They could be moved to a service, but that does not avoid duplication.
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 of the codes are copied from /lib/services/obm-api-services.js the code logic is the same. I think don't need another abstract layer to service api, if ibm and obm really almost the similar in document operation. maybe just a map/dict could reduce the duplication. maintain obm/ibm in /lib/services/bm-api-service.js or lib/services/nm-api-service.js(network management) all the document openration like waterline.obms.xxxx could be waterline.nm[type].xxx, just a method I could think of to de-duplication. or you could use other better ways to do it.
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.
@srinia6 Looks good overall, just a few questions / comments.
| var ibmsPatchById = controller( function(req) { | ||
| var ibmId = req.swagger.params.identifier.value; | ||
| var values = req.swagger.params.body.value; | ||
| return waterline.ibms.needByIdentifier(ibmId) |
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.
@anhou @srinia6 The duplicated code is in ibmsGet, ibmsPut, ibmsGetById, and ibmsGetAll. These are all basically one-liners, does it really make sense to create another layer of abstraction for this? The two verbs with some substance to them (patch and delete) are not common anyway. They could be moved to a service, but that does not avoid duplication.
| .then(function(newNode) { | ||
| return eventsProtocol.publishNodeAttrEvent(oldNode, newNode, 'ibms'); | ||
| }) | ||
| .catch(function (error) { |
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 It's probably worth appending error.message to your base error message.
| return waterline.ibms.needByIdentifier(ibmId) | ||
| .then(function(oldIbm) { | ||
| /* Get nodes that need to publish events */ | ||
| if (oldIbm.node && !values.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.
srinia6 Is this logic needed? Couldn't we just compare the old node to the new node and alert if anything has changed? Or maybe even just always alert?
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 think this part of codes are copied from /lib/service/obm-api-service.js they are written and tested by me several months ago. the logic could be referenced from the unit test cases. the behavior is documented in RackHD/docs in 'event notification' section about obms.assigned/unassigned/updated
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.
Thanks @anhou
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.
@anhou - we have created another story to handle slightly similar code in this story - https://www.pivotaltracker.com/story/show/133740825
|
@srinia6 a strange issue. RackHD/on-tasks#361 but not a URL. I add sub line to correct this test this please still not support branch Thanks. |
| var obms = Promise.map(waterline.obms.find({node: node.id}), function(obm) { | ||
| return _.pick(obm.toJSON(), 'service', 'config'); | ||
| }); | ||
| var sshSettings = waterline.ibms.findByNode(node.id, 'ssh-ibm-service'); |
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.
Since this is only for a 1.1 API backwards compatibility edge case, I'm not going to raise an issue. But in any 2.0 controller I would object to hardcoding for specific IBM service types, especially just for doing 'REDACT' which shouldn't be handled at this layer anyways.
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.
Besides, the function name is _renderNodeObmSettings but the function covers both obm & ibm (ssh), so this doesn't match.
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.
@benbp : Thanks ben! @yyscamper : I will rename the function.
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
|
@srinia6 : this is a reminder for you. When I worked on the issue https://github.com/RackHD/RackHD/issues/483, I found the obm setting was not added while manually adding node, so the node's discovery will fail. The solution is in my PR #524. After the ibm is merged, and when you plan to move the |
| "type": "object", | ||
| "properties": { | ||
| "host": { | ||
| "description": "BMC address", |
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 is not BMC address!
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.
OK
static/monorail-2.0.yaml
Outdated
| get: | ||
| description: 'Get a list of all In Band Management settings that have been associated | ||
|
|
||
| with nodes. |
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 multiple lines style is very strange for me. this line should be put together with line630, the same for a lot below lines.
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 Because this pr has been sitting in review for ~14 days, it needs to be changed per the new master file. Will update it.
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
| "type": "<%=type%>", | ||
| "workflows": "<%=basepath %>/nodes/<%=id%>/workflows" | ||
| "workflows": "<%=basepath %>/nodes/<%=id%>/workflows", | ||
| <% if (ibms === null) { %> |
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 minor suggestion, put the ibm together with obm will help people to compare the difference between them.
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.
Since this has been tested with these changes, i plan to keep them as is for now. Will change them in the snmp story.
lib/api/1.1/northbound/nodes.js
Outdated
| ) | ||
| 'Assert', | ||
| 'Errors' | ||
| ) |
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.
The previous indent is better, please remain it.
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.
ok
|
BUILD on-http #2799 : FAILURE
|
|
@yyscamper : Looking at your PR, that is no way related to this PR. #524 What issue are you talking about? |
|
BUILD on-http #2803 : FAILURE
|
|
BUILD on-http #2804 : FAILURE
|
|
FYI - Jenkins build and CI failures are due to unavailability of on-core models. |
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.
👍
This PR Jenkins:depends on RackHD/on-core#222 and Jenkins:depends on RackHD/on-tasks#361
In this PR:
@RackHD/corecommitters @dalebremner @brianparry @BillyAbildgaard @geoff-reid