def fetch_service_snapshot_from_ftp_and_install(snapshot_name, tar_target_path, username, password, use_sesame=True, use_elasticsearch=True, test=False, is_local=False): if not role_is_active('service'): return if not test: tomcat_stop() try: sudo("/etc/init.d/elasticsearch stop") except: e = sys.exc_info()[0] print "Warning: problems stopping elastic search because %s" % e clean_path(tar_target_path, test=test) create_path(tar_target_path, test=test) if use_sesame: ftp_fetch_and_untar(snapshot_name, 'sesame', tar_target_path, '/opt/rinfo/sesame-repo/', username, password, test=test, is_local=is_local) if use_elasticsearch: ftp_fetch_and_untar(snapshot_name, 'elasticsearch', tar_target_path, '/opt/elasticsearch/var/data/', username, password, test=test, is_local=is_local) if not test: tomcat_start() sudo("/etc/init.d/elasticsearch start")
def destroy_main_data(start_top_tomcat=True): if not role_is_active('main'): return if start_top_tomcat: tomcat_stop() sudo("rm -rf %(rinfo_main_store)s/*" % venv()) if start_top_tomcat: tomcat_start()
def update_hosts(ip="127.0.0.1", role=None): if role and not role_is_active(role): return add_to_hosts = "\n%(ip)s %(target)s.lagrummet.se\n" \ "%(ip)s admin.%(target)s.lagrummet.se\n" \ "%(ip)s rinfo.%(target)s.lagrummet.se\n" \ "%(ip)s service.%(target)s.lagrummet.se\n" \ "%(ip)s checker.%(target)s.lagrummet.se\n" % venv() append("/etc/hosts", add_to_hosts, use_sudo=True)
def take_main_snapshot_and_push_to_ftp(snapshot_name, target_path, username, password, test=False): if not role_is_active('main'): return if not test: tomcat_stop() tar_and_ftp_push(snapshot_name, 'depot', password, '/opt/rinfo/store/', target_path, username, test=test) if not test: tomcat_start()
def bootstrap(role=None): _needs_targetenv() if role and not role_is_active(role): return #if not os_version() == 'Debian7': # print 'Unsupported os version %%' % os_version() # return prepare_sudo_for_debian_and_add_rinfo_user() prefere_ipv4_to_speed_up_debian_updates() install_public_key() if os.path.isfile('%s/.ssh/jenkins_id_rsa.pub' % expanduser('~')): install_public_key('jenkins_id_rsa.pub')
def configure_sites(role=None): if role and not role_is_active(role): return _sync_workdir() targetenv_etc_dir = "%(mgr_workdir)s/%(target)s/etc" % env with cd(targetenv_etc_dir): for role in env.roles: sites = env.get('apache_sites') if not sites or role not in sites: continue for site in sites[role]: print "Site %s" % site sudo("cp -vu apache2/sites-available/%s /etc/apache2/sites-available/" % site) sudo("a2ensite %s" % site)
def test_all(): if not role_is_active('admin'): return all() restart_apache() restart_tomcat() msg_sleep(10, " apache and tomcat restart") try: test() except: e = sys.exc_info()[0] print e sys.exit(1) finally: clean()
def test_all(): if not role_is_active('service'): return all(deps="1", test="0") restart_tomcat() restart_apache() msg_sleep(20, "restart and tomcat apache") try: test() except: e = sys.exc_info()[0] print e sys.exit(1) finally: clean()
def fetch_main_snapshot_from_ftp_and_install(snapshot_name, tar_target_path, username, password, test=False, is_local=False): if not role_is_active('main'): return if not test: tomcat_stop() clean_path(tar_target_path, test=test) create_path(tar_target_path, test=test) ftp_fetch_and_untar(snapshot_name, 'depot', tar_target_path, '/opt/rinfo/store/', username, password, test=test, is_local=is_local) if not test: tomcat_start()
def test_all(): if not role_is_active('service'): return all(deps="1", test="0") restart_apache() restart_tomcat() msg_sleep(20, "restart apache, tomcat and wait for service to start") try: #ping_start_collect() #msg_sleep(60,"collect feed") test() except: e = sys.exc_info()[0] print e sys.exit(1) finally: clean()
def test_all(): if not role_is_active('service'): return all(deps="1", test="0") restart_apache() #if env.target=='regression': # install_regression_data() #else: restart_tomcat() msg_sleep(60, "restart apache, tomcat and wait for service to start, and depot consistency check") try: #ping_start_collect_admin() #msg_sleep(10,"collect feed") #ping_start_collect_feed() #msg_sleep(60,"collect feed") test() except: e = sys.exc_info()[0] print e sys.exit(1) finally: clean()
def take_service_snapshot_and_push_to_ftp(snapshot_name, target_path, username, password, use_sesame=True, use_elasticsearch=True, test=False): if not role_is_active('service'): return if not test: tomcat_stop() try: sudo("/etc/init.d/elasticsearch stop") except: e = sys.exc_info()[0] print "WARNING! Problems stopping elastic search because %s" % e if use_sesame: tar_and_ftp_push(snapshot_name, 'sesame', password, '/opt/rinfo/sesame-repo/', target_path, username, test=test) if use_elasticsearch: tar_and_ftp_push(snapshot_name, 'elasticsearch', password, '/opt/elasticsearch/var/data/', target_path, username, test=test) if not test: tomcat_start() sudo("/etc/init.d/elasticsearch start")
def destroy_service_data(): if not role_is_active('service'): return destroy_service_repository() delete_elasticsearch_index() ban_varnish()
def print_role_and_host(): for role in ['main', 'service', 'checker', 'admin', 'lagrummet', 'emfs', 'test', 'regression', 'skrapat', 'demosource']: if role_is_active(role): print "role=%s" % role print "host=" + env.host