mhoppa commented on a change in pull request #4072: Prevent Assigning Servers 
to Delivery Services Without Required Capabilities
URL: https://github.com/apache/trafficcontrol/pull/4072#discussion_r342072293
 
 

 ##########
 File path: traffic_ops/traffic_ops_golang/server/servers_assignment.go
 ##########
 @@ -81,6 +89,31 @@ func AssignDeliveryServicesToServerHandler(w 
http.ResponseWriter, r *http.Reques
        api.WriteRespAlertObj(w, r, tc.SuccessLevel, "successfully assigned 
dses to server", tc.AssignedDsResponse{server, assignedDSes, replace})
 }
 
+// ValidateDSCapabilities checks that the server meets the requirements of 
each delivery service to be assigned.
+func ValidateDSCapabilities(dsIDs []int, serverName string, tx *sql.Tx) error {
+       fmt.Println("))) Validate was hit")
+       var dsCaps []string
+       sCaps, err := dbhelpers.GetServerCapabilitiesFromName(serverName, tx)
+
+       if err != nil {
+               return err
+       }
+
+       for _, id := range dsIDs {
+               dsCaps, err = dbhelpers.GetDSRequiredCapabilitiesFromID(id, tx)
+               if err != nil {
+                       return err
+               }
+               for _, dsc := range dsCaps {
+                       if !util.ContainsStr(sCaps, dsc) {
+                               return errors.New(fmt.Sprintf("Caching server 
cannot assign this delivery service without having the required delivery 
service capabilities: [%v]", dsCaps))
 
 Review comment:
   again include identifying ids to help the user 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to