Advertisement
Guest User

Untitled

a guest
Oct 10th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. diff --git a/rbd-target-api.py b/rbd-target-api.py
  2. index 394c7e0..3217b32 100755
  3. --- a/rbd-target-api.py
  4. +++ b/rbd-target-api.py
  5. @@ -763,34 +763,38 @@ def _disk(image_id):
  6. logger.error("LUN alloc problem - too many LUNs")
  7. return jsonify(message="LUN allocation failure: too many LUNs"), 500
  8.  
  9. - lun.allocate()
  10. - if lun.error:
  11. - logger.error("LUN alloc problem - {}".format(lun.error_msg))
  12. - return jsonify(message="LUN allocation failure"), 500
  13. + try:
  14. + lun.allocate()
  15. + if lun.error:
  16. + logger.error("LUN alloc problem - {}".format(lun.error_msg))
  17. + return jsonify(message="LUN allocation failure"), 500
  18.  
  19. - if mode == 'create':
  20. - # new disk is allocated, so refresh the local config object
  21. - config.refresh()
  22. + if mode == 'create':
  23. + # new disk is allocated, so refresh the local config object
  24. + config.refresh()
  25.  
  26. - iqn = config.config['gateways']['iqn']
  27. - ip_list = config.config['gateways']['ip_list']
  28. + iqn = config.config['gateways']['iqn']
  29. + ip_list = config.config['gateways']['ip_list']
  30.  
  31. - # Add the mapping for the lun to ensure the block device is
  32. - # present on all TPG's
  33. - gateway = GWTarget(logger,
  34. - iqn,
  35. - ip_list)
  36. + # Add the mapping for the lun to ensure the block device is
  37. + # present on all TPG's
  38. + gateway = GWTarget(logger,
  39. + iqn,
  40. + ip_list)
  41.  
  42. - gateway.manage('map')
  43. - if gateway.error:
  44. - logger.error("LUN mapping failed : "
  45. - "{}".format(gateway.error_msg))
  46. - return jsonify(message="LUN map failed"), 500
  47. + gateway.manage('map')
  48. + if gateway.error:
  49. + logger.error("LUN mapping failed : "
  50. + "{}".format(gateway.error_msg))
  51. + return jsonify(message="LUN map failed"), 500
  52. + return jsonify(message="LUN created"), 200
  53.  
  54. - return jsonify(message="LUN created"), 200
  55. + elif mode == 'resize':
  56. + return jsonify(message="LUN resized"), 200
  57.  
  58. - elif mode == 'resize':
  59. - return jsonify(message="LUN resized"), 200
  60. + except Exception as err:
  61. + logger.error("LUN create failed : {}".format(err))
  62. + return jsonify(message="LUN create failed"), 500
  63.  
  64. elif mode in ['activate', 'deactivate']:
  65. config.refresh()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement