hpcview for hpc monitoring
diff --git a/xos/core/xoslib/methods/hpcview.py b/xos/core/xoslib/methods/hpcview.py
new file mode 100644
index 0000000..9a62b5c
--- /dev/null
+++ b/xos/core/xoslib/methods/hpcview.py
@@ -0,0 +1,90 @@
+from rest_framework.decorators import api_view
+from rest_framework.response import Response
+from rest_framework.reverse import reverse
+from rest_framework import serializers
+from rest_framework import generics
+from rest_framework.views import APIView
+from core.models import *
+from hpc.models import *
+from requestrouter.models import *
+from django.forms import widgets
+from syndicate_storage.models import Volume
+from django.core.exceptions import PermissionDenied
+from django.contrib.contenttypes.models import ContentType
+import time
+
+# This REST API endpoint contains a bunch of misc information that the
+# tenant view needs to display
+
+def get_service_slices(service):
+    try:
+        return service.slices.all()
+    except:
+        return service.service.all()
+
+def lookup_tag(service, sliver, name, default=None):
+    sliver_type = ContentType.objects.get_for_model(sliver)
+    t = Tag.objects.filter(service=service, name=name, content_type__pk=sliver_type.id, object_id=sliver.id)
+    if t:
+        return t[0].value
+    else:
+        return default
+
+def lookup_time(service, sliver, name):
+    v = lookup_tag(service, sliver, name)
+    if v:
+        return str(time.time() - float(v))
+    else:
+        return None
+
+def getHpcDict(user, pk):
+    hpc = HpcService.objects.get(pk=pk)
+    slices = get_service_slices(hpc)
+
+    dnsdemux_slice = None
+    for slice in slices:
+        if "dnsdemux" in slice.name:
+            dnsdemux_service = hpc
+            dnsdemux_slice = slice
+
+    if not dnsdemux_slice:
+        rr = RequestRouterService.objects.all()
+        if rr:
+            rr=rr[0]
+            slices = get_service_slices(rr)
+            for slice in slices:
+                if "dnsdemux" in slice.name:
+                    dnsdemux_service = rr
+                    dnsdemux_slice = slice
+
+    dnsdemux=[]
+    for sliver in dnsdemux_slice.slivers.all():
+        dnsdemux.append( {"name": sliver.node.name,
+                       "watcher.DNS.msg": lookup_tag(dnsdemux_service, sliver, "watcher.DNS.msg"),
+                       "watcher.DNS.time": lookup_time(dnsdemux_service, sliver, "watcher.DNS.time"),
+                       "ip": sliver.get_public_ip() })
+
+    return { "dnsdemux": dnsdemux }
+
+
+class HpcList(APIView):
+    method_kind = "list"
+    method_name = "hpcview"
+
+    def get(self, request, format=None):
+        if (not request.user.is_authenticated()):
+            raise PermissionDenied("You must be authenticated in order to use this API")
+        results = []
+        for hpc in HpcService.objects.all():
+            results.append(getHpcDict(request.user, hpc.pk))
+        return Response( results )
+
+class HpcDetail(APIView):
+    method_kind = "detail"
+    method_name = "hpcview"
+
+    def get(self, request, format=None, pk=0):
+        if (not request.user.is_authenticated()):
+            raise PermissionDenied("You must be authenticated in order to use this API")
+        return Response( [getHpcViewDict(request.user, pk)] )
+