Merge "Revert "VNF's LCP regions found by Line-of-business (and owning-entity)" This reverts commit e2a7abb45b953d405fc5aa1917f74e2da9f188c0."
diff --git a/vid-webpack-master/src/app/shared/models/vfModuleInstance.ts b/vid-webpack-master/src/app/shared/models/vfModuleInstance.ts
index 566c913..ed5a072 100644
--- a/vid-webpack-master/src/app/shared/models/vfModuleInstance.ts
+++ b/vid-webpack-master/src/app/shared/models/vfModuleInstance.ts
@@ -5,6 +5,8 @@
   instanceParams: { [key: string] : string; };
   position: any;
   statusMessage?: string;
+  tenantId? :string;
+  lcpCloudRegionId?: string;
 
   constructor() {
     super();
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts
index 91b749e..9ef440f 100644
--- a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts
@@ -106,28 +106,7 @@
   test('#UPDATE_VFMODULE_FEILD: should update field with some value', () => {
     const newFieldName = 'newFieldName';
     const newFieldValue = 'newFieldValue';
-    let oldState = {
-      serviceHierarchy: {
-        'serviceModelId': {}
-      },
-      serviceInstance: {
-        'serviceModelId': {
-          vnfs: {
-            'vnfStoreKey': {
-              vfModules: {
-                'modelName': {
-                  'dynamicModelName1': {
-                    isMissingData: true,
-                    action: 'None'
-                  },
-                  'dynamicModelName2': {},
-                }
-              }
-            }
-          }
-        }
-      }
-    };
+    let oldState = getReduxState();
 
     let newState = vfModuleReducer(<any>oldState,
       <UpdateVFModuleField>{
@@ -222,40 +201,24 @@
 });
 
 test('#DELETE_ACTION_VF_MODULE_INSTANCE', () => {
-  let vfModule = vfModuleReducer(<any>{
-      serviceHierarchy: {
-        'serviceModelId': {}
-      },
-      serviceInstance: {
-        'serviceModelId': {
-          vnfs: {
-            'vnfStoreKey': {
-              vfModules: {
-                'modelName': {
-                  'dynamicModelName1': {
-                    isMissingData: true,
-                    action: 'None'
-                  },
-                  'dynamicModelName2': {},
-                }
-              }
-            }
-          }
-        }
-      }
-    },
-    <DeleteActionVfModuleInstanceAction>{
-      type: VfModuleActions.DELETE_ACTION_VF_MODULE_INSTANCE,
-      dynamicModelName: 'dynamicModelName1',
-      vnfStoreKey: 'vnfStoreKey',
-      serviceId: 'serviceModelId'
-    }).serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1'];
+  let vfModule = vfModuleReducer(<any>getReduxState(), getDeleteActionVfModule())
+    .serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1'];
 
   expect(vfModule).toBeDefined();
   expect(vfModule.isMissingData).toBeTruthy();
   expect(vfModule.action).toEqual(ServiceInstanceActions.None_Delete);
 });
 
+test('#DELETE_ACTION_VF_MODULE_INSTANCE set tenantId and lcpCloudRegion to VFM', () => {
+  let vfModule = vfModuleReducer(<any>getReduxState(), getDeleteActionVfModule())
+    .serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1'];
+
+  expect(vfModule).toBeDefined();
+  expect(vfModule.tenantId).toEqual('tenantId');
+  expect(vfModule.lcpCloudRegionId).toEqual('lcpCloudRegionId');
+
+});
+
 test('#UNDO_DELETE_ACTION_VF_MODULE_INSTANCE', () => {
   let vfModule = vfModuleReducer(<any>{
       serviceHierarchy: {
@@ -291,28 +254,7 @@
 });
 
 test('#UPGRADE_VFMODULE', () => {
-  let vfModule = vfModuleReducer(<any>{
-      serviceHierarchy: {
-        'serviceModelId': {}
-      },
-      serviceInstance: {
-        'serviceModelId': {
-          vnfs: {
-            'vnfStoreKey': {
-              vfModules: {
-                'modelName': {
-                  'dynamicModelName1': {
-                    isMissingData: true,
-                    action: 'None'
-                  },
-                  'dynamicModelName2': {},
-                }
-              }
-            }
-          }
-        }
-      }
-    },
+  let vfModule = vfModuleReducer(<any>getReduxState(),
     <UpgradeVfModuleInstanceAction>{
       type: VfModuleActions.UPGRADE_VFMODULE,
       dynamicModelName: 'dynamicModelName1',
@@ -358,5 +300,39 @@
   expect(vfModule.action).toEqual(ServiceInstanceActions.None);
 });
 
-})
-;
+function getReduxState() {
+ return {
+   serviceHierarchy: {
+     'serviceModelId': {}
+   },
+   serviceInstance: {
+     'serviceModelId': {
+       vnfs: {
+         'vnfStoreKey': {
+           tenantId: 'tenantId',
+           lcpCloudRegionId: 'lcpCloudRegionId',
+           vfModules: {
+             'modelName': {
+               'dynamicModelName1': {
+                 isMissingData: true,
+                 action: 'None',
+               },
+               'dynamicModelName2': {},
+             }
+           }
+         }
+       }
+     }
+   }
+ }
+}
+
+function getDeleteActionVfModule() {
+  return <DeleteActionVfModuleInstanceAction>{
+    type: VfModuleActions.DELETE_ACTION_VF_MODULE_INSTANCE,
+    dynamicModelName: 'dynamicModelName1',
+    vnfStoreKey: 'vnfStoreKey',
+    serviceId: 'serviceModelId'
+  }
+}
+});
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts
index 2e91f87..1ab275e 100644
--- a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts
@@ -79,6 +79,7 @@
           let oldAction = newState.serviceInstance[(<DeleteActionVfModuleInstanceAction>action).serviceId].vnfs[(<DeleteActionVfModuleInstanceAction>action).vnfStoreKey].vfModules[key][firstKey].action;
           if(oldAction === ServiceInstanceActions.None_Delete || oldAction === ServiceInstanceActions.Update_Delete) return newState;
           newState.serviceInstance[(<DeleteActionVfModuleInstanceAction>action).serviceId].vnfs[(<DeleteActionVfModuleInstanceAction>action).vnfStoreKey].vfModules[key][firstKey].action = (oldAction + '_Delete') as ServiceInstanceActions;
+          setLcpCloudRegionIdAndTenantIdFromVnf(newState, (<DeleteActionVfModuleInstanceAction>action).serviceId, (<DeleteActionVfModuleInstanceAction>action).vnfStoreKey, key, firstKey);
           updateIsMissingDataOnDeleteVFModule(newState, (<UndoDeleteActionVfModuleInstanceAction>action).serviceId, (<UndoDeleteActionVfModuleInstanceAction>action).vnfStoreKey, key);
           return newState;
         }
@@ -177,6 +178,13 @@
   });
 };
 
+const  setLcpCloudRegionIdAndTenantIdFromVnf = (state: any, serviceModelId: string, vnfStoreKey: string, key: string, firstKey: string) :void => {
+  let tenantId = state.serviceInstance[serviceModelId].vnfs[vnfStoreKey].tenantId;
+  let lcpCloudRegion = state.serviceInstance[serviceModelId].vnfs[vnfStoreKey].lcpCloudRegionId;
+
+  state.serviceInstance[serviceModelId].vnfs[vnfStoreKey].vfModules[key][firstKey].tenantId = tenantId;
+  state.serviceInstance[serviceModelId].vnfs[vnfStoreKey].vfModules[key][firstKey].lcpCloudRegionId = lcpCloudRegion;
+}
 
 const updateUniqueNames = (oldName : string, newName : string, serviceInstance : ServiceInstance) : void => {
   let existingNames = serviceInstance.existingNames;