def upgrade_icat(icat_server, packages_root_directory): host_list = [icat_server['deployment_information']['ip_address']] complex_args = { 'irods_packages_root_directory': packages_root_directory, 'icat_database_type': icat_server['database_config']['catalog_database_type'], } library.run_ansible(module_name='irods_upgrading_icat_server', complex_args=complex_args, host_list=host_list)
def main(zone_bundle, deployment_name, irods_core_packages_root_directory, plugin_package_root_directory, plugin_package_prefix, ansible_module_to_run, python_test_module_to_run, output_directory): zone_bundle_output_file = os.path.join(output_directory, 'deployed_zone.json') version_to_packages_map = { 'deployment-determined': irods_core_packages_root_directory, } deployed_zone_bundle = library.deploy(zone_bundle, deployment_name, version_to_packages_map, zone_bundle_output_file) with library.deployed_zone_bundle_manager(deployed_zone_bundle): icat_ip = deployed_zone_bundle['zones'][0]['icat_server'][ 'deployment_information']['ip_address'] complex_args = { 'plugin_package_root_directory': plugin_package_root_directory, 'plugin_package_prefix': plugin_package_prefix, 'python_test_module_to_run': python_test_module_to_run, 'output_directory': output_directory } try: library.run_ansible(module_name=ansible_module_to_run, complex_args=complex_args, host_list=[icat_ip], sudo=True) finally: library.gather(deployed_zone_bundle, output_directory)
def upgrade_resource_servers(resource_servers, packages_root_directory): if len(resource_servers) > 0: host_list = [server['deployment_information']['ip_address'] for server in resource_servers] complex_args = { 'irods_packages_root_directory': packages_root_directory, } library.run_ansible(module_name='irods_upgrading_resource_server', complex_args=complex_args, host_list=host_list)
def test_federation_zone_to_zone(local_zone, remote_zone, use_ssl, use_mungefs, output_directory): complex_args = { 'username': '******'.format( local_zone['icat_server']['server_config']['zone_name']) } remote_icat_ip = remote_zone['icat_server']['deployment_information'][ 'ip_address'] library.run_ansible(module_name='irods_configuration_federation_testing', complex_args=complex_args, host_list=[remote_icat_ip], sudo=True) complex_args = { 'test_type': 'federation', 'output_directory': output_directory, 'use_ssl': use_ssl, 'use_mungefs': use_mungefs, 'federation_args': [ remote_zone['icat_server']['version']['irods_version'], remote_zone['icat_server']['server_config']['zone_name'], remote_zone['icat_server']['hostname'], ] } local_icat_ip = local_zone['icat_server']['deployment_information'][ 'ip_address'] data = library.run_ansible(module_name='irods_testing', complex_args=complex_args, host_list=[local_icat_ip]) return data
def configure_federation_on_zone(zone, disable_client_server_negotiation): host_list = [zone['icat_server']['deployment_information']['ip_address']] complex_args = { 'federation': zone['icat_server']['server_config']['federation'], 'disable_client_server_negotiation': disable_client_server_negotiation, } library.run_ansible(module_name='irods_configuration_federation', complex_args=complex_args, host_list=host_list, sudo=True)
def configure_ssh_client(zone): servers = library.get_servers_from_zone(zone) complex_args = { 'ssh_config_file':'/etc/ssh/ssh_config', } for server in servers: server_ip = server['deployment_information']['ip_address'] library.run_ansible(module_name='ssh_config_file', complex_args=complex_args, host_list=[server_ip], sudo=True)
def configure_zone_hostnames(zone): servers = library.get_servers_from_zone(zone) for server in servers: server_ip = server['deployment_information']['ip_address'] library.run_ansible(module_name='hostname', module_args='name={0}'.format(server['hostname']), host_list=[server_ip], sudo=True)
def install_plugin_on_server(server_ip, plugin_packages_directory): logger = logging.getLogger(__name__) logger.info('jaspreet ' + server_ip) complex_args = { 'irods_plugin_packages_directory': plugin_packages_directory, } library.run_ansible(module_name='irods_install_plugin', complex_args=complex_args, host_list=[server_ip])
def gather_zone(zone, output_root_directory): servers = library.get_servers_from_zone(zone) host_list = [server['deployment_information']['ip_address'] for server in servers] complex_args = { 'output_root_directory': output_root_directory, } library.run_ansible(module_name='irods_gathering', complex_args=complex_args, host_list=host_list)
def build_plugin_on_vms(ip_addresses, git_repository, git_commitish, python_script, passthrough_arguments): complex_args = { 'git_repository': git_repository, 'git_commitish': git_commitish, 'python_script': python_script, 'passthrough_arguments': passthrough_arguments, } library.run_ansible(module_name='irods_clone_git_repo_and_run_python_script', complex_args=complex_args, host_list=ip_addresses)
def build_plugin_on_vms(ip_addresses, output_root_directory, irods_packages_root_directory, git_repository, git_commitish, platform_targets, debug_build): complex_args = { 'output_root_directory': output_root_directory, 'irods_packages_root_directory': irods_packages_root_directory, 'git_repository': git_repository, 'git_commitish': git_commitish, 'debug_build': debug_build, } library.run_ansible(module_name='irods_build_plugin', complex_args=complex_args, host_list=ip_addresses)
def configure_ssh_client(zone): servers = library.get_servers_from_zone(zone) complex_args = { 'ssh_config_file': '/etc/ssh/ssh_config', } for server in servers: server_ip = server['deployment_information']['ip_address'] library.run_ansible(module_name='ssh_config_file', complex_args=complex_args, host_list=[server_ip], sudo=True)
def update_core_re_zone(zone): servers = library.get_servers_from_zone(zone) host_list = [server['deployment_information']['ip_address'] for server in servers] complex_args = { 'dest': '/etc/irods/core.re', 'regexp': r'^acPreConnect\(\*OUT\) \{ \*OUT="CS_NEG_(DONT_CARE|REFUSE)"; \}$', 'replace': 'acPreConnect(*OUT) { *OUT="CS_NEG_REQUIRE"; }', } library.run_ansible(module_name='replace', complex_args=complex_args, host_list=host_list, sudo=True)
def configure_ssh_known_hosts(icat_server, resource_servers): icat_server_ip = icat_server['deployment_information']['ip_address'] icat_hostname = icat_server['hostname'] complex_args = { 'server_host_name':icat_hostname, 'server_ip_address':icat_server_ip, } for server in resource_servers: server_ip = server['deployment_information']['ip_address'] library.run_ansible(module_name='ssh_known_hosts', complex_args=complex_args, host_list=[server_ip], sudo=True)
def upgrade_resource_servers(resource_servers, packages_root_directory): if len(resource_servers) > 0: host_list = [ server['deployment_information']['ip_address'] for server in resource_servers ] complex_args = { 'irods_packages_root_directory': packages_root_directory, } library.run_ansible(module_name='irods_upgrading_resource_server', complex_args=complex_args, host_list=host_list)
def build_plugin_on_vms(ip_addresses, git_repository, git_commitish, python_script, passthrough_arguments): complex_args = { 'git_repository': git_repository, 'git_commitish': git_commitish, 'python_script': python_script, 'passthrough_arguments': passthrough_arguments, } library.run_ansible( module_name='irods_clone_git_repo_and_run_python_script', complex_args=complex_args, host_list=ip_addresses)
def run_tests(zone, test_type, output_directory): if test_type == 'topology_resource': ip_address = zone['resource_servers'][0]['deployment_information'][ 'ip_address'] complex_args = { 'test_type': test_type, 'test_args': '--run_specific_test test_native_rule_engine_plugin.Test_Native_Rule_Engine_Plugin.test_remote_rule_execution --topology_test resource', 'output_directory': output_directory, } library.run_ansible(module_name='irods_topo_testing', complex_args=complex_args, host_list=[ip_address])
def configure_ssh_known_hosts(icat_server, resource_servers): icat_server_ip = icat_server['deployment_information']['ip_address'] icat_hostname = icat_server['hostname'] complex_args = { 'server_host_name': icat_hostname, 'server_ip_address': icat_server_ip, } for server in resource_servers: server_ip = server['deployment_information']['ip_address'] library.run_ansible(module_name='ssh_known_hosts', complex_args=complex_args, host_list=[server_ip], sudo=True)
def get_first_zone_irods_version(zone_bundle): icat_ip = zone_bundle['zones'][0]['icat_server']['deployment_information'][ 'ip_address'] data = library.run_ansible(module_name='irods_version', complex_args={}, host_list=[icat_ip]) return data['contacted'][icat_ip]['irods_version']
def install_irods_on_zone_icat_server(icat_server, version_to_packages_map, mungefs_packages_dir, install_dev_package): if icat_server['version']['irods_version'] != '3.3.1': icat_ip = icat_server['deployment_information']['ip_address'] complex_args = { 'icat_server': icat_server, 'irods_packages_root_directory': version_to_packages_map[icat_server['version']['irods_version']], 'mungefs_packages_root_directory': mungefs_packages_dir, 'install_dev_package': install_dev_package, } data = library.run_ansible( module_name='irods_installation_icat_server', complex_args=complex_args, host_list=[icat_ip], sudo=True) if icat_server['version']['irods_version'] == 'deployment-determined': icat_server['version']['irods_version'] = '.'.join( map(str, data['contacted'][icat_ip]['irods_version'])) return icat_server
def update_irods_environment_zone(zone): servers = library.get_servers_from_zone(zone) host_list = [server['deployment_information']['ip_address'] for server in servers] complex_args = { 'filename': '/var/lib/irods/.irods/irods_environment.json', 'update_dict': { 'irods_ssl_certificate_key_file': rsa_keyfile_path, 'irods_ssl_certificate_chain_file': ssl_certificate_path, 'irods_ssl_dh_params_file': diffie_hellman_parameters_path, 'irods_client_server_policy': 'CS_NEG_REQUIRE', 'irods_ssl_verify_server': 'cert', 'irods_ssl_ca_certificate_file': ssl_certificate_path, } } library.run_ansible(module_name='update_json_file', complex_args=complex_args, host_list=host_list, sudo=True)
def update_core_re_zone(zone): servers = library.get_servers_from_zone(zone) host_list = [ server['deployment_information']['ip_address'] for server in servers ] complex_args = { 'dest': '/etc/irods/core.re', 'regexp': r'^acPreConnect\(\*OUT\) \{ \*OUT="CS_NEG_(DONT_CARE|REFUSE)"; \}$', 'replace': 'acPreConnect(*OUT) { *OUT="CS_NEG_REQUIRE"; }', } library.run_ansible(module_name='replace', complex_args=complex_args, host_list=host_list, sudo=True)
def test_federation_zone_to_zone(local_zone, remote_zone, use_ssl, use_mungefs, output_directory): complex_args = { 'username': '******'.format(local_zone['icat_server']['server_config']['zone_name']) } remote_icat_ip = remote_zone['icat_server']['deployment_information']['ip_address'] library.run_ansible(module_name='irods_configuration_federation_testing', complex_args=complex_args, host_list=[remote_icat_ip], sudo=True) complex_args = { 'test_type': 'federation', 'output_directory': output_directory, 'use_ssl': use_ssl, 'use_mungefs': use_mungefs, 'federation_args': [remote_zone['icat_server']['version']['irods_version'], remote_zone['icat_server']['server_config']['zone_name'], remote_zone['icat_server']['hostname'],] } local_icat_ip = local_zone['icat_server']['deployment_information']['ip_address'] data = library.run_ansible(module_name='irods_testing', complex_args=complex_args, host_list=[local_icat_ip]) return data
def test_zone(zone, test_type, use_ssl, use_mungefs, output_directory): test_server_ip = get_test_server_ip(zone, test_type) complex_args = { 'test_type': test_type, 'output_directory': output_directory, 'use_ssl': use_ssl, 'use_mungefs': use_mungefs, } data = library.run_ansible(module_name='irods_testing', complex_args=complex_args, host_list=[test_server_ip]) return data['contacted'][test_server_ip]['tests_passed']
def install_irods_on_zone_resource_server(resource_server, version_to_packages_map, install_dev_package): resource_ip = resource_server['deployment_information']['ip_address'] complex_args = { 'resource_server': resource_server, 'irods_packages_root_directory': version_to_packages_map[resource_server['version']['irods_version']], 'install_dev_package': install_dev_package, } data = library.run_ansible(module_name='irods_installation_resource_server', complex_args=complex_args, host_list=[resource_ip], sudo=True) if resource_server['version']['irods_version'] == 'deployment-determined': resource_server['version']['irods_version'] = '.'.join(map(str, data['contacted'][resource_ip]['irods_version'])) return resource_server
def main(zone_bundle, deployment_name, irods_core_packages_root_directory, plugin_package_root_directory, plugin_package_prefix, ansible_module_to_run, python_test_module_to_run, output_directory): logger = logging.getLogger(__name__) zone_bundle_output_file = os.path.join(output_directory, 'deployed_zone.json') version_to_packages_map = { 'deployment-determined': irods_core_packages_root_directory, } deployed_zone_bundle = library.deploy(zone_bundle, deployment_name, version_to_packages_map, zone_bundle_output_file) with library.deployed_zone_bundle_manager(deployed_zone_bundle): icat_ip = deployed_zone_bundle['zones'][0]['icat_server']['deployment_information']['ip_address'] complex_args = { 'plugin_package_root_directory': plugin_package_root_directory, 'plugin_package_prefix': plugin_package_prefix, 'python_test_module_to_run': python_test_module_to_run, 'output_directory': output_directory } try: library.run_ansible(module_name=ansible_module_to_run, complex_args=complex_args, host_list=[icat_ip], sudo=True) finally: library.gather(deployed_zone_bundle, output_directory)
def update_irods_environment_zone(zone): servers = library.get_servers_from_zone(zone) host_list = [ server['deployment_information']['ip_address'] for server in servers ] complex_args = { 'filename': '/var/lib/irods/.irods/irods_environment.json', 'update_dict': { 'irods_ssl_certificate_key_file': rsa_keyfile_path, 'irods_ssl_certificate_chain_file': ssl_certificate_path, 'irods_ssl_dh_params_file': diffie_hellman_parameters_path, 'irods_client_server_policy': 'CS_NEG_REQUIRE', 'irods_ssl_verify_server': 'cert', 'irods_ssl_ca_certificate_file': ssl_certificate_path, } } library.run_ansible(module_name='update_json_file', complex_args=complex_args, host_list=host_list, sudo=True)
def configure_zone_hosts_files(zone, servers): ip_address_to_hostnames_dict = {server['deployment_information']['ip_address']: [server['hostname']] for server in servers} ip_address_to_hostnames_dict['127.0.0.1'] = ['localhost'] complex_args = { 'ip_address_to_hostnames_dict': ip_address_to_hostnames_dict, 'hosts_file': '/etc/hosts', } host_list = [server['deployment_information']['ip_address'] for server in servers] library.run_ansible(module_name='hosts_file', complex_args=complex_args, host_list=host_list, sudo=True) database_config = zone['icat_server']['database_config'] if database_config['db_host'] != 'localhost': db_hostname = database_config['db_host'] db_ip_address = database_config['deployment_information']['ip_address'] complex_args = { 'ip_address_to_hostnames_dict': {db_ip_address: [db_hostname]}, 'hosts_file': '/etc/hosts', } icat_ip_address = zone['icat_server']['deployment_information']['ip_address'] library.run_ansible(module_name='hosts_file', complex_args=complex_args, host_list=[icat_ip_address], sudo=True)
def install_irods_on_zone_icat_server(icat_server, version_to_packages_map, mungefs_packages_dir, install_dev_package): if icat_server['version']['irods_version'] != '3.3.1': icat_ip = icat_server['deployment_information']['ip_address'] complex_args = { 'icat_server': icat_server, 'irods_packages_root_directory': version_to_packages_map[icat_server['version']['irods_version']], 'mungefs_packages_root_directory': mungefs_packages_dir, 'install_dev_package': install_dev_package, } data = library.run_ansible(module_name='irods_installation_icat_server', complex_args=complex_args, host_list=[icat_ip], sudo=True) if icat_server['version']['irods_version'] == 'deployment-determined': icat_server['version']['irods_version'] = '.'.join(map(str, data['contacted'][icat_ip]['irods_version'])) return icat_server
def configure_zone_hosts_files(zone, servers): ip_address_to_hostnames_dict = { server['deployment_information']['ip_address']: [server['hostname']] for server in servers } ip_address_to_hostnames_dict['127.0.0.1'] = ['localhost'] complex_args = { 'ip_address_to_hostnames_dict': ip_address_to_hostnames_dict, 'hosts_file': '/etc/hosts', } host_list = [ server['deployment_information']['ip_address'] for server in servers ] library.run_ansible(module_name='hosts_file', complex_args=complex_args, host_list=host_list, sudo=True) database_config = zone['icat_server']['database_config'] if database_config['db_host'] != 'localhost': db_hostname = database_config['db_host'] db_ip_address = database_config['deployment_information']['ip_address'] complex_args = { 'ip_address_to_hostnames_dict': { db_ip_address: [db_hostname] }, 'hosts_file': '/etc/hosts', } icat_ip_address = zone['icat_server']['deployment_information'][ 'ip_address'] library.run_ansible(module_name='hosts_file', complex_args=complex_args, host_list=[icat_ip_address], sudo=True)
def main(zone_bundle, deployment_name, packages_root_directory, output_directory, python_client_git_repository, python_client_git_commitish): logger = logging.getLogger(__name__) zone_bundle_output_file = os.path.join(output_directory, 'deployed_zone.json') version_to_packages_map = { 'deployment-determined': packages_root_directory, } deployed_zone_bundle = library.deploy(zone_bundle, deployment_name, version_to_packages_map, zone_bundle_output_file) with library.deployed_zone_bundle_manager(deployed_zone_bundle): icat_ip = deployed_zone_bundle['zones'][0]['icat_server']['deployment_information']['ip_address'] complex_args = { 'output_directory': output_directory, 'python_client_git_repository': python_client_git_repository, 'python_client_git_commitish': python_client_git_commitish, } data = library.run_ansible(module_name='irods_test_python_client', complex_args=complex_args, host_list=[icat_ip])
def checkout_git_repo_and_run_python_script_on_icat(deployed_zone_bundle, git_repository, git_commitish, python_script, passthrough_arguments): complex_args = { 'git_repository': git_repository, 'git_commitish': git_commitish, 'python_script': python_script, 'passthrough_arguments': passthrough_arguments, } return library.run_ansible( module_name='irods_clone_git_repo_and_run_python_script', complex_args=complex_args, host_list=[ deployed_zone_bundle['zones'][0]['icat_server'] ['deployment_information']['ip_address'] ])
def install_irods_on_zone_resource_server(resource_server, version_to_packages_map, install_dev_package): resource_ip = resource_server['deployment_information']['ip_address'] complex_args = { 'resource_server': resource_server, 'irods_packages_root_directory': version_to_packages_map[resource_server['version']['irods_version']], 'install_dev_package': install_dev_package, } data = library.run_ansible( module_name='irods_installation_resource_server', complex_args=complex_args, host_list=[resource_ip], sudo=True) if resource_server['version']['irods_version'] == 'deployment-determined': resource_server['version']['irods_version'] = '.'.join( map(str, data['contacted'][resource_ip]['irods_version'])) return resource_server
def run_ansible_module_on_vms(ip_addresses, ansible_module, ansible_arguments, sudo, ansible_module_directories): library.run_ansible(module_name=ansible_module, complex_args=ansible_arguments, host_list=ip_addresses, additional_modules_directories=ansible_module_directories, sudo=sudo)
def get_first_zone_irods_version(zone_bundle): icat_ip = zone_bundle['zones'][0]['icat_server']['deployment_information']['ip_address'] data = library.run_ansible(module_name='irods_version', complex_args={}, host_list=[icat_ip]) return data['contacted'][icat_ip]['irods_version']
def copy_testing_code(source_zone, target_zone): ip_address_source = source_zone['icat_server']['deployment_information']['ip_address'] ip_address_dest = target_zone['icat_server']['deployment_information']['ip_address'] temp_dir = tempfile.mkdtemp() with directory_deleter(temp_dir): def get_complex_args_fetch(dirname, filename): return { 'dest': temp_dir + '/', 'flat': 'yes', 'src': os.path.join(dirname, filename), 'fail_on_missing': 'yes', } def get_complex_args_copy(filename): return { 'dest': os.path.join('/var/lib/irods/tests/pydevtest', filename), 'src': os.path.join(temp_dir, filename), } def get_complex_args_synchronize_pull(): return { 'recursive': 'yes', 'src': '/var/lib/irods/scripts', 'dest': temp_dir + '/', 'mode': 'pull', } def get_complex_args_synchronize_push(): return { 'recursive': 'yes', 'src': temp_dir + '/scripts', 'dest': '/var/lib/irods/', 'mode': 'push', } def get_complex_args_file(): return { 'mode': 0777, 'path': '/var/lib/irods/scripts', 'recurse': 'yes', 'owner': 'irods', 'group': 'irods', } data = library.run_ansible(module_name='stat', complex_args={'path':'/var/lib/irods/scripts/run_tests.py'}, host_list=[ip_address_source], sudo=True) if data['contacted'][ip_address_source]['stat']['exists']: library.run_ansible(module_name='synchronize', complex_args=get_complex_args_synchronize_pull(), host_list=[ip_address_source], sudo=True) library.run_ansible(module_name='synchronize', complex_args=get_complex_args_synchronize_push(), host_list=[ip_address_dest], sudo=True) library.run_ansible(module_name='file', complex_args=get_complex_args_file(), host_list=[ip_address_dest], sudo=True) else: library.run_ansible(module_name='file', complex_args={'mode':'u=rwx,g=rwx,o=rwx', 'path':'/var/lib/irods/tests/pydevtest', 'state':'directory'}, host_list=[ip_address_dest], sudo=True) for f in ['run_tests.py', 'configuration.py', 'test_federation.py', 'lib.py', 'test_framework_configuration.json']: library.run_ansible(module_name='fetch', complex_args=get_complex_args_fetch('/var/lib/irods/tests/pydevtest', f), host_list=[ip_address_source], sudo=True) library.run_ansible(module_name='copy', complex_args=get_complex_args_copy(f), host_list=[ip_address_dest], sudo=True)
def copy_testing_code(source_zone, target_zone): ip_address_source = source_zone['icat_server']['deployment_information'][ 'ip_address'] ip_address_dest = target_zone['icat_server']['deployment_information'][ 'ip_address'] temp_dir = tempfile.mkdtemp() with directory_deleter(temp_dir): def get_complex_args_fetch(dirname, filename): return { 'dest': temp_dir + '/', 'flat': 'yes', 'src': os.path.join(dirname, filename), 'fail_on_missing': 'yes', } def get_complex_args_copy(filename): return { 'dest': os.path.join('/var/lib/irods/tests/pydevtest', filename), 'src': os.path.join(temp_dir, filename), } def get_complex_args_synchronize_pull(): return { 'recursive': 'yes', 'src': '/var/lib/irods/scripts', 'dest': temp_dir + '/', 'mode': 'pull', } def get_complex_args_synchronize_push(): return { 'recursive': 'yes', 'src': temp_dir + '/scripts', 'dest': '/var/lib/irods/', 'mode': 'push', } def get_complex_args_file(): return { 'mode': 0777, 'path': '/var/lib/irods/scripts', 'recurse': 'yes', 'owner': 'irods', 'group': 'irods', } data = library.run_ansible( module_name='stat', complex_args={'path': '/var/lib/irods/scripts/run_tests.py'}, host_list=[ip_address_source], sudo=True) if data['contacted'][ip_address_source]['stat']['exists']: library.run_ansible( module_name='synchronize', complex_args=get_complex_args_synchronize_pull(), host_list=[ip_address_source], sudo=True) library.run_ansible( module_name='synchronize', complex_args=get_complex_args_synchronize_push(), host_list=[ip_address_dest], sudo=True) library.run_ansible(module_name='file', complex_args=get_complex_args_file(), host_list=[ip_address_dest], sudo=True) else: library.run_ansible(module_name='file', complex_args={ 'mode': 'u=rwx,g=rwx,o=rwx', 'path': '/var/lib/irods/tests/pydevtest', 'state': 'directory' }, host_list=[ip_address_dest], sudo=True) for f in [ 'run_tests.py', 'configuration.py', 'test_federation.py', 'lib.py', 'test_framework_configuration.json' ]: library.run_ansible(module_name='fetch', complex_args=get_complex_args_fetch( '/var/lib/irods/tests/pydevtest', f), host_list=[ip_address_source], sudo=True) library.run_ansible(module_name='copy', complex_args=get_complex_args_copy(f), host_list=[ip_address_dest], sudo=True)