Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install Pack Fix #10759

Merged
merged 7 commits into from
Jan 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Tests/Marketplace/configure_and_install_packs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import argparse
import logging
import sys

from Tests.configure_and_test_integration_instances import set_marketplace_url, MARKET_PLACE_CONFIGURATION, \
Build, Server
@@ -27,7 +28,7 @@ def main():
options = options_handler()

# Get the host by the ami env
hosts, _ = Build.get_servers(ami_env=options.ami_env)
hosts, 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)
@@ -45,8 +46,13 @@ def main():
# 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}')
success_flag = install_all_content_packs(client=server.client, host=server_host, server_version=server_version)

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


if __name__ == '__main__':
17 changes: 12 additions & 5 deletions Tests/Marketplace/search_and_install_packs.py
Original file line number Diff line number Diff line change
@@ -332,11 +332,14 @@ def install_packs(client: demisto_client,
result_object = ast.literal_eval(response_data)
message = result_object.get('message', '')
raise Exception(f'Failed to install packs - with status code {status_code}\n{message}')
except Exception:
logging.exception('The request to install packs has failed.')
except Exception as e:
logging.exception(f'The request to install packs has failed. Additional info: {str(e)}')
global SUCCESS_FLAG
SUCCESS_FLAG = False

finally:
return SUCCESS_FLAG


def search_pack_and_its_dependencies(client: demisto_client,
pack_id: str,
@@ -441,12 +444,13 @@ def install_all_content_packs_for_nightly(client: demisto_client, host: str, ser
install_packs(client, host, all_packs, is_nightly=True)


def install_all_content_packs(client: demisto_client, host: str):
def install_all_content_packs(client: demisto_client, host: str, server_version: str):
""" Iterates over the packs currently located in the Packs directory. Wrapper for install_packs.
Retrieving the latest version of each pack from the metadata file in content repo.

:param client: Demisto-py client to connect to the server.
:param host: FQDN of the server.
:param server_version: The version of the server the packs are installed on.
:return: None. Prints the response from the server in the build.
"""
all_packs = []
@@ -458,8 +462,11 @@ def install_all_content_packs(client: demisto_client, host: str):
with open(metadata_path, 'r') as json_file:
pack_metadata = json.load(json_file)
pack_version = pack_metadata.get('currentVersion')
all_packs.append(get_pack_installation_request_data(pack_id, pack_version))
install_packs(client, host, all_packs)
server_min_version = pack_metadata.get('serverMinVersion', '6.0.0')
# Check if the server version is greater than the minimum server version required for this pack:
if 'Master' in server_version or LooseVersion(server_version) >= LooseVersion(server_min_version):
all_packs.append(get_pack_installation_request_data(pack_id, pack_version))
return install_packs(client, host, all_packs)


def upload_zipped_packs(client: demisto_client,