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.
18 from django.test import Client
19 from rest_framework import status
21 from lcm.pub.vimapi import api
23 inst_res_url = "/api/vnflcm/v1/resources/inst"
24 term_res_url = "/api/vnflcm/v1/resources/term"
32 "artifact_name": "cirros.img",
33 "type": "tosca.artifacts.nfv.SwImage",
35 "operating_system": "unbant",
36 "sw_image": "/swimages/xenial-snat.qcow2",
40 "disk_format": "qcow2",
42 "container_format": "bare",
46 "file": "/swimages/xenial-snat.qcow2"
50 "flavor_extra_specs": {
55 "image_file": "cirros.img",
57 "intel_local_storages_1"
68 "configurable_properties": {
70 "additional_vnfc_configurable_properties": {
77 "vimid": "f1e33529-4a88-4155-9d7a-893cf2c80527",
79 "availability_zone": "zone1",
82 "descrption": "the virtual machine of vNat",
91 "volume_storage_id": "volume_storage1",
96 "volume_name": "volumeStorage1",
97 "custom_volume_type": "type1",
99 "delete_on_termination_vm": True,
101 "vimid": "f1e33529-4a88-4155-9d7a-893cf2c80527",
103 "availability_zone": "zone1"
105 "is_predefined": False,
115 "local_storage_id": "omp_local_disk1",
129 "operating_system": "unbant",
130 "sw_image": "/swimages/xenial-snat.qcow2",
131 "name": "cirros.img",
134 "disk_format": "qcow2",
136 "container_format": "bare",
140 "image_file_id": "cirros.img"
146 "key_name": "sriov_plane",
147 "cp_id": "SRIOV_Port"
158 "name": "vNat_big_subnet",
159 "network_name": "vNat_big",
160 "is_predefined": False,
162 "netmask": "255.255.255.0",
164 "network_type": "vlan",
165 "physical_network": "physnet1",
166 "segmentation_id": "30",
167 "vlan_transparent": False,
169 "cidr": "10.43.38.0/24",
171 "gateway_ip": "10.43.38.1",
172 "dhcp_enabled": False,
173 "start_ip": "10.43.38.2",
174 "end_ip": "10.43.38.254",
177 "destination": "10.43.26.0/24",
178 "nexthop": "10.41.23.1"
182 "vimid": "f1e33529-4a88-4155-9d7a-893cf2c80527",
187 "route_id": "router01",
188 "route_external": False
194 "name": "vNat_big_subnet_port",
195 "ip_address": "10.43.38.253",
196 "vnic_type": "normal",
198 "virtual_network_interface_requirements": [
203 "support_mandatory": False,
205 "description": "sriov"
208 "layer_protocol": "ipv4",
209 "description": "sriov port"
218 "vnfSoftwareVersion": "1.0.0",
219 "vnfmType": "gvnfmdriver",
220 "vnfProductName": "openNAT",
221 "localizationLanguage": "[english, chinese]",
222 "vnfProvider": "intel",
224 "defaultLocalizationLanguage": "english",
225 "csarVersion": "1.0.0",
226 "vnfdId": "openNAT-1.0",
227 "csarProvider": "intel",
228 "vnfProductInfoDescription": "openNAT",
230 "vnfdVersion": "1.0.0",
231 "vnfProductInfoName": "openNAT",
238 "volume": [{"vim_id": "1", "tenant_id": "2", "res_id": "3"}],
239 "network": [{"vim_id": "2", "tenant_id": "3", "res_id": "4"}],
240 "subnet": [{"vim_id": "3", "tenant_id": "4", "res_id": "5"}],
241 "port": [{"vim_id": "4", "tenant_id": "5", "res_id": "6"}],
242 "flavor": [{"vim_id": "5", "tenant_id": "6", "res_id": "7"}],
243 "vm": [{"vim_id": "6", "tenant_id": "7", "res_id": "8"}]
246 class SampleViewTest(unittest.TestCase):
248 self.client = Client()
253 def test_sample(self):
254 response = self.client.get("/samples/")
255 self.assertEqual(status.HTTP_200_OK, response.status_code, response.content)
256 resp_data = json.loads(response.content)
257 self.assertEqual({"status": "active"}, resp_data)
259 def test_inst_res(self):
260 resp = self.client.post(inst_res_url, data=json.dumps(inst_res_data), content_type='application/json')
261 self.failUnlessEqual(status.HTTP_204_NO_CONTENT, resp.status_code)
263 def test_term_res(self):
264 resp = self.client.post(term_res_url, data=json.dumps(term_res_data), content_type='application/json')
265 self.failUnlessEqual(status.HTTP_204_NO_CONTENT, resp.status_code)