Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/rbd-target-api.py b/rbd-target-api.py
- index 394c7e0..3217b32 100755
- --- a/rbd-target-api.py
- +++ b/rbd-target-api.py
- @@ -763,34 +763,38 @@ def _disk(image_id):
- logger.error("LUN alloc problem - too many LUNs")
- return jsonify(message="LUN allocation failure: too many LUNs"), 500
- - lun.allocate()
- - if lun.error:
- - logger.error("LUN alloc problem - {}".format(lun.error_msg))
- - return jsonify(message="LUN allocation failure"), 500
- + try:
- + lun.allocate()
- + if lun.error:
- + logger.error("LUN alloc problem - {}".format(lun.error_msg))
- + return jsonify(message="LUN allocation failure"), 500
- - if mode == 'create':
- - # new disk is allocated, so refresh the local config object
- - config.refresh()
- + if mode == 'create':
- + # new disk is allocated, so refresh the local config object
- + config.refresh()
- - iqn = config.config['gateways']['iqn']
- - ip_list = config.config['gateways']['ip_list']
- + iqn = config.config['gateways']['iqn']
- + ip_list = config.config['gateways']['ip_list']
- - # Add the mapping for the lun to ensure the block device is
- - # present on all TPG's
- - gateway = GWTarget(logger,
- - iqn,
- - ip_list)
- + # Add the mapping for the lun to ensure the block device is
- + # present on all TPG's
- + gateway = GWTarget(logger,
- + iqn,
- + ip_list)
- - gateway.manage('map')
- - if gateway.error:
- - logger.error("LUN mapping failed : "
- - "{}".format(gateway.error_msg))
- - return jsonify(message="LUN map failed"), 500
- + gateway.manage('map')
- + if gateway.error:
- + logger.error("LUN mapping failed : "
- + "{}".format(gateway.error_msg))
- + return jsonify(message="LUN map failed"), 500
- + return jsonify(message="LUN created"), 200
- - return jsonify(message="LUN created"), 200
- + elif mode == 'resize':
- + return jsonify(message="LUN resized"), 200
- - elif mode == 'resize':
- - return jsonify(message="LUN resized"), 200
- + except Exception as err:
- + logger.error("LUN create failed : {}".format(err))
- + return jsonify(message="LUN create failed"), 500
- elif mode in ['activate', 'deactivate']:
- config.refresh()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement