def get_source_file_path(self, device):
        source_device_path = ConfigLoader.get_test_run_config(
            "Source_Values")["Device_Folder"]
        source_folder_path = FileTools.get_device_source_folder(
            device, source_device_path)
        source_file_name = self._get_source_file(source_folder_path, device)

        build_number = Common.Utilities.DeploymentUtils.DeploymentHelper.get_build_version(
            source_file_name)
        PrintMessage("Extracted build number from zip file {0} > {1}".format(
            source_file_name, build_number))

        return source_folder_path + '/' + source_file_name, build_number
Exemple #2
0
    def process_arguments_group_test_run():
        parser = argparse.ArgumentParser(prefix_chars='-')
        CommandLineArgumentsParser.add_argument_configuration_file(parser)
        CommandLineArgumentsParser.add_argument_build_number(parser)
        CommandLineArgumentsParser.add_argument_list_of_report_recipients(
            parser)
        CommandLineArgumentsParser.add_argument_run_type(parser)

        parsed_args = parser.parse_args()

        Test_Context.current_config_file_name = './ConfigFiles/TestRunConfig_{0}.json'.format(
            parsed_args.config_file)
        Test_Context.run_config = ConfigLoader.get_test_run_config()

        return parsed_args
    def create_device_template_from_config(device_name):
        deployment_values = ConfigLoader.get_test_run_config(
            'Deployment_Values')

        device = Device(device_name,
                        DeviceManager.get_device_type_from_name(device_name),
                        deployment_values[device_name]['IP_ADDRESS'],
                        deployment_values[device_name]['Deployment_Type'],
                        deployment_values[device_name]['Device_Release'])

        for key in deployment_values[device_name].keys():
            if key in ['IP_ADDRESS', 'Deployment_Type', 'Device_Release']:
                continue

            device.deployment_config[key] = deployment_values[device_name][key]

        return device
def get_ips_folder_path(device_version, prefix='', zero_fill=4):
    """
    Returns path to ips folder where packages are located
    :param device_version:
    :param prefix: GX has 'V' pefix in release and version folder names
    :param zero_fill: GX uses 3 digits to indicate build number
    :return:
    """
    release_folder = prefix + "{0}/"
    version_folder = prefix + "{1}/"
    package_path = release_folder + version_folder + "packages/"
    ips_path = ConfigLoader.get_test_run_config(
        "Source_Values")["Package_Folder"] + package_path

    return ips_path.format(
        device_version.release_version,
        device_version.get_as_string(fill_with_zeros=zero_fill))
Exemple #5
0
    def process_arguments_single_test_run():
        parser = argparse.ArgumentParser(prefix_chars='-')
        CommandLineArgumentsParser.add_argument_configuration_file(parser)
        CommandLineArgumentsParser.add_argument_list_of_test_ids(parser)
        CommandLineArgumentsParser.add_argument_list_of_class_names(parser)

        parsed_args = parser.parse_args()

        if len(parsed_args.test_ids) == 0 and len(
                parsed_args.test_class_names) == 0:
            parser.error(TestClassNameOrTestCaseID)

        Test_Context.current_config_file_name = './ConfigFiles/TestRunConfig_{0}.json'.format(
            parsed_args.config_file)
        Test_Context.run_config = ConfigLoader.get_test_run_config()

        return parsed_args.test_ids, parsed_args.test_class_names
def deploy_devices(device_names, build_number_to_deploy=None):
    """
    Deploys ntd and sms VMs
    The build number is expected to be the same for both
    :param device_names:
    :param build_number_to_deploy:
    :return:
    """

    deployment_config = ConfigLoader.get_test_run_config('Deployment_Values')

    for device_name in device_names:
        device_to_deploy = DeviceManager.create_device_template_from_config(
            device_name)
        device_to_deploy.version.build = build_number_to_deploy

        device_deployment_type = deployment_config[device_name][
            'Deployment_Type']
        if device_deployment_type == DeploymentType.ntd1100:
            deployed_device = deploy_with_deployer(LannerDeviceDeploy(),
                                                   device_to_deploy)
        elif device_deployment_type == DeploymentType.vmware:
            deployed_device = deploy_with_deployer(VMWareDeviceDeploy(),
                                                   device_to_deploy)
        elif device_deployment_type == DeploymentType.kvm:
            deployed_device = deploy_with_deployer(KVMDeviceDeploy(),
                                                   device_to_deploy)
        elif device_deployment_type == DeploymentType.gx:
            deployed_device = deploy_with_deployer(GXDeviceDeploy(),
                                                   device_to_deploy)
        else:
            raise Exception("Unknown deployment type")

        Test_Context.deployed_devices[deployed_device.name] = deployed_device

        # this ensures, all subsequent devices are of the same build number
        build_number_to_deploy = deployed_device.version.build

    Test_Context.build_number = build_number_to_deploy

    connect_to_all_devices(device_names, deployment_config)

    PrintMessage('Initial deployment complete!')

    return Test_Context.build_number
    def get_connector():
        """
        sys.version_info returns python version (major, minor, build)
        we do not want SSL context to be used with python where build is less than 13
        :return:
        """
        run_config = ConfigLoader.get_test_run_config('VMWare_Values')

        if sys.version_info[0] == 2 and sys.version_info[2] < 13:
            esx_connection = connect.SmartConnect(
                host=run_config['Host'],
                user=run_config['ESX_User'],
                pwd=run_config['ESX_Password'])
        else:
            context = ssl.SSLContext(ssl.PROTOCOL_TLS)
            esx_connection = connect.SmartConnect(
                host=run_config['Host'],
                user=run_config['ESX_User'],
                pwd=run_config['ESX_Password'],
                sslContext=context)

        atexit.register(connect.Disconnect, esx_connection)
        return esx_connection