'Get a list of application services based on their state.
Args:
state(ApplicationServiceState): The state to filter on.
Returns:
A Deferred which resolves to a list of ApplicationServices, which
may be empty.'

@defer.inlineCallbacks
def get_appservices_by_state(self, state):

    results = (yield self._simple_select_list('application_services_state', dict(state=state), ['as_id']))
    as_list = self.get_app_services()
    services = []
    for res in results:
        for service in as_list:
            if (service.id == res['as_id']):
                services.append(service)
    defer.returnValue(services)
