+ @mock.patch.object(restcall, "call_req")
+ @mock.patch.object(vimadaptor.VimAdaptor, "create_network")
+ def test_create_vl_when_vim_id_in_additional_param(self, mock_create_network, mock_req_by_rest):
+ network_id = str(uuid.uuid4())
+ subnetwork_id = str(uuid.uuid4())
+ mock_create_network.return_value = [0,
+ {"status": "ACTIVE", "id": network_id, "name": "net1",
+ "provider:segmentation_id": 204, "provider:network_type": "vlan",
+ "res_type": 1,
+ "subnet_list": [
+ {"id": subnetwork_id, "name": "subnet1", "res_type": 1}]}]
+ mock_req_by_rest.return_value = [0, json.JSONEncoder().encode(vim_info), '200']
+ vim_id = '{"cloud_owner": "cloud_owner", "cloud_regionid": "cloud_regionid"}'
+ req_data = {
+ "nsInstanceId": self.ns_inst_id,
+ "context": json.JSONEncoder().encode(self.context),
+ "vlIndex": self.vl_id_2,
+ "additionalParamForNs": '{"location": %s}' % vim_id}
+ response = self.client.post("/api/nslcm/v1/ns/vls", data=req_data)
+ self.assertEqual(status.HTTP_201_CREATED, response.status_code)
+ self.assertEqual(0, response.data["result"], response.data)
+ vl_from_vl_2 = VLInstModel.objects.filter(vldid=self.vl_id_2, ownerid=self.ns_inst_id)
+ self.assertEqual(network_id, vl_from_vl_2[0].relatednetworkid)
+ self.assertEqual(subnetwork_id, vl_from_vl_2[0].relatedsubnetworkid)
+ self.assertEqual(self.tenant, vl_from_vl_2[0].tenant)
+