Merge branch 'master' of https://github.com/open-cloud/xos
diff --git a/xos/configurations/cord-pod/make-vtn-networkconfig-json.sh b/xos/configurations/cord-pod/make-vtn-networkconfig-json.sh
index 8302ab0..e7aac2e 100755
--- a/xos/configurations/cord-pod/make-vtn-networkconfig-json.sh
+++ b/xos/configurations/cord-pod/make-vtn-networkconfig-json.sh
@@ -16,8 +16,8 @@
 NODES=$( sudo bash -c "source $SETUPDIR/admin-openrc.sh ; nova hypervisor-list" |grep -v ID|grep -v +|awk '{print $4}' )
 
 # also configure ONOS to manage the nm node
-NM="neutron-gateway"
-NODES="$NODES $NM"
+#NM="neutron-gateway"
+#NODES="$NODES $NM"
 
 NODECOUNT=0
 for NODE in $NODES; do
@@ -29,7 +29,7 @@
     echo $NODE
     NODEIP=`getent hosts $NODE | awk '{ print $1 }'`
 
-    PHYPORT=eth0
+    PHYPORT=mlx0
     LOCALIP=$NODEIP
 
     ((I++))
diff --git a/xos/configurations/opencloud/cdn-content.yaml b/xos/configurations/opencloud/cdn-content.yaml
index d4d1445..ebf6b82 100644
--- a/xos/configurations/opencloud/cdn-content.yaml
+++ b/xos/configurations/opencloud/cdn-content.yaml
@@ -111,37 +111,113 @@
                   node: main_service_provider
                   relationship: tosca.relationships.MemberOfServiceProvider
 
-    downloads.onosproject.org:
-        type: tosca.nodes.CDNPrefix
-        requirements:
-             - content_provider:
-                   node: on_lab_content
+    # Create CDN prefix onlab.vicci.org
+    onlab.vicci.org:

+        type: tosca.nodes.CDNPrefix

+        requirements:

+             - content_provider:

+                   node: on_lab_content

                    relationship: tosca.relationships.MemberOfContentProvider
-             - default_origin_server:
-                   node: http_downloads.onosproject.org
+
+    http_onos-videos.s3.amazonaws.com:
+        type: tosca.nodes.OriginServer

+        requirements:

+             - content_provider:

+                   node: on_lab_content

+                   relationship: tosca.relationships.MemberOfContentProvider
+
+    # Create origin server s3-us-west-1.amazonaws.com
+    http_s3-us-west-1.amazonaws.com:

+        type: tosca.nodes.OriginServer

+        requirements:

+             - content_provider:

+                   node: on_lab_content

+                   relationship: tosca.relationships.MemberOfContentProvider

+

+    # Create origin server s3.amazonaws.com

+    http_s3.amazonaws.com:

+        type: tosca.nodes.OriginServer

+        requirements:

+             - content_provider:

+                   node: on_lab_content

+                   relationship: tosca.relationships.MemberOfContentProvider
+
+    # Test Content Provider
+
+    testcp2:
+        type: tosca.nodes.ContentProvider

+        requirements:

+            - service_provider:

+                  node: main_service_provider

+                  relationship: tosca.relationships.MemberOfServiceProvider
+
+    http_www.cs.arizona.edu:
+        type: tosca.nodes.OriginServer

+        requirements:

+             - content_provider:

+                   node: testcp2

+                   relationship: tosca.relationships.MemberOfContentProvider
+
+    test-cdn.opencloud.us:
+        type: tosca.nodes.CDNPrefix

+        requirements:

+             - content_provider:

+                   node: testcp2

+                   relationship: tosca.relationships.MemberOfContentProvider

+

+             - default_origin_server:

+                   node: http_www.cs.arizona.edu

                    relationship: tosca.relationships.DefaultOriginServer
 
-    onlab.vicci.org:
-        type: tosca.nodes.CDNPrefix
-        requirements:
-             - content_provider:
-                   node: on_lab_content
-                   relationship: tosca.relationships.MemberOfContentProvider
-             - default_origin_server:
-                   node: http_onlab.vicci.org
-                   relationship: tosca.relationships.DefaultOriginServer
+    # Health Checks
 
-    http_downloads.onosproject.org:
-        type: tosca.nodes.OriginServer
+    healthcheck_dns_onlab.vicci.org:
+        type: tosca.nodes.HpcHealthCheck
         requirements:
-             - content_provider:
-                   node: on_lab_content
-                   relationship: tosca.relationships.MemberOfContentProvider
+           - hpc_service:
+                 node: HyperCache
+                 relationship: tosca.relationships.MemberOfService
+        properties:
+           kind: dns
+           resource_name: onlab.vicci.org
 
