scheduler: better handle format status error

When the scheduler is still building the layout, status request may
fails with this exception:

File "zuul/scheduler.py", line 1088, in formatStatusJSON
    for pipeline in tenant.layout.pipelines.values():
AttributeError: 'NoneType' object has no attribute 'layout'

This change verifies the tenant is not None and return a more user
friendly error message.

Change-Id: Ieed498dd7269767fe47ae5892fdbb5e220036b62
diff --git a/zuul/scheduler.py b/zuul/scheduler.py
index a2e3b6e..8b7a3f1 100644
--- a/zuul/scheduler.py
+++ b/zuul/scheduler.py
@@ -1085,6 +1085,10 @@
         pipelines = []
         data['pipelines'] = pipelines
         tenant = self.abide.tenants.get(tenant_name)
+        if not tenant:
+            self.log.warning("Tenant %s isn't loaded" % tenant_name)
+            return json.dumps(
+                {"message": "Tenant %s isn't ready" % tenant_name})
         for pipeline in tenant.layout.pipelines.values():
             pipelines.append(pipeline.formatStatusJSON(websocket_url))
         return json.dumps(data)