):
target_vim, vim_info = next(k_v for k_v in vdu["vim_info"].items())
self._assign_vim(target_vim)
+ ns_preffix = "nsrs:{}".format(nsr_id)
+ flavor_text = ns_preffix + ":flavor." + vdu["ns-flavor-id"]
+ extra_dict["depends_on"] = [flavor_text]
+ extra_dict["params"].update({"flavor_id": "TASK-" + flavor_text})
target_record = "vnfrs:{}:vdur.{}.vim_info.{}".format(
vnf["_id"], vdu_index, target_vim
)
)
return task
+ def verticalscale_flavor_task(
+ self, vdu, vnf, vdu_index, action_id, nsr_id, task_index, extra_dict
+ ):
+ target_vim, vim_info = next(k_v for k_v in vdu["vim_info"].items())
+ self._assign_vim(target_vim)
+ db_nsr = self.db.get_one("nsrs", {"_id": nsr_id})
+ target_record = "nsrs:{}:flavor.{}.vim_info.{}".format(
+ nsr_id, len(db_nsr["flavor"]) - 1, target_vim
+ )
+ target_record_id = "nsrs:{}:flavor.{}".format(nsr_id, len(db_nsr["flavor"]) - 1)
+ deployment_info = {
+ "action_id": action_id,
+ "nsr_id": nsr_id,
+ "task_index": task_index,
+ }
+ task = Ns._create_task(
+ deployment_info=deployment_info,
+ target_id=target_vim,
+ item="flavor",
+ action="CREATE",
+ target_record=target_record,
+ target_record_id=target_record_id,
+ extra_dict=extra_dict,
+ )
+ return task
+
def verticalscale(self, session, indata, version, nsr_id, *args, **kwargs):
task_index = 0
extra_dict = {}
+ flavor_extra_dict = {}
now = time()
action_id = indata.get("action_id", str(uuid4()))
step = ""
"vcpus": numVirtualCpu,
"disk": sizeOfStorage,
}
+ flavor_data = {
+ "ram": virtualMemory,
+ "vcpus": numVirtualCpu,
+ "disk": sizeOfStorage,
+ }
+ flavor_extra_dict["find_params"] = {"flavor_data": flavor_data}
+ flavor_extra_dict["params"] = {"flavor_data": flavor_dict}
db_new_tasks = []
step = "Creating Tasks for vertical scaling"
with self.write_lock:
extra_dict["params"] = {
"vim_vm_id": vdu["vim-id"],
"flavor_dict": flavor_dict,
+ "vdu-id-ref": vdu["vdu-id-ref"],
+ "count-index": vdu["count-index"],
+ "vnf_instance_id": vnf_instance_id,
}
+ task = self.verticalscale_flavor_task(
+ vdu,
+ db_vnfr,
+ vdu_index,
+ action_id,
+ nsr_id,
+ task_index,
+ flavor_extra_dict,
+ )
+ db_new_tasks.append(task)
+ task_index += 1
task = self.verticalscale_task(
vdu,
db_vnfr,
target_vim = self.my_vims[ro_task["target_id"]]
try:
+ params = task["params"]
+ params_copy = deepcopy(params)
+ target_flavor_uuid = task_depends[params_copy["flavor_id"]]
vim_vm_id = ""
if task.get("params"):
- vim_vm_id = task["params"].get("vim_vm_id")
- flavor_dict = task["params"].get("flavor_dict")
- self.logger.info("flavor_dict %s", flavor_dict)
-
- try:
- target_flavor_uuid = target_vim.get_flavor_id_from_data(flavor_dict)
- except Exception as e:
- self.logger.info("Cannot find any flavor matching %s.", str(e))
- try:
- target_flavor_uuid = target_vim.new_flavor(flavor_dict)
- except Exception as e:
- self.logger.error("Error creating flavor at VIM %s.", str(e))
+ self.logger.info("vim_vm_id %s", vim_vm_id)
if target_flavor_uuid is not None:
resized_status = target_vim.resize_instance(
"params": {
"vim_vm_id": "f37b18ef-3caa-4dc9-ab91-15c669b16396",
"flavor_dict": "flavor_dict",
+ "flavor_id": "TASK-nsrs:993166fe-723e-4680-ac4b-b1af2541ae31:flavor.0",
},
+ "depends_on": ["nsrs:993166fe-723e-4680-ac4b-b1af2541ae31:flavor.0"],
}
vdu = {
"id": vdu_id,
"vim_info": {target_vim: {"interfaces": []}},
+ "ns-flavor-id": "0",
}
vnf = {"_id": vnf_id}
extra_dict_vertical_scale = {
self, assign_vim
):
self.ns = Ns()
- extra_dict = {}
+ extra_dict = {"params": {}}
vdu_index = "1"
task_index = 1
- expected_result = deepcopy(expected_result_vertical_scale)
- expected_result.pop("params")
+ expected_result = {
+ "target_id": "vim:f9f370ac-0d44-41a7-9000-457f2332bc35",
+ "action_id": "bb937f49-3870-4169-b758-9732e1ff40f3",
+ "nsr_id": "993166fe-723e-4680-ac4b-b1af2541ae31",
+ "task_id": "bb937f49-3870-4169-b758-9732e1ff40f3:1",
+ "status": "SCHEDULED",
+ "action": "EXEC",
+ "item": "verticalscale",
+ "target_record": "vnfrs:665b4165-ce24-4320-bf19-b9a45bade49f:vdur.1.vim_info.vim:f9f370ac-0d44-41a7-9000-457f2332bc35",
+ "target_record_id": "vnfrs:665b4165-ce24-4320-bf19-b9a45bade49f:vdur.bb9c43f9-10a2-4569-a8a8-957c3528b6d1",
+ "params": {
+ "flavor_id": "TASK-nsrs:993166fe-723e-4680-ac4b-b1af2541ae31:flavor.0"
+ },
+ "depends_on": ["nsrs:993166fe-723e-4680-ac4b-b1af2541ae31:flavor.0"],
+ }
+
task = self.ns.verticalscale_task(
vdu, vnf, vdu_index, action_id, nsr_id_2, task_index, extra_dict
)
"params": {
"vim_vm_id": "f37b18ef-3caa-4dc9-ab91-15c669b16396",
"flavor_dict": "flavor_dict",
+ "flavor_id": "TASK-nsrs:993166fe-723e-4680-ac4b-b1af2541ae31:flavor.0",
},
}
},
}
+ task_depends = {
+ "TASK-nsrs:993166fe-723e-4680-ac4b-b1af2541ae31:flavor.0": "1"
+ }
task_index = "task_index_1"
- result = instance.exec(ro_task, task_index, self.task_depends)
+ result = instance.exec(ro_task, task_index, task_depends)
self.assertEqual(result[0], "DONE")
self.assertEqual(result[1].get("vim_status"), "ACTIVE")
--- /dev/null
+#######################################################################################
+# Copyright ETSI Contributors and Others.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#######################################################################################
+---
+fixes:
+ - |
+ Bug Fix 2304 Flavor Not getting Updated in Mongodb nsrs after Vertical scaling,
+ because, in vertical scale feature, Ro task creation is not added for flavor.
+ This fix will add the new flavor in nsrs after scaling and will addits reference
+ in vnfrs.