support get_artifact intrinsic, add support for public key in service objs
diff --git a/xos/tosca/custom_types/xos.m4 b/xos/tosca/custom_types/xos.m4
index 471bfc8..9ba9973 100644
--- a/xos/tosca/custom_types/xos.m4
+++ b/xos/tosca/custom_types/xos.m4
@@ -27,6 +27,15 @@
                 required: false
             icon_url:
                 type: string
+                required: false
+            enabled:
+                type: boolean
+                default: true
+            published:
+                type: boolean
+                default: true
+            public_key:
+                type: string
                 required: false)
 
 # end m4 macros
diff --git a/xos/tosca/resources/service.py b/xos/tosca/resources/service.py
index 6b84d0b..4b32b8a 100644
--- a/xos/tosca/resources/service.py
+++ b/xos/tosca/resources/service.py
@@ -4,6 +4,7 @@
 import tempfile
 sys.path.append("/opt/tosca")
 from translator.toscalib.tosca_template import ToscaTemplate
+import pdb
 
 from core.models import Service,User,CoarseTenant
 
@@ -12,7 +13,7 @@
 class XOSService(XOSResource):
     provides = "tosca.nodes.Service"
     xos_model = Service
-    copyin_props = ["view_url", "kind"]
+    copyin_props = ["view_url", "kind", "enabled", "published", "public_key"]
 
     def postprocess(self, obj):
         for provider_service_name in self.get_requirements("tosca.relationships.TenantOfService"):
diff --git a/xos/tosca/resources/vcpeservice.py b/xos/tosca/resources/vcpeservice.py
index a2247c6..e163520 100644
--- a/xos/tosca/resources/vcpeservice.py
+++ b/xos/tosca/resources/vcpeservice.py
@@ -12,5 +12,5 @@
 class XOSVcpeService(XOSService):
     provides = "tosca.nodes.VCPEService"
     xos_model = VCPEService
-    copyin_props = ["view_url", "icon_url", "backend_network_label"]
+    copyin_props = ["view_url", "icon_url", "backend_network_label", "enabled", "published", "public_key"]
 
diff --git a/xos/tosca/resources/xosresource.py b/xos/tosca/resources/xosresource.py
index 8507172..159156b 100644
--- a/xos/tosca/resources/xosresource.py
+++ b/xos/tosca/resources/xosresource.py
@@ -1,4 +1,6 @@
+import os
 import pdb
+import json
 
 class XOSResource(object):
     xos_base_class = "XOSResource"
@@ -52,11 +54,8 @@
         else:
             return {}
 
-    def get_property(self, name, default=None):
-        v = self.nodetemplate.get_property_value(name)
-        if (v==None):
-            return default
-        return v
+    def get_property(self, name):
+        return self.nodetemplate.get_property_value(name)
 
     def get_xos_object(self, cls, throw_exception=True, **kwargs):
         objs = cls.objects.filter(**kwargs)
@@ -86,6 +85,37 @@
     def postprocess(self, obj):
         pass
 
+    def intrinsic_get_artifact(self, obj=None, name=None, method=None):
+        if obj!="SELF":
+            raise Exception("only SELF is supported for get_artifact first arg")
+        if method!="LOCAL_FILE":
+            raise Exception("only LOCAL_FILE is supported for get_artifact third arg")
+
+        for (k,v) in self.nodetemplate.entity_tpl.get("artifacts", {}).items():
+            if k == name:
+                if not os.path.exists(v):
+                    raise Exception("Artifact local file %s for artifact %s does not exist" % (v, k))
+                return open(v).read()
+
+        raise Exception("artifact %s not found" % name)
+
+    def try_intrinsic_function(self, v):
+        try:
+            jsv = v.replace("'", '"')
+            jsv = json.loads(jsv)
+        except:
+            #import traceback
+            #traceback.print_exc()
+            return v
+
+        if type(jsv)!=dict:
+            return v
+
+        if "get_artifact" in jsv:
+            return self.intrinsic_get_artifact(*jsv["get_artifact"])
+
+        return v
+
     def get_xos_args(self):
         args = {}
 
@@ -95,6 +125,9 @@
         # copy simple string properties from the template into the arguments
         for prop in self.copyin_props:
             v = self.get_property(prop)
+
+            v = self.try_intrinsic_function(v)
+
             if v:
                 args[prop] = v