-    http_onlab.vicci.org:
-        type: tosca.nodes.OriginServer
+    healthcheck_dns_test-cdn.opencloud.us:
+        type: tosca.nodes.HpcHealthCheck
         requirements:
-             - content_provider:
-                   node: on_lab_content
-                   relationship: tosca.relationships.MemberOfContentProvider
+           - hpc_service:
+                 node: HyperCache
+                 relationship: tosca.relationships.MemberOfService
+        properties:
+           kind: dns
+           resource_name: test-cdn.opencloud.us
 
+    healthcheck_http_test-cdn-index:
+        type: tosca.nodes.HpcHealthCheck
+        requirements:
+           - hpc_service:
+                 node: HyperCache
+                 relationship: tosca.relationships.MemberOfService
+        properties:
+           kind: http
+           resource_name: test-cdn.opencloud.us:/
+           result_contains: Lowenthal
+
+    healthcheck_http_onlab_onos_image:
+        type: tosca.nodes.HpcHealthCheck
+        requirements:
+           - hpc_service:
+                 node: HyperCache
+                 relationship: tosca.relationships.MemberOfService
+        properties:
+           kind: http
+           resource_name: onlab.vicci.org:/onos/vm/onos-tutorial-1.1.0r220-ovf.zip
+
+    healthcheck_http_onlab_mininet_image:
+        type: tosca.nodes.HpcHealthCheck
+        requirements:
+           - hpc_service:
+                 node: HyperCache
+                 relationship: tosca.relationships.MemberOfService
+        properties:
+           kind: http
+           resource_name: onlab.vicci.org:/mininet-vm/mininet-2.1.0-130919-ubuntu-13.04-server-amd64-ovf.zip
diff --git a/xos/configurations/opencloud/docker-compose.yml b/xos/configurations/opencloud/docker-compose.yml
index ec5d7d0..3813dee 100644
--- a/xos/configurations/opencloud/docker-compose.yml
+++ b/xos/configurations/opencloud/docker-compose.yml
@@ -5,8 +5,8 @@
 
 xos_synchronizer_openstack:
     image: xosproject/xos-synchronizer-openstack
-    #command: bash -c "update-ca-certificates; sleep 120; python /opt/xos/synchronizers/openstack/xos-synchronizer.py"
-    command: sleep 86400
+    command: bash -c "update-ca-certificates; sleep 120; python /opt/xos/synchronizers/openstack/xos-synchronizer.py"
+    #command: sleep 86400
     labels:
         org.xosproject.kind: synchronizer
         org.xosproject.target: openstack
@@ -17,6 +17,34 @@
         - /usr/local/share/ca-certificates:/usr/local/share/ca-certificates:ro
         - ./files/xos_opencloud_config:/opt/xos/xos_configuration/xos_opencloud_config:ro
 
+xos_synchronizer_hpc:
+    image: xosproject/xos-synchronizer-openstack
+    command: bash -c "sleep 120; python /opt/xos/synchronizers/hpc/hpc-synchronizer.py -C /opt/xos/synchronizers/hpc/hpc_synchronizer_config"
+    #command: sleep 86400
+    labels:
+        org.xosproject.kind: synchronizer
+        org.xosproject.target: hpc
+    links:
+        - xos_db
+    volumes:
+        - ../common/xos_common_config:/opt/xos/xos_configuration/xos_common_config:ro
+        - /usr/local/share/ca-certificates:/usr/local/share/ca-certificates:ro
+        - ./files/xos_opencloud_config:/opt/xos/xos_configuration/xos_opencloud_config:ro
+
+xos_watcher_hpc:
+    image: xosproject/xos-synchronizer-openstack
+    command: bash -c "sleep 120; python /opt/xos/synchronizers/hpc/hpc_watcher.py"
+    #command: sleep 86400
+    labels:
+        org.xosproject.kind: watcher
+        org.xosproject.target: hpc
+    links:
+        - xos_db
+    volumes:
+        - ../common/xos_common_config:/opt/xos/xos_configuration/xos_common_config:ro
+        - /usr/local/share/ca-certificates:/usr/local/share/ca-certificates:ro
+        - ./files/xos_opencloud_config:/opt/xos/xos_configuration/xos_opencloud_config:ro
+
 # FUTURE
 #xos_swarm_synchronizer:
 #    image: xosproject/xos-swarm-synchronizer
