text: ##########################################################################
  # If not stated otherwise in this file or this component's Licenses.txt
  # file the following copyright and licenses apply:
  #
  # Copyright 2016 RDK Management
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  # http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  ##########################################################################
  '''
  <?xml version='1.0' encoding='utf-8'?>
  <xml>
    <id></id>
    <!-- Do not edit id. This will be auto filled while exporting. If you are adding a new script keep the id empty -->
    <version>6</version>
    <!-- Do not edit version. This will be auto incremented while updating. If you are adding a new script you can keep the vresion as 1 -->
    <name>TS_TAD_SetTraceRoute</name>
    <!-- If you are adding a new script you can specify the script name. Script Name should be unique same as this file name with out .py extension -->
    <primitive_test_id> </primitive_test_id>
    <!-- Do not change primitive_test_id if you are editing an existing script. -->
    <primitive_test_name>TADstub_Set</primitive_test_name>
    <!--  -->
    <primitive_test_version>1</primitive_test_version>
    <!--  -->
    <status>FREE</status>
    <!--  -->
    <synopsis>To set all the parameters of trace route and check whether the result is success or not</synopsis>
    <!--  -->
    <groups_id />
    <!--  -->
    <execution_time>17</execution_time>
    <!--  -->
    <long_duration>false</long_duration>
    <!--  -->
    <advanced_script>false</advanced_script>
    <!-- execution_time is the time out time for test execution -->
    <remarks></remarks>
    <!-- Reason for skipping the tests if marked to skip -->
    <skip>false</skip>
    <!--  -->
    <box_types>
      <box_type>Broadband</box_type>
      <!--  -->
      <box_type>Emulator</box_type>
      <!--  -->
      <box_type>RPI</box_type>
      <!--  -->
    </box_types>
    <rdk_versions>
      <rdk_version>RDKB</rdk_version>
      <!--  -->
    </rdk_versions>
    <test_cases>
      <test_case_id>TC_TAD_06</test_case_id>
      <test_objective>To set all the parameters of trace route and check whether the result is success or not</test_objective>
      <test_type>Positive</test_type>
      <test_setup>XB3,Emulator</test_setup>
      <pre_requisite>1.Ccsp Components  should be in a running state else invoke cosa_start.sh manually that includes all the ccsp components.
  2.TDK Agent should be in running state or invoke it through StartTdk.sh script</pre_requisite>
      <api_or_interface_used>TADstub_Get, TADstub_Set</api_or_interface_used>
      <input_parameters>Device.IP.Diagnostics.TraceRoute.Interface
  Device.IP.Diagnostics.TraceRoute.Host
  Device.IP.Diagnostics.TraceRoute.DiagnosticsState
  Device.IP.Diagnostics.TraceRoute.RouteHopsNumberOfEntries</input_parameters>
      <automation_approch>1. Load TAD modules
  2. From script invoke TADstub_Set to set all the trace route parameters
  3. Check if the set returning success
  4. Validation of  the result is done within the python script and send the result status to Test Manager.
  5.Test Manager will publish the result in GUI as PASS/FAILURE based on the response from TAD stub.</automation_approch>
      <except_output>CheckPoint 1:
   The output  should be logged in the Agent console/Component log
  
  CheckPoint 2:
  Stub function result should be success and should see corresponding log in the agent console log
  
  CheckPoint 3:
  TestManager GUI will publish the result as PASS in Execution/Console page of Test Manager</except_output>
      <priority>High</priority>
      <test_stub_interface>None</test_stub_interface>
      <test_script>TS_TAD_SetTraceRoute</test_script>
      <skipped>No</skipped>
      <release_version></release_version>
      <remarks></remarks>
    </test_cases>
    <script_tags />
  </xml>
  '''
  # use tdklib library,which provides a wrapper for tdk testcase script
  import tdklib;
  import time;
  import tdkutility;
  
  #Test component to be tested
  obj = tdklib.TDKScriptingLibrary("tad","1");
  
  #IP and Port of box, No need to change,
  #This will be replaced with correspoing Box Ip and port while executing script
  ip = <ipaddress>
  port = <port>
  obj.configureTestCase(ip,port,'TS_TAD_SetTraceRoute');
  #Get the result of connection with test component and STB
  loadmodulestatus =obj.getLoadModuleResult();
  print "[LIB LOAD STATUS]  :  %s" %loadmodulestatus ;
  
  if "SUCCESS" in loadmodulestatus.upper():
      #Set the result status of execution
      obj.setLoadModuleStatus("SUCCESS");
      host = tdkutility.readtdkbConfigFile(obj);
      tdkTestObj = obj.createTestStep('TADstub_Get');
      tdkTestObj.addParameter("paramName","Device.IP.Diagnostics.TraceRoute.Host");
      expectedresult="SUCCESS";
      tdkTestObj.executeTestCase(expectedresult);
      if host == "NULL":
          tdkTestObj.setResultStatus("FAILURE");
          print "Host name not available in tdkb config file"
      else:
  
          tdkTestObj = obj.createTestStep('TADstub_Set');
          tdkTestObj.addParameter("ParamName","Device.IP.Diagnostics.TraceRoute.Interface");
          tdkTestObj.addParameter("ParamValue","Interface_erouter0");
          tdkTestObj.addParameter("Type","string");
          expectedresult="SUCCESS";
          tdkTestObj.executeTestCase(expectedresult);
          actualresult = tdkTestObj.getResult();
          details = tdkTestObj.getResultDetails();
          if expectedresult in actualresult:
              #Set the result status of execution
              tdkTestObj.setResultStatus("SUCCESS");
              print "TEST STEP 1: Set the interface of TraceRoute";
              print "EXPECTED RESULT 1: Should set the interface of TraceRoute";
              print "ACTUAL RESULT 1: %s" %details;
              #Get the result of execution
              print "[TEST EXECUTION RESULT] : SUCCESS";
  
              tdkTestObj = obj.createTestStep('TADstub_Set');
              tdkTestObj.addParameter("ParamName","Device.IP.Diagnostics.TraceRoute.Host");
              tdkTestObj.addParameter("ParamValue",host);
              tdkTestObj.addParameter("Type","string");
              expectedresult="SUCCESS";
              tdkTestObj.executeTestCase(expectedresult);
              actualresult = tdkTestObj.getResult();
              details = tdkTestObj.getResultDetails();
              if expectedresult in actualresult:
                  #Set the result status of execution
                  tdkTestObj.setResultStatus("SUCCESS");
                  print "TEST STEP 2: Set the host of TraceRoute";
                  print "EXPECTED RESULT 2: Should set the host of TraceRoute";
                  print "ACTUAL RESULT 2: %s" %details;
                  #Get the result of execution
                  print "[TEST EXECUTION RESULT] : SUCCESS";
  
                  tdkTestObj = obj.createTestStep('TADstub_Set');
                  tdkTestObj.addParameter("ParamName","Device.IP.Diagnostics.TraceRoute.DiagnosticsState");
                  tdkTestObj.addParameter("ParamValue","Requested");
                  tdkTestObj.addParameter("Type","string");
                  expectedresult="SUCCESS";
                  tdkTestObj.executeTestCase(expectedresult);
                  actualresult = tdkTestObj.getResult();
                  details = tdkTestObj.getResultDetails();
                  if expectedresult in actualresult:
                      #Set the result status of execution
                      tdkTestObj.setResultStatus("SUCCESS");
                      print "TEST STEP 3: Set DiagnosticsState of TraceRoute as Requested";
                      print "EXPECTED RESULT 3: Should set DiagnosticsState of TraceRoute as Requested";
                      print "ACTUAL RESULT 3: %s" %details;
                      #Get the result of execution
                      print "[TEST EXECUTION RESULT] : SUCCESS";
                      time.sleep(180);
                      tdkTestObj = obj.createTestStep('TADstub_Get');
                      tdkTestObj.addParameter("paramName","Device.IP.Diagnostics.TraceRoute.RouteHopsNumberOfEntries");
                      expectedresult="SUCCESS";
                      tdkTestObj.executeTestCase(expectedresult);
                      actualresult = tdkTestObj.getResult();
                      details = tdkTestObj.getResultDetails();
                      if expectedresult in actualresult and int(details)>0:
                          #Set the result status of execution
                          tdkTestObj.setResultStatus("SUCCESS");
                          print "TEST STEP 4: Check if the request is set successfully";
                          print "EXPECTED RESULT 4: Should get the routehops greater than zero";
                          print "ACTUAL RESULT 4: Route hops count is :%s" %details;
                          #Get the result of execution
                          print "[TEST EXECUTION RESULT] : SUCCESS";
                      else:
                          #Set the result status of execution
                          tdkTestObj.setResultStatus("FAILURE");
                          print "TEST STEP 4: Check if the request is set successfully";
                          print "EXPECTED RESULT 4: Should get the routehops greater than zero";
                          print "ACTUAL RESULT 4: Route hops count is :%s" %details;
                          #Get the result of execution
                          print "[TEST EXECUTION RESULT] : FAILURE";
                  else:
                      #Set the result status of execution
                      tdkTestObj.setResultStatus("FAILURE");
                      print "TEST STEP 3: Set DiagnosticsState of TraceRoute as Requested";
                      print "EXPECTED RESULT 3: Should set DiagnosticsState of TraceRoute as Requested";
                      print "ACTUAL RESULT 3: %s" %details;
                      #Get the result of execution
                      print "[TEST EXECUTION RESULT] : FAILURE";
              else:
                  #Set the result status of execution
                  tdkTestObj.setResultStatus("FAILURE");
                  print "TEST STEP 2: Set the host of TraceRoute";
                  print "EXPECTED RESULT 2: Should set the host of TraceRoute";
                  print "ACTUAL RESULT 2: %s" %details;
                  #Get the result of execution
                  print "[TEST EXECUTION RESULT] : FAILURE";
          else:
              #Set the result status of execution
              tdkTestObj.setResultStatus("FAILURE");
              print "TEST STEP 1: Set the interface of TraceRoute";
              print "EXPECTED RESULT 1: Should set the interface of TraceRoute";
              print "ACTUAL RESULT 1: %s" %details;
              #Get the result of execution
              print "[TEST EXECUTION RESULT] : FAILURE";
      obj.unloadModule("tad");
  
  else:
          print "Failed to load tad module";
          obj.setLoadModuleStatus("FAILURE");
          print "Module loading failed";
  
  					
  