<commit_before>- job:
    name: ardana-job
    concurrent: true
    workspace: "ardana-job-$BUILD_ID"
    # the selected node needs the cloud credentials
    node: cloud-ardana-ci
    wrappers:
      - timestamps
      - build-name:
          name: '#${BUILD_NUMBER}: ${ENV,var="job_name"}/${ENV,var="model"}'

      - timeout:
          timeout: 180
          type: no-activity
          abort: true
          write-description: "Job aborted due to 180 minutes of inactivity"

    triggers:
      - timed: 'H H */2 * *'
      - pollurl:
          cron: 'H/5 * * * *'
          polling-node: cloud-trigger
          urls:
            - url: 'http://clouddata.cloud.suse.de/cgi-bin/grep/download.suse.de/ibs/Devel:/Cloud:/8:/Staging/images/iso/?regexp=x86_64'
              check-content:
                - simple: true

    logrotate:
      numToKeep: 20
      daysToKeep: 30

    parameters:
      - string:
          name: git_automation_repo
          default: https://github.com/SUSE-Cloud/automation.git
          description: >-
            The git automation repository to use

      - string:
          name: git_automation_branch
          default: master
          description: >-
            The git automation branch

      - string:
          name: model
          default: std-min
          description: >-
            The Input Model to use

      - string:
          name: job_name
          default: ''
          description: >-
            This name reserves job environment and prevents deletion at the end.

      - string:
          name: cloudsource
          default: 'SUSE-OpenStack-Cloud-8-devel-staging'
          description: >-
            This is used as input repository (from provo-clouddata) for testing

      - string:
          name: tempest_run_filter
          default: smoke
          description: >-
            Name of the filter file to use for tempest. Possible values:
            ci, compute, designate, lbaas, network, neutron-api, periodic,
            periodic-virtual, refstack, smoke, swift, tests2skip, tests-ci,
            upgrade-ci or upgrade

    builders:
      - shell: |
          set +x
          cloudsource_url=http://provo-clouddata.cloud.suse.de/repos/x86_64/$cloudsource
          cloudsource_media_build=$( curl -s $cloudsource_url/media.1/build )
          echo cloudsource=$cloudsource
          echo cloudsource URL is $cloudsource_url
          echo media build version is $cloudsource_media_build
          echo

          set -ex
          STACK_NAME=cloud-ci-ardana-job-${BUILD_NUMBER}
          if [ -n "${JOB_NAME}" ]; then
              STACK_NAME=${STACK_NAME}-${JOB_NAME}
          fi
          CLOUD_CONFIG_NAME=engcloud-cloud-ci
          cat - > stack_env <<EOF
          JOB_NAME="$JOB_NAME"
          STACK_NAME="$STACK_NAME"
          CLOUD_CONFIG_NAME="$CLOUD_CONFIG_NAME"
          EOF

          export ANSIBLE_HOST_KEY_CHECKING=False
          export ANSIBLE_KEEP_REMOTE_FILES=1
          # the name for the cloud defined in ~./config/openstack/clouds.yaml

          # init the git tree
          git clone $git_automation_repo --branch $git_automation_branch automation-git
          pushd automation-git/scripts/jenkins/ardana/


          case $model in
              standard)
                  num_controller=3
                  num_compute=3
                  ;;
              std-split|std-3cp)
                  num_controller=3
                  num_compute=1
                  ;;
              std-min)
                  num_controller=2
                  num_compute=1
                  ;;
              std-3cm)
                  num_controller=1
                  num_compute=3
                  ;;
              dac-min*)
                  num_controller=0
                  num_compute=1
                  ;;
              deployerincloud*)
                  num_controller=0
                  num_compute=2
                  ;;
              *)
                  num_controller=1
                  num_compute=2
                  ;;
          esac

          openstack --os-cloud $CLOUD_CONFIG_NAME stack create --timeout 5 --wait \
              -t heat-ardana-${model}.yaml  \
              --parameter number_of_computes=$num_compute \
              --parameter number_of_controllers=$num_controller \
              $STACK_NAME

          DEPLOYER_IP=$(openstack --os-cloud $CLOUD_CONFIG_NAME stack output show $STACK_NAME deployer-ip-floating -c output_value -f value)
          NETWORK_MGMT_ID=$(openstack --os-cloud $CLOUD_CONFIG_NAME stack output show $STACK_NAME network-mgmt-id -c output_value -f value)
          # FIXME: Use cloud-init in the used image
          sshpass -p linux ssh-copy-id -o ConnectionAttempts=120 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${DEPLOYER_IP}
          pushd ansible
          cat << EOF > hosts
          [hosts]
          $DEPLOYER_IP ansible_user=root
          EOF

          cat hosts

          cat << EOF > ardana_net_vars.yml
          ---
          deployer_mgmt_ip: $(openstack --os-cloud $CLOUD_CONFIG_NAME stack output show $STACK_NAME deployer-net-mgmt-ip -c output_value -f value)
          EOF

          echo "controller_mgmt_ips:" >> ardana_net_vars.yml
          for ip in $(openstack --os-cloud $CLOUD_CONFIG_NAME stack output show $STACK_NAME controllers-net-mgmt-ips -c output_value -f value); do
              cat << EOF >> ardana_net_vars.yml
              - $ip
          EOF
          done

          echo "compute_mgmt_ips:" >> ardana_net_vars.yml
          for ip in $(openstack --os-cloud $CLOUD_CONFIG_NAME stack output show $STACK_NAME computes-net-mgmt-ips -c output_value -f value); do
              cat << EOF >> ardana_net_vars.yml
              - $ip
          EOF
          done

          # Get the IP addresses of the dns servers from the mgmt network
          echo "mgmt_dnsservers:" >> ardana_net_vars.yml
          openstack --os-cloud $CLOUD_CONFIG_NAME port list --network $NETWORK_MGMT_ID \
                    --device-owner network:dhcp -f value -c 'Fixed IP Addresses' | \
              sed -e "s/^ip_address='\(.*\)', .*$/\1/" | \
              while read line; do echo "  - $line" >> ardana_net_vars.yml; done;

          cat ardana_net_vars.yml

          ansible-playbook -vvv -i hosts ssh-keys.yml
          ansible-playbook -vvv -i hosts -e "cloudsource=${cloudsource}" repositories.yml
          ansible-playbook -vvv -i hosts -e "deployer_floating_ip=$DEPLOYER_IP" \
                                         -e "deployer_model=${model}" \
                                         -e "tempest_run_filter=${tempest_run_filter}" \
                                         init.yml


    publishers:
      - post-tasks:
        - matches:
          - log-text: heat-ardana-
          script: |
            set -x
            . $WORKSPACE/stack_env
            if [ -z "${JOB_NAME}" ]; then
                openstack --os-cloud $CLOUD_CONFIG_NAME stack delete --wait \
                      $STACK_NAME || :
            fi
      - workspace-cleanup<commit_msg>skip workspace cleanup when the build failed<commit_after>- job:
    name: ardana-job
    concurrent: true
    workspace: "ardana-job-$BUILD_ID"
    # the selected node needs the cloud credentials
    node: cloud-ardana-ci
    wrappers:
      - timestamps
      - build-name:
          name: '#${BUILD_NUMBER}: ${ENV,var="job_name"}/${ENV,var="model"}'

      - timeout:
          timeout: 180
          type: no-activity
          abort: true
          write-description: "Job aborted due to 180 minutes of inactivity"

    triggers:
      - timed: 'H H */2 * *'
      - pollurl:
          cron: 'H/5 * * * *'
          polling-node: cloud-trigger
          urls:
            - url: 'http://clouddata.cloud.suse.de/cgi-bin/grep/download.suse.de/ibs/Devel:/Cloud:/8:/Staging/images/iso/?regexp=x86_64'
              check-content:
                - simple: true

    logrotate:
      numToKeep: 20
      daysToKeep: 30

    parameters:
      - string:
          name: git_automation_repo
          default: https://github.com/SUSE-Cloud/automation.git
          description: >-
            The git automation repository to use

      - string:
          name: git_automation_branch
          default: master
          description: >-
            The git automation branch

      - string:
          name: model
          default: std-min
          description: >-
            The Input Model to use

      - string:
          name: job_name
          default: ''
          description: >-
            This name reserves job environment and prevents deletion at the end.

      - string:
          name: cloudsource
          default: 'SUSE-OpenStack-Cloud-8-devel-staging'
          description: >-
            This is used as input repository (from provo-clouddata) for testing

      - string:
          name: tempest_run_filter
          default: smoke
          description: >-
            Name of the filter file to use for tempest. Possible values:
            ci, compute, designate, lbaas, network, neutron-api, periodic,
            periodic-virtual, refstack, smoke, swift, tests2skip, tests-ci,
            upgrade-ci or upgrade

    builders:
      - shell: |
          set +x
          cloudsource_url=http://provo-clouddata.cloud.suse.de/repos/x86_64/$cloudsource
          cloudsource_media_build=$( curl -s $cloudsource_url/media.1/build )
          echo cloudsource=$cloudsource
          echo cloudsource URL is $cloudsource_url
          echo media build version is $cloudsource_media_build
          echo

          set -ex
          STACK_NAME=cloud-ci-ardana-job-${BUILD_NUMBER}
          if [ -n "${JOB_NAME}" ]; then
              STACK_NAME=${STACK_NAME}-${JOB_NAME}
          fi
          CLOUD_CONFIG_NAME=engcloud-cloud-ci
          cat - > stack_env <<EOF
          JOB_NAME="$JOB_NAME"
          STACK_NAME="$STACK_NAME"
          CLOUD_CONFIG_NAME="$CLOUD_CONFIG_NAME"
          EOF

          export ANSIBLE_HOST_KEY_CHECKING=False
          export ANSIBLE_KEEP_REMOTE_FILES=1
          # the name for the cloud defined in ~./config/openstack/clouds.yaml

          # init the git tree
          git clone $git_automation_repo --branch $git_automation_branch automation-git
          pushd automation-git/scripts/jenkins/ardana/


          case $model in
              standard)
                  num_controller=3
                  num_compute=3
                  ;;
              std-split|std-3cp)
                  num_controller=3
                  num_compute=1
                  ;;
              std-min)
                  num_controller=2
                  num_compute=1
                  ;;
              std-3cm)
                  num_controller=1
                  num_compute=3
                  ;;
              dac-min*)
                  num_controller=0
                  num_compute=1
                  ;;
              deployerincloud*)
                  num_controller=0
                  num_compute=2
                  ;;
              *)
                  num_controller=1
                  num_compute=2
                  ;;
          esac

          openstack --os-cloud $CLOUD_CONFIG_NAME stack create --timeout 5 --wait \
              -t heat-ardana-${model}.yaml  \
              --parameter number_of_computes=$num_compute \
              --parameter number_of_controllers=$num_controller \
              $STACK_NAME

          DEPLOYER_IP=$(openstack --os-cloud $CLOUD_CONFIG_NAME stack output show $STACK_NAME deployer-ip-floating -c output_value -f value)
          NETWORK_MGMT_ID=$(openstack --os-cloud $CLOUD_CONFIG_NAME stack output show $STACK_NAME network-mgmt-id -c output_value -f value)
          # FIXME: Use cloud-init in the used image
          sshpass -p linux ssh-copy-id -o ConnectionAttempts=120 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${DEPLOYER_IP}
          pushd ansible
          cat << EOF > hosts
          [hosts]
          $DEPLOYER_IP ansible_user=root
          EOF

          cat hosts

          cat << EOF > ardana_net_vars.yml
          ---
          deployer_mgmt_ip: $(openstack --os-cloud $CLOUD_CONFIG_NAME stack output show $STACK_NAME deployer-net-mgmt-ip -c output_value -f value)
          EOF

          echo "controller_mgmt_ips:" >> ardana_net_vars.yml
          for ip in $(openstack --os-cloud $CLOUD_CONFIG_NAME stack output show $STACK_NAME controllers-net-mgmt-ips -c output_value -f value); do
              cat << EOF >> ardana_net_vars.yml
              - $ip
          EOF
          done

          echo "compute_mgmt_ips:" >> ardana_net_vars.yml
          for ip in $(openstack --os-cloud $CLOUD_CONFIG_NAME stack output show $STACK_NAME computes-net-mgmt-ips -c output_value -f value); do
              cat << EOF >> ardana_net_vars.yml
              - $ip
          EOF
          done

          # Get the IP addresses of the dns servers from the mgmt network
          echo "mgmt_dnsservers:" >> ardana_net_vars.yml
          openstack --os-cloud $CLOUD_CONFIG_NAME port list --network $NETWORK_MGMT_ID \
                    --device-owner network:dhcp -f value -c 'Fixed IP Addresses' | \
              sed -e "s/^ip_address='\(.*\)', .*$/\1/" | \
              while read line; do echo "  - $line" >> ardana_net_vars.yml; done;

          cat ardana_net_vars.yml

          ansible-playbook -vvv -i hosts ssh-keys.yml
          ansible-playbook -vvv -i hosts -e "cloudsource=${cloudsource}" repositories.yml
          ansible-playbook -vvv -i hosts -e "deployer_floating_ip=$DEPLOYER_IP" \
                                         -e "deployer_model=${model}" \
                                         -e "tempest_run_filter=${tempest_run_filter}" \
                                         init.yml


    publishers:
      - post-tasks:
        - matches:
          - log-text: heat-ardana-
          script: |
            set -x
            . $WORKSPACE/stack_env
            if [ -z "${JOB_NAME}" ]; then
                openstack --os-cloud $CLOUD_CONFIG_NAME stack delete --wait \
                      $STACK_NAME || :
            fi
      - workspace-cleanup:
          clean-if:
            - failure: false
            - aborted: false
            - unstable: false
{'fraction_non_alphanumeric': 0.08905834615922764, 'fraction_numerical': 0.006436266965160207, 'mean_word_length': 1.4986890403775563, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 45, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2117715', 'n_tokens_mistral': 4282, 'n_tokens_neox': 4058, 'n_words': 954}