Merge remote-tracking branch 'origin/master' into reconcile_openstack
diff --git a/xos/observers/vcpe/steps/sync_vcpetenant.py b/xos/observers/vcpe/steps/sync_vcpetenant.py
index bc08845..7ce3eaa 100644
--- a/xos/observers/vcpe/steps/sync_vcpetenant.py
+++ b/xos/observers/vcpe/steps/sync_vcpetenant.py
@@ -107,8 +107,8 @@
logger.info("unsupported configuration -- bbs_slice is set, but backend_network_label is not")
if not bbs_addrs:
logger.info("failed to find any usable addresses on bbs_slice")
- elif vcpe.bbs_server:
- bbs_addrs.append(vcpe.bbs_server)
+ elif vcpe_service.bbs_server:
+ bbs_addrs.append(vcpe_service.bbs_server)
else:
logger.info("neither bbs_slice nor bbs_server is configured in the vCPE")
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/network.py b/xos/tosca/resources/network.py
index 96bc190..e5b8b80 100644
--- a/xos/tosca/resources/network.py
+++ b/xos/tosca/resources/network.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 Slice,User,Network,NetworkTemplate
@@ -12,7 +13,6 @@
class XOSNetwork(XOSResource):
provides = ["tosca.nodes.network.Network", "tosca.nodes.network.Network.XOS"]
xos_model = Network
- defaults = {"permit_all_slices": True}
def get_xos_args(self):
args = {"name": self.nodetemplate.name,
@@ -26,11 +26,16 @@
if net_template_name:
args["template"] = self.get_xos_object(NetworkTemplate, name=net_template_name)
- # copy simple string properties from the template into the arguments
- for prop in ["ports", "labels", "permit_all_slices"]:
- v = self.get_property(prop, self.defaults.get(prop,None))
- if v:
- args[prop] = v
+ if self.nodetemplate.type == "tosca.nodes.network.Network.XOS":
+ # copy simple string properties from the template into the arguments
+ for prop in ["ports", "labels", "permit_all_slices"]:
+ v = self.get_property(prop)
+ if v:
+ args[prop] = v
+ else:
+ # tosca.nodes.network.Netwrok is not as rich as an XOS network. So
+ # we have to manually fill in some defaults.
+ args["permit_all_slices"] = True
return args
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
diff --git a/xos/tosca/samples/cord.yaml b/xos/tosca/samples/cord.yaml
index f160cb6..885435d 100644
--- a/xos/tosca/samples/cord.yaml
+++ b/xos/tosca/samples/cord.yaml
@@ -27,6 +27,9 @@
properties:
view_url: /admin/cord/vcpeservice/$id$/
backend_network_label: hpc_client
+ public_key: { get_artifact: [ SELF, pubkey, LOCAL_FILE] }
+ artifacts:
+ pubkey: /opt/xos/observers/vcpe/vcpe_public_key
service_vbng:
type: tosca.nodes.VBNGService