Resilience and Application Deployment in Software-Defined Networks