Guest User

Untitled

a guest
Feb 1st, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. As part of planned host maintenance, tried to play around how it could be
  2.  
  3. #In Nova hostid is uniq identifier for host for a tenant/project (somebody else than admin):
  4. import hashlib
  5. projectid = str(instance.project_id)
  6. host = instance.host
  7. hostid = hashlib.sha224(projectid + host).hexdigest()
  8.  
  9. #As other than admin is not allowed to know hostname, they should refer to it with other uniq identifier.
  10. #Nova has hostid for this. Here with some imaginery projectid and host:
  11. projectid = "8a3169016ed14558bf062b1a4ce21737"
  12. host = "compute.host.example.com"
  13. hostid = hashlib.sha224(projectid + host).hexdigest()
  14. print hostid
  15. fc9ec958261e33fb40e4ff08e3602797143817c15ee47a5bd3c048eb
  16.  
  17. #In Craton admin can refer host by its name, where again other users should use hostid as they should not be aware about the hostname.
  18.  
  19. #admin sets host_details to host as namespace:
  20. craton host-set-vars compute.host.example.com /host_details
  21.  
  22. #admin sets maintenance_state variable to host_details namespace:
  23. craton host-set-vars compute.host.example.com /host_details/maintenance_state="PLANNED_MAINTENANCE"
  24.  
  25. #Can one set multiple variables with one call? This would be important to not to trigger notification on each change?
  26. #There could be something more like:
  27. maintenance_reason="firmware update"
  28. maintenance_start="2016-03-22T00:46:25Z",
  29. maintenance_end="2016-03-22T04:46:25Z",
  30.  
  31. #Notification would be triggered with payload from host_details namespace with host from host namespace included
  32. #Assuming this can be admin level as other user would not directly consume notification, but alarm
  33.  
  34. #Based on Nova discussions and Nova spec: https://review.openstack.org/310510
  35. #in Nova you would set to nova-compute service a link to Craton:
  36.  
  37. PUT /v2.1/{tenant_id}/os-services/host-details
  38. {
  39. "host": "compute.host.example.com",
  40. "binary": "nova-compute",
  41. "host_details": "http://${CRATON_IP}:8080/v1/hosts/host_details/compute.host.example.com",
  42. }
  43. 200 OK
  44. {
  45. "service": {
  46. "host": "my.host.example.com",
  47. "binary": "nova-compute",
  48. "host_details": "http://${CRATON_IP}:8080/v1/hosts/host_details/compute.host.example.com",
  49. }
  50. }
  51.  
  52. #In Nova server API project could get link to Craton host data he is allowed to see.
  53. #Nova translates internally the url given to nova-compute service host_details
  54. #by replacing "hostname" with project specific hostid
  55. GET /v2.1/8a3169016ed14558bf062b1a4ce21737/servers/{server_id}
  56. 200 OK
  57. {
  58. "server": {
  59. ...
  60. "host_details": "http://${CRATON_IP}:8080/v1/hosts/host_details/fc9ec958261e33fb40e4ff08e3602797143817c15ee47a5bd3c048eb",
  61. ...
  62. }
  63. }
  64.  
  65. How would this work for project: "GET http://${CRATON_IP}:8080/v1/hosts/host_details/fc9ec958261e33fb40e4ff08e3602797143817c15ee47a5bd3c048eb"
  66. Data should be same as
  67. "GET http://${CRATON_IP}:8080/v1/hosts/host_details"
  68. Unless admin would place some variable not to be seen by other users.
Advertisement
Add Comment
Please, Sign In to add comment