VDU scaling
Change-Id: Iece9e0b9daad27144a2ca50add72c66366e107fa
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
diff --git a/osm_nbi/engine.py b/osm_nbi/engine.py
index 50d1bd1..aaa94f0 100644
--- a/osm_nbi/engine.py
+++ b/osm_nbi/engine.py
@@ -342,16 +342,22 @@
:param indata: descriptor with the parameters of the operation
:return: None
"""
+ def check_valid_vnf_member_index(member_vnf_index):
+ for vnf in nsr["nsd"]["constituent-vnfd"]:
+ if member_vnf_index == vnf["member-vnf-index"]:
+ break
+ else:
+ raise EngineException("Invalid parameter member_vnf_index='{}' is not one of the "
+ "nsd:constituent-vnfd".format(member_vnf_index))
+
if operation == "action":
if indata.get("vnf_member_index"):
indata["member_vnf_index"] = indata.pop("vnf_member_index") # for backward compatibility
- for vnf in nsr["nsd"]["constituent-vnfd"]:
- if indata["member_vnf_index"] == vnf["member-vnf-index"]:
- # TODO get vnfd, check primitives
- break
- else:
- raise EngineException("Invalid parameter member_vnf_index='{}' is not one of the nsd "
- "constituent-vnfd".format(indata["member_vnf_index"]))
+ check_valid_vnf_member_index(indata["member_vnf_index"])
+ # TODO get vnfd, check primitives
+ if operation == "scale":
+ check_valid_vnf_member_index(indata["scaleVnfData"]["scaleByStepData"]["member-vnf-index"])
+ # TODO check vnf scaling primitives
def _format_new_data(self, session, item, indata):
now = time()
@@ -624,9 +630,11 @@
vdur = {
"id": vdur_id,
"vdu-id-ref": vdu["id"],
+ # TODO "name": "" Name of the VDU in the VIM
"ip-address": None, # mgmt-interface filled by LCM
# "vim-id", "flavor-id", "image-id", "management-ip" # filled by LCM
"internal-connection-point": [],
+ "interfaces": [],
}
# TODO volumes: name, volume-id
for icp in vdu.get("internal-connection-point", ()):
@@ -638,6 +646,13 @@
# vim-id # TODO it would be nice having a vim port id
}
vdur["internal-connection-point"].append(vdu_icp)
+ for iface in vdu.get("interface", ()):
+ vdu_iface = {
+ "name": iface.get("name"),
+ # "ip-address", "mac-address" # filled by LCM
+ # vim-id # TODO it would be nice having a vim port id
+ }
+ vdur["interfaces"].append(vdu_iface)
vnfr_descriptor["vdur"].append(vdur)
step = "creating vnfr vnfd-id='{}' constituent-vnfd='{}' at database".format(
diff --git a/osm_nbi/html_out.py b/osm_nbi/html_out.py
index a5b1bca..857d954 100644
--- a/osm_nbi/html_out.py
+++ b/osm_nbi/html_out.py
@@ -26,7 +26,8 @@
<a href="/osm/admin/v1/users">USERs </a>
<a href="/osm/admin/v1/projects">PROJECTs </a>
<a href="/osm/admin/v1/tokens">TOKENs </a>
- <a href="/osm/admin/v1/vims">VIMs </a>
+ <a href="/osm/admin/v1/vim_accounts">VIMs </a>
+ <a href="/osm/admin/v1/sdns">SDNs </a>
<a href="/osm/admin/v1/tokens?METHOD=DELETE">logout </a>
</div>
</div>
@@ -91,7 +92,7 @@
html_nslcmop_body = """
<a href="/osm/nslcm/v1/ns_lcm_op_occs?nsInstanceId={id}">nslcm operations </a>
-<a href="/osm/nslcm/v1/vnfrs?nsr-id-ref={id}">VNFRS </a>
+<a href="/osm/nslcm/v1/vnf_instances?nsr-id-ref={id}">VNFRS </a>
<form action="/osm/nslcm/v1/ns_instances/{id}/terminate" method="post" enctype="multipart/form-data">
<h3> <table style="border: 0;"> <tr>
<td> <input type="submit" value="Terminate"/> </td>
diff --git a/osm_nbi/html_public/version b/osm_nbi/html_public/version
index c9b57d9..9dd5ce5 100644
--- a/osm_nbi/html_public/version
+++ b/osm_nbi/html_public/version
@@ -1,3 +1,3 @@
-0.1.11
-2018-06-27
+0.1.12
+2018-07-02
diff --git a/osm_nbi/nbi.py b/osm_nbi/nbi.py
index e34cfad..796558d 100644
--- a/osm_nbi/nbi.py
+++ b/osm_nbi/nbi.py
@@ -68,8 +68,8 @@
/ns_lcm_op_occs 5 5
/<nsLcmOpOccId> 5 5 5
TO BE COMPLETED 5 5
- /vnfrs O
- /<vnfrId> O
+ /vnf_instances (also vnfrs for compatibility) O
+ /<vnfInstanceId> O
/subscriptions 5 5
/<subscriptionId> 5 X
/admin/v1
@@ -216,7 +216,7 @@
},
"ns_instances": {"METHODS": ("GET", "POST"),
"<ID>": {"METHODS": ("GET", "DELETE"),
- "scale": {"TODO": "POST"},
+ "scale": {"METHODS": "POST"},
"terminate": {"METHODS": "POST"},
"instantiate": {"METHODS": "POST"},
"action": {"METHODS": "POST"},
@@ -228,6 +228,9 @@
"vnfrs": {"METHODS": ("GET"),
"<ID>": {"METHODS": ("GET")}
},
+ "vnf_instances": {"METHODS": ("GET"),
+ "<ID>": {"METHODS": ("GET")}
+ },
}
},
}
@@ -657,7 +660,7 @@
engine_item = "nsrs"
if item == "ns_lcm_op_occs":
engine_item = "nslcmops"
- if item == "vnfrs":
+ if item == "vnfrs" or item == "vnf_instances":
engine_item = "vnfrs"
if engine_item == "vims": # TODO this is for backward compatibility, it will remove in the future
engine_item = "vim_accounts"
diff --git a/osm_nbi/validation.py b/osm_nbi/validation.py
index 308d872..cb249ba 100644
--- a/osm_nbi/validation.py
+++ b/osm_nbi/validation.py
@@ -22,6 +22,7 @@
"maxLength": 36}
# "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
id_schema = {"type": "string", "pattern": "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$"}
+time_schema = {"type": "string", "pattern": "^[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]([0-5]:){2}"}
pci_schema = {"type": "string", "pattern": "^[0-9a-fA-F]{4}(:[0-9a-fA-F]{2}){2}\.[0-9a-fA-F]$"}
http_schema = {"type": "string", "pattern": "^https?://[^'\"=]+$"}
bandwidth_schema = {"type": "string", "pattern": "^[0-9]+ *([MG]bps)?$"}
@@ -88,7 +89,7 @@
}
ns_action = { # TODO for the moment it is only contemplated the vnfd primitive execution
- "title": "ns action update input schema",
+ "title": "ns action input schema",
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
@@ -100,6 +101,36 @@
"required": ["primitive", "primitive_params"], # TODO add member_vnf_index
"additionalProperties": False
}
+ns_scale = { # TODO for the moment it is only VDU-scaling
+ "title": "ns scale input schema",
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "scaleType": {"enum": ["SCALE_VNF"]},
+ "scaleVnfData": {
+ "type": "object",
+ "properties": {
+ "vnfInstanceId": name_schema,
+ "scaleVnfType": {"enum": ["SCALE_OUT", 'SCALE_IN']},
+ "scaleByStepData": {
+ "type": "object",
+ "properties": {
+ "scaling-group-descriptor": name_schema,
+ "member-vnf-index": name_schema,
+ "scaling-policy": name_schema,
+ },
+ "required": ["scaling-group-descriptor", "member-vnf-index"],
+ "additionalProperties": False
+ },
+ },
+ "required": ["scaleVnfType", "scaleByStepData"], # vnfInstanceId
+ "additionalProperties": False
+ },
+ "scaleTime": time_schema,
+ },
+ "required": ["scaleType", "scaleVnfData"],
+ "additionalProperties": False
+}
schema_version = {"type": "string", "enum": ["1.0"]}
@@ -219,6 +250,7 @@
"sdns": sdn_new_schema,
"ns_instantiate": ns_instantiate,
"ns_action": ns_action,
+ "ns_scale": ns_scale
}
nbi_edit_input_schemas = {