Added DistributeTrafficCheck LCM command support

Proposed change adds support for new LCM API dedicated for
traffic distribution pre- or post-checks that should
assist DistributeTraffic LCM.

Few small bugs fixed when multiple ansible server has been
added and DistributeTraffic changes were not counted
properly.

Change-Id: I5606a2dd73e8f051f9a69a02bf7c51770f173263
Issue-ID: APPC-1470
Signed-off-by: Lukasz Rajewski <lukasz.rajewski@orange.com>
diff --git a/src/app/pipes/vm-filtering.pipe.ts b/src/app/pipes/vm-filtering.pipe.ts
index eef39cf..6da7840 100644
--- a/src/app/pipes/vm-filtering.pipe.ts
+++ b/src/app/pipes/vm-filtering.pipe.ts
@@ -27,7 +27,7 @@
         let filterValue
         if(action == 'ConfigScaleOut'){
             filterValue= templateId
-        } else if(action == 'Configure' || action == 'ConfigModify'){
+        } else if(action == 'Configure' || action == 'ConfigModify' || action == 'DistributeTraffic' || action == 'DistributeTrafficCheck'){
             filterValue= newVnfc
         }
         if (action == 'ConfigScaleOut') {
@@ -38,7 +38,7 @@
 
 
             return x;
-        } else if( action == 'Configure' || action == 'ConfigModify'){
+        } else if( action == 'Configure' || action == 'ConfigModify' || action == 'DistributeTraffic' || action == 'DistributeTrafficCheck'){
             let x = value.filter(obj => {
                 //return value
                 return ( obj['vnfcType-id'] == filterValue || obj['vnfcType-id'] == undefined);
diff --git a/src/app/shared/pipes/vm-filtering.pipe.ts b/src/app/shared/pipes/vm-filtering.pipe.ts
index eef39cf..6da7840 100644
--- a/src/app/shared/pipes/vm-filtering.pipe.ts
+++ b/src/app/shared/pipes/vm-filtering.pipe.ts
@@ -27,7 +27,7 @@
         let filterValue
         if(action == 'ConfigScaleOut'){
             filterValue= templateId
-        } else if(action == 'Configure' || action == 'ConfigModify'){
+        } else if(action == 'Configure' || action == 'ConfigModify' || action == 'DistributeTraffic' || action == 'DistributeTrafficCheck'){
             filterValue= newVnfc
         }
         if (action == 'ConfigScaleOut') {
@@ -38,7 +38,7 @@
 
 
             return x;
-        } else if( action == 'Configure' || action == 'ConfigModify'){
+        } else if( action == 'Configure' || action == 'ConfigModify' || action == 'DistributeTraffic' || action == 'DistributeTrafficCheck'){
             let x = value.filter(obj => {
                 //return value
                 return ( obj['vnfcType-id'] == filterValue || obj['vnfcType-id'] == undefined);
diff --git a/src/app/test/test.component.spec.ts b/src/app/test/test.component.spec.ts
index cb69445..752ff55 100644
--- a/src/app/test/test.component.spec.ts
+++ b/src/app/test/test.component.spec.ts
@@ -427,6 +427,7 @@
             expect(component.getUrlEndPoint('quiescetraffic')).toEqual('quiesce-traffic');
             expect(component.getUrlEndPoint('resumetraffic')).toEqual('resume-traffic');
             expect(component.getUrlEndPoint('distributetraffic')).toEqual('distribute-traffic');
+            expect(component.getUrlEndPoint('distributetrafficcheck')).toEqual('distribute-traffic-check');
             expect(component.getUrlEndPoint('startapplication')).toEqual('start-application');
             expect(component.getUrlEndPoint('stopapplication')).toEqual('stop-application');
             expect(component.getUrlEndPoint('upgradebackout')).toEqual('upgrade-backout');
diff --git a/src/app/vnfs/build-artifacts/build-artifacts.component.ts b/src/app/vnfs/build-artifacts/build-artifacts.component.ts
index 9079abb..4e00341 100644
--- a/src/app/vnfs/build-artifacts/build-artifacts.component.ts
+++ b/src/app/vnfs/build-artifacts/build-artifacts.component.ts
@@ -28,7 +28,7 @@
 import { NotificationsService } from 'angular2-notifications';
 import { appConstants } from '../../../constants/app-constants';
 
-export const ACTIONS_REQUIRED_DROPDOWN = ['Configure', 'ConfigModify', 'ConfigScaleOut', 'DistributeTraffic']
+export const ACTIONS_REQUIRED_DROPDOWN = ['Configure', 'ConfigModify', 'ConfigScaleOut', 'DistributeTraffic', 'DistributeTrafficCheck']
 
 
 @Component({ selector: 'app-build-design', templateUrl: './build-artifacts.component.html', styleUrls: ['./build-artifacts.component.css'] })
diff --git a/src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.ts b/src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.ts
index 6ba8e52..ad0adf3 100644
--- a/src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.ts
+++ b/src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.ts
@@ -88,7 +88,8 @@
         { action: appConstants.Actions.healthCheck, value: appConstants.Actions.healthCheck },
         { action: appConstants.Actions.startApplication, value: appConstants.Actions.startApplication },
         { action: appConstants.Actions.stopApplication, value: appConstants.Actions.stopApplication },
-        { action: appConstants.Actions.distributeTraffic, value: appConstants.Actions.distributeTraffic }
+        { action: appConstants.Actions.distributeTraffic, value: appConstants.Actions.distributeTraffic },
+        { action: appConstants.Actions.distributeTrafficCheck, value: appConstants.Actions.distributeTrafficCheck }
     ];
     public uploadTypes = appConstants.uploadTypes;
 
diff --git a/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.html b/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.html
index 6225ea0..bf1589b 100644
--- a/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.html
+++ b/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.html
@@ -44,7 +44,7 @@
                     <span class="error-message" [hidden]="vnfParams?.vnfType || vnftype.valid || (vnftype.pristine && !userForm.submitted)">Required Field</span>
                 </div>
 
-                    <div class="col-lg-3 col-sm-6 col-md-3 col-xs-12" *ngIf="((displayVnfc=='true') || isVnfcType) && (referenceDataObject['action']=='Configure' || referenceDataObject['action']=='ConfigModify' || referenceDataObject['action']=='DistributeTraffic')">
+                    <div class="col-lg-3 col-sm-6 col-md-3 col-xs-12" *ngIf="((displayVnfc=='true') || isVnfcType) && (referenceDataObject['action']=='Configure' || referenceDataObject['action']=='ConfigModify' || referenceDataObject['action']=='DistributeTraffic' || referenceDataObject['action']=='DistributeTrafficCheck')">
                     <label>VNFC Type</label>  <label style="font-size:12px;">(NFC Function)</label>
                     <input *ngIf="isVnfcType" type="text" class="form-control" readonly id="txtVnfcType" [(ngModel)]="referenceDataObject.scope['vnfc-type']" (blur)="setVnfcType($event.target.value)" (ngModelChange)="updateSessionValues($event,'vnfcType')" #vnfcType="ngModel"
                         name="vnfcType">
@@ -56,7 +56,7 @@
                 </div>
                 
 
-                 <div class="col-lg-3 col-sm-6 col-md-3 col-xs-12" *ngIf="displayVnfc!='true' || (referenceDataObject['action']!='Configure' && referenceDataObject['action']!='ConfigModify' || referenceDataObject['action']=='DistributeTraffic')">
+                 <div class="col-lg-3 col-sm-6 col-md-3 col-xs-12" *ngIf="displayVnfc!='true' || (referenceDataObject['action']!='Configure' && referenceDataObject['action']!='ConfigModify' && referenceDataObject['action']!='DistributeTraffic' && referenceDataObject['action']!='DistributeTrafficCheck')">
                 </div>
                 <div class="col-lg-3 col-sm-6 col-md-3 col-xs-12">
                     <label>Device Protocol*</label>
diff --git a/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.ts b/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.ts
index 5cd0e71..b0fc7d2 100644
--- a/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.ts
+++ b/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.ts
@@ -128,7 +128,7 @@
         'artifact-list': []
     };
     public refernceScopeObj = { sourceType: '', from: '', to: '' };
-    public actions = ['', 'Configure', 'ConfigModify', 'ConfigBackup', 'ConfigRestore', 'GetRunningConfig', 'HealthCheck', 'StartApplication', 'StopApplication', 'QuiesceTraffic', 'ResumeTraffic', 'DistributeTraffic', 'UpgradeBackout', 'UpgradeBackup', 'UpgradePostCheck', 'UpgradePreCheck', 'UpgradeSoftware', 'OpenStack Actions', 'ConfigScaleOut'];
+    public actions = ['', 'Configure', 'ConfigModify', 'ConfigBackup', 'ConfigRestore', 'GetRunningConfig', 'HealthCheck', 'StartApplication', 'StopApplication', 'QuiesceTraffic', 'ResumeTraffic', 'DistributeTraffic', 'DistributeTrafficCheck', 'UpgradeBackout', 'UpgradeBackup', 'UpgradePostCheck', 'UpgradePreCheck', 'UpgradeSoftware', 'OpenStack Actions', 'ConfigScaleOut'];
     public groupAnotationValue = ['', 'Pair'];
     public groupAnotationType = ['', 'first-vnfc-name', 'fixed-value', 'relative-value'];
     public deviceProtocols = ['', 'ANSIBLE', 'CHEF', 'NETCONF-XML', 'REST', 'CLI', 'RESTCONF'];
@@ -219,9 +219,9 @@
         this.configScaleOutExist = require('../../../../cdt.application.properties.json').displayConfigScaleout;
         this.displayVnfc = sessionStorage.getItem("vnfcSelectionFlag");
         if (this.configScaleOutExist) {
-            this.actions = ['', 'Configure', 'ConfigModify', 'ConfigBackup', 'ConfigRestore', 'GetRunningConfig', 'HealthCheck', 'StartApplication', 'StopApplication', 'QuiesceTraffic', 'ResumeTraffic', 'DistributeTraffic', 'UpgradeBackout', 'UpgradeBackup', 'UpgradePostCheck', 'UpgradePreCheck', 'UpgradeSoftware', 'OpenStack Actions', 'ConfigScaleOut'];
+            this.actions = ['', 'Configure', 'ConfigModify', 'ConfigBackup', 'ConfigRestore', 'GetRunningConfig', 'HealthCheck', 'StartApplication', 'StopApplication', 'QuiesceTraffic', 'ResumeTraffic', 'DistributeTraffic', 'DistributeTrafficCheck', 'UpgradeBackout', 'UpgradeBackup', 'UpgradePostCheck', 'UpgradePreCheck', 'UpgradeSoftware', 'OpenStack Actions', 'ConfigScaleOut'];
         } else {
-            this.actions = ['', 'Configure', 'ConfigModify', 'ConfigBackup', 'ConfigRestore', 'GetRunningConfig', 'HealthCheck', 'StartApplication', 'StopApplication', 'QuiesceTraffic', 'ResumeTraffic', 'DistributeTraffic', 'UpgradeBackout', 'UpgradeBackup', 'UpgradePostCheck', 'UpgradePreCheck', 'UpgradeSoftware', 'OpenStack Actions'];
+            this.actions = ['', 'Configure', 'ConfigModify', 'ConfigBackup', 'ConfigRestore', 'GetRunningConfig', 'HealthCheck', 'StartApplication', 'StopApplication', 'QuiesceTraffic', 'ResumeTraffic', 'DistributeTraffic', 'DistributeTrafficCheck', 'UpgradeBackout', 'UpgradeBackup', 'UpgradePostCheck', 'UpgradePreCheck', 'UpgradeSoftware', 'OpenStack Actions'];
         }
         this.self = this;
         let path = this.location.path;
@@ -556,14 +556,14 @@
 
         let mberOFVm = Number(this.refernceScopeObj.from);
         let key
-        if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic') {
+        if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic' || this.referenceDataObject.action == 'DistributeTrafficCheck') {
             key = "vnfcType-id"
         } else if (this.referenceDataObject.action == 'ConfigScaleOut') {
             key = "template-id"
         }
-        if (this.referenceDataObject.action == 'ConfigScaleOut' || this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic') {
+        if (this.referenceDataObject.action == 'ConfigScaleOut' || this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic' || this.referenceDataObject.action == 'DistributeTrafficCheck') {
             let existingVmsLength = this.referenceDataObject.vm.map(obj => {
-                if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic') {
+                if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic' || this.referenceDataObject.action == 'DistributeTrafficCheck') {
                     return obj["vnfcType-id"] == this.templateIdentifier
                 } else if (this.referenceDataObject.action == 'ConfigScaleOut') {
                     return obj["template-id"] == this.templateIdentifier
@@ -574,12 +574,12 @@
             let identifierValue
             if (this.referenceDataObject.action == 'ConfigScaleOut') {
                 identifierValue = this.templateIdentifier
-            } else if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify'  || this.referenceDataObject.action == 'DistributeTraffic') {
+            } else if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify'  || this.referenceDataObject.action == 'DistributeTraffic' || this.referenceDataObject.action == 'DistributeTrafficCheck') {
                 identifierValue = this.vnfcIdentifier
             }
 
             for (var i = 0; i < mberOFVm; i++) {
-                if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic') {
+                if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic' || this.referenceDataObject.action == 'DistributeTrafficCheck') {
 
                     if (identifierValue && identifierValue != "") {
                         this.referenceDataObject.vm.push({ 'vnfcType-id': identifierValue, 'vm-instance': (existingVmsLength + index + 1), vnfc: [Object.assign({}, this.Sample)] });
@@ -1107,6 +1107,7 @@
             case 'UpgradeBackout':
             case 'ResumeTraffic':
             case 'DistributeTraffic':
+            case 'DistributeTrafficCheck':
             case 'QuiesceTraffic':
             case 'UpgradeBackup':
             case 'UpgradePostCheck':
@@ -1194,7 +1195,7 @@
                         this.refernceScopeObj.from = '';
                     }
 
-                    if (this.referenceDataObject.action === 'Configure' || this.referenceDataObject.action === 'ConfigModify' || this.referenceDataObject.action === 'DistributeTraffic') {
+                    if (this.referenceDataObject.action === 'Configure' || this.referenceDataObject.action === 'ConfigModify' || this.referenceDataObject.action === 'DistributeTraffic' || this.referenceDataObject.action === 'DistributeTrafficCheck') {
                         this.isConfigOrConfigModify = true;
                     } else {
                         this.isConfigOrConfigModify = false;
@@ -1251,7 +1252,7 @@
         else {
             this.buildDesignComponent.tabs = this.allTabs;
         }
-        if (data == 'Configure' || data == 'ConfigModify' || data == 'DistributeTraffic') {
+        if (data == 'Configure' || data == 'ConfigModify' || data == 'DistributeTraffic' || data == 'DistributeTrafficCheck') {
             this.nonConfigureAction = false;
         } else {
             this.nonConfigureAction = true;
@@ -1458,7 +1459,7 @@
             this.referenceDataObject.scope['vnfc-type-list'].push(newVnfcTypeV);
         }
         this.tempAllData.forEach(obj => {
-            if (obj.action == "Configure" || obj.action == "ConfigModify"  || obj.action == "DistributeTraffic") {
+            if (obj.action == "Configure" || obj.action == "ConfigModify" || obj.action == "DistributeTraffic" || obj.action == "DistributeTrafficCheck") {
                 obj.scope['vnfc-type-list'] = this.referenceDataObject.scope['vnfc-type-list']
             }
             this.resetArtifactList(obj);
@@ -1526,7 +1527,7 @@
                 //    scopeName = this.referenceDataObject.scope['vnfc-type-list'];
             }
 
-            if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic') {
+            if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic' || this.referenceDataObject.action == 'DistributeTrafficCheck') {
                 this.referenceDataObject['action-level'] = 'vnf';
                 this.referenceDataObject['scopeType'] = 'vnfc-type';
             } else {
@@ -1545,7 +1546,7 @@
         let pdTemplate
         let paramValue
         let vnf = this.referenceDataObject.scope['vnf-type']
-        if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic') {
+        if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic' || this.referenceDataObject.action == 'DistributeTrafficCheck') {
             let vnfcTypeList = this.referenceDataObject.scope['vnfc-type-list'];
             let pd_fileName
             let config_template_fileName
@@ -1642,7 +1643,7 @@
         let configTemplate
         let pdTemplate
         let paramValue
-        if (newObj.action == "Configure" || newObj.action == "ConfigModify" || newObj.action == "DistributeTraffic") {
+        if (newObj.action == "Configure" || newObj.action == "ConfigModify" || newObj.action == "DistributeTraffic" || newObj.action == "DistributeTrafficCheck") {
             let extension = this.referenceDataFormUtil.decideExtension(this.referenceDataObject);
             let pd_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + (newObj['vnfcIdentifier'] ? (newObj['vnfcIdentifier'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_') : "") + '0.0.1V.yaml';
             let config_template_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + (newObj['vnfcIdentifier'] ? (newObj['vnfcIdentifier'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_') : "") + '0.0.1V' + extension;
@@ -1746,7 +1747,7 @@
         if (newObj.action != 'HealthCheck') {
             delete newObj['url'];
         }
-        if (newObj.action != "Configure" && newObj.action != "ConfigModify" && newObj.action == "DistributeTraffic") {
+        if (newObj.action != "Configure" && newObj.action != "ConfigModify" && newObj.action != "DistributeTraffic" && newObj.action != "DistributeTrafficCheck") {
             newObj.scope['vnfc-type-list'] = [];
         }
         return newObj
diff --git a/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts b/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts
index 760fbfe..cee9629 100644
--- a/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts
+++ b/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts
@@ -89,7 +89,8 @@
     { action: "HealthCheck", value: "HealthCheck" },
     { action: "StartApplication", value: "StartApplication" },
     { action: "StopApplication", value: "StopApplication" },
-    { action: "DistributeTraffic", value: "DistributeTraffic" }
+    { action: "DistributeTraffic", value: "DistributeTraffic" },
+    { action: "DistributeTrafficCheck", value: "DistributeTrafficCheck" }
 
   ];
   options = {
diff --git a/src/constants/app-constants.ts b/src/constants/app-constants.ts
index bd06feb..68ff6c4 100644
--- a/src/constants/app-constants.ts
+++ b/src/constants/app-constants.ts
@@ -64,6 +64,7 @@
         "quiesceTraffic": "QuiesceTraffic",
         "resumeTraffic": "ResumeTraffic",
         "distributeTraffic": "DistributeTraffic",
+        "distributeTrafficCheck": "DistributeTrafficCheck",
         "upgradeBackout": "UpgradeBackout",
         "upgradeBackup": "UpgradeBackup",
         "upgradePostCheck": "UpgradePostCheck",