diff --git a/xos/core/models/instance.py b/xos/core/models/instance.py
index 62a86c4..86774b0 100644
--- a/xos/core/models/instance.py
+++ b/xos/core/models/instance.py
@@ -101,6 +101,9 @@
     volumes = models.TextField(null=True, blank=True, help_text="Comma-separated list of directories to expose to parent context")
     parent = models.ForeignKey("Instance", null=True, blank=True, help_text="Parent Instance for containers nested inside of VMs")
 
+    def get_controller (self):
+        return self.node.site_deployment.controller
+
     def __unicode__(self):
         if self.name and Slice.objects.filter(id=self.slice_id) and (self.name != self.slice.name):
             # NOTE: The weird check on self.slice_id was due to a problem when
diff --git a/xos/core/models/plcorebase.py b/xos/core/models/plcorebase.py
index 0822bf5..99acc15 100644
--- a/xos/core/models/plcorebase.py
+++ b/xos/core/models/plcorebase.py
@@ -224,6 +224,9 @@
         self._initial = self._dict # for PlModelMixIn
         self.silent = False
 
+    def get_controller(self):
+        return self.controller
+
     def can_update(self, user):
         return user.can_update_root()
 
diff --git a/xos/core/models/site.py b/xos/core/models/site.py
index 1bdef36..b98c40a 100644
--- a/xos/core/models/site.py
+++ b/xos/core/models/site.py
@@ -310,6 +310,11 @@
     site = models.ForeignKey(Site,related_name='controllersite')
     controller = models.ForeignKey(Controller, null=True, blank=True, related_name='controllersite')
     tenant_id = StrippedCharField(null=True, blank=True, max_length=200, db_index=True, help_text="Keystone tenant id")
+
+    def delete(self, *args, **kwds):
+        pdb.set_trace()
+        super(ControllerSite, self).delete(*args, **kwds)
+
     
     class Meta:
         unique_together = ('site', 'controller') 
diff --git a/xos/synchronizers/base/syncstep.py b/xos/synchronizers/base/syncstep.py
index bdab8f3..54c4b89 100644
--- a/xos/synchronizers/base/syncstep.py
+++ b/xos/synchronizers/base/syncstep.py
@@ -142,10 +142,10 @@
     def sync_record(self, o):
         try:
             controller = o.get_controller()
-            controller_register = json.loads(o.node.site_deployment.controller.backend_register)
+            controller_register = json.loads(controller.backend_register)
 
             if (controller_register.get('disabled',False)):
-                raise InnocuousException('Controller %s is disabled'%sliver.node.site_deployment.controller.name)
+                raise InnocuousException('Controller %s is disabled'%controller.name)
         except AttributeError:
             pass
 
@@ -249,7 +249,7 @@
                     except:
                         error = '%s'%str_e
 
-                    if isinstance(e, InnocuousException) and not force_error:
+                    if isinstance(e, InnocuousException):
                         o.backend_status = '1 - %s'%error
                     else:
                         o.backend_status = '2 - %s'%error
diff --git a/xos/synchronizers/openstack/event_loop.py b/xos/synchronizers/openstack/event_loop.py
index 6cfc9f6..3a14511 100644
--- a/xos/synchronizers/openstack/event_loop.py
+++ b/xos/synchronizers/openstack/event_loop.py
@@ -23,8 +23,8 @@
 #from timeout import timeout
 from xos.config import Config, XOS_DIR
 from synchronizers.base.steps import *
-from syncstep import SyncStep
-from toposort import toposort
+from synchronizers.base.syncstep import SyncStep
+from synchronizers.base.toposort import toposort
 from synchronizers.base.error_mapper import *
 from synchronizers.openstack.openstacksyncstep import OpenStackSyncStep
 from synchronizers.base.steps.sync_object import SyncObject
diff --git a/xos/synchronizers/openstack/openstacksyncstep.py b/xos/synchronizers/openstack/openstacksyncstep.py
index cc568f8..46056cf 100644
--- a/xos/synchronizers/openstack/openstacksyncstep.py
+++ b/xos/synchronizers/openstack/openstacksyncstep.py
@@ -1,6 +1,6 @@
 import os
 import base64
