from lcm.pub.utils.timeutil import now_time
from lcm.pub.utils.values import ignore_case_get
from lcm.ns_vnfs.biz.create_vnfs import CreateVnfs
+from lcm.ns_vnfs.biz.grant_vnf import GrantVnf
from lcm.ns_vnfs.biz.heal_vnfs import NFHealService
from lcm.ns_vnfs.biz.scale_vnfs import NFManualScaleService
from lcm.ns_vnfs.biz.subscribe import SubscriptionDeletion
from lcm.ns_vnfs.const import VNF_STATUS, INST_TYPE
from lcm.ns_vnfs.biz import create_vnfs
from lcm.ns_vnfs.biz.place_vnfs import PlaceVnfs
+from lcm.pub.msapi import resmgr
class TestGetVnfViews(TestCase):
class TestPlaceVnfViews(TestCase):
def setUp(self):
self.vnf_inst_id = "1234"
- self.vnf_inst_name = "vG"
+ self.vnf_id = "vG"
self.client = Client()
OOFDataModel.objects.all().delete()
OOFDataModel.objects.create(
request_id="1234",
transaction_id="1234",
request_status="init",
- request_module_name=self.vnf_inst_name,
+ request_module_name=self.vnf_id,
service_resource_id=self.vnf_inst_id,
vim_id="",
cloud_owner="",
vdu_info_json = [{
"vduName": "vG_0",
"flavorName": "HPA.flavor.1",
+ "flavorId": "12345",
"directive": []
}]
PlaceVnfs(vnf_place_request).extract()
"placementSolutions": [
[
{
- "resourceModuleName": self.vnf_inst_name,
+ "resourceModuleName": self.vnf_id,
"serviceResourceId": self.vnf_inst_id,
"solution": {
"identifierType": "serviceInstanceId",
"placementSolutions": [
[
{
- "resourceModuleName": self.vnf_inst_name,
+ "resourceModuleName": self.vnf_id,
"serviceResourceId": self.vnf_inst_id,
"solution": {
"identifierType": "serviceInstanceId",
"placementSolutions": [
[
{
- "resourceModuleName": self.vnf_inst_name,
+ "resourceModuleName": self.vnf_id,
"serviceResourceId": self.vnf_inst_id,
"solution": {
"identifierType": "serviceInstanceId",
self.assertEqual(db_info[0].vdu_info, "none")
+class TestGrantVnfViews(TestCase):
+ def setUp(self):
+ self.vnf_inst_id = str(uuid.uuid4())
+ self.data = {
+ "vnfInstanceId": self.vnf_inst_id,
+ "vnfLcmOpOccId": "1234",
+ "operation": "INSTANTIATE"
+ }
+ vdu_info_dict = [{"vduName": "vg", "flavorName": "flavor_1", "flavorId": "12345", "directive": []}]
+ OOFDataModel(request_id='1234', transaction_id='1234', request_status='done', request_module_name='vg',
+ service_resource_id=self.vnf_inst_id, vim_id='cloudOwner_casa', cloud_owner='cloudOwner',
+ cloud_region_id='casa', vdu_info=json.dumps(vdu_info_dict)).save()
+
+ def tearDown(self):
+ OOFDataModel.objects.all().delete()
+
+ @mock.patch.object(resmgr, "grant_vnf")
+ def test_exec_grant(self, mock_grant):
+ resmgr_grant_resp = {
+ "vim": {
+ "vimId": "cloudOwner_casa",
+ "accessInfo": {
+ "tenant": "tenantA"
+ }
+ }
+ }
+ mock_grant.return_value = resmgr_grant_resp
+ resp = GrantVnf(self.data).exec_grant()
+ self.assertEquals(resp['vimAssets']['computeResourceFlavours'][0]['vimConnectionId'], 'cloudOwner_casa')
+ self.assertEquals(resp['vimAssets']['computeResourceFlavours'][0]['resourceProviderId'], 'vg')
+ self.assertEquals(resp['vimAssets']['computeResourceFlavours'][0]['vimFlavourId'], '12345')
+
+
vnfd_model_dict = {
'local_storages': [],
'vdus': [
"directives": [
{
"id": "vG_0",
- "type": "tocsa.nodes.nfv.Vdu.Compute",
+ "type": "tosca.nodes.nfv.Vdu.Compute",
"directives": [
{
"type": "flavor_directives",
"attributes": [
{
- "attribute_name": "flavor_name",
+ "attribute_name": "flavorName",
"attribute_value": "HPA.flavor.1"
- }
+ },
+ {
+ "attribute_name": "flavorId",
+ "attribute_value": "12345"
+ },
]
}
]