Skip to content
Snippets Groups Projects

How to use infrastructure-entity-exporter?

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by František Řezníček
    Edited
    .gitlab-ci.yml 2.00 KiB
    stages:
      - entities-dump
      - push-state
    
    # common part
    # ---------------------------------------------------------------------------
    image:
      name: registry.gitlab.ics.muni.cz:443/cloud/infrastructure-entity-exporter:latest
      entrypoint: [""]
    
    before_script:
      - source "${OSTACK_RC_FILE}"
      - openstack versions show | grep identity
    
    variables:
      ENTITY_DUMP_DIR: "_dump/openstack"
    
    .common-artifacts: &common-artifacts
      artifacts:
        expire_in: 2 mo
        when: always
        name: cloud-entities-dump-${CI_BUILD_NAME}-${CI_BUILD_REF_NAME}-data
        paths:
          - "*.log"
          - "${ENTITY_DUMP_DIR}/"
    
    .common-only: &common-only
      only:
        - schedules
    
    # entities-dump
    # ---------------------------------------------------------------------------
    entities-dump:
      <<: *common-artifacts
      <<: *common-only
      variables:
        ENTITY: "domain user project image flavor server mapping quota volume service region hypervisor floating-ip subnet network router"
      stage: entities-dump
      script:
        - ostack-entity-dump.sh "${ENTITY_DUMP_DIR}" "${ENTITY}"
        - ostack-entity-normalize.sh "${ENTITY_DUMP_DIR}" '*.json'
    
    # push entities
    # ---------------------------------------------------------------------------
    push-state:
      <<: *common-artifacts
      <<: *common-only
      stage: push-state
      variables:
        REPO_DIR: _repo
      before_script:
        - git config --global user.email "prod-ostrava-cloud-entities-dump@ci.cz"
        - git config --global user.name "ci-prod-ostrava-cloud-entities-dump"
        - git clone "https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git" ${REPO_DIR}
    
        - rm -rf "${ENTITY_DUMP_DIR}/__raw"
        - rm -rf ${REPO_DIR}/$(basename "${ENTITY_DUMP_DIR}")
      script:
        - mv -f "${ENTITY_DUMP_DIR}" ${REPO_DIR}
        - cd ${REPO_DIR}
        - git add .
        - >
          if [ "$(git status -s | wc -l)" -gt "0" ]; then
            git commit -m "Cloud entities dump $(date +'%Y-%m-%dT%H:%M:%S')"
            git push "https://oauth2:$PULL_PUSH_TOKEN@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git" "${CI_DEFAULT_BRANCH}"
          fi
    README.md 1.16 KiB
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment