Add port of SR-IOV NIC support 11/64411/2
authorHuang Haibin <haibin.huang@intel.com>
Tue, 4 Sep 2018 12:13:58 +0000 (20:13 +0800)
committerHuang Haibin <haibin.huang@intel.com>
Thu, 6 Sep 2018 03:18:53 +0000 (11:18 +0800)
Change-Id: I2f50063d6e9a7c383b62e81bd9cefb532172cae3
Issue-ID: VFC-939
Signed-off-by: Huang Haibin <haibin.huang@intel.com>
lcm/lcm/nf/const.py
lcm/lcm/pub/vimapi/adaptor.py
lcm/lcm/samples/tests.py

index 37205c5..a20d39f 100644 (file)
@@ -489,7 +489,7 @@ c4_data_create_network = {
     "vlanTransparent": True,
     "networkType": "vlan",
     "segmentationId": 202,
-    "physicalNetwork": "ctrl",
+    "physicalNetwork": "physnet1",
     "routerExternal": False
 }
 
@@ -533,7 +533,7 @@ c6_data_create_port = {
     "subnetName": "subnet1",
     "macAddress": "212.12.61.23",
     "ip": "10.43.38.11",
-    "vnicType": "normal",
+    "vnicType": "direct",
     "securityGroups": ""
 }
 
@@ -663,7 +663,18 @@ vnfdModel = {
                         },
                     },
                 ],
-                "vnic_type": "test",
+                "vnic_type": "direct",
+                "role": "root",
+                "virtual_network_interface_requirements": [
+                    {
+                        "network_interface_requirements": {
+                            "interfaceType": '{"schema-version": "0", "schema-location":"", "platform-id": "generic", "mandatory": false, "configuration-value": "SR-IOV"}'
+                        },
+                        "support_mandatory": False,
+                        "name": "SRIOV_Port",
+                        "description": "sriov"
+                    }
+                ]
             }
         }
     ],
index 8ebddab..bbc9109 100644 (file)
@@ -15,6 +15,7 @@
 import logging
 import time
 import ast
+import json
 
 from lcm.pub.utils.values import ignore_case_get, set_opt_val
 from lcm.pub.msapi.aai import get_flavor_info
@@ -245,8 +246,17 @@ def create_port(vim_cache, res_cache, data, port, do_notify, res_type):
         l3_address_data = one_protocol_data["address_data"]["l3_address_data"]  # l3 is not 13
         fixed_ip_address = ignore_case_get(l3_address_data, "fixed_ip_address")
         ip_address.extend(fixed_ip_address)
+    for one_virtual_network_interface in port["properties"]["virtual_network_interface_requirements"]:
+        interfaceTypeString = one_virtual_network_interface["network_interface_requirements"]["interfaceType"]
+        interfaceType = json.loads(interfaceTypeString)["configuration-value"]
+        vnic_type = ignore_case_get(port["properties"], "vnic_type")
+        if vnic_type == "":
+            if interfaceType == "SR-IOV":
+                set_opt_val(param, "vnicType", "direct")
+        else:
+            set_opt_val(param, "vnicType", vnic_type)
+
     set_opt_val(param, "ip", ",".join(ip_address))
-    set_opt_val(param, "vnicType", ignore_case_get(port["properties"], "vnic_type"))
     set_opt_val(param, "securityGroups", "")   # TODO
     vim_id, tenant_name = location_info["vimid"], location_info["tenant"]
     tenant_id = get_tenant_id(vim_cache, vim_id, tenant_name)
index 47e2353..42d96b0 100644 (file)
@@ -154,7 +154,7 @@ inst_res_data = {
         "external_cps": [
             {
                 "key_name": "sriov_plane",
-                "cp_id": "SRIOV_Port"
+                "cp_id": "sriov-support"
             }
         ],
         "forward_cps": [
@@ -215,15 +215,15 @@ inst_res_data = {
                         },
                     }
                 ],
-                "vnic_type": "normal",
+                "vnic_type": "direct",
                 "role": "root",
                 "virtual_network_interface_requirements": [
                     {
-                        "requirement": {
-                            "SRIOV": "true"
+                        "network_interface_requirements": {
+                            "interfaceType": '{"schema-version": "0", "schema-location":"", "platform-id": "generic", "mandatory": false, "configuration-value": "SR-IOV"}'
                         },
                         "support_mandatory": False,
-                        "name": "sriov",
+                        "name": "sriov-support",
                         "description": "sriov"
                     }
                 ],