Repository: incubator-trafficcontrol Updated Branches: refs/heads/master ff950d4ec -> 992f0cd85
reject to delete cdn if server or ds associated Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/c87e8437 Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/c87e8437 Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/c87e8437 Branch: refs/heads/master Commit: c87e843725f99aa86dc7d6688fbd662a07877980 Parents: c824778 Author: Zhilin Huang <zhilh...@cisco.com> Authored: Mon Feb 27 14:45:37 2017 +0800 Committer: David Neuman <david.neuma...@gmail.com> Committed: Wed Mar 1 20:39:10 2017 -0700 ---------------------------------------------------------------------- traffic_ops/app/lib/UI/Cdn.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c87e8437/traffic_ops/app/lib/UI/Cdn.pm ---------------------------------------------------------------------- diff --git a/traffic_ops/app/lib/UI/Cdn.pm b/traffic_ops/app/lib/UI/Cdn.pm index d9f9d80..c27c9a7 100644 --- a/traffic_ops/app/lib/UI/Cdn.pm +++ b/traffic_ops/app/lib/UI/Cdn.pm @@ -160,6 +160,16 @@ sub delete { $self->flash( alertmsg => "You must be an ADMIN to perform this operation!" ); } else { + my $server_count = $self->db->resultset('Server')->search( { cdn_id => $id } )->count(); + if ($server_count > 0) { + $self->flash( alertmsg => "Failed to delete cdn id = $id has servers." ); + return $self->redirect_to('/close_fancybox.html'); + } + my $ds_count = $self->db->resultset('Deliveryservice')->search( { cdn_id => $id } )->count(); + if ($ds_count > 0) { + $self->flash( alertmsg => "Failed to delete cdn id = $id has delivery services." ); + return $self->redirect_to('/close_fancybox.html'); + } my $p_name = $self->db->resultset('Cdn')->search( { id => $id } )->get_column('name')->single(); my $delete = $self->db->resultset('Cdn')->search( { id => $id } ); $delete->delete();