Getting flavor info from OOF
[vfc/gvnfm/vnflcm.git] / lcm / lcm / samples / tests.py
index e34f6a1..a1d13be 100644 (file)
@@ -39,29 +39,19 @@ inst_res_data = {
                     "num_virtual_cpu": "2",
                     "cpu_architecture": "generic"
                 },
-                "virtual_storage": {
-                    "type_of_storage": "root",
-                    "size_of_storage": "40 GB"
-                },
+            },
+            "virtual_storage": {
+                "type_of_storage": "root",
+                "size_of_storage": "40 GB"
             },
             "artifacts": [
                 {
-                    "artifact_name": "cirros.img",
+                    "artifact_name": "sw_image",
+                    "deploy_path": "",
                     "type": "tosca.artifacts.nfv.SwImage",
-                    "properties": {
-                        "operating_system": "unbant",
-                        "sw_image": "/swimages/xenial-snat.qcow2",
-                        "name": "cirros.img",
-                        "checksum": "5000",
-                        "min_ram": "1 GB",
-                        "disk_format": "qcow2",
-                        "version": "1.0",
-                        "container_format": "bare",
-                        "min_disk": "10 GB",
-                        "size": "10 GB"
-                    },
-                    "file": "/swimages/xenial-snat.qcow2"
-                }
+                    "repository": "",
+                    "file": "ubuntu_16.04"
+                },
             ],
             "image_file": "cirros.img",
             "local_storages": [
@@ -76,6 +66,15 @@ inst_res_data = {
                 "cp_vNat"
             ],
             "properties": {
+                "user_data": "just test user data",
+                "meta_data": "just test meta data",
+                "inject_files": [
+                    {
+                        "source_path": "artifacts/keys/authorized_keys",
+                        "source_data_base64": "c3NoLXJzYSBBQUFBQjNOemFDMXljMkVBQUFBREFRQUJBQUFCQVFER3g2U0tyQXVDejFWOEtHZXZa\ndWVrc0xkV29QV0pQNnozcjI5WjdUbVBWRU9qTSs3UElQZVNzMkJWUngzcm5IWkJBbGFzTXJaK2ZK\nQlMyNXRzOXZmQytJdGV6UWFoL2hyOXZya213eENSNTRMYjg0cG9XK3NUb1BlRjZpNWVaWTdXK2pX\nSmZMYUZTRng5ZDJ2cDR6ZXMvZk9sVDNOdllDWGJuLzNRZHJ5UW9HbDdWRkk4b2VtWnlwVmNpa1pY\nRWxKZWVLZ0FWZFN3bnJ6dXF0Ty90bWJYY0FlU2JZdlZqa2k4eXdZY3NXTVZNWVdVV2hoKzFCQUI2\na1huVHNJV3F6cnEwUGZ2eSs4MVdEd3RpcXNxbWQ5M0hZOGhFMHNjQnJYRkJaelFTL0FZZklGQmxF\ndUZOZExjemNobnRqYlowbjdkbURYazh6SHRDWllOazdrd2I4ay8gbHVsaWFuaGFvQGxsdS1udWMx\nCg==\n",
+                        "dest_path": "/home/ubuntu/.ssh/authorized_keys"
+                    }
+                ],
                 "configurable_properties": {
                     "test": {
                         "additional_vnfc_configurable_properties": {
@@ -88,7 +87,18 @@ inst_res_data = {
                     "vimid": "f1e33529-4a88-4155-9d7a-893cf2c80527",
                     "tenant": "vnfm",
                     "availability_zone": "zone1",
-                    "host": "host1"
+                    "host": "host1",
+                    "vnfId": "",
+                    "vnfName": "",
+                    "cloudOwner": "",
+                    "cloudRegionId": "",
+                    "vduInfo": [
+                        {
+                            "vduName": "VDU_vbng_0",
+                            "flavorName": "flavor_1",
+                            "directive": "",
+                        },
+                    ]
                 },
                 "descrption": "the virtual machine of vNat",
                 "boot_order": [
@@ -155,7 +165,7 @@ inst_res_data = {
         "external_cps": [
             {
                 "key_name": "sriov_plane",
-                "cp_id": "SRIOV_Port"
+                "cp_id": "sriov-support"
             }
         ],
         "forward_cps": [
@@ -166,23 +176,26 @@ inst_res_data = {
             "vl_id": "vl_vNat",
             "description": "",
             "properties": {
-                "name": "vNat_big_subnet",
-                "network_name": "vNat_big",
+                "connectivity_type": {
+                    "layer_protocol": "ipv4"
+                },
+                "vl_profile": {
+                    "networkName": "vNat_big",
+                    "networkType": "vlan",
+                    "physicalNetwork": "physnet1",
+                    "segmentationId": "30",
+                    "vlanTransparent": False,
+                    "cidr": "10.43.38.0/24",
+                    "gatewayIp": "10.43.38.1",
+                    "dhcpEnabled": False,
+                    "startIp": "10.43.38.2",
+                    "endIp": "10.43.38.254"
+                },
                 "is_predefined": False,
                 "vendor": "zte",
                 "netmask": "255.255.255.0",
                 "mtu": 1500,
-                "network_type": "vlan",
-                "physical_network": "physnet1",
-                "segmentation_id": "30",
-                "vlan_transparent": False,
                 "vds_name": "vds1",
-                "cidr": "10.43.38.0/24",
-                "ip_version": 4,
-                "gateway_ip": "10.43.38.1",
-                "dhcp_enabled": False,
-                "start_ip": "10.43.38.2",
-                "end_ip": "10.43.38.254",
                 "host_routes": [
                     {
                         "destination": "10.43.26.0/24",
@@ -201,18 +214,27 @@ inst_res_data = {
     ],
     "cps": [
         {
+
             "properties": {
                 "name": "vNat_big_subnet_port",
-                "ip_address": "10.43.38.253",
-                "vnic_type": "normal",
+                "protocol_data": [
+                    {
+                        "address_data": {
+                            "l3_address_data": {
+                                "fixed_ip_address": ["10.43.38.253"]
+                            },
+                        },
+                    }
+                ],
+                "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"
                     }
                 ],
@@ -293,32 +315,25 @@ c4_data_create_port = {
     "nodeId": "",
     "id": "456"
 }
+c5_data_create_flavor = {
+    "vimId": "f1e33529-4a88-4155-9d7a-893cf2c80527",
+    "nodeId": "",
+    "id": "6456",
+}
 
-c5_data_get_flavor = [{
-    "flavors": {
-        "flavor": [
-            {
-                "flavor-id": "111111",
-                "hpa-capabilities": [
-                    {
-                        "hpa-capability-id": "1243",
-                        "hpa-feature-attributes": [
-                            {
-                                "hpa-attribute-key": "memoryPageSize",
-                                "hpa-attribute-value": {"value": 2, "unit": "MB"}
-                            }
-                        ]
-                    }
-                ]
-            }
-        ]
-    }
-}]
+c5_data_get_flavor = {
+    "flavor": [
+        {
+            "flavor-id": "111111",
+            "flavor-name": "flavor_1",
+        }
+    ]
+}
 
 c6_data_list_image = {
     "images": [
         {
-            "name": "cirros.img",
+            "name": "ubuntu_16.04",
             "id": "678"
         }
     ]
@@ -358,6 +373,7 @@ class SampleViewTest(unittest.TestCase):
         r3_data_create_subnet = [0, json.JSONEncoder().encode(c3_data_create_subnet), '200']
         r4_data_create_port = [0, json.JSONEncoder().encode(c4_data_create_port), '200']
         r5_data_get_flavor = [0, json.JSONEncoder().encode(c5_data_get_flavor), '200']
+        r5_data_create_flavor = [0, json.JSONEncoder().encode(c5_data_create_flavor), '200']
         r6_data_list_image = [0, json.JSONEncoder().encode(c6_data_list_image), '200']
         r6_data_create_vm = [0, json.JSONEncoder().encode(c6_data_create_vm), '200']
         r6_data_get_vm = [0, json.JSONEncoder().encode(c6_data_get_vm), '200']
@@ -367,7 +383,7 @@ class SampleViewTest(unittest.TestCase):
                                      r2_data_create_network,
                                      r3_data_create_subnet,
                                      r4_data_create_port,
-                                     r5_data_get_flavor,
+                                     r5_data_get_flavor, r5_data_create_flavor,
                                      r6_data_list_image, r6_data_create_vm, r6_data_get_vm]
         resp = self.client.post(inst_res_url, data=json.dumps(inst_res_data), content_type='application/json')
         self.failUnlessEqual(status.HTTP_204_NO_CONTENT, resp.status_code)