<commit_before>#!/usr/bin/python
# IBM_PROLOG_BEGIN_TAG
# This is an automatically generated prolog.
#
# $Source: op-test-framework/ci/source/op_opal_fvt.py $
#
# OpenPOWER Automated Test Project
#
# Contributors Listed Below - COPYRIGHT 2015
# [+] International Business Machines Corp.
#
#
# 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.
#
# IBM_PROLOG_END_TAG
"""
.. module:: op_opal_fvt
    :platform: Unix
    :synopsis: This module contains functional verification test functions
               for OPAL firmware. Corresponding source files for new OPAL
               features will be adding in testcases directory

.. moduleauthor:: <NAME> <<EMAIL>>


"""
import sys
import os

# Get path to base directory and append to path to get common modules
full_path = os.path.dirname(os.path.abspath(__file__))
full_path = full_path.split('ci')[0]

sys.path.append(full_path)
import ConfigParser

from common.OpTestConstants import OpTestConstants as BMC_CONST
from testcases.OpTestSensors import OpTestSensors
from testcases.OpTestSwitchEndianSyscall import OpTestSwitchEndianSyscall
from testcases.OpTestHeartbeat import OpTestHeartbeat
from testcases.OpTestRTCdriver import OpTestRTCdriver
from testcases.OpTestAt24driver import OpTestAt24driver
from testcases.OpTestI2Cdriver import OpTestI2Cdriver
from testcases.OpTestMtdPnorDriver import OpTestMtdPnorDriver
from testcases.OpTestInbandIPMI import OpTestInbandIPMI
from testcases.OpTestHMIHandling import OpTestHMIHandling
from testcases.OpTestPrdDriver import OpTestPrdDriver
from testcases.OpTestIPMILockMode import OpTestIPMILockMode
from testcases.OpTestIPMIPowerControl import OpTestIPMIPowerControl
from testcases.OpTestInbandUsbInterface import OpTestInbandUsbInterface
from testcases.OpTestOOBIPMI import OpTestOOBIPMI
from testcases.OpTestSystemBootSequence import OpTestSystemBootSequence


def _config_read():
    """ returns bmc system and test config options """
    bmcConfig = ConfigParser.RawConfigParser()
    configFile = os.path.join(os.path.dirname(__file__), 'op_ci_tools.cfg')
    print configFile
    bmcConfig.read(configFile)
    return dict(bmcConfig.items('bmc')), dict(bmcConfig.items('test')), dict(bmcConfig.items('host'))

''' Read the configuration settings into global space so they can be used by
    other functions '''

bmcCfg, testCfg, hostCfg = _config_read()
opTestSensors = OpTestSensors(bmcCfg['ip'], bmcCfg['username'],
                              bmcCfg['password'],
                              bmcCfg.get('usernameipmi'),
                              bmcCfg.get('passwordipmi'),
                              testCfg['ffdcdir'], hostCfg['hostip'],
                              hostCfg['hostuser'], hostCfg['hostpasswd'])

opTestSwitchEndianSyscall = OpTestSwitchEndianSyscall(bmcCfg['ip'],
                                                      bmcCfg['username'],
                                                      bmcCfg['password'],
                                                      bmcCfg.get('usernameipmi'),
                                                      bmcCfg.get('passwordipmi'),
                                                      testCfg['ffdcdir'],
                                                      hostCfg['hostip'],
                                                      hostCfg['hostuser'],
                                                      hostCfg['hostpasswd'])

opTestRTCdriver = OpTestRTCdriver(bmcCfg['ip'],
                                  bmcCfg['username'],
                                  bmcCfg['password'],
                                  bmcCfg.get('usernameipmi'),
                                  bmcCfg.get('passwordipmi'),
                                  testCfg['ffdcdir'],
                                  hostCfg['hostip'],
                                  hostCfg['hostuser'],
                                  hostCfg['hostpasswd'])

opTestAt24driver = OpTestAt24driver(bmcCfg['ip'], bmcCfg['username'],
                                    bmcCfg['password'],
                                    bmcCfg.get('usernameipmi'),
                                    bmcCfg.get('passwordipmi'),
                                    testCfg['ffdcdir'], hostCfg['hostip'],
                                    hostCfg['hostuser'], hostCfg['hostpasswd'])

opTestI2Cdriver = OpTestI2Cdriver(bmcCfg['ip'], bmcCfg['username'],
                                  bmcCfg['password'],
                                  bmcCfg.get('usernameipmi'),
                                  bmcCfg.get('passwordipmi'),
                                  testCfg['ffdcdir'], hostCfg['hostip'],
                                  hostCfg['hostuser'], hostCfg['hostpasswd'])

