<commit_before>#!/bin/bash
. `dirname $0`/../helper_scripts/cosmic/helperlib.sh
set -e

function usage {
  printf "Usage: %s: -m marvin_config \n" $(basename $0) >&2
}

say "Running script: $0"

function update_management_server_in_marvin_config {
  marvin_config=$1
  csip=$2

  sed -i "s/\"mgtSvrIp\": \"localhost\"/\"mgtSvrIp\": \"${csip}\"/" ${marvin_config}

  say "Management Server in Marvin Config updated to ${csip}"
}

function wait_for_port {
  hostname=$1
  port=$2
  transport=$3

  while ! nmap -Pn -p${port} ${hostname} | grep "${port}/${transport} open" 2>&1 > /dev/null; do sleep 1; done
}

function wait_for_management_server {
  hostname=$1

  say "Waiting for Cosmic Management Server to be running on ${hostname}"
  wait_for_port ${hostname} 8096 tcp
}

function wait_for_systemvm_templates {
  hostname=$1

  say "Waiting for SystemVM templates to be ready on ${hostname}"
  /data/shared/helper_scripts/cosmic/wait_template_ready.py -t ${hostname}
}

function deploy_data_center {
  marvin_config=$1

  python -m marvin.deployDataCenter -i ${marvin_config}

  say "Data center deployed"
}

function add_nsx_connectivy_to_offerings {
  csip=$1

  mysql -h ${csip} -u cloud -pcloud cloud -e "INSERT INTO cloud.ntwk_offering_service_map (network_offering_id, service, provider, created) (SELECT DISTINCT X.network_offering_id, 'Connectivity', 'NiciraNvp', X.created FROM cloud.ntwk_offering_service_map X);"
  mysql -h ${csip} -u cloud -pcloud cloud -e "INSERT INTO cloud.vpc_offering_service_map (vpc_offering_id, service, provider, created) (SELECT DISTINCT X.vpc_offering_id, 'Connectivity', 'NiciraNvp', X.created FROM cloud.vpc_offering_service_map X);"
  mysql -h ${csip} -u cloud -pcloud cloud -e "INSERT INTO cloud.ntwk_offering_service_map (network_offering_id, service, provider, created) (SELECT DISTINCT X.id, 'Connectivity', 'NiciraNvp', X.created FROM cloud.network_offerings X WHERE name = 'System-Private-Gateway-Network-Offering');"
  mysql -h ${csip} -u cloud -pcloud cloud -e "UPDATE network_offerings SET dedicated_lb_service=0, eip_associate_public_ip=0, specify_ip_ranges=1, system_only=0 WHERE name='System-Private-Gateway-Network-Offering';"
}

function add_nsx_controller_to_cosmic {
  bash -x /tmp/nsx_cosmic.sh
}

# Options
while getopts ':m:' OPTION
do
  case $OPTION in
  m)    marvin_config="$OPTARG"
        ;;
  esac
done

say "Received arguments:"
say "marvin_config = ${marvin_config}"
<commit_msg>Handle new name of default private gateway offering<commit_after>#!/bin/bash
. `dirname $0`/../helper_scripts/cosmic/helperlib.sh
set -e

function usage {
  printf "Usage: %s: -m marvin_config \n" $(basename $0) >&2
}

say "Running script: $0"

function update_management_server_in_marvin_config {
  marvin_config=$1
  csip=$2

  sed -i "s/\"mgtSvrIp\": \"localhost\"/\"mgtSvrIp\": \"${csip}\"/" ${marvin_config}

  say "Management Server in Marvin Config updated to ${csip}"
}

function wait_for_port {
  hostname=$1
  port=$2
  transport=$3

  while ! nmap -Pn -p${port} ${hostname} | grep "${port}/${transport} open" 2>&1 > /dev/null; do sleep 1; done
}

function wait_for_management_server {
  hostname=$1

  say "Waiting for Cosmic Management Server to be running on ${hostname}"
  wait_for_port ${hostname} 8096 tcp
}

function wait_for_systemvm_templates {
  hostname=$1

  say "Waiting for SystemVM templates to be ready on ${hostname}"
  /data/shared/helper_scripts/cosmic/wait_template_ready.py -t ${hostname}
}

function deploy_data_center {
  marvin_config=$1

  python -m marvin.deployDataCenter -i ${marvin_config}

  say "Data center deployed"
}

function add_nsx_connectivy_to_offerings {
  csip=$1

  mysql -h ${csip} -u cloud -pcloud cloud -e "INSERT INTO cloud.ntwk_offering_service_map (network_offering_id, service, provider, created) (SELECT DISTINCT X.network_offering_id, 'Connectivity', 'NiciraNvp', X.created FROM cloud.ntwk_offering_service_map X);"
  mysql -h ${csip} -u cloud -pcloud cloud -e "INSERT INTO cloud.vpc_offering_service_map (vpc_offering_id, service, provider, created) (SELECT DISTINCT X.vpc_offering_id, 'Connectivity', 'NiciraNvp', X.created FROM cloud.vpc_offering_service_map X);"
  mysql -h ${csip} -u cloud -pcloud cloud -e "INSERT INTO cloud.ntwk_offering_service_map (network_offering_id, service, provider, created) (SELECT DISTINCT X.id, 'Connectivity', 'NiciraNvp', X.created FROM cloud.network_offerings X WHERE name IN ('DefaultPrivateGatewayNetworkOffering', 'System-Private-Gateway-Network-Offering'));"
}

function add_nsx_controller_to_cosmic {
  bash -x /tmp/nsx_cosmic.sh
}

# Options
while getopts ':m:' OPTION
do
  case $OPTION in
  m)    marvin_config="$OPTARG"
        ;;
  esac
done

say "Received arguments:"
say "marvin_config = ${marvin_config}"

{'fraction_non_alphanumeric': 0.12292846654080135, 'fraction_numerical': 0.009230123767568701, 'mean_word_length': 4.930348258706467, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 9, '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': '4367937', 'n_tokens_mistral': 1734, 'n_tokens_neox': 1677, 'n_words': 438}