Beispiel #1
0
def main():
    install_logging('Install_Packs.log')
    options = options_handler()

    # Get the host by the ami env
    hosts, _ = Build.get_servers(ami_env=options.ami_env)

    logging.info('Retrieving the credentials for Cortex XSOAR server')
    secret_conf_file = get_json_file(path=options.secret)
    username: str = secret_conf_file.get('username')
    password: str = secret_conf_file.get('userPassword')

    # Configure the Servers
    for host in hosts:
        server = Server(host=host, user_name=username, password=password)
        logging.info(f'Adding Marketplace configuration to {host}')
        error_msg: str = 'Failed to set marketplace configuration.'
        server.add_server_configuration(config_dict=MARKET_PLACE_CONFIGURATION, error_msg=error_msg)
        set_marketplace_url(servers=[server], branch_name=options.branch, ci_build_number=options.build_number)

        # Acquire the server's host and install all content packs (one threaded execution)
        logging.info(f'Starting to install all content packs in {host}')
        server_host: str = server.client.api_client.configuration.host
        install_all_content_packs(client=server.client, host=server_host)
        logging.success(f'Finished installing all content packs in {host}')
def main():
    install_logging('Install_Packs.log')
    options = options_handler()

    # Get the host by the ami env
    server_to_port_mapping, server_version = Build.get_servers(
        ami_env=options.ami_env)

    logging.info('Retrieving the credentials for Cortex XSOAR server')
    secret_conf_file = get_json_file(path=options.secret)
    username: str = secret_conf_file.get('username')
    password: str = secret_conf_file.get('userPassword')
    branch_name: str = options.branch
    build_number: str = options.build_number

    # Configure the Servers
    for server_url, port in server_to_port_mapping.items():
        server = Server(internal_ip=server_url,
                        port=port,
                        user_name=username,
                        password=password)
        logging.info(f'Adding Marketplace configuration to {server_url}')
        error_msg: str = 'Failed to set marketplace configuration.'
        server.add_server_configuration(config_dict=MARKET_PLACE_CONFIGURATION,
                                        error_msg=error_msg)
        set_marketplace_url(servers=[server],
                            branch_name=branch_name,
                            ci_build_number=build_number)

        # Acquire the server's host and install all content packs (one threaded execution)
        logging.info(f'Starting to install all content packs in {server_url}')
        server_host: str = server.client.api_client.configuration.host
        success_flag = install_all_content_packs_from_build_bucket(
            client=server.client,
            host=server_host,
            server_version=server_version,
            bucket_packs_root_path=GCPConfig.BUILD_BUCKET_PACKS_ROOT_PATH.
            format(branch=branch_name, build=build_number),
            service_account=options.service_account,
            extract_destination_path=options.extract_path)

        if success_flag:
            logging.success(
                f'Finished installing all content packs in {server_url}')
        else:
            logging.error('Failed to install all packs.')
            sys.exit(1)