self.assertEqual(application_name, expected_result)
self.assertLess(len(application_name), 50)
- def test_generate_application_name_vdu_charm(self):
+ def test_generate_application_name_vdu_charm_kdu_name_in_vca_record_is_none(self):
charm_level = "vdu-level"
vnfrs = {
"member-vnf-index-ref": "vnf111-xxx-yyy-zzz",
"model": "dbfbd751-3de4-4e68-bd40-ec5ae0a53898",
},
{
- "target_element": "vnf/vnf1/datavm",
+ "target_element": "vnf/vnf1/dataVM",
"member-vnf-index": "vnf111-xxx-yyy-zzz",
- "vdu_id": "45512ff7-5bdd-4228-911f-c2bee259c44a",
+ "vdu_id": "dataVM",
"kdu_name": None,
"vdu_count_index": None,
"vnfd_id": "r7fbd751-3de4-4e68-bd40-ec5ae0a53898",
self.assertEqual(application_name, expected_result)
self.assertLess(len(application_name), 50)
- def test_generate_application_name_vdu_charm_vdu_id_none(self):
+ def test_generate_application_name_vdu_charm_vdu_id_kdu_name_in_vca_record_are_both_set(
+ self,
+ ):
charm_level = "vdu-level"
vnfrs = {
"member-vnf-index-ref": "vnf111-xxx-yyy-zzz",
+ "vdur": [
+ {"_id": "38912ff7-5bdd-4228-911f-c2bee259c44a", "vdu-id-ref": "mgmtVM"},
+ {"_id": "45512ff7-5bdd-4228-911f-c2bee259c44a", "vdu-id-ref": "dataVM"},
+ ],
}
vca_records = [
{
- "target_element": "vnf/vnf1/mgmtvm",
+ "target_element": "vnf/vnf1/mgmtVM",
+ "member-vnf-index": "vnf111-xxx-yyy-zzz",
+ "vdu_id": "mgmtVM",
+ "kdu_name": "mgmtVM",
+ "vdu_count_index": None,
+ "vnfd_id": "r7fbd751-3de4-4e68-bd40-ec5ae0a53898",
+ "vdu_name": "mgmtvm",
+ "ee_descriptor_id": "simple-ee-abc-000-rrrr-nnnn-4444-hhh-3333-yyyy-333-hhh-ttt-444",
+ "charm_name": "",
+ "model": "dbfbd751-3de4-4e68-bd40-ec5ae0a53898",
+ },
+ {
+ "target_element": "vnf/vnf1/dataVM",
+ "member-vnf-index": "vnf111-xxx-yyy-zzz",
+ "vdu_id": "dataVM",
+ "kdu_name": None,
+ "vdu_count_index": None,
+ "vnfd_id": "r7fbd751-3de4-4e68-bd40-ec5ae0a53898",
+ "vdu_name": "datavm",
+ "ee_descriptor_id": "simple-ee-abc-000-rrrr-nnnn-8888-hhh-3333-yyyy-888-hhh-ttt-444",
+ "charm_name": "",
+ "model": "dbfbd751-3de4-4e68-bd40-ec5ae0a53898",
+ },
+ ]
+ vnf_count = "2"
+ vdu_count = "0"
+ vdu_id = "mgmtVM"
+ expected_result = "simple-ee-ab-2-vnf111-xxx-y-mgmtVM-0-vdu"
+ application_name = self.n2vc._generate_application_name(
+ charm_level,
+ vnfrs,
+ vca_records,
+ vnf_count=vnf_count,
+ vdu_id=vdu_id,
+ vdu_count=vdu_count,
+ )
+ self.assertEqual(application_name, expected_result)
+ self.assertLess(len(application_name), 50)
+
+ def test_generate_application_name_vdu_charm_both_vdu_id_kdu_name_in_vca_record_are_none(
+ self,
+ ):
+ charm_level = "vdu-level"
+ vnfrs = {
+ "member-vnf-index-ref": "vnf111-xxx-yyy-zzz",
+ }
+ vca_records = [
+ {
+ "target_element": "vnf/vnf1/mgmtVM",
"member-vnf-index": "vnf111-xxx-yyy-zzz",
"vdu_id": None,
"kdu_name": None,
]
vnf_count = "2"
vdu_count = "0"
+ vdu_id = "mgmtVM"
+ with self.assertRaises(KeyError):
+ self.n2vc._generate_application_name(
+ charm_level,
+ vnfrs,
+ vca_records,
+ vnf_count=vnf_count,
+ vdu_id=vdu_id,
+ vdu_count=vdu_count,
+ )
+
+ def test_generate_application_name_vdu_charm_given_vdu_id_is_none(self):
+ charm_level = "vdu-level"
+ vnfrs = {
+ "member-vnf-index-ref": "vnf111-xxx-yyy-zzz",
+ }
+ vca_records = [
+ {
+ "target_element": "vnf/vnf1/mgmtvVM",
+ "member-vnf-index": "vnf111-xxx-yyy-zzz",
+ "vdu_id": None,
+ "kdu_name": "mgmtVM",
+ "vdu_count_index": None,
+ "vnfd_id": "r7fbd751-3de4-4e68-bd40-ec5ae0a53898",
+ "vdu_name": "mgmtvm",
+ "ee_descriptor_id": "simple-ee-abc-000-rrrr-nnnn-4444-hhh-3333-yyyy-333-hhh-ttt-444",
+ "charm_name": "",
+ "model": "dbfbd751-3de4-4e68-bd40-ec5ae0a53898",
+ },
+ ]
+ vnf_count = "2"
+ vdu_count = "0"
vdu_id = None
with self.assertRaises(N2VCException):
self.n2vc._generate_application_name(
vdu_count=vdu_count,
)
+ def test_generate_application_name_vdu_charm_vdu_id_does_not_match_with_the_key_in_vca_record(
+ self,
+ ):
+ charm_level = "vdu-level"
+ vnfrs = {
+ "member-vnf-index-ref": "vnf111-xxx-yyy-zzz",
+ }
+ vca_records = [
+ {
+ "target_element": "vnf/vnf1/mgmtVM",
+ "member-vnf-index": "vnf111-xxx-yyy-zzz",
+ "vdu_id": None,
+ "kdu_name": "mgmtVM",
+ "vdu_count_index": None,
+ "vnfd_id": "r7fbd751-3de4-4e68-bd40-ec5ae0a53898",
+ "vdu_name": "mgmtvm",
+ "ee_descriptor_id": "simple-ee-abc-000-rrrr-nnnn-4444-hhh-3333-yyyy-333-hhh-ttt-444",
+ "charm_name": "",
+ "model": "dbfbd751-3de4-4e68-bd40-ec5ae0a53898",
+ },
+ ]
+ vnf_count = "2"
+ vdu_count = "0"
+ vdu_id = "mgmtvm"
+ with self.assertRaises(KeyError):
+ self.n2vc._generate_application_name(
+ charm_level,
+ vnfrs,
+ vca_records,
+ vnf_count=vnf_count,
+ vdu_id=vdu_id,
+ vdu_count=vdu_count,
+ )
+
+ def test_generate_application_name_vdu_charm_vdu_id_in_vca_record_is_none(self):
+ charm_level = "vdu-level"
+ vnfrs = {
+ "member-vnf-index-ref": "vnf111-xxx-yyy-zzz",
+ }
+ vca_records = [
+ {
+ "target_element": "vnf/vnf1/mgmtVM",
+ "member-vnf-index": "vnf111-xxx-yyy-zzz",
+ "vdu_id": None,
+ "kdu_name": "mgmtVM",
+ "vdu_count_index": None,
+ "vnfd_id": "r7fbd751-3de4-4e68-bd40-ec5ae0a53898",
+ "vdu_name": "mgmtvm",
+ "ee_descriptor_id": "simple-ee-abc-000-rrrr-nnnn-4444-hhh-3333-yyyy-333-hhh-ttt-444",
+ "charm_name": "",
+ "model": "dbfbd751-3de4-4e68-bd40-ec5ae0a53898",
+ },
+ ]
+ vnf_count = "2"
+ vdu_count = "0"
+ vdu_id = "mgmtVM"
+ expected_result = "simple-ee-ab-2-vnf111-xxx-y-mgmtVM-0-vdu"
+ application_name = self.n2vc._generate_application_name(
+ charm_level,
+ vnfrs,
+ vca_records,
+ vnf_count=vnf_count,
+ vdu_id=vdu_id,
+ vdu_count=vdu_count,
+ )
+ self.assertEqual(application_name, expected_result)
+ self.assertLess(len(application_name), 50)
+
def test_get_vnf_count_db_vnfr_ns_charm(self):
self.db.get_one.return_value = {"member-vnf-index-ref": "sample-ref"}
charm_level = "ns-level"
{
"target_element": "vnf/openldap/kdu/ldap",
"member-vnf-index": "openldap",
- "vdu_id": "ldap",
+ "vdu_id": None,
"kdu_name": "ldap",
"vdu_count_index": 0,
"operational-status": "init",
"deployed": {
"VCA": [
{
- "target_element": "vnf/vnf1/mgmtvm",
+ "target_element": "vnf/vnf1/mgmtVM",
"member-vnf-index": "vnf111-xxx-yyy-zzz",
- "vdu_id": "38912ff7-5bdd-4228-911f-c2bee259c44a",
+ "vdu_id": "mgmtVM",
"kdu_name": None,
"vdu_count_index": None,
"vnfd_id": "r7fbd751-3de4-4e68-bd40-ec5ae0a53898",