opTestHeartbeat = OpTestHeartbeat(bmcCfg['ip'], bmcCfg['username'],
                              bmcCfg['password'],
                              bmcCfg.get('usernameipmi'),
                              bmcCfg.get('passwordipmi'),
                              testCfg['ffdcdir'], hostCfg['hostip'],
                              hostCfg['hostuser'], hostCfg['hostpasswd'])

opTestMtdPnorDriver = OpTestMtdPnorDriver(bmcCfg['ip'], bmcCfg['username'],
                                          bmcCfg['password'],
                                          bmcCfg.get('usernameipmi'),
                                          bmcCfg.get('passwordipmi'),
                                          testCfg['ffdcdir'], hostCfg['hostip'],
                                          hostCfg['hostuser'], hostCfg['hostpasswd'])

opTestInbandIPMI = OpTestInbandIPMI(bmcCfg['ip'], bmcCfg['username'],
                              bmcCfg['password'],
                              bmcCfg.get('usernameipmi'),
                              bmcCfg.get('passwordipmi'),
                              testCfg['ffdcdir'], hostCfg['hostip'],
                              hostCfg['hostuser'], hostCfg['hostpasswd'])

opTestHMIHandling = OpTestHMIHandling(bmcCfg['ip'], bmcCfg['username'],
                                          bmcCfg['password'],
                                          bmcCfg.get('usernameipmi'),
                                          bmcCfg.get('passwordipmi'),
                                          testCfg['ffdcdir'], hostCfg['hostip'],
                                          hostCfg['hostuser'], hostCfg['hostpasswd'])

opTestPrdDriver = OpTestPrdDriver(bmcCfg['ip'], bmcCfg['username'],
                                  bmcCfg['password'],
                                  bmcCfg.get('usernameipmi'),
                                  bmcCfg.get('passwordipmi'),
                                  testCfg['ffdcdir'], hostCfg['hostip'],
                                  hostCfg['hostuser'], hostCfg['hostpasswd'])

opTestIPMILockMode = OpTestIPMILockMode(bmcCfg['ip'], bmcCfg['username'],
                                        bmcCfg['password'],
                                        bmcCfg.get('usernameipmi'),
                                        bmcCfg.get('passwordipmi'),
                                        testCfg['ffdcdir'], hostCfg['hostip'],
                                        hostCfg['hostuser'], hostCfg['hostpasswd'])


opTestIPMIPowerControl = OpTestIPMIPowerControl(bmcCfg['ip'], bmcCfg['username'],
                                        bmcCfg['password'],
                                        bmcCfg.get('usernameipmi'),
                                        bmcCfg.get('passwordipmi'),
                                        testCfg['ffdcdir'], hostCfg['hostip'],
                                        hostCfg['hostuser'], hostCfg['hostpasswd'])

opTestInbandUsbInterface = OpTestInbandUsbInterface(bmcCfg['ip'], bmcCfg['username'],
                                                    bmcCfg['password'],
                                                    bmcCfg.get('usernameipmi'),
                                                    bmcCfg.get('passwordipmi'),
                                                    testCfg['ffdcdir'], hostCfg['hostip'],
                                                    hostCfg['hostuser'], hostCfg['hostpasswd'])

opTestOOBIPMI = OpTestOOBIPMI(bmcCfg['ip'], bmcCfg['username'],
                                        bmcCfg['password'],
                                        bmcCfg.get('usernameipmi'),
                                        bmcCfg.get('passwordipmi'),
                                        testCfg['ffdcdir'], hostCfg['hostip'],
                                        hostCfg['hostuser'], hostCfg['hostpasswd'])

opTestSystemBootSequence = OpTestSystemBootSequence(bmcCfg['ip'], bmcCfg['username'],
                                                    bmcCfg['password'],
                                                    bmcCfg.get('usernameipmi'),
                                                    bmcCfg.get('passwordipmi'),
                                                    testCfg['ffdcdir'], hostCfg['hostip'],
                                                    hostCfg['hostuser'], hostCfg['hostpasswd'])


def test_init():
    """This function validates the test config before running other functions
    """

    ''' create FFDC dir if it does not exist '''<commit_msg>Import reprovision module.<commit_after>#!/usr/bin/python
