Skip to content

Conversation

@lanchongyizu
Copy link
Member

@lanchongyizu lanchongyizu commented Nov 16, 2016

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.

  1. one MAC address could map to multiple IP addresses, which exists in ARP cache.
  2. one IP address could map to multiple MAC addresses, when users want to set multiple nodes with the same IP address, and it may exist in ARP cache sometime.

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

#531 (this PR)
RackHD/on-tasks#374
RackHD/on-taskgraph#187
RackHD/on-skupack#57
RackHD/docs#362

are to refactor

/templates/:name

to

/templates/:name?nodeId=:nodeId
/templates/:name?macs=:macs

Additional work:

  • make option downloadUrl to use FULL PATH
  • remove postLookup() in esx-ks

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.

Ubuntu 14.04
ESXi 6.0
CentOS 6.5
CentOS 7.0
openSUSE 42.1
CoreOS
Windows Server 2012
Photon OS

@RackHD/corecommitters @panpan0000 @iceiilin @keedya @johren

var configuration;
var templates;
var taskProtocol;
var commonApiPresenter;

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.

* @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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long.

var router = express.Router();

/**
* @api {get} /api/1.1/nodes/:indentifier/templates/:templateName GET /:indentifier/templates/:templateName

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long.

@lanchongyizu
Copy link
Member Author

lanchongyizu commented Nov 16, 2016

jenkins: depends on RackHD/on-tasks#374 RackHD/on-taskgraph#187

@lanchongyizu lanchongyizu force-pushed the refactor-southbound-template-api branch 2 times, most recently from 46691a8 to 19baff4 Compare November 16, 2016 09:37
@changev
Copy link
Member

changev commented Nov 16, 2016

test this please

A new setup vmslave took the test task unexpected, now has been fixed

@lanchongyizu
Copy link
Member Author

test this please.

@changev
Copy link
Member

changev commented Nov 18, 2016

test this please

@lanchongyizu lanchongyizu force-pushed the refactor-southbound-template-api branch 2 times, most recently from c4e901c to b786882 Compare November 21, 2016 10:16
@brianparry
Copy link
Contributor

@keedya Would you mind taking a look through this? I know you had some similar ideas about using nodeId in place of a lookup.

Copy link
Contributor

@brianparry brianparry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@brianparry
Copy link
Contributor

@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.

@keedya
Copy link

keedya commented Nov 22, 2016

looks good 👍

]);
})
.spread(function(workflow, node) {
var nodeId = req.swagger.query.nodeId;
Copy link
Contributor

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.

Copy link
Member Author

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.

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')
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks.

Copy link
Contributor

@yyscamper yyscamper left a 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.

Copy link
Contributor

@cgx027 cgx027 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

@lanchongyizu
Copy link
Member Author

lanchongyizu commented Nov 24, 2016

@yyscamper Currently, the Jenkins-Dependency-PR can't work properly.

@lanchongyizu lanchongyizu force-pushed the refactor-southbound-template-api branch 2 times, most recently from 48bf699 to 27f8016 Compare November 24, 2016 09:53
@lanchongyizu
Copy link
Member Author

test this please.

@lanchongyizu
Copy link
Member Author

@brianparry OK, thanks for your review.

@lanchongyizu lanchongyizu force-pushed the refactor-southbound-template-api branch 2 times, most recently from 4a4f468 to 2611de0 Compare November 25, 2016 13:21
@lanchongyizu
Copy link
Member Author

test this please.

@lanchongyizu lanchongyizu force-pushed the refactor-southbound-template-api branch from 2611de0 to 29b2f64 Compare November 28, 2016 10:07
'use strict';

var di = require('di'),
ejs = require('ejs');

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);

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.

*/
NodeApiService.prototype.getNodeByIdentifier = function(identifier) {
return waterline.nodes.findByIdentifier(identifier);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

@lanchongyizu lanchongyizu force-pushed the refactor-southbound-template-api branch 2 times, most recently from f53cc4d to eac0ad4 Compare November 29, 2016 02:04
@leoyjchang
Copy link

@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
@lanchongyizu lanchongyizu force-pushed the refactor-southbound-template-api branch from eac0ad4 to 71cc464 Compare November 29, 2016 08:20
@JenkinsRHD
Copy link
Contributor

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):
File "/usr/lib/python2.7/unittest/case.py", line 331, in run
testMethod()
File "/usr/lib/python2.7/unittest/case.py", line 1043, in runTest
self._testFunc()
File "/tmp/.venv/local/lib/python2.7/site-packages/proboscis/case.py", line 296, in testng_method_mistake_capture_func
compatability.capture_type_error(s_func)
File "/tmp/.venv/local/lib/python2.7/site-packages/proboscis/compatability/exceptions_2_6.py", line 27, in capture_type_error
func()
File "/tmp/.venv/local/lib/python2.7/site-packages/proboscis/case.py", line 350, in func
func(test_case.state.get_state())
File "/home/jenkins/workspace/on-http/RackHD/test/tests/api/redfish_1_0/systems_tests.py", line 110, in test_list_simple_storage
redfish().list_simple_storage(dataId)
File "/tmp/.venv/local/lib/python2.7/site-packages/on_http_redfish_1_0/apis/redfishv_api.py", line 4047, in list_simple_storage
callback=params.get('callback'))
File "/tmp/.venv/local/lib/python2.7/site-packages/on_http_redfish_1_0/api_client.py", line 322, in call_api
response_type, auth_settings, callback)
File "/tmp/.venv/local/lib/python2.7/site-packages/on_http_redfish_1_0/api_client.py", line 149, in __call_api
post_params=post_params, body=body)
File "/tmp/.venv/local/lib/python2.7/site-packages/on_http_redfish_1_0/api_client.py", line 342, in request
headers=headers)
File "/tmp/.venv/local/lib/python2.7/site-packages/on_http_redfish_1_0/rest.py", line 184, in GET
query_params=query_params)
File "/tmp/.venv/local/lib/python2.7/site-packages/on_http_redfish_1_0/rest.py", line 177, in request
raise ApiException(http_resp=r)
ApiException: (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"}]}}

Test Name: test_catalogs
Error Details: Catalog smart not found in node 583d3f13d4bd2df6087fe2a3!
Stack Trace: Traceback (most recent call last):
File "/usr/lib/python2.7/unittest/case.py", line 331, in run
testMethod()
File "/usr/lib/python2.7/unittest/case.py", line 1043, in runTest
self._testFunc()
File "/tmp/.venv/local/lib/python2.7/site-packages/proboscis/case.py", line 296, in testng_method_mistake_capture_func
compatability.capture_type_error(s_func)
File "/tmp/.venv/local/lib/python2.7/site-packages/proboscis/compatability/exceptions_2_6.py", line 27, in capture_type_error
func()
File "/tmp/.venv/local/lib/python2.7/site-packages/proboscis/case.py", line 350, in func
func(test_case.state.get_state())
File "/home/jenkins/workspace/on-http/RackHD/test/tests/api/v2_0/catalogs_tests.py", line 48, in test_catalogs
fail('Catalog {0} not found in node {1}!'.format(source,node.get('id')))
File "/tmp/.venv/local/lib/python2.7/site-packages/proboscis/asserts.py", line 220, in fail
raise ASSERTION_ERROR(message)
AssertionError: Catalog smart not found in node 583d3f13d4bd2df6087fe2a3!

@lanchongyizu
Copy link
Member Author

test this please.

@JenkinsRHD
Copy link
Contributor

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):
File "/usr/lib/python2.7/unittest/case.py", line 331, in run
testMethod()
File "/usr/lib/python2.7/unittest/case.py", line 1043, in runTest
self._testFunc()
File "/tmp/.venv/local/lib/python2.7/site-packages/proboscis/case.py", line 296, in testng_method_mistake_capture_func
compatability.capture_type_error(s_func)
File "/tmp/.venv/local/lib/python2.7/site-packages/proboscis/compatability/exceptions_2_6.py", line 27, in capture_type_error
func()
File "/tmp/.venv/local/lib/python2.7/site-packages/proboscis/case.py", line 350, in func
func(test_case.state.get_state())
File "/home/jenkins/workspace/on-http/RackHD/test/tests/api/redfish_1_0/systems_tests.py", line 110, in test_list_simple_storage
redfish().list_simple_storage(dataId)
File "/tmp/.venv/local/lib/python2.7/site-packages/on_http_redfish_1_0/apis/redfishv_api.py", line 4047, in list_simple_storage
callback=params.get('callback'))
File "/tmp/.venv/local/lib/python2.7/site-packages/on_http_redfish_1_0/api_client.py", line 322, in call_api
response_type, auth_settings, callback)
File "/tmp/.venv/local/lib/python2.7/site-packages/on_http_redfish_1_0/api_client.py", line 149, in __call_api
post_params=post_params, body=body)
File "/tmp/.venv/local/lib/python2.7/site-packages/on_http_redfish_1_0/api_client.py", line 342, in request
headers=headers)
File "/tmp/.venv/local/lib/python2.7/site-packages/on_http_redfish_1_0/rest.py", line 184, in GET
query_params=query_params)
File "/tmp/.venv/local/lib/python2.7/site-packages/on_http_redfish_1_0/rest.py", line 177, in request
raise ApiException(http_resp=r)
ApiException: (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"}]}}

Test Name: test_catalogs
Error Details: Catalog smart not found in node 583d528dab9f5ec308385a55!
Stack Trace: Traceback (most recent call last):
File "/usr/lib/python2.7/unittest/case.py", line 331, in run
testMethod()
File "/usr/lib/python2.7/unittest/case.py", line 1043, in runTest
self._testFunc()
File "/tmp/.venv/local/lib/python2.7/site-packages/proboscis/case.py", line 296, in testng_method_mistake_capture_func
compatability.capture_type_error(s_func)
File "/tmp/.venv/local/lib/python2.7/site-packages/proboscis/compatability/exceptions_2_6.py", line 27, in capture_type_error
func()
File "/tmp/.venv/local/lib/python2.7/site-packages/proboscis/case.py", line 350, in func
func(test_case.state.get_state())
File "/home/jenkins/workspace/on-http/RackHD/test/tests/api/v2_0/catalogs_tests.py", line 48, in test_catalogs
fail('Catalog {0} not found in node {1}!'.format(source,node.get('id')))
File "/tmp/.venv/local/lib/python2.7/site-packages/proboscis/asserts.py", line 220, in fail
raise ASSERTION_ERROR(message)
AssertionError: Catalog smart not found in node 583d528dab9f5ec308385a55!

@anhou anhou merged commit dc86cc0 into RackHD:master Nov 30, 2016
@JenkinsRHD JenkinsRHD mentioned this pull request Sep 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants