Proper error should be thrown when server group is created with existing name. Fixes #3693

This commit is contained in:
Aditya Toshniwal
2019-01-15 18:38:01 +05:30
committed by Akshay Joshi
parent 7b0c81126c
commit 2a359d9d77
3 changed files with 7 additions and 0 deletions

View File

@@ -145,6 +145,7 @@ class ServerGroupView(NodeView):
db.session.delete(sg)
db.session.commit()
except Exception as e:
db.session.rollback()
return make_json_response(
status=410, success=0, errormsg=e.message
)
@@ -178,10 +179,12 @@ class ServerGroupView(NodeView):
servergroup.name = data[u'name']
db.session.commit()
except exc.IntegrityError:
db.session.rollback()
return bad_request(gettext(
"The specified server group already exists."
))
except Exception as e:
db.session.rollback()
return make_json_response(
status=410, success=0, errormsg=e.message
)
@@ -251,11 +254,13 @@ class ServerGroupView(NodeView):
)
)
except exc.IntegrityError:
db.session.rollback()
return bad_request(gettext(
"The specified server group already exists."
))
except Exception as e:
db.session.rollback()
return make_json_response(
status=410,
success=0,