<commit_before>#!/bin/bash -xe

disable_wsrep() {
    [ -z "$1" ] && die "No node ID provided, exiting, exiting"
    ssh root@$(get_host_ip_by_node_id $1) "echo \"SET GLOBAL wsrep_on='off';\" | mysql"
}

enable_wsrep() {
    [ -z "$1" ] && die "No node ID provided, exiting"
    ssh root@$(get_host_ip_by_node_id $1) "echo \"SET GLOBAL wsrep_on='ON';\" | mysql"
}

xtrabackup_install() {
    [ -z "$1" ] && die "No node ID provided, exiting"
    ssh root@$(get_host_ip_by_node_id $1) "apt-get -y install percona-xtrabackup"
}

xtrabackup_stream_from_node() {
    [ -z "$1" ] && die "No backup source node ID provided, exiting"
    ssh root@$(get_host_ip_by_node_id $1) "xtrabackup --backup --stream=tar ./ | gzip " \
        | cat - > /tmp/dbs.original.tar.gz
}

xtrabackup_from_env() {
    [ -z "$1" ] && die "No env ID provided, exiting"
    local node=$(list_nodes $1 controller | head -1)
    xtrabackup_install $node
    disable_wsrep $node
    xtrabackup_stream_from_node $node
    enable wsrep $node
}

xtrabackup_restore_to_env() {
    [ -z "$1" ] && die "No env ID provided, exiting"
    local cics=$(list_nodes $1 controller)
    echo $cics | xargs -I{} ssh root@{} \
        "mv /var/lib/mysql/grastate.dat /var/lib/mysql/grastate.old"
    local primary_cic=$(echo $cics | head -1)
    cat /tmp/dbs.original.tar.gz \
        | ssh root@$primary_cic "cat - > /var/lib/mysql/dbs.original.tar.gz"
    ssh root@$primary_cic \
        "cd /var/lib/mysql;
        tar -zxvf db.original.tar.gz;
        chown -R mysql:mysql /var/lib/mysql;
        export OCF_RESOURCE_INSTANCE=p_mysql;
        export OCF_ROOT=/usr/lib/ocf;
        export OCF_RESKEY_socket=/var/run/mysqld/mysqld.sock;
        export OCF_RESKEY_additional_parameters="\""--wsrep-new-cluster"\"";
        /usr/lib/ocf/resource.d/mirantis/mysql-wss start;"
    db_sync ${primary_cic#node-}
    echo $cics | grep -v $primary_cic | xargs -I{} ssh root@{} \
        "export OCF_RESOURCE_INSTANCE=p_mysql;
        export OCF_ROOT=/usr/lib/ocf;
        export OCF_RESKEY_socket=/var/run/mysqld/mysqld.sock;
        /usr/lib/ocf/resource.d/mirantis/mysql-wss start;"
}

db_sync() {
    [ -z "$1" ] && die "No node ID provided, exiting"
    ssh root@node-$1 "keystone-manage db_sync;
nova-manage db sync;
heat-manage db_sync;
neutron-db-manage --config-file=/etc/neutron/neutron.conf upgrade head;
glance-manage db upgrade;
cinder-manage db sync"
}<commit_msg>Always SSH to IP address<commit_after>#!/bin/bash -xe

disable_wsrep() {
    [ -z "$1" ] && die "No node ID provided, exiting, exiting"
    ssh root@$(get_host_ip_by_node_id $1) "echo \"SET GLOBAL wsrep_on='off';\" | mysql"
}

enable_wsrep() {
    [ -z "$1" ] && die "No node ID provided, exiting"
    ssh root@$(get_host_ip_by_node_id $1) "echo \"SET GLOBAL wsrep_on='ON';\" | mysql"
}

xtrabackup_install() {
    [ -z "$1" ] && die "No node ID provided, exiting"
    ssh root@$(get_host_ip_by_node_id $1) "apt-get -y install percona-xtrabackup"
}

xtrabackup_stream_from_node() {
    [ -z "$1" ] && die "No backup source node ID provided, exiting"
    ssh root@$(get_host_ip_by_node_id $1) "xtrabackup --backup --stream=tar ./ | gzip " \
        | cat - > /tmp/dbs.original.tar.gz
}

xtrabackup_from_env() {
    [ -z "$1" ] && die "No env ID provided, exiting"
    local node=$(list_nodes $1 controller | head -1)
    xtrabackup_install $node
    disable_wsrep $node
    xtrabackup_stream_from_node $node
    enable wsrep $node
}

xtrabackup_restore_to_env() {
    [ -z "$1" ] && die "No env ID provided, exiting"
    local cic
    local cics="$(list_nodes $1 controller)"
    for cic in $(echo "$cics");
    do
         ssh root@$(get_host_ip_by_node_id ${cic#node-}) \
        "mv /var/lib/mysql/grastate.dat /var/lib/mysql/grastate.old"
    done
    local primary_cic=$(echo "$cics" | head -1)
    scp /tmp/dbs.original.tar.gz \
        root@$(get_host_ip_by_node_id ${primary_cic#node-}):/var/lib/mysql
    ssh root@$(get_host_ip_by_node_id ${primary_cic#node-}) \
        "cd /var/lib/mysql;
        tar -zxvf dbs.original.tar.gz;
        chown -R mysql:mysql /var/lib/mysql;
        export OCF_RESOURCE_INSTANCE=p_mysql;
        export OCF_ROOT=/usr/lib/ocf;
        export OCF_RESKEY_socket=/var/run/mysqld/mysqld.sock;
        export OCF_RESKEY_additional_parameters="\""--wsrep-new-cluster"\"";
        /usr/lib/ocf/resource.d/mirantis/mysql-wss start;"
    db_sync ${primary_cic#node-}
    for cic in $(echo "$cics" | grep -v $primary_cic);
    do
        ssh root@$(get_host_ip_by_node_id ${cic#node-}) \
        "export OCF_RESOURCE_INSTANCE=p_mysql;
        export OCF_ROOT=/usr/lib/ocf;
        export OCF_RESKEY_socket=/var/run/mysqld/mysqld.sock;
        /usr/lib/ocf/resource.d/mirantis/mysql-wss start;"
    done
}

db_sync() {
    [ -z "$1" ] && die "No node ID provided, exiting"
    ssh root@$(get_host_ip_by_node_id $1) "keystone-manage db_sync;
nova-manage db sync;
heat-manage db_sync;
neutron-db-manage --config-file=/etc/neutron/neutron.conf upgrade head;
glance-manage db upgrade;
cinder-manage db sync"
}
{'fraction_non_alphanumeric': 0.15110759493670886, 'fraction_numerical': 0.006329113924050633, 'mean_word_length': 3.0488390712570057, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '61032', 'n_tokens_mistral': 2047, 'n_tokens_neox': 1955, 'n_words': 410}