updating default services/images test suites to dynamically extract expected services/images based off profile

Change-Id: I2e36b9e5ad54d4a3306faabd21c365a0d365ac7c
diff --git a/src/test/cord-api/Framework/utils/utils.py b/src/test/cord-api/Framework/utils/utils.py
index 38a148f..48dcae2 100644
--- a/src/test/cord-api/Framework/utils/utils.py
+++ b/src/test/cord-api/Framework/utils/utils.py
@@ -9,6 +9,7 @@
 import uuid
 import random
 import re
+import yaml
 
 class utils(object):
 
@@ -228,6 +229,20 @@
         else:
             return str(num)
 
+    def get_dynamic_resources(self, inputfile, resource):
+        resourceNames = []
+        names = {}
+        dnames = []
+        with open(inputfile, 'r') as f:
+            contents = yaml.load(f)
+        resources = contents[resource]
+        for i in resources:
+            resourceNames.append(i["name"])
+        for i in resourceNames:
+            names['name']=i
+            dnames.append(names.copy())
+        return dnames
+
 '''
 #Test
 dict_list = {
diff --git a/src/test/cord-api/Framework/utils/utils.robot b/src/test/cord-api/Framework/utils/utils.robot
index d456308..41944a4 100644
--- a/src/test/cord-api/Framework/utils/utils.robot
+++ b/src/test/cord-api/Framework/utils/utils.robot
@@ -73,3 +73,12 @@
     SSHLibrary.Close Connection
     Log    ${container_logs}
     [Return]    ${container_logs}
+
+Remove Value From List
+    [Arguments]    ${list}    ${val}
+    ${length}=    Get Length    ${list}
+    : FOR    ${INDEX}    IN RANGE    0    ${length}-1
+    \    Log    ${list[${INDEX}]}
+    \    ${value}=    Get Dictionary Values    ${list[${INDEX}]}
+    \    Log    ${value[0]}
+    \    Run Keyword If    '${value[0]}' == '${val}'    Remove From List    ${list}    ${INDEX}
diff --git a/src/test/cord-api/Tests/Ch_DefaultServiceCheck.txt b/src/test/cord-api/Tests/Ch_DefaultServiceCheck.txt
index 2d9b5f2..07c7a68 100644
--- a/src/test/cord-api/Tests/Ch_DefaultServiceCheck.txt
+++ b/src/test/cord-api/Tests/Ch_DefaultServiceCheck.txt
@@ -9,11 +9,13 @@
 Library           RequestsLibrary
 Library           ../Framework/utils/utils.py
 Library           ../Framework/restApi.py
+Resource          ../Framework/utils/utils.robot
 
 *** Variables ***
 ${USER}           admin
 ${PASSWORD}       admin
-${PATHFILE}       ${CURDIR}/data/Ch_defaultServices.json
+${PROFILE}        mock-rcord
+${PROFILE_FILE}   %{HOME}/cord/build/platform-install/profile_manifests/${PROFILE}.yml
 
 *** Test Cases ***    TYPE
 Test Service Sanity
@@ -21,8 +23,13 @@
 
 *** Keywords ***
 Read InputFile
-    ${serviceList}=    utils.jsonToList    ${PATHFILE}    ServiceInfo
-    Set Suite Variable    ${slist}    ${serviceList}
+    ${status}    ${dynamicServiceList}=    Run Keyword And Ignore Error    utils.get_dynamic_resources    ${PROFILE_FILE}    xos_services
+    Run Keyword If    '${status}' == 'FAIL'    Fail    No Services in given profile manifest
+    Set Suite Variable    ${dynamicServiceList}
+    ##need to remove openstack and onos from xos_services list in each manifest as these services arent treated as typical xos synchronizers
+    utils.Remove Value From List    ${dynamicServiceList}    openstack
+    utils.Remove Value From List    ${dynamicServiceList}    onos
+    Log    ${dynamicServiceList}
 
 Verify Service Sanity
     [Arguments]    ${type}
@@ -32,6 +39,6 @@
     ${json_result}=    restApi.ApiGet    CH_CORE_SERVICES
     ${json_result_list}=    Get From Dictionary    ${json_result}    items
     Log    ${json_result_list}
-    ${serviceList}=    Get Variable Value    ${slist}
-    ${test_result}=    utils.compare_list_of_dicts    ${serviceList}    ${json_result_list}
-    Should Be True    ${test_result}
+    ${dList}=    Get Variable Value    ${dynamicServiceList}
+    ${test_result}=    utils.compare_list_of_dicts    ${dList}    ${json_result_list}
+    Should Be True    ${test_result}
\ No newline at end of file
diff --git a/src/test/cord-api/Tests/Ch_defaultImagesCheck.txt b/src/test/cord-api/Tests/Ch_defaultImagesCheck.txt
index 541cf80..3346864 100644
--- a/src/test/cord-api/Tests/Ch_defaultImagesCheck.txt
+++ b/src/test/cord-api/Tests/Ch_defaultImagesCheck.txt
@@ -1,5 +1,5 @@
 *** Settings ***
-Documentation     Test suite for checking default images for R-CORD
+Documentation     Test suite for checking default images
 Suite Setup       Read InputFile
 Test Template     Verify Image Check
 Library           Collections
@@ -13,16 +13,20 @@
 *** Variables ***
 ${USER}           admin
 ${PASSWORD}       admin
+${PROFILE}        mock-rcord
+${PROFILE_FILE}   %{HOME}/cord/build/platform-install/profile_manifests/${PROFILE}.yml
 ${PATHFILE}       ${CURDIR}/data/defaultImages.json
 
 *** Test Cases ***    TYPE
-Test Default Images on R-CORD
+Test Default Images
                       IMAGE
 
 *** Keywords ***
 Read InputFile
-    ${imageList}=    utils.jsonToList    ${PATHFILE}    imagesInfo
-    Set Suite Variable    ${ilist}    ${imageList}
+    ${defaultImageList}=    utils.jsonToList    ${PATHFILE}    imagesInfo
+    ${status}    ${dynamicImageList}=    Run Keyword And Ignore Error    utils.get_dynamic_resources    ${PROFILE_FILE}    xos_images
+    ${imageList}=    Set Variable If    '${status}' == 'FAIL'    ${defaultImageList}    ${dynamicImageList}
+    Set Suite Variable    ${imageList}
 
 Verify Image Check
     [Arguments]    ${type}
@@ -32,6 +36,7 @@
     ${json_result}=    restApi.ApiGet    CH_CORE_IMAGES
     ${json_result_list}=    Get From Dictionary    ${json_result}    items
     Log    ${json_result_list}
-    ${imageList}=    Get Variable Value    ${ilist}
-    ${test_result}=    utils.compare_list_of_dicts    ${imageList}    ${json_result_list}
+    ${image_list}=    Get Variable Value    ${imageList}
+    ${test_result}=    utils.compare_list_of_dicts    ${image_list}    ${json_result_list}
     Should Be True    ${test_result}
+
diff --git a/src/test/cord-api/Tests/data/defaultImages.json b/src/test/cord-api/Tests/data/defaultImages.json
index e308f6f..c29f2bf 100644
--- a/src/test/cord-api/Tests/data/defaultImages.json
+++ b/src/test/cord-api/Tests/data/defaultImages.json
@@ -1,8 +1,6 @@
 {
     "imagesInfo":
     [
-        {"name": "ceilometer-service-trusty-server-multi-nic"},
-        {"name": "trusty-server-multi-nic"},
-        {"name": "vsg-1.1"}
+        {"name": "trusty-server-multi-nic"}
     ]
 }
diff --git a/src/test/setup/requirements.txt b/src/test/setup/requirements.txt
index 713b3e5..e6c8dab 100644
--- a/src/test/setup/requirements.txt
+++ b/src/test/setup/requirements.txt
@@ -17,6 +17,7 @@
 twisted
 pexpect
 apiclient
+pyyaml
 #python-libmaas
 #maasclient
 #maasutil