xcat2 / xcat-inventory

An inventory tool for xcat cluster
8 stars 16 forks source link

rinstall RESTful API #197

Closed robin2008 closed 5 years ago

robin2008 commented 5 years ago

This PR is for https://github.ibm.com/xcat2/task_management/issues/136, and below changes included:

robin2008 commented 5 years ago

1, run rinstall <node> osimage with /system/nodes/{node}/_operation curl -X POST "http://10.6.27.1:5000/api/v2/system/nodes/mid05tor12cn03/_operation" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"action\": \"rinstall\", \"action_spec\": {\"osimage\":\"\"}}"

10.0.0.104 - - [10/May/2019 03:46:59] "POST /api/v2/system/nodes/mid05tor12cn03/_operation HTTP/1.1" 400 -
2019-05-10 03:47:08,459 DEBUG node.py:94 action_spec={u'osimage': u''}
2019-05-10 03:47:08,459 DEBUG xcat_client_base.py:106 rinstall: noderange=mid05tor12cn03, boot_state=osimage
2019-05-10 03:47:24,429 DEBUG node.py:103 outputs=['Provision node(s): mid05tor12cn03']
10.0.0.104 - - [10/May/2019 03:47:24] "POST /api/v2/system/nodes/mid05tor12cn03/_operation HTTP/1.1" 200 -

And check the CLI

lsdef mid05tor12cn03 -i status,statustime
Object name: mid05tor12cn03
    status=installing
    statustime=05-10-2019 03:50:39

2, run rinstall <node> shell with /system/nodes/{node}/_operation

curl -X POST "http://10.6.27.1:5000/api/v2/system/nodes/mid05tor12cn03/_operation" -H  "accept: application/json" -H  "Content-Type: application/json" -d "{  \"action\": \"rinstall\",  \"action_spec\": {\"boot_state\":\"shell\"}}"

10.0.0.104 - - [10/May/2019 03:47:24] "POST /api/v2/system/nodes/mid05tor12cn03/_operation HTTP/1.1" 200 -
2019-05-10 03:52:23,826 DEBUG node.py:94 action_spec={u'boot_state': u'shell'}
2019-05-10 03:52:23,826 DEBUG xcat_client_base.py:106 rinstall: noderange=mid05tor12cn03, boot_state=shell
2019-05-10 03:52:48,402 DEBUG node.py:103 outputs=['Provision node(s): mid05tor12cn03']

And check the CLI

lsdef mid05tor12cn03 -i status,statustime
Object name: mid05tor12cn03
    status=powering-on
    statustime=05-10-2019 03:52:48

3, run rinstall <nodes> boot with `` on a failed node

curl -X POST "http://10.6.27.1:5000/api/v2/manager/provision" -H  "accept: application/json" -H  "Content-Type: application/json" -d "{  \"noderange\": \"mid05tor12cn03,testnode\",  \"action_spec\": {\"boot_state\":\"boot\"}}"
{
    "message": "Failed to run 'rsetboot' against the following nodes: testnode"
}

In debug log, we can see below exception:
10.0.0.104 - - [10/May/2019 04:20:51] "POST /api/v2/manager/provision HTTP/1.1" 500 -
2019-05-10 04:22:49,911 DEBUG service.py:43 action_spec={u'boot_state': u'boot'}
2019-05-10 04:22:49,912 DEBUG xcat_client_base.py:106 rinstall: noderange=mid05tor12cn03,testnode, boot_state=boot
2019-05-10 04:23:00,626 ERROR app.py:1761 Exception on /api/v2/manager/provision [POST]
Traceback (most recent call last):
  File "/root/xubin/xcat-inventory/xcat-inventory/venv/lib/python2.7/site-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/root/xubin/xcat-inventory/xcat-inventory/venv/lib/python2.7/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/root/xubin/xcat-inventory/xcat-inventory/venv/lib/python2.7/site-packages/flask_restplus/api.py", line 325, in wrapper
    resp = resource(*args, **kwargs)
  File "/root/xubin/xcat-inventory/xcat-inventory/venv/lib/python2.7/site-packages/flask/views.py", line 88, in view
    return self.dispatch_request(*args, **kwargs)
  File "/root/xubin/xcat-inventory/xcat-inventory/venv/lib/python2.7/site-packages/flask_restplus/resource.py", line 44, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/root/xubin/xcat-inventory/xcat-inventory/xcclient/allien/resources/service.py", line 48, in post
    ns.abort(500, str(e))
  File "/root/xubin/xcat-inventory/xcat-inventory/venv/lib/python2.7/site-packages/flask_restplus/namespace.py", line 133, in abort
    abort(*args, **kwargs)
  File "/root/xubin/xcat-inventory/xcat-inventory/venv/lib/python2.7/site-packages/flask_restplus/errors.py", line 31, in abort
    flask.abort(code)
  File "/root/xubin/xcat-inventory/xcat-inventory/venv/lib/python2.7/site-packages/werkzeug/exceptions.py", line 752, in abort
    return _aborter(status, *args, **kwargs)
  File "/root/xubin/xcat-inventory/xcat-inventory/venv/lib/python2.7/site-packages/werkzeug/exceptions.py", line 733, in __call__
    raise self.mapping[code](*args, **kwargs)
InternalServerError: 500 Internal Server Error: The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
10.6.27.1 - - [10/May/2019 04:23:00] "POST /api/v2/manager/provision HTTP/1.1" 500 -

4,

curl -X POST "http://10.6.27.1:5000/api/v2/manager/provision" -H  "accept: application/json" -H  "Content-Type: application/json" -d "{  \"noderange\": \"mid05tor12cn03\",  \"action_spec\": {\"boot_state\":\"shell\"}}"

10.6.27.1 - - [10/May/2019 04:23:00] "POST /api/v2/manager/provision HTTP/1.1" 500 -
2019-05-10 05:03:26,204 DEBUG service.py:43 action_spec={u'boot_state': u'shell'}
2019-05-10 05:03:26,205 DEBUG xcat_client_base.py:106 rinstall: noderange=mid05tor12cn03, boot_state=shell
10.0.0.104 - - [10/May/2019 05:03:38] "POST /api/v2/manager/provision HTTP/1.1" 200 -

And the response body container the below information:

{
  "outputs": [
    "Provision node(s): mid05tor12cn03"
  ]
}
bybai commented 5 years ago

I am ok to merge it.

whowutwut commented 5 years ago

@cxhong @gurevichmark We should take a look at these changes and see if we can compare it... or at least push the performance testing framework to compare with legacy code. Seems like with this change we can do something with the new server

robin2008 commented 5 years ago

@vhu This is bypass to xcatd, REST -> xcatd -> old plugin. I don't think there would be better performance, but we care not bad performance is okay when comparing the legacy code.