# IBM_PROLOG_BEGIN_TAG
# This is an automatically generated prolog.
#
# $Source: op-test-framework/ci/source/op_opal_fvt.py $
#
# OpenPOWER Automated Test Project
#
# Contributors Listed Below - COPYRIGHT 2015
# [+] International Business Machines Corp.
#
#
# 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.
#
# IBM_PROLOG_END_TAG
"""
.. module:: op_opal_fvt
    :platform: Unix
    :synopsis: This module contains functional verification test functions
               for OPAL firmware. Corresponding source files for new OPAL
               features will be adding in testcases directory

.. moduleauthor:: <NAME> <<EMAIL>>


"""
import sys
import os

# Get path to base directory and append to path to get common modules
full_path = os.path.dirname(os.path.abspath(__file__))
full_path = full_path.split('ci')[0]

sys.path.append(full_path)
import ConfigParser

from common.OpTestConstants import OpTestConstants as BMC_CONST
from testcases.OpTestSensors import OpTestSensors
from testcases.OpTestSwitchEndianSyscall import OpTestSwitchEndianSyscall
from testcases.OpTestHeartbeat import OpTestHeartbeat
from testcases.OpTestRTCdriver import OpTestRTCdriver
from testcases.OpTestAt24driver import OpTestAt24driver
from testcases.OpTestI2Cdriver import OpTestI2Cdriver
from testcases.OpTestMtdPnorDriver import OpTestMtdPnorDriver
from testcases.OpTestInbandIPMI import OpTestInbandIPMI
from testcases.OpTestHMIHandling import OpTestHMIHandling
from testcases.OpTestPrdDriver import OpTestPrdDriver
from testcases.OpTestIPMILockMode import OpTestIPMILockMode
from testcases.OpTestIPMIPowerControl import OpTestIPMIPowerControl
from testcases.OpTestInbandUsbInterface import OpTestInbandUsbInterface
from testcases.OpTestOOBIPMI import OpTestOOBIPMI
from testcases.OpTestSystemBootSequence import OpTestSystemBootSequence
from testcases.OpTestIPMIReprovision import OpTestIPMIReprovision


def _config_read():
    """ returns bmc system and test config options """
    bmcConfig = ConfigParser.RawConfigParser()
    configFile = os.path.join(os.path.dirname(__file__), 'op_ci_tools.cfg')
    print configFile
    bmcConfig.read(configFile)
    return dict(bmcConfig.items('bmc')), dict(bmcConfig.items('test')), dict(bmcConfig.items('host'))

''' Read the configuration settings into global space so they can be used by
    other functions '''

bmcCfg, testCfg, hostCfg = _config_read()
opTestSensors = OpTestSensors(bmcCfg['ip'], bmcCfg['username'],
                              bmcCfg['password'],
                              bmcCfg.get('usernameipmi'),
                              bmcCfg.get('<PASSWORD>'),
                              testCfg['ffdcdir'], hostCfg['hostip'],
                              hostCfg['hostuser'], hostCfg['hostpasswd'])

opTestSwitchEndianSyscall = OpTestSwitchEndianSyscall(bmcCfg['ip'],
                                                      bmcCfg['username'],
                                                      bmcCfg['password'],
                                                      bmcCfg.get('usernameipmi'),
                                                      bmcCfg.get('<PASSWORD>'),
                                                      testCfg['ffdcdir'],
                                                      hostCfg['hostip'],
                                                      hostCfg['hostuser'],
                                                      hostCfg['hostpasswd'])

opTestRTCdriver = OpTestRTCdriver(bmcCfg['ip'],
                                  bmcCfg['username'],
                                  bmcCfg['password'],
                                  bmcCfg.get('usernameipmi'),
                                  bmcCfg.get('passwordipmi'),
                                  testCfg['ffdcdir'],
                                  hostCfg['hostip'],
                                  hostCfg['hostuser'],
                                  hostCfg['hostpasswd'])

opTestAt24driver = OpTestAt24driver(bmcCfg['ip'], bmcCfg['username'],
                                    bmcCfg['password'],
                                    bmcCfg.get('usernameipmi'),
                                    bmcCfg.get('passwordipmi'),
                                    testCfg['ffdcdir'], hostCfg['hostip'],
                                    hostCfg['hostuser'], hostCfg['hostpasswd'])

opTestI2Cdriver = OpTestI2Cdriver(bmcCfg['ip'], bmcCfg['username'],
                                  bmcCfg['password'],
                                  bmcCfg.get('usernameipmi'),
                                  bmcCfg.get('passwordipmi'),
                                  testCfg['ffdcdir'], hostCfg['hostip'],
                                  hostCfg['hostuser'], hostCfg['hostpasswd'])

opTestHeartbeat = OpTestHeartbeat(bmcCfg['ip'], bmcCfg['username'],
                              bmcCfg['password'],
                              bmcCfg.get('usernameipmi'),
                              bmcCfg.get('passwordipmi'),
                              testCfg['ffdcdir'], hostCfg['hostip'],
                              hostCfg['hostuser'], hostCfg['hostpasswd'])