-from syncstep import SyncStep
+from synchronizers.base.syncstep import SyncStep
 
 class OpenStackSyncStep(SyncStep):
     """ XOS Sync step for copying data to OpenStack 
diff --git a/xos/synchronizers/openstack/syncstep.py b/xos/synchronizers/openstack/syncstep.py
index bdab8f3..d1639b4 100644
--- a/xos/synchronizers/openstack/syncstep.py
+++ b/xos/synchronizers/openstack/syncstep.py
@@ -142,10 +142,10 @@
     def sync_record(self, o):
         try:
             controller = o.get_controller()
-            controller_register = json.loads(o.node.site_deployment.controller.backend_register)
+            controller_register = json.loads(controller.backend_register)
 
             if (controller_register.get('disabled',False)):
-                raise InnocuousException('Controller %s is disabled'%sliver.node.site_deployment.controller.name)
+                raise InnocuousException('Controller %s is disabled'%controller.name)
         except AttributeError:
             pass
 
diff --git a/xos/tosca/custom_types/cdn.m4 b/xos/tosca/custom_types/cdn.m4
index 59d4ee6..0d33715 100644
--- a/xos/tosca/custom_types/cdn.m4
+++ b/xos/tosca/custom_types/cdn.m4
@@ -33,6 +33,26 @@
             user:
                 type: tosca.capabilities.xos.CDNPrefix
 
+    tosca.nodes.HpcHealthCheck:
+        derived_from: tosca.nodes.Root
+
+        properties:
+            kind:
+                type: string
+                required: true
+                description: dns | http | nameserver
+            resource_name:
+                type: string
+                required: true
+                description: name of resource to query
+            result_contains:
+                type: string
+                required: false
+                description: soemthing to look for inside the result
+        capabilities:
+            healthcheck:
+                type: tosca.capabilities.xos.HpcHealthCheck
+
     tosca.relationships.MemberOfServiceProvider:
         derived_from: tosca.relationships.Root
         valid_target_types: [ tosca.capabilities.xos.ServiceProvider ]
@@ -57,4 +77,7 @@
     tosca.capabilities.xos.OriginServer:
         derived_from: tosca.capabilities.Root
 
+    tosca.capabilities.xos.HpcHealthCheck:
+        derived_from: tosca.capabilities.Root
+
 
diff --git a/xos/tosca/custom_types/cdn.yaml b/xos/tosca/custom_types/cdn.yaml
index 59d4ee6..0d33715 100644
--- a/xos/tosca/custom_types/cdn.yaml
+++ b/xos/tosca/custom_types/cdn.yaml
@@ -33,6 +33,26 @@
             user:
                 type: tosca.capabilities.xos.CDNPrefix
 
+    tosca.nodes.HpcHealthCheck:
+        derived_from: tosca.nodes.Root
+
+        properties:
+            kind:
+                type: string
+                required: true
+                description: dns | http | nameserver
+            resource_name:
+                type: string
+                required: true
+                description: name of resource to query
+            result_contains:
+                type: string
+                required: false
+                description: soemthing to look for inside the result
+        capabilities:
+            healthcheck:
+                type: tosca.capabilities.xos.HpcHealthCheck
+
     tosca.relationships.MemberOfServiceProvider:
         derived_from: tosca.relationships.Root
         valid_target_types: [ tosca.capabilities.xos.ServiceProvider ]
@@ -57,4 +77,7 @@
     tosca.capabilities.xos.OriginServer:
         derived_from: tosca.capabilities.Root
 
+    tosca.capabilities.xos.HpcHealthCheck:
+        derived_from: tosca.capabilities.Root
+
 
diff --git a/xos/tosca/resources/hpchealthcheck.py b/xos/tosca/resources/hpchealthcheck.py
new file mode 100644
index 0000000..93a0912
--- /dev/null
+++ b/xos/tosca/resources/hpchealthcheck.py
@@ -0,0 +1,39 @@
+import importlib
+import os
+import pdb
+import sys
+import tempfile
+sys.path.append("/opt/tosca")
+from translator.toscalib.tosca_template import ToscaTemplate
+import pdb
+
+from services.hpc.models import HpcHealthCheck, HpcService
+
+from xosresource import XOSResource
+
+class XOSHpcHealthCheck(XOSResource):
+    provides = "tosca.nodes.HpcHealthCheck"
+    xos_model = HpcHealthCheck
+    name_field = None
+    copyin_props = ("kind", "resource_name", "result_contains")
+
+    def get_xos_args(self, throw_exception=True):
+        args = super(XOSHpcHealthCheck, self).get_xos_args()
+
+        service_name = self.get_requirement("tosca.relationships.MemberOfService", throw_exception=throw_exception)
+        if service_name:
+            args["hpcService"] = self.get_xos_object(HpcService, throw_exception=throw_exception, name=service_name)
+
+        return args
+
+    def get_existing_objs(self):
+        args = self.get_xos_args(throw_exception=True)
+
+        return list( HpcHealthCheck.objects.filter(hpcService=args["hpcService"], kind=args["kind"], resource_name=args["resource_name"]) )
+
+    def postprocess(self, obj):
+        pass
+
+    def can_delete(self, obj):
+        return super(XOSTenant, self).can_delete(obj)
+