allow kind#objname syntax
diff --git a/xos/tosca/resources/CORDUser.py b/xos/tosca/resources/CORDUser.py
index 566e205..705a895 100644
--- a/xos/tosca/resources/CORDUser.py
+++ b/xos/tosca/resources/CORDUser.py
@@ -28,12 +28,12 @@
if not sub:
return []
for user in sub.users:
- if user["name"] == self.nodetemplate.name:
+ if user["name"] == self.obj_name:
result.append(user)
return result
def get_xos_args(self):
- args = {"name": self.nodetemplate.name,
+ args = {"name": self.obj_name,
"level": self.get_property("level"),
"mac": self.get_property("mac")}
return args
@@ -46,7 +46,7 @@
sub.create_user(**xos_args)
sub.save()
- self.info("Created CORDUser %s for Subscriber %s" % (self.nodetemplate.name, sub.name))
+ self.info("Created CORDUser %s for Subscriber %s" % (self.obj_name, sub.name))
def update(self, obj):
pass
diff --git a/xos/tosca/resources/cdnprefix.py b/xos/tosca/resources/cdnprefix.py
index 5faaca8..8daf7fb 100644
--- a/xos/tosca/resources/cdnprefix.py
+++ b/xos/tosca/resources/cdnprefix.py
@@ -16,7 +16,7 @@
copyin_props = []
def get_xos_args(self):
- args = {"prefix": self.nodetemplate.name}
+ args = {"prefix": self.obj_name}
cp_name = self.get_requirement("tosca.relationships.MemberOfContentProvider")
if cp_name:
diff --git a/xos/tosca/resources/compute.py b/xos/tosca/resources/compute.py
index 37ba390..2af010a 100644
--- a/xos/tosca/resources/compute.py
+++ b/xos/tosca/resources/compute.py
@@ -39,7 +39,7 @@
nodetemplate = self.nodetemplate
if not name:
- name = nodetemplate.name
+ name = self.obj_name
args = {"name": name}
@@ -105,7 +105,7 @@
if scalable:
default_instances = scalable.get("default_instances",1)
for i in range(0, default_instances):
- name = "%s-%d" % (self.nodetemplate.name, i)
+ name = "%s-%d" % (self.obj_name, i)
existing_instances = Instance.objects.filter(name=name)
if existing_instances:
self.info("%s %s already exists" % (self.xos_model.__name__, name))
@@ -121,7 +121,7 @@
existing_instances = []
max_instances = scalable.get("max_instances",1)
for i in range(0, max_instances):
- name = "%s-%d" % (self.nodetemplate.name, i)
+ name = "%s-%d" % (self.obj_name, i)
existing_instances = existing_instances + list(Instance.objects.filter(name=name))
return existing_instances
else:
diff --git a/xos/tosca/resources/contentprovider.py b/xos/tosca/resources/contentprovider.py
index 06ca02e..66742ea 100644
--- a/xos/tosca/resources/contentprovider.py
+++ b/xos/tosca/resources/contentprovider.py
@@ -17,7 +17,7 @@
def get_xos_args(self):
sp_name = self.get_requirement("tosca.relationships.MemberOfServiceProvider", throw_exception=True)
sp = self.get_xos_object(ServiceProvider, name=sp_name)
- return {"name": self.nodetemplate.name,
+ return {"name": self.obj_name,
"serviceProvider": sp}
def can_delete(self, obj):
diff --git a/xos/tosca/resources/node.py b/xos/tosca/resources/node.py
index 99e756f..128aaed 100644
--- a/xos/tosca/resources/node.py
+++ b/xos/tosca/resources/node.py
@@ -14,7 +14,7 @@
xos_model = Node
def get_xos_args(self):
- args = {"name": self.nodetemplate.name}
+ args = {"name": self.obj_name}
site = None
siteName = self.get_requirement("tosca.relationships.MemberOfSite", throw_exception=False)
@@ -44,9 +44,6 @@
obj.save()
def create(self):
- nodetemplate = self.nodetemplate
- sliceName = nodetemplate.name
-
xos_args = self.get_xos_args()
if not xos_args.get("site", None):
diff --git a/xos/tosca/resources/onosapp.py b/xos/tosca/resources/onosapp.py
index 72511b3..dccc8db 100644
--- a/xos/tosca/resources/onosapp.py
+++ b/xos/tosca/resources/onosapp.py
@@ -33,7 +33,7 @@
def get_existing_objs(self):
objs = ONOSApp.get_tenant_objects().all()
- objs = [x for x in objs if x.name == self.nodetemplate.name]
+ objs = [x for x in objs if x.name == self.obj_name]
return objs
def set_tenant_attr(self, obj, prop_name, value):
diff --git a/xos/tosca/resources/originserver.py b/xos/tosca/resources/originserver.py
index 196ce2e..46cf87e 100644
--- a/xos/tosca/resources/originserver.py
+++ b/xos/tosca/resources/originserver.py
@@ -15,18 +15,18 @@
name_field = "url"
copyin_props = []
- def nodetemplate_name_to_url(self):
- url = self.nodetemplate.name
+ def obj_name_to_url(self):
+ url = self.obj_name
if url.startswith("http_"):
url = url[5:]
return url
def get_existing_objs(self):
- url = self.nodetemplate_name_to_url()
+ url = self.obj_name_to_url()
return self.xos_model.objects.filter(**{self.name_field: url})
def get_xos_args(self):
- url = self.nodetemplate_name_to_url()
+ url = self.obj_name_to_url()
cp_name = self.get_requirement("tosca.relationships.MemberOfContentProvider", throw_exception=True)
cp = self.get_xos_object(ContentProvider, name=cp_name)
return {"url": url,
diff --git a/xos/tosca/resources/serviceprovider.py b/xos/tosca/resources/serviceprovider.py
index 8faec6c..2c9a167 100644
--- a/xos/tosca/resources/serviceprovider.py
+++ b/xos/tosca/resources/serviceprovider.py
@@ -17,7 +17,7 @@
def get_xos_args(self):
hpc_service_name = self.get_requirement("tosca.relationships.MemberOfService", throw_exception=True)
hpc_service = self.get_xos_object(HpcService, name=hpc_service_name)
- return {"name": self.nodetemplate.name,
+ return {"name": self.obj_name,
"hpcService": hpc_service}
def can_delete(self, obj):
diff --git a/xos/tosca/resources/slice.py b/xos/tosca/resources/slice.py
index 22978a2..0add5ac 100644
--- a/xos/tosca/resources/slice.py
+++ b/xos/tosca/resources/slice.py
@@ -50,19 +50,6 @@
("tosca.relationships.PIPrivilege", "pi"), ("tosca.relationships.TechPrivilege", "tech") )
self.postprocess_privileges(SliceRole, SlicePrivilege, rolemap, obj, "slice")
- def create(self):
- nodetemplate = self.nodetemplate
- sliceName = nodetemplate.name
-
- xos_args = self.get_xos_args()
- slice = Slice(**xos_args)
- slice.caller = self.user
- slice.save()
-
- self.postprocess(slice)
-
- self.info("Created Slice '%s' on Site '%s'" % (str(slice), str(slice.site)))
-
def delete(self, obj):
if obj.instances.exists():
self.info("Slice %s has active instances; skipping delete" % obj.name)
diff --git a/xos/tosca/resources/user.py b/xos/tosca/resources/user.py
index 8587c89..79b2e71 100644
--- a/xos/tosca/resources/user.py
+++ b/xos/tosca/resources/user.py
@@ -25,7 +25,7 @@
return args
def get_existing_objs(self):
- return self.xos_model.objects.filter(email = self.nodetemplate.name)
+ return self.xos_model.objects.filter(email = self.obj_name)
def postprocess(self, obj):
rolemap = ( ("tosca.relationships.AdminPrivilege", "admin"), ("tosca.relationships.AccessPrivilege", "access"),
@@ -62,8 +62,6 @@
udv.save()
def create(self):
- nodetemplate = self.nodetemplate
-
xos_args = self.get_xos_args()
if not xos_args.get("site",None):
diff --git a/xos/tosca/resources/xosresource.py b/xos/tosca/resources/xosresource.py
index 7a6c194..3a7d80d 100644
--- a/xos/tosca/resources/xosresource.py
+++ b/xos/tosca/resources/xosresource.py
@@ -19,6 +19,17 @@
self.nodetemplate = nodetemplate
self.engine = engine
+ @property
+ def full_name(self):
+ return self.nodetemplate.name
+
+ @property
+ def obj_name(self):
+ if "#" in self.nodetemplate.name:
+ return.self.nodetemplate.name.split("#",1)[1]
+ else:
+ return self.nodetemplate.name
+
def get_all_required_node_names(self):
results = []
for reqs in self.nodetemplate.requirements:
@@ -38,7 +49,7 @@
results.append(v["node"])
if (not results) and throw_exception:
- raise Exception("Failed to find requirement in %s using relationship %s" % (self.nodetemplate.name, relationship_name))
+ raise Exception("Failed to find requirement in %s using relationship %s" % (self.full_name, relationship_name))
return results
@@ -75,7 +86,7 @@
return objs[0]
def get_existing_objs(self):
- return self.xos_model.objects.filter(**{self.name_field: self.nodetemplate.name})
+ return self.xos_model.objects.filter(**{self.name_field: self.obj_name})
def get_model_class_name(self):
return self.xos_model.__name__
@@ -84,19 +95,19 @@
existing_objs = self.get_existing_objs()
if existing_objs:
if self.get_property_default("no-update", False):
- self.info("%s %s already exists. Skipping update due to 'no-update' property" % (self.get_model_class_name(), self.nodetemplate.name))
+ self.info("%s:%s (%s) already exists. Skipping update due to 'no-update' property" % (self.get_model_class_name(), self.obj_name, self.full_name))
else:
- self.info("%s %s already exists" % (self.get_model_class_name(), self.nodetemplate.name))
+ self.info("%s:%s (%s) already exists" % (self.get_model_class_name(), self.obj_name, self.full_name))
self.update(existing_objs[0])
else:
if self.get_property_default("no-create", False):
- self.info("%s %s does not exist, but 'no-create' is specified" % (self.get_model_class_name(), self.nodetemplate.name))
+ self.info("%s:%s (%s) does not exist, but 'no-create' is specified" % (self.get_model_class_name(), self.obj_name, self.full_name))
else:
self.create()
def can_delete(self, obj):
if self.get_property_default("no-delete",False):
- self.info("%s %s is marked 'no-delete'. Skipping delete." % (self.get_model_class_name(), self.nodetemplate.name))
+ self.info("%s:%s %s is marked 'no-delete'. Skipping delete." % (self.get_model_class_name(), self.obj_name, self.full_name))
return False
return True
@@ -170,7 +181,7 @@
args = {}
if self.name_field:
- args[self.name_field] = self.nodetemplate.name
+ args[self.name_field] = self.obj_name
# copy simple string properties from the template into the arguments
for prop in self.copyin_props:
diff --git a/xos/tosca/resources/xossite.py b/xos/tosca/resources/xossite.py
index 616e397..9b03bc5 100644
--- a/xos/tosca/resources/xossite.py
+++ b/xos/tosca/resources/xossite.py
@@ -19,9 +19,9 @@
def get_xos_args(self):
display_name = self.get_property("display_name")
if not display_name:
- display_name = self.nodetemplate.name
+ display_name = self.obj_name
- args = {"login_base": self.nodetemplate.name,
+ args = {"login_base": self.obj_name,
"name": display_name}
# copy simple string properties from the template into the arguments
@@ -33,7 +33,7 @@
return args
def get_existing_objs(self):
- return self.xos_model.objects.filter(login_base = self.nodetemplate.name)
+ return self.xos_model.objects.filter(login_base = self.obj_name)
def postprocess(self, obj):
results = []
@@ -68,20 +68,6 @@
sitedep.save()
self.info("Created SiteDeployment from %s to %s" % (str(obj), str(deployment)))
- def create(self):
- nodetemplate = self.nodetemplate
- siteName = nodetemplate.name
-
- xos_args = self.get_xos_args()
-
- site = Site(**xos_args)
- site.caller = self.user
- site.save()
-
- self.postprocess(site)
-
- self.info("Created Site '%s'" % (str(site), ))
-
def delete(self, obj):
if obj.slices.exists():
self.info("Site %s has active slices; skipping delete" % obj.name)