opTestMtdPnorDriver = OpTestMtdPnorDriver(bmcCfg['ip'], bmcCfg['username'],
                                          bmcCfg['password'],
                                          bmcCfg.get('usernameipmi'),
                                          bmcCfg.get('passwordipmi'),
                                          testCfg['ffdcdir'], hostCfg['hostip'],
                                          hostCfg['hostuser'], hostCfg['hostpasswd'])

opTestInbandIPMI = OpTestInbandIPMI(bmcCfg['ip'], bmcCfg['username'],
                              bmcCfg['password'],
                              bmcCfg.get('usernameipmi'),
                              bmcCfg.get('passwordipmi'),
                              testCfg['ffdcdir'], hostCfg['hostip'],
                              hostCfg['hostuser'], hostCfg['hostpasswd'])

opTestHMIHandling = OpTestHMIHandling(bmcCfg['ip'], bmcCfg['username'],
                                          bmcCfg['password'],
                                          bmcCfg.get('usernameipmi'),
                                          bmcCfg.get('passwordipmi'),
                                          testCfg['ffdcdir'], hostCfg['hostip'],
                                          hostCfg['hostuser'], hostCfg['hostpasswd'])

opTestPrdDriver = OpTestPrdDriver(bmcCfg['ip'], bmcCfg['username'],
                                  bmcCfg['password'],
                                  bmcCfg.get('usernameipmi'),
                                  bmcCfg.get('passwordipmi'),
                                  testCfg['ffdcdir'], hostCfg['hostip'],
                                  hostCfg['hostuser'], hostCfg['hostpasswd'])

opTestIPMILockMode = OpTestIPMILockMode(bmcCfg['ip'], bmcCfg['username'],
                                        bmcCfg['password'],
                                        bmcCfg.get('usernameipmi'),
                                        bmcCfg.get('passwordipmi'),
                                        testCfg['ffdcdir'], hostCfg['hostip'],
                                        hostCfg['hostuser'], hostCfg['hostpasswd'])


opTestIPMIPowerControl = OpTestIPMIPowerControl(bmcCfg['ip'], bmcCfg['username'],
                                        bmcCfg['password'],
                                        bmcCfg.get('usernameipmi'),
                                        bmcCfg.get('passwordipmi'),
                                        testCfg['ffdcdir'], hostCfg['hostip'],
                                        hostCfg['hostuser'], hostCfg['hostpasswd'])

opTestInbandUsbInterface = OpTestInbandUsbInterface(bmcCfg['ip'], bmcCfg['username'],
                                                    bmcCfg['password'],
                                                    bmcCfg.get('usernameipmi'),
                                                    bmcCfg.get('passwordipmi'),
                                                    testCfg['ffdcdir'], hostCfg['hostip'],
                                                    hostCfg['hostuser'], hostCfg['hostpasswd'])

opTestOOBIPMI = OpTestOOBIPMI(bmcCfg['ip'], bmcCfg['username'],
                                        bmcCfg['password'],
                                        bmcCfg.get('usernameipmi'),
                                        bmcCfg.get('passwordipmi'),
                                        testCfg['ffdcdir'], hostCfg['hostip'],
                                        hostCfg['hostuser'], hostCfg['hostpasswd'])

opTestSystemBootSequence = OpTestSystemBootSequence(bmcCfg['ip'], bmcCfg['username'],
                                                    bmcCfg['password'],
                                                    bmcCfg.get('usernameipmi'),
                                                    bmcCfg.get('<PASSWORD>'),
                                                    testCfg['ffdcdir'], hostCfg['hostip'],
                                                    hostCfg['hostuser'], hostCfg['hostpasswd'])

opTestIPMIReprovision = OpTestIPMIReprovision(bmcCfg['ip'], bmcCfg['username'],
                                              bmcCfg['password'],
                                              bmcCfg.get('usernameipmi'),
                                              bmcCfg.get('<PASSWORD>'),
                                              testCfg['ffdcdir'], hostCfg['hostip'],
                                              hostCfg['hostuser'], hostCfg['hostpasswd'])


def test_init():
    """This function validates the test config before running other functions
    """

    ''' create FFDC dir if it does not exist '''
{'fraction_non_alphanumeric': 0.09761583445793973, 'fraction_numerical': 0.002099265257159994, 'mean_word_length': 1.4802280897483575, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 198, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7115383', 'n_tokens_mistral': 4669, 'n_tokens_neox': 4545, 'n_words': 882}