"""
try:
myvnfd = vnfd_catalog.vnfd()
- pybindJSONDecoder.load_ietf_json(vnf_descriptor, None, None, obj=myvnfd)
+ try:
+ pybindJSONDecoder.load_ietf_json(vnf_descriptor, None, None, obj=myvnfd)
+ except Exception as e:
+ raise NfvoException("Invalid yang descriptor format " + str(e), HTTP_Bad_Request)
db_vnfs = []
db_nets = []
db_vms = []
# table interfaces (internal/external interfaces)
cp_name2iface_uuid = {}
cp_name2vm_uuid = {}
- for iface in chain(vdu.get("internal-interface").itervalues(), vdu.get("external-interface").itervalues()):
+ # for iface in chain(vdu.get("internal-interface").itervalues(), vdu.get("external-interface").itervalues()):
+ for iface in vdu.get("interface").itervalues():
iface_uuid = str(uuid4())
uuid_list.append(iface_uuid)
db_interface = {
else:
raise ValueError("Interface type {} not supported".format(iface.get("virtual-interface").get("type")))
- if iface.get("vnfd-connection-point-ref"):
+ if iface.get("external-connection-point-ref"):
try:
- cp = vnfd.get("connection-point")[iface.get("vnfd-connection-point-ref")]
+ cp = vnfd.get("connection-point")[iface.get("external-connection-point-ref")]
db_interface["external_name"] = get_str(cp, "name", 255)
cp_name2iface_uuid[db_interface["external_name"]] = iface_uuid
cp_name2vm_uuid[db_interface["external_name"]] = vm_uuid
vnf=vnfd["id"], vdu=vdu["id"], iface=iface["name"],
cp=iface.get("vnfd-connection-point-ref"))
)
- elif iface.get("vdu-internal-connection-point-ref"):
+ elif iface.get("internal-connection-point-ref"):
try:
for vld in vnfd.get("internal-vld").itervalues():
for cp in vld.get("internal-connection-point").itervalues():
- if cp.get("id-ref") == iface.get("vdu-internal-connection-point-ref"):
+ if cp.get("id-ref") == iface.get("internal-connection-point-ref"):
db_interface["net_id"] = net_id2uuid[vld.get("id")]
break
except KeyError:
vnf=vnfd["id"], vdu=vdu["id"], iface=iface["name"],
cp=iface.get("vdu-internal-connection-point-ref"))
)
-
+ if iface.get("position") is not None:
+ db_interface["created_at"] = int(iface.get("position")) - 1000
db_interfaces.append(db_interface)
# VNF affinity and antiaffinity
format(vnf=vnfd["id"], cp=vnfd["mgmt-interface"]["cp"]))
mgmt_access["vm_id"] = cp_name2vm_uuid[vnfd["mgmt-interface"]["cp"]]
mgmt_access["interface_id"] = cp_name2iface_uuid[vnfd["mgmt-interface"]["cp"]]
- default_user = get_str(vnfd.get("vnf-configuration").get("config-access", {}).get("ssh-access", {}),
+ default_user = get_str(vnfd.get("vnf-configuration", {}).get("config-access", {}).get("ssh-access", {}),
"default-user", 64)
if default_user:
mgmt_access["default_user"] = default_user
"""
try:
mynsd = nsd_catalog.nsd()
- pybindJSONDecoder.load_ietf_json(nsd_descriptor, None, None, obj=mynsd)
+ try:
+ pybindJSONDecoder.load_ietf_json(nsd_descriptor, None, None, obj=mynsd)
+ except Exception as e:
+ raise NfvoException("Invalid yang descriptor format " + str(e), HTTP_Bad_Request)
db_scenarios = []
db_sce_nets = []
db_sce_vnfs = []
{"table2": [ {"column1": value, "column2: value, ... }, {"column1": value, "column2: value, ... }, ...],
{"table3": {"column1": value, "column2: value, ... }
}
+ If tables does not contain the 'created_at', it is generated incrementally with the order of tables. You can
+ provide a integer value, that it is an index multiply by 0.00001 to add to the created time to manually set
+ up and order
:param uuid_list: list of created uuids, first one is the root (#TODO to store at uuid table)
:return: None if success, raise exception otherwise
"""
row_list = (row_list, ) #create a list with the single value
for row in row_list:
if table_name in self.tables_with_created_field:
- created_time_param = created_time + index*0.00001
+ if "created_at" in row:
+ created_time_param = created_time + row.pop("created_at")*0.00001
+ else:
+ created_time_param = created_time + index*0.00001
+ index += 1
else:
- created_time_param=0
+ created_time_param = 0
self._new_row_internal(table_name, row, add_uuid=False, root_uuid=None,
created_time=created_time_param)
- index += 1
return
except (mdb.Error, AttributeError) as e:
self._format_error(e, tries)