1 # Copyright 2017 ZTE Corporation.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
17 from django.test import Client
18 from rest_framework import status
20 inst_res_url = "/api/vnflcm/v1/resources/inst"
21 term_res_url = "/api/vnflcm/v1/resources/term"
29 "artifact_name": "cirros.img",
30 "type": "tosca.artifacts.nfv.SwImage",
32 "operating_system": "unbant",
33 "sw_image": "/swimages/xenial-snat.qcow2",
37 "disk_format": "qcow2",
39 "container_format": "bare",
43 "file": "/swimages/xenial-snat.qcow2"
47 "flavor_extra_specs": {
52 "image_file": "cirros.img",
54 "intel_local_storages_1"
65 "configurable_properties": {
67 "additional_vnfc_configurable_properties": {
74 "vimid": "f1e33529-4a88-4155-9d7a-893cf2c80527",
76 "availability_zone": "zone1",
79 "descrption": "the virtual machine of vNat",
88 "volume_storage_id": "volume_storage1",
93 "volume_name": "volumeStorage1",
94 "custom_volume_type": "type1",
96 "delete_on_termination_vm": True,
98 "vimid": "f1e33529-4a88-4155-9d7a-893cf2c80527",
100 "availability_zone": "zone1"
102 "is_predefined": False,
112 "local_storage_id": "omp_local_disk1",
126 "operating_system": "unbant",
127 "sw_image": "/swimages/xenial-snat.qcow2",
128 "name": "cirros.img",
131 "disk_format": "qcow2",
133 "container_format": "bare",
137 "image_file_id": "cirros.img"
143 "key_name": "sriov_plane",
144 "cp_id": "SRIOV_Port"
155 "name": "vNat_big_subnet",
156 "network_name": "vNat_big",
157 "is_predefined": False,
159 "netmask": "255.255.255.0",
161 "network_type": "vlan",
162 "physical_network": "physnet1",
163 "segmentation_id": "30",
164 "vlan_transparent": False,
166 "cidr": "10.43.38.0/24",
168 "gateway_ip": "10.43.38.1",
169 "dhcp_enabled": False,
170 "start_ip": "10.43.38.2",
171 "end_ip": "10.43.38.254",
174 "destination": "10.43.26.0/24",
175 "nexthop": "10.41.23.1"
179 "vimid": "f1e33529-4a88-4155-9d7a-893cf2c80527",
184 "route_id": "router01",
185 "route_external": False
191 "name": "vNat_big_subnet_port",
192 "ip_address": "10.43.38.253",
193 "vnic_type": "normal",
195 "virtual_network_interface_requirements": [
200 "support_mandatory": False,
202 "description": "sriov"
205 "layer_protocol": "ipv4",
206 "description": "sriov port"
215 "vnfSoftwareVersion": "1.0.0",
216 "vnfmType": "gvnfmdriver",
217 "vnfProductName": "openNAT",
218 "localizationLanguage": "[english, chinese]",
219 "vnfProvider": "intel",
221 "defaultLocalizationLanguage": "english",
222 "csarVersion": "1.0.0",
223 "vnfdId": "openNAT-1.0",
224 "csarProvider": "intel",
225 "vnfProductInfoDescription": "openNAT",
227 "vnfdVersion": "1.0.0",
228 "vnfProductInfoName": "openNAT",
235 "volume": [{"vim_id": "1", "tenant_id": "2", "res_id": "3"}],
236 "network": [{"vim_id": "2", "tenant_id": "3", "res_id": "4"}],
237 "subnet": [{"vim_id": "3", "tenant_id": "4", "res_id": "5"}],
238 "port": [{"vim_id": "4", "tenant_id": "5", "res_id": "6"}],
239 "flavor": [{"vim_id": "5", "tenant_id": "6", "res_id": "7"}],
240 "vm": [{"vim_id": "6", "tenant_id": "7", "res_id": "8"}]
244 class SampleViewTest(unittest.TestCase):
246 self.client = Client()
251 def test_sample(self):
252 response = self.client.get("/samples/")
253 self.assertEqual(status.HTTP_200_OK, response.status_code, response.content)
254 resp_data = json.loads(response.content)
255 self.assertEqual({"status": "active"}, resp_data)
257 def test_inst_res(self):
258 resp = self.client.post(inst_res_url, data=json.dumps(inst_res_data), content_type='application/json')
259 self.failUnlessEqual(status.HTTP_204_NO_CONTENT, resp.status_code)
261 def test_term_res(self):
262 resp = self.client.post(term_res_url, data=json.dumps(term_res_data), content_type='application/json')
263 self.failUnlessEqual(status.HTTP_204_NO_CONTENT, resp.status_code)