diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000000..a07b39fe3e --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,144 @@ +edit:dependencies: +- changed-files: + - any-glob-to-any-file: + - 'go.mod' + - 'go.sum' + - '.github/dependabot.yml' +edit:actions: +- changed-files: + - any-glob-to-any-file: + - '.github/**' +edit:gophercloud: +- changed-files: + - any-glob-to-any-file: + - '*.go' + - 'testing/**' + - 'pagination/**' +edit:openstack: +- changed-files: + - any-glob-to-any-file: + - 'openstack/*' + - 'openstack/testing/**' +edit:baremetal: +- changed-files: + - any-glob-to-any-file: + - 'openstack/baremetal/**' + - 'internal/acceptance/openstack/baremetal/**' +edit:baremetalintrospection: +- changed-files: + - any-glob-to-any-file: + - 'openstack/baremetalintrospection/**' +edit:blockstorage: +- changed-files: + - any-glob-to-any-file: + - 'openstack/blockstorage/**' + - 'internal/acceptance/openstack/blockstorage/**' +edit:common: +- changed-files: + - any-glob-to-any-file: + - 'openstack/common/**' +edit:compute: +- changed-files: + - any-glob-to-any-file: + - 'openstack/compute/**' + - 'internal/acceptance/openstack/compute/**' +edit:config: +- changed-files: + - any-glob-to-any-file: + - 'openstack/config/**' +edit:container: +- changed-files: + - any-glob-to-any-file: + - 'openstack/container/**' + - 'internal/acceptance/openstack/container/**' +edit:containerinfra: +- changed-files: + - any-glob-to-any-file: + - 'openstack/containerinfra/**' + - 'internal/acceptance/openstack/containerinfra/**' +edit:db: +- changed-files: + - any-glob-to-any-file: + - 'openstack/db/**' + - 'internal/acceptance/openstack/db/**' +edit:dns: +- changed-files: + - any-glob-to-any-file: + - 'openstack/dns/**' + - 'internal/acceptance/openstack/dns/**' +edit:identity: +- changed-files: + - any-glob-to-any-file: + - 'openstack/identity/**' + - 'internal/acceptance/openstack/identity/**' +edit:image: +- changed-files: + - any-glob-to-any-file: + - 'openstack/image/**' + - 'internal/acceptance/openstack/image/**' +edit:keymanager: +- changed-files: + - any-glob-to-any-file: + - 'openstack/keymanager/**' + - 'internal/acceptance/openstack/keymanager/**' +edit:loadbalancer: +- changed-files: + - any-glob-to-any-file: + - 'openstack/loadbalancer/**' + - 'internal/acceptance/openstack/loadbalancer/**' +edit:messaging: +- changed-files: + - any-glob-to-any-file: + - 'openstack/messaging/**' + - 'internal/acceptance/openstack/messaging/**' +edit:networking: +- changed-files: + - any-glob-to-any-file: + - 'openstack/networking/**' + - 'internal/acceptance/openstack/networking/**' +edit:objectstorage: +- changed-files: + - any-glob-to-any-file: + - 'openstack/objectstorage/**' + - 'internal/acceptance/openstack/objectstorage/**' +edit:orchestration: +- changed-files: + - any-glob-to-any-file: + - 'openstack/orchestration/**' + - 'internal/acceptance/openstack/orchestration/**' +edit:placement: +- changed-files: + - any-glob-to-any-file: + - 'openstack/placement/**' + - 'internal/acceptance/openstack/placement/**' +edit:sharedfilesystems: +- changed-files: + - any-glob-to-any-file: + - 'openstack/sharedfilesystems/**' + - 'internal/acceptance/openstack/sharedfilesystems/**' +edit:testinfra: +- changed-files: + - any-glob-to-any-file: + - 'testhelper/**' + - 'internal/acceptance/*' + - 'internal/acceptance/openstack/*' + - 'internal/acceptance/clients/**' + - 'internal/acceptance/tools/**' + - '.github/workflows/functional-*.yaml' + - '.github/workflows/unit.yaml' + - '.github/workflows/lint.yaml' + - 'script/**' +edit:utils: +- changed-files: + - any-glob-to-any-file: + - 'openstack/utils/**' +edit:workflow: +- changed-files: + - any-glob-to-any-file: + - 'openstack/workflow/**' + - 'internal/acceptance/openstack/workflow/**' + +v1: +- base-branch: 'v1' +v2: +- base-branch: 'v2' diff --git a/.github/labels.yaml b/.github/labels.yaml new file mode 100644 index 0000000000..4f888b4d4f --- /dev/null +++ b/.github/labels.yaml @@ -0,0 +1,113 @@ +- color: '30ABB9' + description: This PR will be backported to v1 + name: backport-v1 +- color: 'E99695' + description: This PR will be backported to v2 + name: backport-v2 +- color: 'BCF611' + description: A good issue for first-time contributors + name: good first issue +- color: '9E1957' + description: Breaking change + name: semver:major +- color: 'FBCA04' + description: Backwards-compatible change + name: semver:minor +- color: '6E7624' + description: No API change + name: semver:patch +- color: 'D73A4A' + description: Do not merge + name: hold +- color: 'F9D0C4' + description: Additional information requested + name: needinfo + +- color: '30ABB9' + description: This PR targets v1 + name: v1 +- color: 'E99695' + description: This PR targets v2 + name: v2 + +- color: '000000' + description: This PR updates dependencies + name: edit:dependencies +- color: '000000' + description: This PR updates GitHub Actions code + name: edit:actions +- color: '000000' + description: This PR updates common Gophercloud code + name: edit:gophercloud +- color: '000000' + description: This PR updates common OpenStack code + name: edit:openstack +- color: '000000' + description: This PR updates baremetal code + name: edit:baremetal +- color: '000000' + description: This PR updates baremetalintrospection code + name: edit:baremetalintrospection +- color: '000000' + description: This PR updates blockstorage code + name: edit:blockstorage +- color: '000000' + description: This PR updates common code + name: edit:common +- color: '000000' + description: This PR updates compute code + name: edit:compute +- color: '000000' + description: This PR updates config code + name: edit:config +- color: '000000' + description: This PR updates container code + name: edit:container +- color: '000000' + description: This PR updates containerinfra code + name: edit:containerinfra +- color: '000000' + description: This PR updates db code + name: edit:db +- color: '000000' + description: This PR updates dns code + name: edit:dns +- color: '000000' + description: This PR updates identity code + name: edit:identity +- color: '000000' + description: This PR updates image code + name: edit:image +- color: '000000' + description: This PR updates keymanager code + name: edit:keymanager +- color: '000000' + description: This PR updates loadbalancer code + name: edit:loadbalancer +- color: '000000' + description: This PR updates messaging code + name: edit:messaging +- color: '000000' + description: This PR updates networking code + name: edit:networking +- color: '000000' + description: This PR updates objectstorage code + name: edit:objectstorage +- color: '000000' + description: This PR updates orchestration code + name: edit:orchestration +- color: '000000' + description: This PR updates placement code + name: edit:placement +- color: '000000' + description: This PR updates sharedfilesystems code + name: edit:sharedfilesystems +- color: '000000' + description: This PR updates testing code + name: edit:testing +- color: '000000' + description: This PR updates utils code + name: edit:utils +- color: '000000' + description: This PR updates workflow code + name: edit:workflow diff --git a/.github/semver-labels.yaml b/.github/semver-labels.yaml deleted file mode 100644 index 7e9c8811b5..0000000000 --- a/.github/semver-labels.yaml +++ /dev/null @@ -1,9 +0,0 @@ -- name: semver:major - description: Breaking change - color: '9E1957' -- name: semver:minor - description: Backwards-compatible change - color: 'FBCA04' -- name: semver:patch - description: No API change - color: '6E7624' diff --git a/.github/workflows/check-pr-labels.yaml b/.github/workflows/check-pr-labels.yaml new file mode 100644 index 0000000000..4fbb7fc0b8 --- /dev/null +++ b/.github/workflows/check-pr-labels.yaml @@ -0,0 +1,21 @@ +name: Ready +on: + pull_request_target: + types: + - labeled + - opened + - reopened + - synchronize + - unlabeled + +jobs: + hold: + if: github.event.pull_request.merged == false + runs-on: ubuntu-latest + steps: + - if: > + contains(github.event.pull_request.labels.*.name, 'hold') + run: 'false' + - if: > + !contains(github.event.pull_request.labels.*.name, 'hold') + run: 'true' diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index db762de4d7..9e1b8711dd 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -1,13 +1,6 @@ name: "CodeQL" -on: - push: - branches: [ master ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ master ] - schedule: - - cron: '18 8 * * 6' +on: [push, pull_request] jobs: analyze: @@ -25,15 +18,15 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@v3 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/functional-baremetal.yaml b/.github/workflows/functional-baremetal.yaml index 0ae2f53a29..c0f51e36bb 100644 --- a/.github/workflows/functional-baremetal.yaml +++ b/.github/workflows/functional-baremetal.yaml @@ -3,8 +3,6 @@ on: pull_request: paths: - '**baremetal**' - schedule: - - cron: '0 0 */3 * *' jobs: functional-baremetal: strategy: @@ -12,30 +10,39 @@ jobs: matrix: name: ["master"] openstack_version: ["master"] - ubuntu_version: ["20.04"] + ubuntu_version: ["22.04"] + os_system_scope: ["all"] include: - - name: "zed" - openstack_version: "stable/zed" - ubuntu_version: "20.04" - - name: "yoga" - openstack_version: "stable/yoga" - ubuntu_version: "20.04" - - name: "xena" - openstack_version: "stable/xena" - ubuntu_version: "20.04" - - name: "wallaby" - openstack_version: "stable/wallaby" - ubuntu_version: "20.04" - - name: "victoria" - openstack_version: "stable/victoria" - ubuntu_version: "20.04" + - name: "caracal" + openstack_version: "stable/2024.1" + ubuntu_version: "22.04" + os_system_scope: "" + - name: "bobcat" + openstack_version: "stable/2023.2" + ubuntu_version: "22.04" + os_system_scope: "" + - name: "antelope" + openstack_version: "stable/2023.1" + ubuntu_version: "22.04" + os_system_scope: "" runs-on: ubuntu-${{ matrix.ubuntu_version }} name: Deploy OpenStack ${{ matrix.name }} with Ironic and run baremetal acceptance tests steps: - name: Checkout Gophercloud - uses: actions/checkout@v3 + uses: actions/checkout@v4 + - name: Workaround for grub-efi-amd64-signed + run: sudo rm /var/cache/debconf/config.dat + shell: bash + if: matrix.ubuntu_version == '20.04' + - name: Ensure update and upgrade + run: sudo apt update && sudo apt -y upgrade + shell: bash + if: matrix.ubuntu_version == '20.04' + - name: Work around broken dnsmasq + run: sudo apt-get purge -y dnsmasq-base + if: matrix.ubuntu_version == '22.04' - name: Deploy devstack - uses: EmilienM/devstack-action@v0.11 + uses: EmilienM/devstack-action@e82a9cbead099cba72f99537e82a360c3e319c69 with: branch: ${{ matrix.openstack_version }} conf_overrides: | @@ -74,7 +81,7 @@ jobs: SWIFT_TEMPURL_KEY=secretkey enabled_services: 'ir-api,ir-cond,s-account,s-container,s-object,s-proxy,q-svc,q-agt,q-dhcp,q-l3,q-meta,-cinder,-c-sch,-c-api,-c-vol,-c-bak,-ovn,-ovn-controller,-ovn-northd,-q-ovn-metadata-agent' - name: Checkout go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '^1.15' - name: Run Gophercloud acceptance tests @@ -83,12 +90,14 @@ jobs: DEVSTACK_PATH: ${{ github.workspace }}/devstack ACCEPTANCE_TESTS_FILTER: '^.*baremetal(.(?!noauth).*)?$' OS_BRANCH: ${{ matrix.openstack_version }} + # TODO(dtantsur): default to "all" when no longer supporting versions before 2024.1 + OS_SYSTEM_SCOPE: ${{ matrix.os_system_scope }} - name: Generate logs on failure run: ./script/collectlogs if: failure() - name: Upload logs artifacts on failure if: failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: functional-baremetal-${{ matrix.name }} path: /tmp/devstack-logs/* diff --git a/.github/workflows/functional-basic.yaml b/.github/workflows/functional-basic.yaml index 727fb9d1e0..1030ac20fd 100644 --- a/.github/workflows/functional-basic.yaml +++ b/.github/workflows/functional-basic.yaml @@ -6,8 +6,6 @@ on: - '**.md' - '**.gitignore' - '**LICENSE' - schedule: - - cron: '0 0 */3 * *' jobs: functional-basic: strategy: @@ -15,49 +13,43 @@ jobs: matrix: name: ["master"] openstack_version: ["master"] - ubuntu_version: ["20.04"] + ubuntu_version: ["22.04"] include: - - name: "zed" - openstack_version: "stable/zed" - ubuntu_version: "20.04" - - name: "yoga" - openstack_version: "stable/yoga" - ubuntu_version: "20.04" - - name: "xena" - openstack_version: "stable/xena" - ubuntu_version: "20.04" - - name: "wallaby" - openstack_version: "stable/wallaby" - ubuntu_version: "20.04" - - name: "victoria" - openstack_version: "stable/victoria" - ubuntu_version: "20.04" + - name: "caracal" + openstack_version: "stable/2024.1" + ubuntu_version: "22.04" + - name: "bobcat" + openstack_version: "stable/2023.2" + ubuntu_version: "22.04" + - name: "antelope" + openstack_version: "stable/2023.1" + ubuntu_version: "22.04" runs-on: ubuntu-${{ matrix.ubuntu_version }} name: Deploy OpenStack ${{ matrix.name }} with defaults and run basic acceptance tests steps: - name: Checkout Gophercloud - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Deploy devstack - uses: EmilienM/devstack-action@v0.11 + uses: EmilienM/devstack-action@e82a9cbead099cba72f99537e82a360c3e319c69 with: branch: ${{ matrix.openstack_version }} enabled_services: 's-account,s-container,s-object,s-proxy' - name: Checkout go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '^1.15' - name: Run Gophercloud acceptance tests run: ./script/acceptancetest env: DEVSTACK_PATH: ${{ github.workspace }}/devstack - ACCEPTANCE_TESTS_FILTER: '^acceptance/openstack$' + ACCEPTANCE_TESTS_FILTER: '^internal/acceptance/openstack$' OS_BRANCH: ${{ matrix.openstack_version }} - name: Generate logs on failure run: ./script/collectlogs if: failure() - name: Upload logs artifacts on failure if: failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: functional-basic-${{ matrix.name }} path: /tmp/devstack-logs/* diff --git a/.github/workflows/functional-blockstorage.yaml b/.github/workflows/functional-blockstorage.yaml index 07624e7cb1..84b88b2b34 100644 --- a/.github/workflows/functional-blockstorage.yaml +++ b/.github/workflows/functional-blockstorage.yaml @@ -3,8 +3,6 @@ on: pull_request: paths: - '**blockstorage**' - schedule: - - cron: '0 0 */3 * *' jobs: functional-blockstorage: strategy: @@ -12,37 +10,31 @@ jobs: matrix: name: ["master"] openstack_version: ["master"] - ubuntu_version: ["20.04"] + ubuntu_version: ["22.04"] include: - - name: "zed" - openstack_version: "stable/zed" - ubuntu_version: "20.04" - - name: "yoga" - openstack_version: "stable/yoga" - ubuntu_version: "20.04" - - name: "xena" - openstack_version: "stable/xena" - ubuntu_version: "20.04" - - name: "wallaby" - openstack_version: "stable/wallaby" - ubuntu_version: "20.04" - - name: "victoria" - openstack_version: "stable/victoria" - ubuntu_version: "20.04" + - name: "caracal" + openstack_version: "stable/2024.1" + ubuntu_version: "22.04" + - name: "bobcat" + openstack_version: "stable/2023.2" + ubuntu_version: "22.04" + - name: "antelope" + openstack_version: "stable/2023.1" + ubuntu_version: "22.04" runs-on: ubuntu-${{ matrix.ubuntu_version }} name: Deploy OpenStack ${{ matrix.name }} with Cinder and run blockstorage acceptance tests steps: - name: Checkout Gophercloud - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Deploy devstack - uses: EmilienM/devstack-action@v0.11 + uses: EmilienM/devstack-action@e82a9cbead099cba72f99537e82a360c3e319c69 with: branch: ${{ matrix.openstack_version }} conf_overrides: | - CINDER_ISCSI_HELPER=tgtadm + CINDER_ISCSI_HELPER=lioadm enabled_services: 's-account,s-container,s-object,s-proxy,c-bak' - name: Checkout go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '^1.15' - name: Run Gophercloud acceptance tests @@ -56,7 +48,7 @@ jobs: if: failure() - name: Upload logs artifacts on failure if: failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: functional-blockstorage-${{ matrix.name }} path: /tmp/devstack-logs/* diff --git a/.github/workflows/functional-clustering.yaml b/.github/workflows/functional-clustering.yaml index 110920487b..fb777b1ade 100644 --- a/.github/workflows/functional-clustering.yaml +++ b/.github/workflows/functional-clustering.yaml @@ -3,8 +3,6 @@ on: pull_request: paths: - '**clustering**' - schedule: - - cron: '0 0 */3 * *' jobs: functional-clustering: strategy: @@ -14,28 +12,23 @@ jobs: openstack_version: ["master"] ubuntu_version: ["22.04"] include: - - name: "zed" - openstack_version: "stable/zed" - ubuntu_version: "20.04" - - name: "yoga" - openstack_version: "stable/yoga" - ubuntu_version: "20.04" - - name: "xena" - openstack_version: "stable/xena" - ubuntu_version: "20.04" - - name: "wallaby" - openstack_version: "stable/wallaby" - ubuntu_version: "20.04" - - name: "victoria" - openstack_version: "stable/victoria" - ubuntu_version: "20.04" +## Senlin has not made a caracal release yet +# - name: "caracal" +# openstack_version: "stable/2024.1" +# ubuntu_version: "22.04" + - name: "bobcat" + openstack_version: "stable/2023.2" + ubuntu_version: "22.04" + - name: "antelope" + openstack_version: "stable/2023.1" + ubuntu_version: "22.04" runs-on: ubuntu-${{ matrix.ubuntu_version }} name: Deploy OpenStack ${{ matrix.name }} with Senlin and run clustering acceptance tests steps: - name: Checkout Gophercloud - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Deploy devstack - uses: EmilienM/devstack-action@v0.11 + uses: EmilienM/devstack-action@e82a9cbead099cba72f99537e82a360c3e319c69 with: branch: ${{ matrix.openstack_version }} conf_overrides: | @@ -43,7 +36,7 @@ jobs: enable_plugin zaqar https://github.com/openstack/zaqar ${{ matrix.openstack_version }} ZAQARCLIENT_BRANCH=${{ matrix.openstack_version }} - name: Checkout go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '^1.15' - name: Run Gophercloud acceptance tests @@ -57,7 +50,7 @@ jobs: if: failure() - name: Upload logs artifacts on failure if: failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: functional-clustering-${{ matrix.name }} path: /tmp/devstack-logs/* diff --git a/.github/workflows/functional-compute.yaml b/.github/workflows/functional-compute.yaml index 188064e4dc..1804224221 100644 --- a/.github/workflows/functional-compute.yaml +++ b/.github/workflows/functional-compute.yaml @@ -3,8 +3,6 @@ on: pull_request: paths: - '**compute**' - schedule: - - cron: '0 0 */3 * *' jobs: functional-compute: strategy: @@ -12,36 +10,30 @@ jobs: matrix: name: ["master"] openstack_version: ["master"] - ubuntu_version: ["20.04"] + ubuntu_version: ["22.04"] include: - - name: "zed" - openstack_version: "stable/zed" - ubuntu_version: "20.04" - - name: "yoga" - openstack_version: "stable/yoga" - ubuntu_version: "20.04" - - name: "xena" - openstack_version: "stable/xena" - ubuntu_version: "20.04" - - name: "wallaby" - openstack_version: "stable/wallaby" - ubuntu_version: "20.04" - - name: "victoria" - openstack_version: "stable/victoria" - ubuntu_version: "20.04" + - name: "caracal" + openstack_version: "stable/2024.1" + ubuntu_version: "22.04" + - name: "bobcat" + openstack_version: "stable/2023.2" + ubuntu_version: "22.04" + - name: "antelope" + openstack_version: "stable/2023.1" + ubuntu_version: "22.04" runs-on: ubuntu-${{ matrix.ubuntu_version }} name: Deploy OpenStack ${{ matrix.name }} with Nova and run compute acceptance tests steps: - name: Checkout Gophercloud - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Deploy devstack - uses: EmilienM/devstack-action@v0.11 + uses: EmilienM/devstack-action@e82a9cbead099cba72f99537e82a360c3e319c69 with: branch: ${{ matrix.openstack_version }} conf_overrides: | - CINDER_ISCSI_HELPER=tgtadm + CINDER_ISCSI_HELPER=lioadm - name: Checkout go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '^1.15' - name: Run Gophercloud acceptance tests @@ -55,7 +47,7 @@ jobs: if: failure() - name: Upload logs artifacts on failure if: failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: functional-compute-${{ matrix.name }} path: /tmp/devstack-logs/* diff --git a/.github/workflows/functional-containerinfra.yaml b/.github/workflows/functional-containerinfra.yaml index 4f1aca8db3..269bcd4584 100644 --- a/.github/workflows/functional-containerinfra.yaml +++ b/.github/workflows/functional-containerinfra.yaml @@ -3,8 +3,6 @@ on: pull_request: paths: - '**containerinfra**' - schedule: - - cron: '0 0 */3 * *' jobs: functional-containerinfra: strategy: @@ -13,41 +11,35 @@ jobs: include: - name: "master" openstack_version: "master" - ubuntu_version: "20.04" + ubuntu_version: "22.04" devstack_conf_overrides: | enable_plugin magnum https://github.com/openstack/magnum master - - name: "zed" - openstack_version: "stable/zed" - ubuntu_version: "20.04" + MAGNUMCLIENT_BRANCH=master + - name: "caracal" + openstack_version: "stable/2024.1" + ubuntu_version: "22.04" devstack_conf_overrides: | - enable_plugin magnum https://github.com/openstack/magnum stable/zed - - name: "yoga" - openstack_version: "stable/yoga" - ubuntu_version: "20.04" + enable_plugin magnum https://github.com/openstack/magnum stable/2024.1 + MAGNUMCLIENT_BRANCH=stable/2024.1 + - name: "bobcat" + openstack_version: "stable/2023.2" + ubuntu_version: "22.04" devstack_conf_overrides: | - enable_plugin magnum https://github.com/openstack/magnum stable/yoga - - name: "xena" - openstack_version: "stable/xena" - ubuntu_version: "20.04" + enable_plugin magnum https://github.com/openstack/magnum stable/2023.2 + MAGNUMCLIENT_BRANCH=stable/2023.2 + - name: "antelope" + openstack_version: "stable/2023.1" + ubuntu_version: "22.04" devstack_conf_overrides: | - enable_plugin magnum https://github.com/openstack/magnum stable/xena - - name: "wallaby" - openstack_version: "stable/wallaby" - ubuntu_version: "20.04" - devstack_conf_overrides: | - enable_plugin magnum https://github.com/openstack/magnum stable/wallaby - - name: "victoria" - openstack_version: "stable/victoria" - ubuntu_version: "20.04" - devstack_conf_overrides: | - enable_plugin magnum https://github.com/openstack/magnum stable/victoria + enable_plugin magnum https://github.com/openstack/magnum stable/2023.1 + MAGNUMCLIENT_BRANCH=stable/2023.1 runs-on: ubuntu-${{ matrix.ubuntu_version }} name: Deploy OpenStack ${{ matrix.name }} with Magnum and run containerinfra acceptance tests steps: - name: Checkout Gophercloud - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Deploy devstack - uses: EmilienM/devstack-action@v0.11 + uses: EmilienM/devstack-action@e82a9cbead099cba72f99537e82a360c3e319c69 with: branch: ${{ matrix.openstack_version }} conf_overrides: | @@ -56,11 +48,10 @@ jobs: GLANCE_LIMIT_IMAGE_SIZE_TOTAL=5000 SWIFT_MAX_FILE_SIZE=5368709122 KEYSTONE_ADMIN_ENDPOINT=true - MAGNUMCLIENT_BRANCH=${{ matrix.openstack_version }} ${{ matrix.devstack_conf_overrides }} enabled_services: 'h-eng,h-api,h-api-cfn,h-api-cw' - name: Checkout go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '^1.15' - name: Run Gophercloud acceptance tests @@ -74,7 +65,7 @@ jobs: if: failure() - name: Upload logs artifacts on failure if: failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: functional-containerinfra-${{ matrix.name }} path: /tmp/devstack-logs/* diff --git a/.github/workflows/functional-dns.yaml b/.github/workflows/functional-dns.yaml index ec9b829d96..44e1d017ea 100644 --- a/.github/workflows/functional-dns.yaml +++ b/.github/workflows/functional-dns.yaml @@ -4,8 +4,6 @@ on: paths: - '**openstack/dns**' - '**functional-dns.yaml' - schedule: - - cron: '0 0 */3 * *' jobs: functional-dns: strategy: @@ -14,48 +12,30 @@ jobs: include: - name: "master" openstack_version: "master" - ubuntu_version: "20.04" - devstack_conf_overrides: | - enable_plugin designate https://github.com/openstack/designate master - - name: "zed" - openstack_version: "stable/zed" - ubuntu_version: "20.04" - devstack_conf_overrides: | - enable_plugin designate https://github.com/openstack/designate stable/zed - - name: "yoga" - openstack_version: "stable/yoga" - ubuntu_version: "20.04" - devstack_conf_overrides: | - enable_plugin designate https://github.com/openstack/designate stable/yoga - - name: "xena" - openstack_version: "stable/xena" - ubuntu_version: "20.04" - devstack_conf_overrides: | - enable_plugin designate https://github.com/openstack/designate stable/xena - - name: "wallaby" - openstack_version: "stable/wallaby" - ubuntu_version: "20.04" - devstack_conf_overrides: | - enable_plugin designate https://github.com/openstack/designate stable/wallaby - - name: "victoria" - openstack_version: "stable/victoria" - ubuntu_version: "20.04" - devstack_conf_overrides: | - enable_plugin designate https://github.com/openstack/designate stable/victoria + ubuntu_version: "22.04" + - name: "caracal" + openstack_version: "stable/2024.1" + ubuntu_version: "22.04" + - name: "bobcat" + openstack_version: "stable/2023.2" + ubuntu_version: "22.04" + - name: "antelope" + openstack_version: "stable/2023.1" + ubuntu_version: "22.04" runs-on: ubuntu-${{ matrix.ubuntu_version }} name: Deploy OpenStack ${{ matrix.name }} with Designate and run dns acceptance tests steps: - name: Checkout Gophercloud - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Deploy devstack - uses: EmilienM/devstack-action@v0.11 + uses: EmilienM/devstack-action@e82a9cbead099cba72f99537e82a360c3e319c69 with: branch: ${{ matrix.openstack_version }} conf_overrides: | - ${{ matrix.devstack_conf_overrides }} + enable_plugin designate https://github.com/openstack/designate ${{ matrix.openstack_version }} enabled_services: 'designate,designate-central,designate-api,designate-worker,designate-producer,designate-mdns' - name: Checkout go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '^1.15' - name: Run Gophercloud acceptance tests @@ -69,7 +49,7 @@ jobs: if: failure() - name: Upload logs artifacts on failure if: failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: functional-dns-${{ matrix.name }} path: /tmp/devstack-logs/* diff --git a/.github/workflows/functional-fwaas_v2.yaml b/.github/workflows/functional-fwaas_v2.yaml index 4c0b4463ee..535bb58e86 100644 --- a/.github/workflows/functional-fwaas_v2.yaml +++ b/.github/workflows/functional-fwaas_v2.yaml @@ -3,8 +3,6 @@ on: pull_request: paths: - '**networking/extensions/fwaas_v2**' - schedule: - - cron: '0 0 */3 * *' jobs: functional-fwaas_v2: strategy: @@ -14,19 +12,22 @@ jobs: openstack_version: ["master"] ubuntu_version: ["22.04"] include: + - name: "caracal" + openstack_version: "stable/2024.1" + ubuntu_version: "22.04" + - name: "bobcat" + openstack_version: "stable/2023.2" + ubuntu_version: "22.04" - name: "antelope" openstack_version: "stable/2023.1" ubuntu_version: "22.04" - - name: "zed" - openstack_version: "stable/zed" - ubuntu_version: "22.04" runs-on: ubuntu-${{ matrix.ubuntu_version }} name: Deploy OpenStack ${{ matrix.name }} with enabled FWaaS_v2 and run networking acceptance tests steps: - name: Checkout Gophercloud - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Deploy devstack - uses: EmilienM/devstack-action@v0.11 + uses: EmilienM/devstack-action@e82a9cbead099cba72f99537e82a360c3e319c69 with: branch: ${{ matrix.openstack_version }} conf_overrides: | @@ -38,7 +39,7 @@ jobs: Q_TUNNEL_TYPES=vxlan,gre enabled_services: 'q-svc,q-agt,q-dhcp,q-l3,q-meta,q-fwaas-v2,-cinder,-horizon,-tempest,-swift,-c-sch,-c-api,-c-vol,-c-bak,-ovn,-ovn-controller,-ovn-northd,-q-ovn-metadata-agent' - name: Checkout go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '^1.15' - name: Run Gophercloud acceptance tests @@ -52,7 +53,7 @@ jobs: if: failure() - name: Upload logs artifacts on failure if: failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: functional-fwaas_v2-${{ matrix.name }} path: /tmp/devstack-logs/* diff --git a/.github/workflows/functional-identity.yaml b/.github/workflows/functional-identity.yaml index 9cf1a44b8b..41863d8b12 100644 --- a/.github/workflows/functional-identity.yaml +++ b/.github/workflows/functional-identity.yaml @@ -3,8 +3,6 @@ on: pull_request: paths: - '**identity**' - schedule: - - cron: '0 0 */3 * *' jobs: functional-identity: strategy: @@ -12,34 +10,28 @@ jobs: matrix: name: ["master"] openstack_version: ["master"] - ubuntu_version: ["20.04"] + ubuntu_version: ["22.04"] include: - - name: "zed" - openstack_version: "stable/zed" - ubuntu_version: "20.04" - - name: "yoga" - openstack_version: "stable/yoga" - ubuntu_version: "20.04" - - name: "xena" - openstack_version: "stable/xena" - ubuntu_version: "20.04" - - name: "wallaby" - openstack_version: "stable/wallaby" - ubuntu_version: "20.04" - - name: "victoria" - openstack_version: "stable/victoria" - ubuntu_version: "20.04" + - name: "caracal" + openstack_version: "stable/2024.1" + ubuntu_version: "22.04" + - name: "bobcat" + openstack_version: "stable/2023.2" + ubuntu_version: "22.04" + - name: "antelope" + openstack_version: "stable/2023.1" + ubuntu_version: "22.04" runs-on: ubuntu-${{ matrix.ubuntu_version }} name: Deploy OpenStack ${{ matrix.name }} with Keystone and run identity acceptance tests steps: - name: Checkout Gophercloud - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Deploy devstack - uses: EmilienM/devstack-action@v0.11 + uses: EmilienM/devstack-action@e82a9cbead099cba72f99537e82a360c3e319c69 with: branch: ${{ matrix.openstack_version }} - name: Checkout go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '^1.15' - name: Run Gophercloud acceptance tests @@ -53,7 +45,7 @@ jobs: if: failure() - name: Upload logs artifacts on failure if: failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: functional-identity-${{ matrix.name }} path: /tmp/devstack-logs/* diff --git a/.github/workflows/functional-imageservice.yaml b/.github/workflows/functional-imageservice.yaml index 7b1c3fefd9..abd020d26f 100644 --- a/.github/workflows/functional-imageservice.yaml +++ b/.github/workflows/functional-imageservice.yaml @@ -3,8 +3,6 @@ on: pull_request: paths: - '**imageservice**' - schedule: - - cron: '0 0 */3 * *' jobs: functional-imageservice: strategy: @@ -12,34 +10,28 @@ jobs: matrix: name: ["master"] openstack_version: ["master"] - ubuntu_version: ["20.04"] + ubuntu_version: ["22.04"] include: - - name: "zed" - openstack_version: "stable/zed" - ubuntu_version: "20.04" - - name: "yoga" - openstack_version: "stable/yoga" - ubuntu_version: "20.04" - - name: "xena" - openstack_version: "stable/xena" - ubuntu_version: "20.04" - - name: "wallaby" - openstack_version: "stable/wallaby" - ubuntu_version: "20.04" - - name: "victoria" - openstack_version: "stable/victoria" - ubuntu_version: "20.04" + - name: "caracal" + openstack_version: "stable/2024.1" + ubuntu_version: "22.04" + - name: "bobcat" + openstack_version: "stable/2023.2" + ubuntu_version: "22.04" + - name: "antelope" + openstack_version: "stable/2023.1" + ubuntu_version: "22.04" runs-on: ubuntu-${{ matrix.ubuntu_version }} name: Deploy OpenStack ${{ matrix.name }} with Glance and run imageservice acceptance tests steps: - name: Checkout Gophercloud - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Deploy devstack - uses: EmilienM/devstack-action@v0.11 + uses: EmilienM/devstack-action@e82a9cbead099cba72f99537e82a360c3e319c69 with: branch: ${{ matrix.openstack_version }} - name: Checkout go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '^1.15' - name: Run Gophercloud acceptance tests @@ -53,7 +45,7 @@ jobs: if: failure() - name: Upload logs artifacts on failure if: failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: functional-imageservice-${{ matrix.name }} path: /tmp/devstack-logs/* diff --git a/.github/workflows/functional-keymanager.yaml b/.github/workflows/functional-keymanager.yaml index cd270e7416..58be09cff8 100644 --- a/.github/workflows/functional-keymanager.yaml +++ b/.github/workflows/functional-keymanager.yaml @@ -3,8 +3,6 @@ on: pull_request: paths: - '**keymanager**' - schedule: - - cron: '0 0 */3 * *' jobs: functional-keymanager: strategy: @@ -12,37 +10,31 @@ jobs: matrix: name: ["master"] openstack_version: ["master"] - ubuntu_version: ["20.04"] + ubuntu_version: ["22.04"] include: - - name: "zed" - openstack_version: "stable/zed" - ubuntu_version: "20.04" - - name: "yoga" - openstack_version: "stable/yoga" - ubuntu_version: "20.04" - - name: "xena" - openstack_version: "stable/xena" - ubuntu_version: "20.04" - - name: "wallaby" - openstack_version: "stable/wallaby" - ubuntu_version: "20.04" - - name: "victoria" - openstack_version: "stable/victoria" - ubuntu_version: "20.04" + - name: "caracal" + openstack_version: "stable/2024.1" + ubuntu_version: "22.04" + - name: "bobcat" + openstack_version: "stable/2023.2" + ubuntu_version: "22.04" + - name: "antelope" + openstack_version: "stable/2023.1" + ubuntu_version: "22.04" runs-on: ubuntu-${{ matrix.ubuntu_version }} name: Deploy OpenStack ${{ matrix.name }} with Barbican and run keymanager acceptance tests steps: - name: Checkout Gophercloud - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Deploy devstack - uses: EmilienM/devstack-action@v0.11 + uses: EmilienM/devstack-action@e82a9cbead099cba72f99537e82a360c3e319c69 with: branch: ${{ matrix.openstack_version }} conf_overrides: | enable_plugin barbican https://github.com/openstack/barbican ${{ matrix.openstack_version }} enabled_services: 'barbican-svc,barbican-retry,barbican-keystone-listener' - name: Checkout go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '^1.15' - name: Run Gophercloud acceptance tests @@ -56,7 +48,7 @@ jobs: if: failure() - name: Upload logs artifacts on failure if: failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: functional-keymanager-${{ matrix.name }} path: /tmp/devstack-logs/* diff --git a/.github/workflows/functional-loadbalancer.yaml b/.github/workflows/functional-loadbalancer.yaml index 843f3645c5..870ba84d5f 100644 --- a/.github/workflows/functional-loadbalancer.yaml +++ b/.github/workflows/functional-loadbalancer.yaml @@ -3,8 +3,6 @@ on: pull_request: paths: - '**loadbalancer**' - schedule: - - cron: '0 0 */3 * *' jobs: functional-loadbalancer: strategy: @@ -12,30 +10,24 @@ jobs: matrix: name: ["master"] openstack_version: ["master"] - ubuntu_version: ["20.04"] + ubuntu_version: ["22.04"] include: - - name: "zed" - openstack_version: "stable/zed" - ubuntu_version: "20.04" - - name: "yoga" - openstack_version: "stable/yoga" - ubuntu_version: "20.04" - - name: "xena" - openstack_version: "stable/xena" - ubuntu_version: "20.04" - - name: "wallaby" - openstack_version: "stable/wallaby" - ubuntu_version: "20.04" - - name: "victoria" - openstack_version: "stable/victoria" - ubuntu_version: "20.04" + - name: "caracal" + openstack_version: "stable/2024.1" + ubuntu_version: "22.04" + - name: "bobcat" + openstack_version: "stable/2023.2" + ubuntu_version: "22.04" + - name: "antelope" + openstack_version: "stable/2023.1" + ubuntu_version: "22.04" runs-on: ubuntu-${{ matrix.ubuntu_version }} name: Deploy OpenStack ${{ matrix.name }} with Octavia and run loadbalancer acceptance tests steps: - name: Checkout Gophercloud - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Deploy devstack - uses: EmilienM/devstack-action@v0.11 + uses: EmilienM/devstack-action@e82a9cbead099cba72f99537e82a360c3e319c69 with: branch: ${{ matrix.openstack_version }} conf_overrides: | @@ -43,7 +35,7 @@ jobs: enable_plugin neutron https://github.com/openstack/neutron ${{ matrix.openstack_version }} enabled_services: 'octavia,o-api,o-cw,o-hk,o-hm,o-da,neutron-qos' - name: Checkout go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '^1.15' - name: Run Gophercloud acceptance tests @@ -57,7 +49,7 @@ jobs: if: failure() - name: Upload logs artifacts on failure if: failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: functional-loadbalancer-${{ matrix.name }} path: /tmp/devstack-logs/* diff --git a/.github/workflows/functional-messaging.yaml b/.github/workflows/functional-messaging.yaml index b727eafbce..d9e03f512e 100644 --- a/.github/workflows/functional-messaging.yaml +++ b/.github/workflows/functional-messaging.yaml @@ -3,8 +3,6 @@ on: pull_request: paths: - '**messaging**' - schedule: - - cron: '0 0 */3 * *' jobs: functional-messaging: strategy: @@ -14,35 +12,29 @@ jobs: openstack_version: ["master"] ubuntu_version: ["22.04"] include: - - name: "zed" - openstack_version: "stable/zed" - ubuntu_version: "20.04" - - name: "yoga" - openstack_version: "stable/yoga" - ubuntu_version: "20.04" - - name: "xena" - openstack_version: "stable/xena" - ubuntu_version: "20.04" - - name: "wallaby" - openstack_version: "stable/wallaby" - ubuntu_version: "20.04" - - name: "victoria" - openstack_version: "stable/victoria" - ubuntu_version: "20.04" + - name: "caracal" + openstack_version: "stable/2024.1" + ubuntu_version: "22.04" + - name: "bobcat" + openstack_version: "stable/2023.2" + ubuntu_version: "22.04" + - name: "antelope" + openstack_version: "stable/2023.1" + ubuntu_version: "22.04" runs-on: ubuntu-${{ matrix.ubuntu_version }} name: Deploy OpenStack ${{ matrix.name }} with Zaqar and run messaging acceptance tests steps: - name: Checkout Gophercloud - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Deploy devstack - uses: EmilienM/devstack-action@v0.11 + uses: EmilienM/devstack-action@e82a9cbead099cba72f99537e82a360c3e319c69 with: branch: ${{ matrix.openstack_version }} conf_overrides: | enable_plugin zaqar https://github.com/openstack/zaqar ${{ matrix.openstack_version }} ZAQARCLIENT_BRANCH=${{ matrix.openstack_version }} - name: Checkout go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '^1.15' - name: Run Gophercloud acceptance tests @@ -56,7 +48,7 @@ jobs: if: failure() - name: Upload logs artifacts on failure if: failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: functional-messaging-${{ matrix.name }} path: /tmp/devstack-logs/* diff --git a/.github/workflows/functional-networking.yaml b/.github/workflows/functional-networking.yaml index 3f69e5abbe..dc4066bcd9 100644 --- a/.github/workflows/functional-networking.yaml +++ b/.github/workflows/functional-networking.yaml @@ -3,8 +3,6 @@ on: pull_request: paths: - '**networking**' - schedule: - - cron: '0 0 */3 * *' jobs: functional-networking: strategy: @@ -13,55 +11,45 @@ jobs: include: - name: "master" openstack_version: "master" - ubuntu_version: "20.04" - devstack_conf_overrides: | - enable_plugin neutron-dynamic-routing https://github.com/openstack/neutron-dynamic-routing master - enable_plugin neutron-vpnaas https://github.com/openstack/neutron-vpnaas master - - name: "zed" - openstack_version: "stable/zed" - ubuntu_version: "20.04" - devstack_conf_overrides: | - enable_plugin neutron-dynamic-routing https://github.com/openstack/neutron-dynamic-routing stable/zed - enable_plugin neutron-vpnaas https://github.com/openstack/neutron-vpnaas stable/zed - - name: "yoga" - openstack_version: "stable/yoga" - ubuntu_version: "20.04" - devstack_conf_overrides: | - enable_plugin neutron-dynamic-routing https://github.com/openstack/neutron-dynamic-routing stable/yoga - enable_plugin neutron-vpnaas https://github.com/openstack/neutron-vpnaas stable/yoga - - name: "xena" - openstack_version: "stable/xena" - ubuntu_version: "20.04" - devstack_conf_overrides: | - enable_plugin neutron-dynamic-routing https://github.com/openstack/neutron-dynamic-routing stable/xena - enable_plugin neutron-vpnaas https://github.com/openstack/neutron-vpnaas stable/xena - - name: "wallaby" - openstack_version: "stable/wallaby" - ubuntu_version: "20.04" - devstack_conf_overrides: | - enable_plugin neutron-dynamic-routing https://github.com/openstack/neutron-dynamic-routing stable/wallaby - enable_plugin neutron-vpnaas https://github.com/openstack/neutron-vpnaas stable/wallaby - - name: "victoria" - openstack_version: "stable/victoria" - ubuntu_version: "20.04" - devstack_conf_overrides: | - enable_plugin neutron-dynamic-routing https://github.com/openstack/neutron-dynamic-routing stable/victoria - enable_plugin neutron-vpnaas https://github.com/openstack/neutron-vpnaas stable/victoria + ubuntu_version: "22.04" + - name: "caracal" + openstack_version: "stable/2024.1" + ubuntu_version: "22.04" + - name: "bobcat" + openstack_version: "stable/2023.2" + ubuntu_version: "22.04" + - name: "antelope" + openstack_version: "stable/2023.1" + ubuntu_version: "22.04" runs-on: ubuntu-${{ matrix.ubuntu_version }} name: Deploy OpenStack ${{ matrix.name }} with Neutron and run networking acceptance tests steps: - name: Checkout Gophercloud - uses: actions/checkout@v3 + uses: actions/checkout@v4 + - name: Create additional neutron policies + run: | + mkdir /tmp/neutron-policies + cat << EOF >> /tmp/neutron-policies/port_binding.yaml + --- + "create_port:binding:profile": "rule:admin_only or rule:service_api" + "update_port:binding:profile": "rule:admin_only or rule:service_api" + EOF - name: Deploy devstack - uses: EmilienM/devstack-action@v0.11 + uses: EmilienM/devstack-action@e82a9cbead099cba72f99537e82a360c3e319c69 with: branch: ${{ matrix.openstack_version }} conf_overrides: | + enable_plugin neutron-dynamic-routing https://github.com/openstack/neutron-dynamic-routing ${{ matrix.openstack_version }} + enable_plugin neutron-vpnaas https://github.com/openstack/neutron-vpnaas ${{ matrix.openstack_version }} + enable_plugin networking-bgpvpn https://github.com/openstack/networking-bgpvpn.git ${{ matrix.openstack_version }} Q_ML2_PLUGIN_EXT_DRIVERS=qos,port_security,dns_domain_keywords - ${{ matrix.devstack_conf_overrides }} + + [[post-config|\$NEUTRON_CONF]] + [oslo_policy] + policy_dirs = /tmp/neutron-policies enabled_services: 'neutron-dns,neutron-qos,neutron-segments,neutron-trunk,neutron-uplink-status-propagation,neutron-network-segment-range,neutron-port-forwarding' - name: Checkout go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '^1.15' - name: Run Gophercloud acceptance tests @@ -75,7 +63,7 @@ jobs: if: failure() - name: Upload logs artifacts on failure if: failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: functional-networking-${{ matrix.name }} path: /tmp/devstack-logs/* diff --git a/.github/workflows/functional-objectstorage.yaml b/.github/workflows/functional-objectstorage.yaml index f43f6cad8a..67c0bb0abf 100644 --- a/.github/workflows/functional-objectstorage.yaml +++ b/.github/workflows/functional-objectstorage.yaml @@ -3,8 +3,6 @@ on: pull_request: paths: - '**objectstorage**' - schedule: - - cron: '0 0 */3 * *' jobs: functional-objectstorage: strategy: @@ -12,30 +10,24 @@ jobs: matrix: name: ["master"] openstack_version: ["master"] - ubuntu_version: ["20.04"] + ubuntu_version: ["22.04"] include: - - name: "zed" - openstack_version: "stable/zed" - ubuntu_version: "20.04" - - name: "yoga" - openstack_version: "stable/yoga" - ubuntu_version: "20.04" - - name: "xena" - openstack_version: "stable/xena" - ubuntu_version: "20.04" - - name: "wallaby" - openstack_version: "stable/wallaby" - ubuntu_version: "20.04" - - name: "victoria" - openstack_version: "stable/victoria" - ubuntu_version: "20.04" + - name: "caracal" + openstack_version: "stable/2024.1" + ubuntu_version: "22.04" + - name: "bobcat" + openstack_version: "stable/2023.2" + ubuntu_version: "22.04" + - name: "antelope" + openstack_version: "stable/2023.1" + ubuntu_version: "22.04" runs-on: ubuntu-${{ matrix.ubuntu_version }} name: Deploy OpenStack ${{ matrix.name }} with Swift and run objectstorage acceptance tests steps: - name: Checkout Gophercloud - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Deploy devstack - uses: EmilienM/devstack-action@v0.11 + uses: EmilienM/devstack-action@e82a9cbead099cba72f99537e82a360c3e319c69 with: branch: ${{ matrix.openstack_version }} conf_overrides: | @@ -46,7 +38,7 @@ jobs: allow_object_versioning = true enabled_services: 's-account,s-container,s-object,s-proxy' - name: Checkout go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '^1.15' - name: Run Gophercloud acceptance tests @@ -60,7 +52,7 @@ jobs: if: failure() - name: Upload logs artifacts on failure if: failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: functional-objectstorage-${{ matrix.name }} path: /tmp/devstack-logs/* diff --git a/.github/workflows/functional-orchestration.yaml b/.github/workflows/functional-orchestration.yaml index 12dbe82a63..2f2cbb12b3 100644 --- a/.github/workflows/functional-orchestration.yaml +++ b/.github/workflows/functional-orchestration.yaml @@ -3,8 +3,6 @@ on: pull_request: paths: - '**orchestration**' - schedule: - - cron: '0 0 */3 * *' jobs: functional-orchestration: strategy: @@ -12,37 +10,31 @@ jobs: matrix: name: ["master"] openstack_version: ["master"] - ubuntu_version: ["20.04"] + ubuntu_version: ["22.04"] include: - - name: "zed" - openstack_version: "stable/zed" - ubuntu_version: "20.04" - - name: "yoga" - openstack_version: "stable/yoga" - ubuntu_version: "20.04" - - name: "xena" - openstack_version: "stable/xena" - ubuntu_version: "20.04" - - name: "wallaby" - openstack_version: "stable/wallaby" - ubuntu_version: "20.04" - - name: "victoria" - openstack_version: "stable/victoria" - ubuntu_version: "20.04" + - name: "caracal" + openstack_version: "stable/2024.1" + ubuntu_version: "22.04" + - name: "bobcat" + openstack_version: "stable/2023.2" + ubuntu_version: "22.04" + - name: "antelope" + openstack_version: "stable/2023.1" + ubuntu_version: "22.04" runs-on: ubuntu-${{ matrix.ubuntu_version }} name: Deploy OpenStack ${{ matrix.name }} with Heat and run orchestration acceptance tests steps: - name: Checkout Gophercloud - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Deploy devstack - uses: EmilienM/devstack-action@v0.11 + uses: EmilienM/devstack-action@e82a9cbead099cba72f99537e82a360c3e319c69 with: branch: ${{ matrix.openstack_version }} conf_overrides: | enable_plugin heat https://github.com/openstack/heat ${{ matrix.openstack_version }} enabled_services: 'h-eng,h-api,h-api-cfn,h-api-cw' - name: Checkout go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '^1.15' - name: Run Gophercloud acceptance tests @@ -56,7 +48,7 @@ jobs: if: failure() - name: Upload logs artifacts on failure if: failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: functional-orchestration-${{ matrix.name }} path: /tmp/devstack-logs/* diff --git a/.github/workflows/functional-placement.yaml b/.github/workflows/functional-placement.yaml index 57d5990b0a..dcbc0935cb 100644 --- a/.github/workflows/functional-placement.yaml +++ b/.github/workflows/functional-placement.yaml @@ -3,8 +3,6 @@ on: pull_request: paths: - '**placement**' - schedule: - - cron: '0 0 */3 * *' jobs: functional-placement: strategy: @@ -12,34 +10,28 @@ jobs: matrix: name: ["master"] openstack_version: ["master"] - ubuntu_version: ["20.04"] + ubuntu_version: ["22.04"] include: - - name: "zed" - openstack_version: "stable/zed" - ubuntu_version: "20.04" - - name: "yoga" - openstack_version: "stable/yoga" - ubuntu_version: "20.04" - - name: "xena" - openstack_version: "stable/xena" - ubuntu_version: "20.04" - - name: "wallaby" - openstack_version: "stable/wallaby" - ubuntu_version: "20.04" - - name: "victoria" - openstack_version: "stable/victoria" - ubuntu_version: "20.04" + - name: "caracal" + openstack_version: "stable/2024.1" + ubuntu_version: "22.04" + - name: "bobcat" + openstack_version: "stable/2023.2" + ubuntu_version: "22.04" + - name: "antelope" + openstack_version: "stable/2023.1" + ubuntu_version: "22.04" runs-on: ubuntu-${{ matrix.ubuntu_version }} name: Deploy OpenStack ${{ matrix.name }} with Placement and run placement acceptance tests steps: - name: Checkout Gophercloud - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Deploy devstack - uses: EmilienM/devstack-action@v0.11 + uses: EmilienM/devstack-action@e82a9cbead099cba72f99537e82a360c3e319c69 with: branch: ${{ matrix.openstack_version }} - name: Checkout go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '^1.15' - name: Run Gophercloud acceptance tests @@ -53,7 +45,7 @@ jobs: if: failure() - name: Upload logs artifacts on failure if: failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: functional-placement-${{ matrix.name }} path: /tmp/devstack-logs/* diff --git a/.github/workflows/functional-sharedfilesystems.yaml b/.github/workflows/functional-sharedfilesystems.yaml index b72c33e75c..cff49aa74e 100644 --- a/.github/workflows/functional-sharedfilesystems.yaml +++ b/.github/workflows/functional-sharedfilesystems.yaml @@ -3,8 +3,6 @@ on: pull_request: paths: - '**sharedfilesystems**' - schedule: - - cron: '0 0 */3 * *' jobs: functional-sharedfilesystems: strategy: @@ -12,30 +10,24 @@ jobs: matrix: name: ["master"] openstack_version: ["master"] - ubuntu_version: ["20.04"] + ubuntu_version: ["22.04"] include: - - name: "zed" - openstack_version: "stable/zed" - ubuntu_version: "20.04" - - name: "yoga" - openstack_version: "stable/yoga" - ubuntu_version: "20.04" - - name: "xena" - openstack_version: "stable/xena" - ubuntu_version: "20.04" - - name: "wallaby" - openstack_version: "stable/wallaby" - ubuntu_version: "20.04" - - name: "victoria" - openstack_version: "stable/victoria" - ubuntu_version: "20.04" + - name: "caracal" + openstack_version: "stable/2024.1" + ubuntu_version: "22.04" + - name: "bobcat" + openstack_version: "stable/2023.2" + ubuntu_version: "22.04" + - name: "antelope" + openstack_version: "stable/2023.1" + ubuntu_version: "22.04" runs-on: ubuntu-${{ matrix.ubuntu_version }} name: Deploy OpenStack ${{ matrix.name }} with Manila and run sharedfilesystems acceptance tests steps: - name: Checkout Gophercloud - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Deploy devstack - uses: EmilienM/devstack-action@v0.11 + uses: EmilienM/devstack-action@e82a9cbead099cba72f99537e82a360c3e319c69 with: branch: ${{ matrix.openstack_version }} conf_overrides: | @@ -55,7 +47,7 @@ jobs: MANILA_CONFIGURE_DEFAULT_TYPES=True MANILA_INSTALL_TEMPEST_PLUGIN_SYSTEMWIDE=false - name: Checkout go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '^1.15' - name: Run Gophercloud acceptance tests @@ -69,7 +61,7 @@ jobs: if: failure() - name: Upload logs artifacts on failure if: failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: functional-sharedfilesystems-${{ matrix.name }} path: /tmp/devstack-logs/* diff --git a/.github/workflows/gomod.yml b/.github/workflows/gomod.yml index 929bad77e9..43dc5c242b 100644 --- a/.github/workflows/gomod.yml +++ b/.github/workflows/gomod.yml @@ -7,8 +7,8 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 with: go-version: '1' - run: if [ $(go mod tidy && git diff | wc -l) -gt 0 ]; then git diff && exit 1; fi diff --git a/.github/workflows/label-issue.yaml b/.github/workflows/label-issue.yaml new file mode 100644 index 0000000000..45ab4cbe34 --- /dev/null +++ b/.github/workflows/label-issue.yaml @@ -0,0 +1,20 @@ +name: Label issue +on: + issue_comment: + types: + - created + +jobs: + clear_needinfo: + name: Clear needinfo + if: ${{ github.event.issue.user.login }} == ${{ github.event.comment.user.login }} + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + steps: + - run: gh issue edit "$NUMBER" --remove-label "needinfo" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + NUMBER: ${{ github.event.issue.number }} diff --git a/.github/workflows/label-pr.yaml b/.github/workflows/label-pr.yaml new file mode 100644 index 0000000000..44d46b0e15 --- /dev/null +++ b/.github/workflows/label-pr.yaml @@ -0,0 +1,87 @@ +name: Label PR +on: + pull_request_target: + types: + - opened + - synchronize + - reopened + +jobs: + semver: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.sha }} + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Rebase the PR against origin/github.base_ref to ensure actual API compatibility + run: | + git config --global user.email "localrebase@gophercloud.io" + git config --global user.name "Local rebase" + git rebase -i origin/${{ github.base_ref }} + env: + GIT_SEQUENCE_EDITOR: '/usr/bin/true' + + - uses: actions/setup-go@v5 + with: + go-version: '1' + + - name: Checking Go API Compatibility + id: go-apidiff + # if semver=major, this will return RC=1, so let's ignore the failure so label + # can be set later. We check for actual errors in the next step. + continue-on-error: true + uses: joelanford/go-apidiff@002aa613b261e8d1547b516fb71793280f05bb78 + + # go-apidiff returns RC=1 when semver=major, which makes the workflow to return + # a failure. Instead let's just return a failure if go-apidiff failed to run. + - name: Return an error if Go API Compatibility couldn't be verified + if: steps.go-apidiff.outcome != 'success' && steps.go-apidiff.outputs.semver-type != 'major' + run: exit 1 + + - name: Add label semver:patch + if: steps.go-apidiff.outputs.semver-type == 'patch' + run: gh pr edit "$NUMBER" --add-label "semver:patch" --remove-label "semver:major,semver:minor" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + NUMBER: ${{ github.event.pull_request.number }} + + - name: Add label semver:minor + if: steps.go-apidiff.outputs.semver-type == 'minor' + run: gh pr edit "$NUMBER" --add-label "semver:minor" --remove-label "semver:major,semver:patch" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + NUMBER: ${{ github.event.pull_request.number }} + + - name: Add label semver:major + if: steps.go-apidiff.outputs.semver-type == 'major' + run: gh pr edit "$NUMBER" --add-label "semver:major" --remove-label "semver:minor,semver:patch" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + NUMBER: ${{ github.event.pull_request.number }} + + - name: Report failure + if: failure() + run: | + gh pr edit "$NUMBER" --remove-label "semver:major,semver:minor,semver:patch" + gh issue comment "$NUMBER" --body "$BODY" + exit 1 + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + NUMBER: ${{ github.event.pull_request.number }} + BODY: > + Failed to assess the semver bump. See [logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details. + + edits: + permissions: + contents: read + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: actions/labeler@v5 diff --git a/.github/workflows/reauth-retests.yaml b/.github/workflows/reauth-retests.yaml index ae1aa17994..983102a048 100644 --- a/.github/workflows/reauth-retests.yaml +++ b/.github/workflows/reauth-retests.yaml @@ -14,11 +14,11 @@ jobs: steps: - name: Setup Go ${{ matrix.go-version }} - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: ${{ matrix.go-version }} - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Run reauth retests run: | diff --git a/.github/workflows/semver-labels.yaml b/.github/workflows/semver-labels.yaml deleted file mode 100644 index ccaf44522b..0000000000 --- a/.github/workflows/semver-labels.yaml +++ /dev/null @@ -1,18 +0,0 @@ -name: Ensure labels -on: - push: - branches: - - master - paths: - - .github/semver-labels.yaml - - .github/workflows/semver-labels.yaml -jobs: - semver: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: micnncim/action-label-syncer@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - manifest: .github/semver-labels.yaml diff --git a/.github/workflows/semver-require.yaml b/.github/workflows/semver-require.yaml deleted file mode 100644 index d584899306..0000000000 --- a/.github/workflows/semver-require.yaml +++ /dev/null @@ -1,17 +0,0 @@ -name: Verify PR Labels -on: - pull_request: - types: - - opened - - labeled - - unlabeled - - synchronize -jobs: - semver: - runs-on: ubuntu-latest - steps: - - uses: mheap/github-action-required-labels@v5 - with: - mode: exactly - count: 1 - labels: "semver:patch, semver:minor, semver:major" diff --git a/.github/workflows/semver-unlabel.yaml b/.github/workflows/semver-unlabel.yaml deleted file mode 100644 index 9fdf5558e4..0000000000 --- a/.github/workflows/semver-unlabel.yaml +++ /dev/null @@ -1,21 +0,0 @@ -name: Reset PR labels on push - -# **What it does**: When the content of a PR changes, this workflow removes the semver label -# **Why we have it**: To make sure semver labels are up-to-date. -# **Who does it impact**: Pull requests. - -on: - pull_request_target: - types: - - synchronize - -jobs: - semver: - runs-on: ubuntu-latest - steps: - - name: Remove the semver label - uses: andymckay/labeler@1.0.4 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - remove-labels: "semver:patch, semver:minor, semver:major" diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index 9a49c86d26..cb981430c2 100644 --- a/.github/workflows/unit.yml +++ b/.github/workflows/unit.yml @@ -6,7 +6,7 @@ permissions: jobs: test: permissions: - checks: write # for shogo82148/actions-goveralls to create a new check based on the results + checks: write # for coverallsapp/github-action to create a new check based on the results contents: read # for actions/checkout to fetch code runs-on: ubuntu-latest strategy: @@ -20,22 +20,23 @@ jobs: GO111MODULE: "on" steps: - - name: Setup Go ${{ matrix.go-version }} - uses: actions/setup-go@v4 - with: - go-version: ${{ matrix.go-version }} + - uses: actions/checkout@v4 - - uses: actions/checkout@v3 + - name: Setup Go v1 + uses: actions/setup-go@v5 + with: + go-version: 1 - - name: Setup environment + - name: Install tools run: | - # Changing into a different directory to avoid polluting go.sum with "go get" - cd "$(mktemp -d)" - go mod init unit_tests + go install github.com/wadey/gocovmerge@master + go install golang.org/x/tools/cmd/goimports@latest - # we use "go get" for Go v1.14 - go install github.com/wadey/gocovmerge@master || go get github.com/wadey/gocovmerge - go install golang.org/x/tools/cmd/goimports@latest || go get golang.org/x/tools/cmd/goimports@v0.8.0 + - if: ${{ matrix.go-version != '1' }} + name: Setup Go ${{ matrix.go-version }} + uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go-version }} - name: Run go vet run: | @@ -43,22 +44,27 @@ jobs: - name: Run unit tests run: | + go version ./script/coverage ./script/format ./script/unittest -v - - uses: shogo82148/actions-goveralls@v1 + - name: Coveralls Parallel + uses: coverallsapp/github-action@v2 with: - path-to-profile: cover.out + file: cover.out flag-name: Go-${{ matrix.go-version }} parallel: true finish: permissions: - checks: write # for shogo82148/actions-goveralls to create a new check based on the results + checks: write # for coverallsapp/github-action to create a new check based on the results needs: test + if: ${{ always() }} runs-on: ubuntu-latest steps: - - uses: shogo82148/actions-goveralls@v1 - with: - parallel-finished: true + - name: Coveralls Finished + uses: coverallsapp/github-action@v2 + with: + parallel-finished: true + carryforward: Go-${{ join(matrix.go-version.*, '-') }} diff --git a/CHANGELOG.md b/CHANGELOG.md index e19d5af517..b19b5e7753 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,113 @@ +## v1.14.1 (2024-09-18) + +* [GH-3162](https://github.com/gophercloud/gophercloud/pull/3162) Fix security group rule "any protocol" + +## v1.14.0 (2024-07-24) + +* [GH-3095](https://github.com/gophercloud/gophercloud/pull/3095) [neutron]: introduce Description argument for the portforwarding +* [GH-3098](https://github.com/gophercloud/gophercloud/pull/3098) [neutron]: introduce Stateful argument for the security groups +* [GH-3099](https://github.com/gophercloud/gophercloud/pull/3099) [networking]: subnet add field dns_publish_fixed_ip + +## v1.13.0 (2024-07-08) + +* [GH-3044](https://github.com/gophercloud/gophercloud/pull/3044) [v1] Add ci jobs for openstack caracal +* [GH-3073](https://github.com/gophercloud/gophercloud/pull/3073) [v1] Adding missing QoS field for router +* [GH-3080](https://github.com/gophercloud/gophercloud/pull/3080) [networking]: add BGP VPNs support (backport to 1.x) + +## v1.12.0 (2024-05-27) + +* [GH-2979](https://github.com/gophercloud/gophercloud/pull/2979) [v1] CI backports +* [GH-2985](https://github.com/gophercloud/gophercloud/pull/2985) [v1] baremetal: fix handling of the "fields" query argument +* [GH-2989](https://github.com/gophercloud/gophercloud/pull/2989) [v1] [CI] Fix portbiding tests +* [GH-2992](https://github.com/gophercloud/gophercloud/pull/2992) [v1] [CI] Fix portbiding tests +* [GH-2993](https://github.com/gophercloud/gophercloud/pull/2993) [v1] build(deps): bump EmilienM/devstack-action from 0.14 to 0.15 +* [GH-2998](https://github.com/gophercloud/gophercloud/pull/2998) [v1] testhelper: mark all helpers with t.Helper +* [GH-3043](https://github.com/gophercloud/gophercloud/pull/3043) [v1] CI: remove Zed from testing coverage + +## v1.11.0 (2024-03-07) + +This version reverts the inclusion of Context in the v1 branch. This inclusion +didn't add much value because no packages were using it; on the other hand, it +introduced a bug when using the Context property of the Provider client. + +## v1.10.0 (2024-02-27) **RETRACTED**: see https://github.com/gophercloud/gophercloud/issues/2969 + +* [GH-2893](https://github.com/gophercloud/gophercloud/pull/2893) [v1] authentication: Add WithContext functions +* [GH-2894](https://github.com/gophercloud/gophercloud/pull/2894) [v1] pager: Add WithContext functions +* [GH-2899](https://github.com/gophercloud/gophercloud/pull/2899) [v1] Authenticate with a clouds.yaml +* [GH-2917](https://github.com/gophercloud/gophercloud/pull/2917) [v1] Add ParseOption type to made clouds.Parse() more usable for optional With* funcs +* [GH-2924](https://github.com/gophercloud/gophercloud/pull/2924) [v1] build(deps): bump EmilienM/devstack-action from 0.11 to 0.14 +* [GH-2933](https://github.com/gophercloud/gophercloud/pull/2933) [v1] Fix AllowReauth reauthentication +* [GH-2950](https://github.com/gophercloud/gophercloud/pull/2950) [v1] compute: Use volumeID, not attachmentID for volume attachments + +## v1.9.0 (2024-02-02) **RETRACTED**: see https://github.com/gophercloud/gophercloud/issues/2969 + +New features and improvements: + +* [GH-2884](https://github.com/gophercloud/gophercloud/pull/2884) [v1] Context-aware methods to ProviderClient and ServiceClient +* [GH-2887](https://github.com/gophercloud/gophercloud/pull/2887) [v1] Add support of Flavors and FlavorProfiles for Octavia +* [GH-2875](https://github.com/gophercloud/gophercloud/pull/2875) [v1] [db/v1/instance]: adding support for availability_zone for a db instance + +CI changes: + +* [GH-2856](https://github.com/gophercloud/gophercloud/pull/2856) [v1] Fix devstack install on EOL magnum branches +* [GH-2857](https://github.com/gophercloud/gophercloud/pull/2857) [v1] Fix networking acceptance tests +* [GH-2858](https://github.com/gophercloud/gophercloud/pull/2858) [v1] build(deps): bump actions/upload-artifact from 3 to 4 +* [GH-2859](https://github.com/gophercloud/gophercloud/pull/2859) [v1] build(deps): bump github/codeql-action from 2 to 3 + +## v1.8.0 (2023-11-30) + +New features and improvements: + +* [GH-2800](https://github.com/gophercloud/gophercloud/pull/2800) [v1] Fix options initialization in ServiceClient.Request (fixes #2798) +* [GH-2823](https://github.com/gophercloud/gophercloud/pull/2823) [v1] Add more godoc to GuestFormat +* [GH-2826](https://github.com/gophercloud/gophercloud/pull/2826) Allow objects.CreateTempURL with names containing /v1/ + +CI changes: + +* [GH-2802](https://github.com/gophercloud/gophercloud/pull/2802) [v1] Add job for bobcat stable/2023.2 +* [GH-2819](https://github.com/gophercloud/gophercloud/pull/2819) [v1] Test files alongside code +* [GH-2814](https://github.com/gophercloud/gophercloud/pull/2814) Make fixtures part of tests +* [GH-2796](https://github.com/gophercloud/gophercloud/pull/2796) [v1] ci/unit: switch to coverallsapp/github-action +* [GH-2840](https://github.com/gophercloud/gophercloud/pull/2840) unit tests: Fix the installation of tools + +## v1.7.0 (2023-09-22) + +New features and improvements: + +* [GH-2782](https://github.com/gophercloud/gophercloud/pull/2782) [v1] (manual clean backport) Add tag field to compute block_device_v2 + +CI changes: + +* [GH-2760](https://github.com/gophercloud/gophercloud/pull/2760) [v1 backports] semver auto labels +* [GH-2775](https://github.com/gophercloud/gophercloud/pull/2775) [v1] Fix typos in comments +* [GH-2783](https://github.com/gophercloud/gophercloud/pull/2783) [v1] (clean manual backport) ci/functional: fix ubuntu version & add antelope +* [GH-2785](https://github.com/gophercloud/gophercloud/pull/2785) [v1] Acceptance: Handle numerical version names in version comparison helpers +* [GH-2787](https://github.com/gophercloud/gophercloud/pull/2787) backport-v1: fixes to semver label +* [GH-2788](https://github.com/gophercloud/gophercloud/pull/2788) [v1] Make acceptance tests internal + + +## v1.6.0 (2023-08-30) + +New features and improvements: + +* [GH-2712](https://github.com/gophercloud/gophercloud/pull/2712) [v1] README: minor change to test backport workflow +* [GH-2713](https://github.com/gophercloud/gophercloud/pull/2713) [v1] tests: run MultiAttach with a capable Cinder Type +* [GH-2714](https://github.com/gophercloud/gophercloud/pull/2714) [v1] Add CRUD support for encryption in volume v3 types +* [GH-2715](https://github.com/gophercloud/gophercloud/pull/2715) [v1] Add projectID to fwaas_v2 policy CreateOpts and ListOpts +* [GH-2716](https://github.com/gophercloud/gophercloud/pull/2716) [v1] Add projectID to fwaas_v2 CreateOpts +* [GH-2717](https://github.com/gophercloud/gophercloud/pull/2717) [v1] [manila]: add reset and force delete actions to a snapshot +* [GH-2718](https://github.com/gophercloud/gophercloud/pull/2718) [v1] [cinder]: add reset and force delete actions to volumes and snapshots +* [GH-2721](https://github.com/gophercloud/gophercloud/pull/2721) [v1] orchestration: Explicit error in optionsmap creation +* [GH-2723](https://github.com/gophercloud/gophercloud/pull/2723) [v1] Add conductor API to Baremetal V1 +* [GH-2729](https://github.com/gophercloud/gophercloud/pull/2729) [v1] networking/v2/ports: allow list filter by security group + +CI changes: + +* [GH-2675](https://github.com/gophercloud/gophercloud/pull/2675) [v1][CI] Drop periodic jobs from stable branch +* [GH-2683](https://github.com/gophercloud/gophercloud/pull/2683) [v1] CI tweaks + + ## v1.5.0 (2023-06-21) New features and improvements: diff --git a/README.md b/README.md index 89b08156fe..4e6e57dadb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # Gophercloud: an OpenStack SDK for Go -[![Build Status](https://travis-ci.org/gophercloud/gophercloud.svg?branch=master)](https://travis-ci.org/gophercloud/gophercloud) -[![Coverage Status](https://coveralls.io/repos/github/gophercloud/gophercloud/badge.svg?branch=master)](https://coveralls.io/github/gophercloud/gophercloud?branch=master) +[![Coverage Status](https://coveralls.io/repos/github/gophercloud/gophercloud/badge.svg?branch=v1)](https://coveralls.io/github/gophercloud/gophercloud?branch=v1) Gophercloud is an OpenStack Go SDK. @@ -40,7 +39,7 @@ You will need to retrieve the following: Credentials, a pre-generated token, or any other supported authentication mechanism. -For users that have the OpenStack dashboard installed, there's a shortcut. If +For users who have the OpenStack dashboard installed, there's a shortcut. If you visit the `project/api_access` path in Horizon and click on the "Download OpenStack RC File" button at the top right hand corner, you can download either a `clouds.yaml` file or an `openrc` bash file that exports all diff --git a/acceptance/openstack/blockstorage/v3/snapshots_test.go b/acceptance/openstack/blockstorage/v3/snapshots_test.go deleted file mode 100644 index 06ad8e8ba0..0000000000 --- a/acceptance/openstack/blockstorage/v3/snapshots_test.go +++ /dev/null @@ -1,75 +0,0 @@ -//go:build acceptance || blockstorage -// +build acceptance blockstorage - -package v3 - -import ( - "testing" - - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" - "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/snapshots" - "github.com/gophercloud/gophercloud/pagination" - th "github.com/gophercloud/gophercloud/testhelper" -) - -func TestSnapshots(t *testing.T) { - clients.RequireLong(t) - - client, err := clients.NewBlockStorageV3Client() - th.AssertNoErr(t, err) - - volume1, err := CreateVolume(t, client) - th.AssertNoErr(t, err) - defer DeleteVolume(t, client, volume1) - - snapshot1, err := CreateSnapshot(t, client, volume1) - th.AssertNoErr(t, err) - defer DeleteSnapshot(t, client, snapshot1) - - // Update snapshot - updatedSnapshotName := tools.RandomString("ACPTTEST", 16) - updatedSnapshotDescription := tools.RandomString("ACPTTEST", 16) - updateOpts := snapshots.UpdateOpts{ - Name: &updatedSnapshotName, - Description: &updatedSnapshotDescription, - } - t.Logf("Attempting to update snapshot: %s", updatedSnapshotName) - updatedSnapshot, err := snapshots.Update(client, snapshot1.ID, updateOpts).Extract() - th.AssertNoErr(t, err) - - tools.PrintResource(t, updatedSnapshot) - th.AssertEquals(t, updatedSnapshot.Name, updatedSnapshotName) - th.AssertEquals(t, updatedSnapshot.Description, updatedSnapshotDescription) - - volume2, err := CreateVolume(t, client) - th.AssertNoErr(t, err) - defer DeleteVolume(t, client, volume2) - - snapshot2, err := CreateSnapshot(t, client, volume2) - th.AssertNoErr(t, err) - defer DeleteSnapshot(t, client, snapshot2) - - listOpts := snapshots.ListOpts{ - Limit: 1, - } - - err = snapshots.List(client, listOpts).EachPage(func(page pagination.Page) (bool, error) { - actual, err := snapshots.ExtractSnapshots(page) - th.AssertNoErr(t, err) - th.AssertEquals(t, 1, len(actual)) - - var found bool - for _, v := range actual { - if v.ID == snapshot1.ID || v.ID == snapshot2.ID { - found = true - } - } - - th.AssertEquals(t, found, true) - - return true, nil - }) - - th.AssertNoErr(t, err) -} diff --git a/docs/contributor-tutorial/.template/testing/fixtures.go b/docs/contributor-tutorial/.template/testing/fixtures_test.go similarity index 100% rename from docs/contributor-tutorial/.template/testing/fixtures.go rename to docs/contributor-tutorial/.template/testing/fixtures_test.go diff --git a/acceptance/README.md b/internal/acceptance/README.md similarity index 98% rename from acceptance/README.md rename to internal/acceptance/README.md index 834cdc12ef..cbbbac7f39 100644 --- a/acceptance/README.md +++ b/internal/acceptance/README.md @@ -100,7 +100,7 @@ Alternatively, add the following to your `.bashrc`: gophercloudtest() { if [[ -n $1 ]] && [[ -n $2 ]]; then pushd $GOPATH/src/github.com/gophercloud/gophercloud - go test -v -tags "fixtures acceptance" -run "$1" github.com/gophercloud/gophercloud/acceptance/openstack/$2 | tee ~/gophercloud.log + go test -v -tags "fixtures acceptance" -run "$1" github.com/gophercloud/gophercloud/internal/acceptance/openstack/$2 | tee ~/gophercloud.log popd fi } diff --git a/acceptance/clients/clients.go b/internal/acceptance/clients/clients.go similarity index 100% rename from acceptance/clients/clients.go rename to internal/acceptance/clients/clients.go diff --git a/acceptance/clients/conditions.go b/internal/acceptance/clients/conditions.go similarity index 72% rename from acceptance/clients/conditions.go rename to internal/acceptance/clients/conditions.go index 44522c2308..a1239a1ba7 100644 --- a/acceptance/clients/conditions.go +++ b/internal/acceptance/clients/conditions.go @@ -2,6 +2,8 @@ package clients import ( "os" + "strconv" + "strings" "testing" ) @@ -90,18 +92,18 @@ func RequireIronicHTTPBasic(t *testing.T) { } func getReleaseFromEnv(t *testing.T) string { - current_branch := os.Getenv("OS_BRANCH") - if current_branch == "" { + current := strings.TrimPrefix(os.Getenv("OS_BRANCH"), "stable/") + if current == "" { t.Fatal("this test requires OS_BRANCH to be set but it wasn't") } - return current_branch + return current } // SkipRelease will have the test be skipped on a certain // release. Releases are named such as 'stable/mitaka', master, etc. func SkipRelease(t *testing.T, release string) { - current_branch := getReleaseFromEnv(t) - if current_branch == release { + current := getReleaseFromEnv(t) + if current == release { t.Skipf("this is not supported in %s", release) } } @@ -109,10 +111,10 @@ func SkipRelease(t *testing.T, release string) { // SkipReleasesBelow will have the test be skipped on releases below a certain // one. Releases are named such as 'stable/mitaka', master, etc. func SkipReleasesBelow(t *testing.T, release string) { - current_branch := getReleaseFromEnv(t) + current := getReleaseFromEnv(t) - if IsReleasesBelow(t, release) { - t.Skipf("this is not supported below %s, testing in %s", release, current_branch) + if IsCurrentBelow(t, release) { + t.Skipf("this is not supported below %s, testing in %s", release, current) } } @@ -120,36 +122,61 @@ func SkipReleasesBelow(t *testing.T, release string) { // one. The test is always skipped on master release. Releases are named such // as 'stable/mitaka', master, etc. func SkipReleasesAbove(t *testing.T, release string) { - current_branch := getReleaseFromEnv(t) + current := getReleaseFromEnv(t) - // Assume master is always too new - if IsReleasesAbove(t, release) { - t.Skipf("this is not supported above %s, testing in %s", release, current_branch) + if IsCurrentAbove(t, release) { + t.Skipf("this is not supported above %s, testing in %s", release, current) } } -// IsReleasesAbove will return true on releases above a certain +func isReleaseNumeral(release string) bool { + _, err := strconv.Atoi(release[0:1]) + return err == nil +} + +// IsCurrentAbove will return true on releases above a certain // one. The result is always true on master release. Releases are named such // as 'stable/mitaka', master, etc. -func IsReleasesAbove(t *testing.T, release string) bool { - current_branch := getReleaseFromEnv(t) - - // Assume master is always too new - if current_branch == "master" || current_branch > release { - return true - } - t.Logf("Target release %s is below the current branch %s", release, current_branch) +func IsCurrentAbove(t *testing.T, release string) bool { + current := getReleaseFromEnv(t) + release = strings.TrimPrefix(release, "stable/") + + if release != "master" { + // Assume master is always too new + if current == "master" { + return true + } + // Numeral releases are always newer than non-numeral ones + if isReleaseNumeral(current) && !isReleaseNumeral(release) { + return true + } + if current > release && !(!isReleaseNumeral(current) && isReleaseNumeral(release)) { + return true + } + } + t.Logf("Target release %s is below the current branch %s", release, current) return false } -// IsReleasesBelow will return true on releases below a certain +// IsCurrentBelow will return true on releases below a certain // one. Releases are named such as 'stable/mitaka', master, etc. -func IsReleasesBelow(t *testing.T, release string) bool { - current_branch := getReleaseFromEnv(t) - - if current_branch != "master" || current_branch < release { - return true - } - t.Logf("Target release %s is above the current branch %s", release, current_branch) +func IsCurrentBelow(t *testing.T, release string) bool { + current := getReleaseFromEnv(t) + release = strings.TrimPrefix(release, "stable/") + + if current != "master" { + // Assume master is always too new + if release == "master" { + return true + } + // Numeral releases are always newer than non-numeral ones + if isReleaseNumeral(release) && !isReleaseNumeral(current) { + return true + } + if release > current && !(!isReleaseNumeral(release) && isReleaseNumeral(current)) { + return true + } + } + t.Logf("Target release %s is above the current branch %s", release, current) return false } diff --git a/acceptance/clients/http.go b/internal/acceptance/clients/http.go similarity index 100% rename from acceptance/clients/http.go rename to internal/acceptance/clients/http.go diff --git a/internal/acceptance/clients/testing/conditions_test.go b/internal/acceptance/clients/testing/conditions_test.go new file mode 100644 index 0000000000..3fbe11260e --- /dev/null +++ b/internal/acceptance/clients/testing/conditions_test.go @@ -0,0 +1,65 @@ +package testing + +import ( + "fmt" + "os" + "testing" + + "github.com/gophercloud/gophercloud/internal/acceptance/clients" +) + +func TestIsCurrentAbove(t *testing.T) { + cases := []struct { + Current string + Release string + Result bool + }{ + {Current: "master", Release: "zed", Result: true}, + {Current: "master", Release: "2023.1", Result: true}, + {Current: "master", Release: "master", Result: false}, + {Current: "zed", Release: "master", Result: false}, + {Current: "zed", Release: "yoga", Result: true}, + {Current: "zed", Release: "2023.1", Result: false}, + {Current: "2023.1", Release: "2023.1", Result: false}, + {Current: "2023.2", Release: "stable/2023.1", Result: true}, + } + + for _, tt := range cases { + t.Run(fmt.Sprintf("%s above %s", tt.Current, tt.Release), func(t *testing.T) { + os.Setenv("OS_BRANCH", tt.Current) + got := clients.IsCurrentAbove(t, tt.Release) + if got != tt.Result { + t.Errorf("got %v want %v", got, tt.Result) + } + }) + + } +} + +func TestIsCurrentBelow(t *testing.T) { + cases := []struct { + Current string + Release string + Result bool + }{ + {Current: "master", Release: "zed", Result: false}, + {Current: "master", Release: "2023.1", Result: false}, + {Current: "master", Release: "master", Result: false}, + {Current: "zed", Release: "master", Result: true}, + {Current: "zed", Release: "yoga", Result: false}, + {Current: "zed", Release: "2023.1", Result: true}, + {Current: "2023.1", Release: "2023.1", Result: false}, + {Current: "2023.2", Release: "stable/2023.1", Result: false}, + } + + for _, tt := range cases { + t.Run(fmt.Sprintf("%s below %s", tt.Current, tt.Release), func(t *testing.T) { + os.Setenv("OS_BRANCH", tt.Current) + got := clients.IsCurrentBelow(t, tt.Release) + if got != tt.Result { + t.Errorf("got %v want %v", got, tt.Result) + } + }) + + } +} diff --git a/acceptance/openstack/baremetal/httpbasic/allocations_test.go b/internal/acceptance/openstack/baremetal/httpbasic/allocations_test.go similarity index 87% rename from acceptance/openstack/baremetal/httpbasic/allocations_test.go rename to internal/acceptance/openstack/baremetal/httpbasic/allocations_test.go index afe44a0cf2..89acfb6a03 100644 --- a/acceptance/openstack/baremetal/httpbasic/allocations_test.go +++ b/internal/acceptance/openstack/baremetal/httpbasic/allocations_test.go @@ -6,8 +6,8 @@ package httpbasic import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - v1 "github.com/gophercloud/gophercloud/acceptance/openstack/baremetal/v1" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + v1 "github.com/gophercloud/gophercloud/internal/acceptance/openstack/baremetal/v1" "github.com/gophercloud/gophercloud/openstack/baremetal/v1/allocations" "github.com/gophercloud/gophercloud/pagination" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/baremetal/httpbasic/doc.go b/internal/acceptance/openstack/baremetal/httpbasic/doc.go similarity index 100% rename from acceptance/openstack/baremetal/httpbasic/doc.go rename to internal/acceptance/openstack/baremetal/httpbasic/doc.go diff --git a/acceptance/openstack/baremetal/httpbasic/nodes_test.go b/internal/acceptance/openstack/baremetal/httpbasic/nodes_test.go similarity index 93% rename from acceptance/openstack/baremetal/httpbasic/nodes_test.go rename to internal/acceptance/openstack/baremetal/httpbasic/nodes_test.go index 79995912e3..993a3ca227 100644 --- a/acceptance/openstack/baremetal/httpbasic/nodes_test.go +++ b/internal/acceptance/openstack/baremetal/httpbasic/nodes_test.go @@ -3,8 +3,8 @@ package httpbasic import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - v1 "github.com/gophercloud/gophercloud/acceptance/openstack/baremetal/v1" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + v1 "github.com/gophercloud/gophercloud/internal/acceptance/openstack/baremetal/v1" "github.com/gophercloud/gophercloud/openstack/baremetal/v1/nodes" "github.com/gophercloud/gophercloud/pagination" diff --git a/acceptance/openstack/baremetal/httpbasic/ports_test.go b/internal/acceptance/openstack/baremetal/httpbasic/ports_test.go similarity index 92% rename from acceptance/openstack/baremetal/httpbasic/ports_test.go rename to internal/acceptance/openstack/baremetal/httpbasic/ports_test.go index ebed5b6785..f69ba2744a 100644 --- a/acceptance/openstack/baremetal/httpbasic/ports_test.go +++ b/internal/acceptance/openstack/baremetal/httpbasic/ports_test.go @@ -6,8 +6,8 @@ package httpbasic import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - v1 "github.com/gophercloud/gophercloud/acceptance/openstack/baremetal/v1" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + v1 "github.com/gophercloud/gophercloud/internal/acceptance/openstack/baremetal/v1" "github.com/gophercloud/gophercloud/openstack/baremetal/v1/ports" "github.com/gophercloud/gophercloud/pagination" diff --git a/acceptance/openstack/baremetal/noauth/allocations_test.go b/internal/acceptance/openstack/baremetal/noauth/allocations_test.go similarity index 87% rename from acceptance/openstack/baremetal/noauth/allocations_test.go rename to internal/acceptance/openstack/baremetal/noauth/allocations_test.go index 825fd4d93e..fe02a1fdb6 100644 --- a/acceptance/openstack/baremetal/noauth/allocations_test.go +++ b/internal/acceptance/openstack/baremetal/noauth/allocations_test.go @@ -6,8 +6,8 @@ package noauth import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - v1 "github.com/gophercloud/gophercloud/acceptance/openstack/baremetal/v1" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + v1 "github.com/gophercloud/gophercloud/internal/acceptance/openstack/baremetal/v1" "github.com/gophercloud/gophercloud/openstack/baremetal/v1/allocations" "github.com/gophercloud/gophercloud/pagination" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/baremetal/noauth/doc.go b/internal/acceptance/openstack/baremetal/noauth/doc.go similarity index 100% rename from acceptance/openstack/baremetal/noauth/doc.go rename to internal/acceptance/openstack/baremetal/noauth/doc.go diff --git a/acceptance/openstack/baremetal/noauth/nodes_test.go b/internal/acceptance/openstack/baremetal/noauth/nodes_test.go similarity index 93% rename from acceptance/openstack/baremetal/noauth/nodes_test.go rename to internal/acceptance/openstack/baremetal/noauth/nodes_test.go index 09969992a3..3d2f36c6f7 100644 --- a/acceptance/openstack/baremetal/noauth/nodes_test.go +++ b/internal/acceptance/openstack/baremetal/noauth/nodes_test.go @@ -3,8 +3,8 @@ package noauth import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - v1 "github.com/gophercloud/gophercloud/acceptance/openstack/baremetal/v1" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + v1 "github.com/gophercloud/gophercloud/internal/acceptance/openstack/baremetal/v1" "github.com/gophercloud/gophercloud/openstack/baremetal/v1/nodes" "github.com/gophercloud/gophercloud/pagination" diff --git a/acceptance/openstack/baremetal/noauth/ports_test.go b/internal/acceptance/openstack/baremetal/noauth/ports_test.go similarity index 91% rename from acceptance/openstack/baremetal/noauth/ports_test.go rename to internal/acceptance/openstack/baremetal/noauth/ports_test.go index a45b26d462..bb59ec6ad4 100644 --- a/acceptance/openstack/baremetal/noauth/ports_test.go +++ b/internal/acceptance/openstack/baremetal/noauth/ports_test.go @@ -6,8 +6,8 @@ package noauth import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - v1 "github.com/gophercloud/gophercloud/acceptance/openstack/baremetal/v1" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + v1 "github.com/gophercloud/gophercloud/internal/acceptance/openstack/baremetal/v1" "github.com/gophercloud/gophercloud/openstack/baremetal/v1/ports" "github.com/gophercloud/gophercloud/pagination" diff --git a/acceptance/openstack/baremetal/v1/allocations_test.go b/internal/acceptance/openstack/baremetal/v1/allocations_test.go similarity index 94% rename from acceptance/openstack/baremetal/v1/allocations_test.go rename to internal/acceptance/openstack/baremetal/v1/allocations_test.go index 7c6bfac52f..c902f4219d 100644 --- a/acceptance/openstack/baremetal/v1/allocations_test.go +++ b/internal/acceptance/openstack/baremetal/v1/allocations_test.go @@ -6,7 +6,7 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" "github.com/gophercloud/gophercloud/openstack/baremetal/v1/allocations" "github.com/gophercloud/gophercloud/pagination" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/baremetal/v1/baremetal.go b/internal/acceptance/openstack/baremetal/v1/baremetal.go similarity index 98% rename from acceptance/openstack/baremetal/v1/baremetal.go rename to internal/acceptance/openstack/baremetal/v1/baremetal.go index 1278de533a..5849957fb8 100644 --- a/acceptance/openstack/baremetal/v1/baremetal.go +++ b/internal/acceptance/openstack/baremetal/v1/baremetal.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/baremetal/v1/allocations" "github.com/gophercloud/gophercloud/openstack/baremetal/v1/nodes" "github.com/gophercloud/gophercloud/openstack/baremetal/v1/ports" diff --git a/internal/acceptance/openstack/baremetal/v1/conductors_test.go b/internal/acceptance/openstack/baremetal/v1/conductors_test.go new file mode 100644 index 0000000000..4dc294c4b6 --- /dev/null +++ b/internal/acceptance/openstack/baremetal/v1/conductors_test.go @@ -0,0 +1,42 @@ +//go:build acceptance || baremetal || conductors +// +build acceptance baremetal conductors + +package v1 + +import ( + "testing" + + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" + "github.com/gophercloud/gophercloud/openstack/baremetal/v1/conductors" + "github.com/gophercloud/gophercloud/pagination" + + th "github.com/gophercloud/gophercloud/testhelper" +) + +func TestConductorsListAndGet(t *testing.T) { + clients.RequireLong(t) + + client, err := clients.NewBareMetalV1Client() + th.AssertNoErr(t, err) + client.Microversion = "1.49" + + err = conductors.List(client, conductors.ListOpts{}).EachPage(func(page pagination.Page) (bool, error) { + conductorList, err := conductors.ExtractConductors(page) + if err != nil { + return false, err + } + + tools.PrintResource(t, conductorList) + + if len(conductorList) > 0 { + conductor, err := conductors.Get(client, conductorList[0].Hostname).Extract() + th.AssertNoErr(t, err) + + tools.PrintResource(t, conductor) + } + + return true, nil + }) + th.AssertNoErr(t, err) +} diff --git a/acceptance/openstack/baremetal/v1/nodes_test.go b/internal/acceptance/openstack/baremetal/v1/nodes_test.go similarity index 79% rename from acceptance/openstack/baremetal/v1/nodes_test.go rename to internal/acceptance/openstack/baremetal/v1/nodes_test.go index 2c0af7c499..2df8c2075f 100644 --- a/acceptance/openstack/baremetal/v1/nodes_test.go +++ b/internal/acceptance/openstack/baremetal/v1/nodes_test.go @@ -6,7 +6,7 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" "github.com/gophercloud/gophercloud/openstack/baremetal/v1/nodes" "github.com/gophercloud/gophercloud/pagination" @@ -45,6 +45,38 @@ func TestNodesCreateDestroy(t *testing.T) { th.AssertEquals(t, found, true) } +func TestNodesFields(t *testing.T) { + clients.RequireLong(t) + + client, err := clients.NewBareMetalV1Client() + th.AssertNoErr(t, err) + client.Microversion = "1.38" + + node, err := CreateNode(t, client) + th.AssertNoErr(t, err) + defer DeleteNode(t, client, node) + err = nodes.List(client, nodes.ListOpts{ + Fields: []string{"uuid", "deploy_interface"}, + }).EachPage(func(page pagination.Page) (bool, error) { + nodeList, err := nodes.ExtractNodes(page) + if err != nil { + return false, err + } + + for _, n := range nodeList { + if n.UUID == "" || n.DeployInterface == "" { + t.Errorf("UUID or DeployInterface empty on %+v", n) + } + if n.BootInterface != "" { + t.Errorf("BootInterface was not fetched but is not empty on %+v", n) + } + } + + return true, nil + }) + th.AssertNoErr(t, err) +} + func TestNodesUpdate(t *testing.T) { clients.RequireLong(t) diff --git a/acceptance/openstack/baremetal/v1/ports_test.go b/internal/acceptance/openstack/baremetal/v1/ports_test.go similarity index 96% rename from acceptance/openstack/baremetal/v1/ports_test.go rename to internal/acceptance/openstack/baremetal/v1/ports_test.go index e263402c29..069a31028d 100644 --- a/acceptance/openstack/baremetal/v1/ports_test.go +++ b/internal/acceptance/openstack/baremetal/v1/ports_test.go @@ -6,7 +6,7 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" "github.com/gophercloud/gophercloud/openstack/baremetal/v1/ports" "github.com/gophercloud/gophercloud/pagination" diff --git a/acceptance/openstack/blockstorage/apiversions_test.go b/internal/acceptance/openstack/blockstorage/apiversions_test.go similarity index 89% rename from acceptance/openstack/blockstorage/apiversions_test.go rename to internal/acceptance/openstack/blockstorage/apiversions_test.go index 77ccda0f31..b9ff57b83f 100644 --- a/acceptance/openstack/blockstorage/apiversions_test.go +++ b/internal/acceptance/openstack/blockstorage/apiversions_test.go @@ -6,8 +6,8 @@ package blockstorage import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/blockstorage/apiversions" ) diff --git a/acceptance/openstack/blockstorage/extensions/backups_test.go b/internal/acceptance/openstack/blockstorage/extensions/backups_test.go similarity index 85% rename from acceptance/openstack/blockstorage/extensions/backups_test.go rename to internal/acceptance/openstack/blockstorage/extensions/backups_test.go index 67f86c8eb6..eea44b511d 100644 --- a/acceptance/openstack/blockstorage/extensions/backups_test.go +++ b/internal/acceptance/openstack/blockstorage/extensions/backups_test.go @@ -6,10 +6,10 @@ package extensions import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" "github.com/gophercloud/gophercloud/openstack/blockstorage/extensions/backups" - blockstorage "github.com/gophercloud/gophercloud/acceptance/openstack/blockstorage/v3" + blockstorage "github.com/gophercloud/gophercloud/internal/acceptance/openstack/blockstorage/v3" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/blockstorage/extensions/extensions.go b/internal/acceptance/openstack/blockstorage/extensions/extensions.go similarity index 94% rename from acceptance/openstack/blockstorage/extensions/extensions.go rename to internal/acceptance/openstack/blockstorage/extensions/extensions.go index d15e4b652d..dca1062035 100644 --- a/acceptance/openstack/blockstorage/extensions/extensions.go +++ b/internal/acceptance/openstack/blockstorage/extensions/extensions.go @@ -9,7 +9,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/blockstorage/extensions/backups" "github.com/gophercloud/gophercloud/openstack/blockstorage/extensions/volumeactions" "github.com/gophercloud/gophercloud/openstack/blockstorage/v2/volumes" @@ -314,6 +314,25 @@ func ChangeVolumeType(t *testing.T, client *gophercloud.ServiceClient, volume *v return nil } +// ResetVolumeStatus will reset the status of a volume. +func ResetVolumeStatus(t *testing.T, client *gophercloud.ServiceClient, volume *v3.Volume, status string) error { + t.Logf("Attempting to reset the status of volume %s from %s to %s", volume.ID, volume.Status, status) + + resetOpts := volumeactions.ResetStatusOpts{ + Status: status, + } + err := volumeactions.ResetStatus(client, volume.ID, resetOpts).ExtractErr() + if err != nil { + return err + } + + if err := volumes.WaitForStatus(client, volume.ID, status, 60); err != nil { + return err + } + + return nil +} + // ReImage will re-image a volume func ReImage(t *testing.T, client *gophercloud.ServiceClient, volume *volumes.Volume, imageID string) error { t.Logf("Attempting to re-image volume %s", volume.ID) diff --git a/acceptance/openstack/blockstorage/extensions/limits_test.go b/internal/acceptance/openstack/blockstorage/extensions/limits_test.go similarity index 92% rename from acceptance/openstack/blockstorage/extensions/limits_test.go rename to internal/acceptance/openstack/blockstorage/extensions/limits_test.go index c1b3994f9c..4ea356f657 100644 --- a/acceptance/openstack/blockstorage/extensions/limits_test.go +++ b/internal/acceptance/openstack/blockstorage/extensions/limits_test.go @@ -3,8 +3,8 @@ package extensions import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/blockstorage/extensions/limits" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/blockstorage/extensions/pkg.go b/internal/acceptance/openstack/blockstorage/extensions/pkg.go similarity index 100% rename from acceptance/openstack/blockstorage/extensions/pkg.go rename to internal/acceptance/openstack/blockstorage/extensions/pkg.go diff --git a/acceptance/openstack/blockstorage/extensions/schedulerhints_test.go b/internal/acceptance/openstack/blockstorage/extensions/schedulerhints_test.go similarity index 91% rename from acceptance/openstack/blockstorage/extensions/schedulerhints_test.go rename to internal/acceptance/openstack/blockstorage/extensions/schedulerhints_test.go index 8ff9fbb6a1..9864428324 100644 --- a/acceptance/openstack/blockstorage/extensions/schedulerhints_test.go +++ b/internal/acceptance/openstack/blockstorage/extensions/schedulerhints_test.go @@ -6,8 +6,8 @@ package extensions import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/blockstorage/extensions/schedulerhints" "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/blockstorage/extensions/schedulerstats_test.go b/internal/acceptance/openstack/blockstorage/extensions/schedulerstats_test.go similarity index 84% rename from acceptance/openstack/blockstorage/extensions/schedulerstats_test.go rename to internal/acceptance/openstack/blockstorage/extensions/schedulerstats_test.go index 7b5f609b1c..f30c4c6120 100644 --- a/acceptance/openstack/blockstorage/extensions/schedulerstats_test.go +++ b/internal/acceptance/openstack/blockstorage/extensions/schedulerstats_test.go @@ -6,8 +6,8 @@ package extensions import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/blockstorage/extensions/schedulerstats" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/blockstorage/extensions/services_test.go b/internal/acceptance/openstack/blockstorage/extensions/services_test.go similarity index 83% rename from acceptance/openstack/blockstorage/extensions/services_test.go rename to internal/acceptance/openstack/blockstorage/extensions/services_test.go index 863d38aaec..9f32132a54 100644 --- a/acceptance/openstack/blockstorage/extensions/services_test.go +++ b/internal/acceptance/openstack/blockstorage/extensions/services_test.go @@ -6,8 +6,8 @@ package extensions import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/blockstorage/extensions/services" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/blockstorage/extensions/volumeactions_test.go b/internal/acceptance/openstack/blockstorage/extensions/volumeactions_test.go similarity index 87% rename from acceptance/openstack/blockstorage/extensions/volumeactions_test.go rename to internal/acceptance/openstack/blockstorage/extensions/volumeactions_test.go index 3c69d17a46..673e968297 100644 --- a/acceptance/openstack/blockstorage/extensions/volumeactions_test.go +++ b/internal/acceptance/openstack/blockstorage/extensions/volumeactions_test.go @@ -6,11 +6,11 @@ package extensions import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - blockstorage "github.com/gophercloud/gophercloud/acceptance/openstack/blockstorage/v2" - blockstorageV3 "github.com/gophercloud/gophercloud/acceptance/openstack/blockstorage/v3" - compute "github.com/gophercloud/gophercloud/acceptance/openstack/compute/v2" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + blockstorage "github.com/gophercloud/gophercloud/internal/acceptance/openstack/blockstorage/v2" + blockstorageV3 "github.com/gophercloud/gophercloud/internal/acceptance/openstack/blockstorage/v3" + compute "github.com/gophercloud/gophercloud/internal/acceptance/openstack/compute/v2" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/blockstorage/v2/volumes" th "github.com/gophercloud/gophercloud/testhelper" ) @@ -145,6 +145,23 @@ func TestVolumeActionsChangeType(t *testing.T) { tools.PrintResource(t, newVolume) } +func TestVolumeActionsResetStatus(t *testing.T) { + client, err := clients.NewBlockStorageV3Client() + th.AssertNoErr(t, err) + + volume, err := blockstorageV3.CreateVolume(t, client) + th.AssertNoErr(t, err) + defer blockstorageV3.DeleteVolume(t, client, volume) + + tools.PrintResource(t, volume) + + err = ResetVolumeStatus(t, client, volume, "error") + th.AssertNoErr(t, err) + + err = ResetVolumeStatus(t, client, volume, "available") + th.AssertNoErr(t, err) +} + func TestVolumeActionsReImage(t *testing.T) { clients.SkipReleasesBelow(t, "stable/yoga") diff --git a/acceptance/openstack/blockstorage/extensions/volumetenants_test.go b/internal/acceptance/openstack/blockstorage/extensions/volumetenants_test.go similarity index 87% rename from acceptance/openstack/blockstorage/extensions/volumetenants_test.go rename to internal/acceptance/openstack/blockstorage/extensions/volumetenants_test.go index e684a79423..2571588537 100644 --- a/acceptance/openstack/blockstorage/extensions/volumetenants_test.go +++ b/internal/acceptance/openstack/blockstorage/extensions/volumetenants_test.go @@ -6,8 +6,8 @@ package extensions import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - blockstorage "github.com/gophercloud/gophercloud/acceptance/openstack/blockstorage/v3" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + blockstorage "github.com/gophercloud/gophercloud/internal/acceptance/openstack/blockstorage/v3" "github.com/gophercloud/gophercloud/openstack/blockstorage/extensions/volumetenants" "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/blockstorage/noauth/blockstorage.go b/internal/acceptance/openstack/blockstorage/noauth/blockstorage.go similarity index 96% rename from acceptance/openstack/blockstorage/noauth/blockstorage.go rename to internal/acceptance/openstack/blockstorage/noauth/blockstorage.go index d057c2e604..6f5580714f 100644 --- a/acceptance/openstack/blockstorage/noauth/blockstorage.go +++ b/internal/acceptance/openstack/blockstorage/noauth/blockstorage.go @@ -7,8 +7,8 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/snapshots" "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes" ) diff --git a/acceptance/openstack/blockstorage/noauth/snapshots_test.go b/internal/acceptance/openstack/blockstorage/noauth/snapshots_test.go similarity index 91% rename from acceptance/openstack/blockstorage/noauth/snapshots_test.go rename to internal/acceptance/openstack/blockstorage/noauth/snapshots_test.go index 2c0cc63dec..a12d1fa66b 100644 --- a/acceptance/openstack/blockstorage/noauth/snapshots_test.go +++ b/internal/acceptance/openstack/blockstorage/noauth/snapshots_test.go @@ -6,8 +6,8 @@ package noauth import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/snapshots" ) diff --git a/acceptance/openstack/blockstorage/noauth/volumes_test.go b/internal/acceptance/openstack/blockstorage/noauth/volumes_test.go similarity index 90% rename from acceptance/openstack/blockstorage/noauth/volumes_test.go rename to internal/acceptance/openstack/blockstorage/noauth/volumes_test.go index 5f80d07cfb..5a66210a33 100644 --- a/acceptance/openstack/blockstorage/noauth/volumes_test.go +++ b/internal/acceptance/openstack/blockstorage/noauth/volumes_test.go @@ -6,8 +6,8 @@ package noauth import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes" ) diff --git a/acceptance/openstack/blockstorage/v1/blockstorage.go b/internal/acceptance/openstack/blockstorage/v1/blockstorage.go similarity index 98% rename from acceptance/openstack/blockstorage/v1/blockstorage.go rename to internal/acceptance/openstack/blockstorage/v1/blockstorage.go index 670eaad50d..e380f80caf 100644 --- a/acceptance/openstack/blockstorage/v1/blockstorage.go +++ b/internal/acceptance/openstack/blockstorage/v1/blockstorage.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/blockstorage/v1/snapshots" "github.com/gophercloud/gophercloud/openstack/blockstorage/v1/volumes" "github.com/gophercloud/gophercloud/openstack/blockstorage/v1/volumetypes" diff --git a/acceptance/openstack/blockstorage/v1/pkg.go b/internal/acceptance/openstack/blockstorage/v1/pkg.go similarity index 100% rename from acceptance/openstack/blockstorage/v1/pkg.go rename to internal/acceptance/openstack/blockstorage/v1/pkg.go diff --git a/acceptance/openstack/blockstorage/v1/snapshots_test.go b/internal/acceptance/openstack/blockstorage/v1/snapshots_test.go similarity index 91% rename from acceptance/openstack/blockstorage/v1/snapshots_test.go rename to internal/acceptance/openstack/blockstorage/v1/snapshots_test.go index 9ff2c192a4..8b02b35486 100644 --- a/acceptance/openstack/blockstorage/v1/snapshots_test.go +++ b/internal/acceptance/openstack/blockstorage/v1/snapshots_test.go @@ -6,8 +6,8 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/blockstorage/v1/snapshots" ) diff --git a/acceptance/openstack/blockstorage/v1/volumes_test.go b/internal/acceptance/openstack/blockstorage/v1/volumes_test.go similarity index 93% rename from acceptance/openstack/blockstorage/v1/volumes_test.go rename to internal/acceptance/openstack/blockstorage/v1/volumes_test.go index c5aba5d539..d22701955c 100644 --- a/acceptance/openstack/blockstorage/v1/volumes_test.go +++ b/internal/acceptance/openstack/blockstorage/v1/volumes_test.go @@ -6,8 +6,8 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/blockstorage/v1/volumes" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/blockstorage/v1/volumetypes_test.go b/internal/acceptance/openstack/blockstorage/v1/volumetypes_test.go similarity index 90% rename from acceptance/openstack/blockstorage/v1/volumetypes_test.go rename to internal/acceptance/openstack/blockstorage/v1/volumetypes_test.go index c1e76a740e..f21fe5eae1 100644 --- a/acceptance/openstack/blockstorage/v1/volumetypes_test.go +++ b/internal/acceptance/openstack/blockstorage/v1/volumetypes_test.go @@ -6,8 +6,8 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/blockstorage/v1/volumetypes" ) diff --git a/acceptance/openstack/blockstorage/v2/blockstorage.go b/internal/acceptance/openstack/blockstorage/v2/blockstorage.go similarity index 97% rename from acceptance/openstack/blockstorage/v2/blockstorage.go rename to internal/acceptance/openstack/blockstorage/v2/blockstorage.go index 6170d555ba..e3027abce9 100644 --- a/acceptance/openstack/blockstorage/v2/blockstorage.go +++ b/internal/acceptance/openstack/blockstorage/v2/blockstorage.go @@ -7,8 +7,8 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/blockstorage/v2/snapshots" "github.com/gophercloud/gophercloud/openstack/blockstorage/v2/volumes" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/blockstorage/v2/pkg.go b/internal/acceptance/openstack/blockstorage/v2/pkg.go similarity index 100% rename from acceptance/openstack/blockstorage/v2/pkg.go rename to internal/acceptance/openstack/blockstorage/v2/pkg.go diff --git a/acceptance/openstack/blockstorage/v2/snapshots_test.go b/internal/acceptance/openstack/blockstorage/v2/snapshots_test.go similarity index 89% rename from acceptance/openstack/blockstorage/v2/snapshots_test.go rename to internal/acceptance/openstack/blockstorage/v2/snapshots_test.go index 22a8a6bd8a..ec8a2775d8 100644 --- a/acceptance/openstack/blockstorage/v2/snapshots_test.go +++ b/internal/acceptance/openstack/blockstorage/v2/snapshots_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/blockstorage/v2/snapshots" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/blockstorage/v2/volumes_test.go b/internal/acceptance/openstack/blockstorage/v2/volumes_test.go similarity index 96% rename from acceptance/openstack/blockstorage/v2/volumes_test.go rename to internal/acceptance/openstack/blockstorage/v2/volumes_test.go index f2f839cc98..3ca33c1b6c 100644 --- a/acceptance/openstack/blockstorage/v2/volumes_test.go +++ b/internal/acceptance/openstack/blockstorage/v2/volumes_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/blockstorage/extensions/volumeactions" "github.com/gophercloud/gophercloud/openstack/blockstorage/v2/snapshots" "github.com/gophercloud/gophercloud/openstack/blockstorage/v2/volumes" diff --git a/acceptance/openstack/blockstorage/v3/blockstorage.go b/internal/acceptance/openstack/blockstorage/v3/blockstorage.go similarity index 86% rename from acceptance/openstack/blockstorage/v3/blockstorage.go rename to internal/acceptance/openstack/blockstorage/v3/blockstorage.go index 5e05024a1c..6a4408a543 100644 --- a/acceptance/openstack/blockstorage/v3/blockstorage.go +++ b/internal/acceptance/openstack/blockstorage/v3/blockstorage.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/qos" "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/snapshots" "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes" @@ -38,6 +38,11 @@ func CreateSnapshot(t *testing.T, client *gophercloud.ServiceClient, volume *vol return snapshot, err } + snapshot, err = snapshots.Get(client, snapshot.ID).Extract() + if err != nil { + return snapshot, err + } + tools.PrintResource(t, snapshot) th.AssertEquals(t, snapshot.Name, snapshotName) th.AssertEquals(t, snapshot.VolumeID, volume.ID) @@ -70,6 +75,11 @@ func CreateVolume(t *testing.T, client *gophercloud.ServiceClient) (*volumes.Vol return volume, err } + volume, err = volumes.Get(client, volume.ID).Extract() + if err != nil { + return volume, err + } + tools.PrintResource(t, volume) th.AssertEquals(t, volume.Name, volumeName) th.AssertEquals(t, volume.Description, volumeDescription) @@ -105,6 +115,11 @@ func CreateVolumeWithType(t *testing.T, client *gophercloud.ServiceClient, vt *v return volume, err } + volume, err = volumes.Get(client, volume.ID).Extract() + if err != nil { + return volume, err + } + tools.PrintResource(t, volume) th.AssertEquals(t, volume.Name, volumeName) th.AssertEquals(t, volume.Description, volumeDescription) @@ -177,6 +192,36 @@ func CreateVolumeTypeNoExtraSpecs(t *testing.T, client *gophercloud.ServiceClien return vt, nil } +// CreateVolumeTypeMultiAttach will create a volume type with a random name and +// extra specs for multi-attach. An error will be returned if the volume type was +// unable to be created. +func CreateVolumeTypeMultiAttach(t *testing.T, client *gophercloud.ServiceClient) (*volumetypes.VolumeType, error) { + name := tools.RandomString("ACPTTEST", 16) + description := "create_from_gophercloud" + t.Logf("Attempting to create volume type: %s", name) + + createOpts := volumetypes.CreateOpts{ + Name: name, + ExtraSpecs: map[string]string{"multiattach": " True"}, + Description: description, + } + + vt, err := volumetypes.Create(client, createOpts).Extract() + if err != nil { + return nil, err + } + + tools.PrintResource(t, vt) + th.AssertEquals(t, vt.IsPublic, true) + th.AssertEquals(t, vt.Name, name) + th.AssertEquals(t, vt.Description, description) + th.AssertEquals(t, vt.ExtraSpecs["multiattach"], " True") + + t.Logf("Successfully created volume type: %s", vt.ID) + + return vt, nil +} + // CreatePrivateVolumeType will create a private volume type with a random // name and no extra specs. An error will be returned if the volume type was // unable to be created. @@ -213,6 +258,9 @@ func CreatePrivateVolumeType(t *testing.T, client *gophercloud.ServiceClient) (* func DeleteSnapshot(t *testing.T, client *gophercloud.ServiceClient, snapshot *snapshots.Snapshot) { err := snapshots.Delete(client, snapshot.ID).ExtractErr() if err != nil { + if _, ok := err.(gophercloud.ErrDefault404); ok { + return + } t.Fatalf("Unable to delete snapshot %s: %+v", snapshot.ID, err) } @@ -240,6 +288,9 @@ func DeleteVolume(t *testing.T, client *gophercloud.ServiceClient, volume *volum err := volumes.Delete(client, volume.ID, volumes.DeleteOpts{}).ExtractErr() if err != nil { + if _, ok := err.(gophercloud.ErrDefault404); ok { + return + } t.Fatalf("Unable to delete volume %s: %v", volume.ID, err) } @@ -268,7 +319,7 @@ func DeleteVolumeType(t *testing.T, client *gophercloud.ServiceClient, vt *volum err := volumetypes.Delete(client, vt.ID).ExtractErr() if err != nil { - t.Fatalf("Unable to delete volume %s: %v", vt.ID, err) + t.Fatalf("Unable to delete volume type %s: %v", vt.ID, err) } t.Logf("Successfully deleted volume type: %s", vt.ID) diff --git a/acceptance/openstack/blockstorage/v3/pkg.go b/internal/acceptance/openstack/blockstorage/v3/pkg.go similarity index 100% rename from acceptance/openstack/blockstorage/v3/pkg.go rename to internal/acceptance/openstack/blockstorage/v3/pkg.go diff --git a/acceptance/openstack/blockstorage/v3/qos_test.go b/internal/acceptance/openstack/blockstorage/v3/qos_test.go similarity index 95% rename from acceptance/openstack/blockstorage/v3/qos_test.go rename to internal/acceptance/openstack/blockstorage/v3/qos_test.go index 82c52a384a..85aa5b1908 100644 --- a/acceptance/openstack/blockstorage/v3/qos_test.go +++ b/internal/acceptance/openstack/blockstorage/v3/qos_test.go @@ -3,8 +3,8 @@ package v3 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/qos" "github.com/gophercloud/gophercloud/pagination" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/blockstorage/v3/quotaset_test.go b/internal/acceptance/openstack/blockstorage/v3/quotaset_test.go similarity index 96% rename from acceptance/openstack/blockstorage/v3/quotaset_test.go rename to internal/acceptance/openstack/blockstorage/v3/quotaset_test.go index bffe0793d1..1106f160da 100644 --- a/acceptance/openstack/blockstorage/v3/quotaset_test.go +++ b/internal/acceptance/openstack/blockstorage/v3/quotaset_test.go @@ -8,8 +8,8 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/blockstorage/extensions/quotasets" "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumetypes" th "github.com/gophercloud/gophercloud/testhelper" @@ -118,7 +118,7 @@ func TestQuotasetUpdate(t *testing.T) { // test that resultQuotas.Extra is populated with the 3 new quota types // for the new volumeType foo, don't take into account other volume types count := 0 - for k, _ := range resultQuotas.Extra { + for k := range resultQuotas.Extra { tools.PrintResource(t, k) switch k { case diff --git a/internal/acceptance/openstack/blockstorage/v3/snapshots_test.go b/internal/acceptance/openstack/blockstorage/v3/snapshots_test.go new file mode 100644 index 0000000000..51cdd1f461 --- /dev/null +++ b/internal/acceptance/openstack/blockstorage/v3/snapshots_test.go @@ -0,0 +1,199 @@ +//go:build acceptance || blockstorage +// +build acceptance blockstorage + +package v3 + +import ( + "fmt" + "testing" + + "github.com/gophercloud/gophercloud" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" + "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/snapshots" + "github.com/gophercloud/gophercloud/pagination" + th "github.com/gophercloud/gophercloud/testhelper" +) + +func TestSnapshots(t *testing.T) { + clients.RequireLong(t) + + client, err := clients.NewBlockStorageV3Client() + th.AssertNoErr(t, err) + + volume1, err := CreateVolume(t, client) + th.AssertNoErr(t, err) + defer DeleteVolume(t, client, volume1) + + snapshot1, err := CreateSnapshot(t, client, volume1) + th.AssertNoErr(t, err) + defer DeleteSnapshot(t, client, snapshot1) + + // Update snapshot + updatedSnapshotName := tools.RandomString("ACPTTEST", 16) + updatedSnapshotDescription := tools.RandomString("ACPTTEST", 16) + updateOpts := snapshots.UpdateOpts{ + Name: &updatedSnapshotName, + Description: &updatedSnapshotDescription, + } + t.Logf("Attempting to update snapshot: %s", updatedSnapshotName) + updatedSnapshot, err := snapshots.Update(client, snapshot1.ID, updateOpts).Extract() + th.AssertNoErr(t, err) + + tools.PrintResource(t, updatedSnapshot) + th.AssertEquals(t, updatedSnapshot.Name, updatedSnapshotName) + th.AssertEquals(t, updatedSnapshot.Description, updatedSnapshotDescription) + + volume2, err := CreateVolume(t, client) + th.AssertNoErr(t, err) + defer DeleteVolume(t, client, volume2) + + snapshot2, err := CreateSnapshot(t, client, volume2) + th.AssertNoErr(t, err) + defer DeleteSnapshot(t, client, snapshot2) + + listOpts := snapshots.ListOpts{ + Limit: 1, + } + + err = snapshots.List(client, listOpts).EachPage(func(page pagination.Page) (bool, error) { + actual, err := snapshots.ExtractSnapshots(page) + th.AssertNoErr(t, err) + th.AssertEquals(t, 1, len(actual)) + + var found bool + for _, v := range actual { + if v.ID == snapshot1.ID || v.ID == snapshot2.ID { + found = true + } + } + + th.AssertEquals(t, found, true) + + return true, nil + }) + + th.AssertNoErr(t, err) +} + +func TestSnapshotsResetStatus(t *testing.T) { + clients.RequireLong(t) + + client, err := clients.NewBlockStorageV3Client() + th.AssertNoErr(t, err) + + volume1, err := CreateVolume(t, client) + th.AssertNoErr(t, err) + defer DeleteVolume(t, client, volume1) + + snapshot1, err := CreateSnapshot(t, client, volume1) + th.AssertNoErr(t, err) + defer DeleteSnapshot(t, client, snapshot1) + + // Reset snapshot status to error + resetOpts := snapshots.ResetStatusOpts{ + Status: "error", + } + t.Logf("Attempting to reset snapshot status to %s", resetOpts.Status) + err = snapshots.ResetStatus(client, snapshot1.ID, resetOpts).ExtractErr() + th.AssertNoErr(t, err) + + snapshot, err := snapshots.Get(client, snapshot1.ID).Extract() + th.AssertNoErr(t, err) + + if snapshot.Status != resetOpts.Status { + th.AssertNoErr(t, fmt.Errorf("unexpected %q snapshot status", snapshot.Status)) + } + + // Reset snapshot status to available + resetOpts = snapshots.ResetStatusOpts{ + Status: "available", + } + t.Logf("Attempting to reset snapshot status to %s", resetOpts.Status) + err = snapshots.ResetStatus(client, snapshot1.ID, resetOpts).ExtractErr() + th.AssertNoErr(t, err) + + snapshot, err = snapshots.Get(client, snapshot1.ID).Extract() + th.AssertNoErr(t, err) + + if snapshot.Status != resetOpts.Status { + th.AssertNoErr(t, fmt.Errorf("unexpected %q snapshot status", snapshot.Status)) + } +} + +func TestSnapshotsUpdateStatus(t *testing.T) { + clients.RequireLong(t) + + client, err := clients.NewBlockStorageV3Client() + th.AssertNoErr(t, err) + + volume1, err := CreateVolume(t, client) + th.AssertNoErr(t, err) + defer DeleteVolume(t, client, volume1) + + snapshot1, err := CreateSnapshot(t, client, volume1) + th.AssertNoErr(t, err) + defer DeleteSnapshot(t, client, snapshot1) + + // Update snapshot status to error + resetOpts := snapshots.ResetStatusOpts{ + Status: "creating", + } + t.Logf("Attempting to update snapshot status to %s", resetOpts.Status) + err = snapshots.ResetStatus(client, snapshot1.ID, resetOpts).ExtractErr() + th.AssertNoErr(t, err) + + snapshot, err := snapshots.Get(client, snapshot1.ID).Extract() + th.AssertNoErr(t, err) + + if snapshot.Status != resetOpts.Status { + th.AssertNoErr(t, fmt.Errorf("unexpected %q snapshot status", snapshot.Status)) + } + + // Update snapshot status to available + updateOpts := snapshots.UpdateStatusOpts{ + Status: "available", + } + t.Logf("Attempting to update snapshot status to %s", updateOpts.Status) + err = snapshots.UpdateStatus(client, snapshot1.ID, updateOpts).ExtractErr() + th.AssertNoErr(t, err) + + snapshot, err = snapshots.Get(client, snapshot1.ID).Extract() + th.AssertNoErr(t, err) + + if snapshot.Status != updateOpts.Status { + th.AssertNoErr(t, fmt.Errorf("unexpected %q snapshot status", snapshot.Status)) + } +} + +func TestSnapshotsForceDelete(t *testing.T) { + clients.RequireLong(t) + + client, err := clients.NewBlockStorageV3Client() + th.AssertNoErr(t, err) + + volume, err := CreateVolume(t, client) + th.AssertNoErr(t, err) + defer DeleteVolume(t, client, volume) + + snapshot, err := CreateSnapshot(t, client, volume) + th.AssertNoErr(t, err) + defer DeleteSnapshot(t, client, snapshot) + + // Force delete snapshot + t.Logf("Attempting to force delete %s snapshot", snapshot.ID) + err = snapshots.ForceDelete(client, snapshot.ID).ExtractErr() + th.AssertNoErr(t, err) + + err = tools.WaitFor(func() (bool, error) { + _, err := snapshots.Get(client, snapshot.ID).Extract() + if err != nil { + if _, ok := err.(gophercloud.ErrDefault404); ok { + return true, nil + } + } + + return false, nil + }) + th.AssertNoErr(t, err) +} diff --git a/acceptance/openstack/blockstorage/v3/volumeattachments.go b/internal/acceptance/openstack/blockstorage/v3/volumeattachments.go similarity index 86% rename from acceptance/openstack/blockstorage/v3/volumeattachments.go rename to internal/acceptance/openstack/blockstorage/v3/volumeattachments.go index 510b6841ca..87eb0d92bd 100644 --- a/acceptance/openstack/blockstorage/v3/volumeattachments.go +++ b/internal/acceptance/openstack/blockstorage/v3/volumeattachments.go @@ -20,10 +20,6 @@ func CreateVolumeAttachment(t *testing.T, client *gophercloud.ServiceClient, vol attachOpts := &attachments.CreateOpts{ VolumeUUID: volume.ID, InstanceUUID: server.ID, - Connector: map[string]interface{}{ - "mode": "rw", - "initiator": "fake", - }, } t.Logf("Attempting to attach volume %s to server %s", volume.ID, server.ID) @@ -56,20 +52,6 @@ func CreateVolumeAttachment(t *testing.T, client *gophercloud.ServiceClient, vol return err } - /* - // Not clear how perform a proper update, OpenStack returns "Unable to update the attachment." - updateOpts := &attachments.UpdateOpts{ - Connector: map[string]interface{}{ - "mode": "ro", - "initiator": "fake", - }, - } - attachment, err = attachments.Update(client, attachment.ID, updateOpts).Extract() - if err != nil { - return err - } - */ - listOpts := &attachments.ListOpts{ VolumeID: volume.ID, InstanceID: server.ID, diff --git a/acceptance/openstack/blockstorage/v3/volumeattachments_test.go b/internal/acceptance/openstack/blockstorage/v3/volumeattachments_test.go similarity index 86% rename from acceptance/openstack/blockstorage/v3/volumeattachments_test.go rename to internal/acceptance/openstack/blockstorage/v3/volumeattachments_test.go index a8cd3b005e..5d2b939dc0 100644 --- a/acceptance/openstack/blockstorage/v3/volumeattachments_test.go +++ b/internal/acceptance/openstack/blockstorage/v3/volumeattachments_test.go @@ -6,8 +6,8 @@ package v3 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - compute "github.com/gophercloud/gophercloud/acceptance/openstack/compute/v2" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + compute "github.com/gophercloud/gophercloud/internal/acceptance/openstack/compute/v2" "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/blockstorage/v3/volumes_test.go b/internal/acceptance/openstack/blockstorage/v3/volumes_test.go similarity index 91% rename from acceptance/openstack/blockstorage/v3/volumes_test.go rename to internal/acceptance/openstack/blockstorage/v3/volumes_test.go index 186b32f039..3bf405e3d5 100644 --- a/acceptance/openstack/blockstorage/v3/volumes_test.go +++ b/internal/acceptance/openstack/blockstorage/v3/volumes_test.go @@ -6,8 +6,8 @@ package v3 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/snapshots" "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes" "github.com/gophercloud/gophercloud/pagination" @@ -67,30 +67,33 @@ func TestVolumes(t *testing.T) { } func TestVolumesMultiAttach(t *testing.T) { + clients.RequireAdmin(t) clients.RequireLong(t) client, err := clients.NewBlockStorageV3Client() th.AssertNoErr(t, err) + vt, err := CreateVolumeTypeMultiAttach(t, client) + th.AssertNoErr(t, err) + defer DeleteVolumeType(t, client, vt) + volumeName := tools.RandomString("ACPTTEST", 16) volOpts := volumes.CreateOpts{ Size: 1, Name: volumeName, Description: "Testing creation of multiattach enabled volume", - Multiattach: true, + VolumeType: vt.ID, } vol, err := volumes.Create(client, volOpts).Extract() th.AssertNoErr(t, err) + defer DeleteVolume(t, client, vol) err = volumes.WaitForStatus(client, vol.ID, "available", 60) th.AssertNoErr(t, err) th.AssertEquals(t, vol.Multiattach, true) - - err = volumes.Delete(client, vol.ID, volumes.DeleteOpts{}).ExtractErr() - th.AssertNoErr(t, err) } func TestVolumesCascadeDelete(t *testing.T) { diff --git a/acceptance/openstack/blockstorage/v3/volumetypes_test.go b/internal/acceptance/openstack/blockstorage/v3/volumetypes_test.go similarity index 74% rename from acceptance/openstack/blockstorage/v3/volumetypes_test.go rename to internal/acceptance/openstack/blockstorage/v3/volumetypes_test.go index b640a63f55..84b5c0fd39 100644 --- a/acceptance/openstack/blockstorage/v3/volumetypes_test.go +++ b/internal/acceptance/openstack/blockstorage/v3/volumetypes_test.go @@ -6,9 +6,9 @@ package v3 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - identity "github.com/gophercloud/gophercloud/acceptance/openstack/identity/v3" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + identity "github.com/gophercloud/gophercloud/internal/acceptance/openstack/identity/v3" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumetypes" th "github.com/gophercloud/gophercloud/testhelper" ) @@ -163,3 +163,44 @@ func TestVolumeTypesAccess(t *testing.T) { th.AssertEquals(t, len(accessList), 0) } + +func TestEncryptionVolumeTypes(t *testing.T) { + clients.RequireAdmin(t) + + client, err := clients.NewBlockStorageV3Client() + th.AssertNoErr(t, err) + + vt, err := CreateVolumeType(t, client) + th.AssertNoErr(t, err) + defer DeleteVolumeType(t, client, vt) + + createEncryptionOpts := volumetypes.CreateEncryptionOpts{ + KeySize: 256, + Provider: "luks", + ControlLocation: "front-end", + Cipher: "aes-xts-plain64", + } + + eVT, err := volumetypes.CreateEncryption(client, vt.ID, createEncryptionOpts).Extract() + th.AssertNoErr(t, err) + defer volumetypes.DeleteEncryption(client, eVT.VolumeTypeID, eVT.EncryptionID) + + geVT, err := volumetypes.GetEncryption(client, vt.ID).Extract() + th.AssertNoErr(t, err) + tools.PrintResource(t, geVT) + + key := "cipher" + gesVT, err := volumetypes.GetEncryptionSpec(client, vt.ID, key).Extract() + th.AssertNoErr(t, err) + tools.PrintResource(t, gesVT) + + updateEncryptionOpts := volumetypes.UpdateEncryptionOpts{ + ControlLocation: "back-end", + } + + newEVT, err := volumetypes.UpdateEncryption(client, vt.ID, eVT.EncryptionID, updateEncryptionOpts).Extract() + tools.PrintResource(t, newEVT) + th.AssertNoErr(t, err) + + th.AssertEquals(t, "back-end", newEVT.ControlLocation) +} diff --git a/acceptance/openstack/client_test.go b/internal/acceptance/openstack/client_test.go similarity index 96% rename from acceptance/openstack/client_test.go rename to internal/acceptance/openstack/client_test.go index d497c969a9..366dd8b664 100644 --- a/acceptance/openstack/client_test.go +++ b/internal/acceptance/openstack/client_test.go @@ -9,8 +9,8 @@ import ( "time" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack" "github.com/gophercloud/gophercloud/openstack/identity/v3/credentials" "github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/ec2tokens" diff --git a/acceptance/openstack/clustering/v1/actions_test.go b/internal/acceptance/openstack/clustering/v1/actions_test.go similarity index 83% rename from acceptance/openstack/clustering/v1/actions_test.go rename to internal/acceptance/openstack/clustering/v1/actions_test.go index f8a7843eb1..9ec67640f4 100644 --- a/acceptance/openstack/clustering/v1/actions_test.go +++ b/internal/acceptance/openstack/clustering/v1/actions_test.go @@ -6,8 +6,8 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/clustering/v1/actions" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/clustering/v1/clustering.go b/internal/acceptance/openstack/clustering/v1/clustering.go similarity index 98% rename from acceptance/openstack/clustering/v1/clustering.go rename to internal/acceptance/openstack/clustering/v1/clustering.go index 6c7a406796..d256bf2790 100644 --- a/acceptance/openstack/clustering/v1/clustering.go +++ b/internal/acceptance/openstack/clustering/v1/clustering.go @@ -7,8 +7,8 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/clustering/v1/actions" "github.com/gophercloud/gophercloud/openstack/clustering/v1/clusters" "github.com/gophercloud/gophercloud/openstack/clustering/v1/nodes" diff --git a/acceptance/openstack/clustering/v1/clusters_test.go b/internal/acceptance/openstack/clustering/v1/clusters_test.go similarity index 99% rename from acceptance/openstack/clustering/v1/clusters_test.go rename to internal/acceptance/openstack/clustering/v1/clusters_test.go index f5e72704c2..9d37267ae2 100644 --- a/acceptance/openstack/clustering/v1/clusters_test.go +++ b/internal/acceptance/openstack/clustering/v1/clusters_test.go @@ -8,8 +8,8 @@ import ( "strings" "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/clustering/v1/actions" "github.com/gophercloud/gophercloud/openstack/clustering/v1/clusters" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/clustering/v1/events_test.go b/internal/acceptance/openstack/clustering/v1/events_test.go similarity index 82% rename from acceptance/openstack/clustering/v1/events_test.go rename to internal/acceptance/openstack/clustering/v1/events_test.go index 6e8b50a827..cb849ad880 100644 --- a/acceptance/openstack/clustering/v1/events_test.go +++ b/internal/acceptance/openstack/clustering/v1/events_test.go @@ -6,8 +6,8 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/clustering/v1/events" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/clustering/v1/nodes_test.go b/internal/acceptance/openstack/clustering/v1/nodes_test.go similarity index 98% rename from acceptance/openstack/clustering/v1/nodes_test.go rename to internal/acceptance/openstack/clustering/v1/nodes_test.go index 50d178672d..f35c3d4a46 100644 --- a/acceptance/openstack/clustering/v1/nodes_test.go +++ b/internal/acceptance/openstack/clustering/v1/nodes_test.go @@ -6,8 +6,8 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/clustering/v1/nodes" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/clustering/v1/pkg.go b/internal/acceptance/openstack/clustering/v1/pkg.go similarity index 100% rename from acceptance/openstack/clustering/v1/pkg.go rename to internal/acceptance/openstack/clustering/v1/pkg.go diff --git a/acceptance/openstack/clustering/v1/policies_test.go b/internal/acceptance/openstack/clustering/v1/policies_test.go similarity index 92% rename from acceptance/openstack/clustering/v1/policies_test.go rename to internal/acceptance/openstack/clustering/v1/policies_test.go index a1fc2be6ef..9502b9a1af 100644 --- a/acceptance/openstack/clustering/v1/policies_test.go +++ b/internal/acceptance/openstack/clustering/v1/policies_test.go @@ -6,8 +6,8 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/clustering/v1/policies" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/clustering/v1/policytypes_test.go b/internal/acceptance/openstack/clustering/v1/policytypes_test.go similarity index 92% rename from acceptance/openstack/clustering/v1/policytypes_test.go rename to internal/acceptance/openstack/clustering/v1/policytypes_test.go index 70a43f9c66..fe930b9c57 100644 --- a/acceptance/openstack/clustering/v1/policytypes_test.go +++ b/internal/acceptance/openstack/clustering/v1/policytypes_test.go @@ -6,8 +6,8 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/clustering/v1/policytypes" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/clustering/v1/profiles_test.go b/internal/acceptance/openstack/clustering/v1/profiles_test.go similarity index 93% rename from acceptance/openstack/clustering/v1/profiles_test.go rename to internal/acceptance/openstack/clustering/v1/profiles_test.go index b65b7d4565..0c6143df57 100644 --- a/acceptance/openstack/clustering/v1/profiles_test.go +++ b/internal/acceptance/openstack/clustering/v1/profiles_test.go @@ -6,8 +6,8 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/clustering/v1/profiles" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/clustering/v1/profiletypes_test.go b/internal/acceptance/openstack/clustering/v1/profiletypes_test.go similarity index 89% rename from acceptance/openstack/clustering/v1/profiletypes_test.go rename to internal/acceptance/openstack/clustering/v1/profiletypes_test.go index 9a7c700252..2fe7c0301c 100644 --- a/acceptance/openstack/clustering/v1/profiletypes_test.go +++ b/internal/acceptance/openstack/clustering/v1/profiletypes_test.go @@ -6,8 +6,8 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/clustering/v1/profiletypes" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/clustering/v1/receivers_test.go b/internal/acceptance/openstack/clustering/v1/receivers_test.go similarity index 94% rename from acceptance/openstack/clustering/v1/receivers_test.go rename to internal/acceptance/openstack/clustering/v1/receivers_test.go index 56b862abbf..6c7149a489 100644 --- a/acceptance/openstack/clustering/v1/receivers_test.go +++ b/internal/acceptance/openstack/clustering/v1/receivers_test.go @@ -6,8 +6,8 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/clustering/v1/receivers" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/clustering/v1/webhooktrigger_test.go b/internal/acceptance/openstack/clustering/v1/webhooktrigger_test.go similarity index 96% rename from acceptance/openstack/clustering/v1/webhooktrigger_test.go rename to internal/acceptance/openstack/clustering/v1/webhooktrigger_test.go index b4b4a2e37e..c481208711 100644 --- a/acceptance/openstack/clustering/v1/webhooktrigger_test.go +++ b/internal/acceptance/openstack/clustering/v1/webhooktrigger_test.go @@ -6,7 +6,7 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" "github.com/gophercloud/gophercloud/openstack/clustering/v1/nodes" "github.com/gophercloud/gophercloud/openstack/clustering/v1/webhooks" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/common.go b/internal/acceptance/openstack/common.go similarity index 100% rename from acceptance/openstack/common.go rename to internal/acceptance/openstack/common.go diff --git a/acceptance/openstack/compute/v2/aggregates_test.go b/internal/acceptance/openstack/compute/v2/aggregates_test.go similarity index 96% rename from acceptance/openstack/compute/v2/aggregates_test.go rename to internal/acceptance/openstack/compute/v2/aggregates_test.go index a90a77b8dd..84e05dec52 100644 --- a/acceptance/openstack/compute/v2/aggregates_test.go +++ b/internal/acceptance/openstack/compute/v2/aggregates_test.go @@ -9,8 +9,8 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/aggregates" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/hypervisors" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/compute/v2/attachinterfaces_test.go b/internal/acceptance/openstack/compute/v2/attachinterfaces_test.go similarity index 90% rename from acceptance/openstack/compute/v2/attachinterfaces_test.go rename to internal/acceptance/openstack/compute/v2/attachinterfaces_test.go index 3efef0c1d5..3887634f1e 100644 --- a/acceptance/openstack/compute/v2/attachinterfaces_test.go +++ b/internal/acceptance/openstack/compute/v2/attachinterfaces_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/compute/v2/availabilityzones_test.go b/internal/acceptance/openstack/compute/v2/availabilityzones_test.go similarity index 91% rename from acceptance/openstack/compute/v2/availabilityzones_test.go rename to internal/acceptance/openstack/compute/v2/availabilityzones_test.go index 967d56f5ab..9d125589e6 100644 --- a/acceptance/openstack/compute/v2/availabilityzones_test.go +++ b/internal/acceptance/openstack/compute/v2/availabilityzones_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/availabilityzones" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/compute/v2/bootfromvolume_test.go b/internal/acceptance/openstack/compute/v2/bootfromvolume_test.go similarity index 93% rename from acceptance/openstack/compute/v2/bootfromvolume_test.go rename to internal/acceptance/openstack/compute/v2/bootfromvolume_test.go index 9980660463..2a054568ec 100644 --- a/acceptance/openstack/compute/v2/bootfromvolume_test.go +++ b/internal/acceptance/openstack/compute/v2/bootfromvolume_test.go @@ -6,9 +6,9 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - blockstorage "github.com/gophercloud/gophercloud/acceptance/openstack/blockstorage/v2" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + blockstorage "github.com/gophercloud/gophercloud/internal/acceptance/openstack/blockstorage/v2" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/bootfromvolume" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/volumeattach" th "github.com/gophercloud/gophercloud/testhelper" @@ -51,6 +51,11 @@ func TestBootFromNewVolume(t *testing.T) { choices, err := clients.AcceptanceTestChoicesFromEnv() th.AssertNoErr(t, err) + // minimum required microversion for getting volume tags is 2.70 + // https://docs.openstack.org/nova/latest/reference/api-microversion-history.html#id64 + client.Microversion = "2.70" + + tagName := "tag1" blockDevices := []bootfromvolume.BlockDevice{ { DeleteOnTermination: true, @@ -58,6 +63,7 @@ func TestBootFromNewVolume(t *testing.T) { SourceType: bootfromvolume.SourceImage, UUID: choices.ImageID, VolumeSize: 2, + Tag: tagName, }, } @@ -73,6 +79,8 @@ func TestBootFromNewVolume(t *testing.T) { tools.PrintResource(t, server) tools.PrintResource(t, attachments) + attachmentTag := *attachments[0].Tag + th.AssertEquals(t, attachmentTag, tagName) if server.Image != nil { t.Fatalf("server image should be nil") diff --git a/acceptance/openstack/compute/v2/compute.go b/internal/acceptance/openstack/compute/v2/compute.go similarity index 99% rename from acceptance/openstack/compute/v2/compute.go rename to internal/acceptance/openstack/compute/v2/compute.go index c34a5f5774..f3d102916e 100644 --- a/acceptance/openstack/compute/v2/compute.go +++ b/internal/acceptance/openstack/compute/v2/compute.go @@ -9,8 +9,8 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/blockstorage/v2/volumes" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/aggregates" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/attachinterfaces" @@ -178,7 +178,6 @@ func CreateBootableVolumeServer(t *testing.T, client *gophercloud.ServiceClient, } th.AssertEquals(t, newServer.Name, name) - th.AssertEquals(t, newServer.Flavor["id"], choices.FlavorID) return newServer, nil } diff --git a/acceptance/openstack/compute/v2/defsecrules_test.go b/internal/acceptance/openstack/compute/v2/defsecrules_test.go similarity index 91% rename from acceptance/openstack/compute/v2/defsecrules_test.go rename to internal/acceptance/openstack/compute/v2/defsecrules_test.go index cb0352f80d..b2e5accad0 100644 --- a/acceptance/openstack/compute/v2/defsecrules_test.go +++ b/internal/acceptance/openstack/compute/v2/defsecrules_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" dsr "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/defsecrules" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/compute/v2/diagnostics_test.go b/internal/acceptance/openstack/compute/v2/diagnostics_test.go similarity index 83% rename from acceptance/openstack/compute/v2/diagnostics_test.go rename to internal/acceptance/openstack/compute/v2/diagnostics_test.go index a19d54fe66..0424bb27a3 100644 --- a/acceptance/openstack/compute/v2/diagnostics_test.go +++ b/internal/acceptance/openstack/compute/v2/diagnostics_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/diagnostics" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/compute/v2/extension_test.go b/internal/acceptance/openstack/compute/v2/extension_test.go similarity index 88% rename from acceptance/openstack/compute/v2/extension_test.go rename to internal/acceptance/openstack/compute/v2/extension_test.go index 8fb0f28ba1..96b321a0c7 100644 --- a/acceptance/openstack/compute/v2/extension_test.go +++ b/internal/acceptance/openstack/compute/v2/extension_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/common/extensions" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/compute/v2/flavors_test.go b/internal/acceptance/openstack/compute/v2/flavors_test.go similarity index 96% rename from acceptance/openstack/compute/v2/flavors_test.go rename to internal/acceptance/openstack/compute/v2/flavors_test.go index 9e3ec1db45..ec14e5ad33 100644 --- a/acceptance/openstack/compute/v2/flavors_test.go +++ b/internal/acceptance/openstack/compute/v2/flavors_test.go @@ -6,9 +6,9 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - identity "github.com/gophercloud/gophercloud/acceptance/openstack/identity/v3" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + identity "github.com/gophercloud/gophercloud/internal/acceptance/openstack/identity/v3" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/compute/v2/flavors" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/compute/v2/floatingip_test.go b/internal/acceptance/openstack/compute/v2/floatingip_test.go similarity index 96% rename from acceptance/openstack/compute/v2/floatingip_test.go rename to internal/acceptance/openstack/compute/v2/floatingip_test.go index dae68e7b63..6e2ecb0399 100644 --- a/acceptance/openstack/compute/v2/floatingip_test.go +++ b/internal/acceptance/openstack/compute/v2/floatingip_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/floatingips" "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/compute/v2/hypervisors_test.go b/internal/acceptance/openstack/compute/v2/hypervisors_test.go similarity index 95% rename from acceptance/openstack/compute/v2/hypervisors_test.go rename to internal/acceptance/openstack/compute/v2/hypervisors_test.go index ee4410726f..4992a62814 100644 --- a/acceptance/openstack/compute/v2/hypervisors_test.go +++ b/internal/acceptance/openstack/compute/v2/hypervisors_test.go @@ -8,8 +8,8 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/hypervisors" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/compute/v2/images_test.go b/internal/acceptance/openstack/compute/v2/images_test.go similarity index 89% rename from acceptance/openstack/compute/v2/images_test.go rename to internal/acceptance/openstack/compute/v2/images_test.go index 4d25d29416..48dae1d974 100644 --- a/acceptance/openstack/compute/v2/images_test.go +++ b/internal/acceptance/openstack/compute/v2/images_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/compute/v2/images" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/compute/v2/instance_actions_test.go b/internal/acceptance/openstack/compute/v2/instance_actions_test.go similarity index 94% rename from acceptance/openstack/compute/v2/instance_actions_test.go rename to internal/acceptance/openstack/compute/v2/instance_actions_test.go index 3b60d90067..9928c2ceb8 100644 --- a/acceptance/openstack/compute/v2/instance_actions_test.go +++ b/internal/acceptance/openstack/compute/v2/instance_actions_test.go @@ -7,8 +7,8 @@ import ( "testing" "time" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/instanceactions" "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/compute/v2/keypairs_test.go b/internal/acceptance/openstack/compute/v2/keypairs_test.go similarity index 94% rename from acceptance/openstack/compute/v2/keypairs_test.go rename to internal/acceptance/openstack/compute/v2/keypairs_test.go index dd6c577963..21e37bd802 100644 --- a/acceptance/openstack/compute/v2/keypairs_test.go +++ b/internal/acceptance/openstack/compute/v2/keypairs_test.go @@ -6,9 +6,9 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - identity "github.com/gophercloud/gophercloud/acceptance/openstack/identity/v3" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + identity "github.com/gophercloud/gophercloud/internal/acceptance/openstack/identity/v3" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs" "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/compute/v2/limits_test.go b/internal/acceptance/openstack/compute/v2/limits_test.go similarity index 90% rename from acceptance/openstack/compute/v2/limits_test.go rename to internal/acceptance/openstack/compute/v2/limits_test.go index 3aab23c3a7..c355ea0181 100644 --- a/acceptance/openstack/compute/v2/limits_test.go +++ b/internal/acceptance/openstack/compute/v2/limits_test.go @@ -7,8 +7,8 @@ import ( "strings" "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/limits" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/compute/v2/migrate_test.go b/internal/acceptance/openstack/compute/v2/migrate_test.go similarity index 95% rename from acceptance/openstack/compute/v2/migrate_test.go rename to internal/acceptance/openstack/compute/v2/migrate_test.go index fcc69e7fb9..8edc44b980 100644 --- a/acceptance/openstack/compute/v2/migrate_test.go +++ b/internal/acceptance/openstack/compute/v2/migrate_test.go @@ -6,7 +6,7 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/migrate" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/compute/v2/network_test.go b/internal/acceptance/openstack/compute/v2/network_test.go similarity index 90% rename from acceptance/openstack/compute/v2/network_test.go rename to internal/acceptance/openstack/compute/v2/network_test.go index 345356830f..0850c040b0 100644 --- a/acceptance/openstack/compute/v2/network_test.go +++ b/internal/acceptance/openstack/compute/v2/network_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/networks" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/compute/v2/pkg.go b/internal/acceptance/openstack/compute/v2/pkg.go similarity index 100% rename from acceptance/openstack/compute/v2/pkg.go rename to internal/acceptance/openstack/compute/v2/pkg.go diff --git a/acceptance/openstack/compute/v2/quotaset_test.go b/internal/acceptance/openstack/compute/v2/quotaset_test.go similarity index 97% rename from acceptance/openstack/compute/v2/quotaset_test.go rename to internal/acceptance/openstack/compute/v2/quotaset_test.go index 3273b81b22..72868e1d25 100644 --- a/acceptance/openstack/compute/v2/quotaset_test.go +++ b/internal/acceptance/openstack/compute/v2/quotaset_test.go @@ -9,8 +9,8 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/quotasets" "github.com/gophercloud/gophercloud/openstack/identity/v3/projects" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/compute/v2/remoteconsoles_test.go b/internal/acceptance/openstack/compute/v2/remoteconsoles_test.go similarity index 81% rename from acceptance/openstack/compute/v2/remoteconsoles_test.go rename to internal/acceptance/openstack/compute/v2/remoteconsoles_test.go index 1a32de0045..f6fa7c8edb 100644 --- a/acceptance/openstack/compute/v2/remoteconsoles_test.go +++ b/internal/acceptance/openstack/compute/v2/remoteconsoles_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/compute/v2/rescueunrescue_test.go b/internal/acceptance/openstack/compute/v2/rescueunrescue_test.go similarity index 89% rename from acceptance/openstack/compute/v2/rescueunrescue_test.go rename to internal/acceptance/openstack/compute/v2/rescueunrescue_test.go index b4304bfdfc..2d660a0b4f 100644 --- a/acceptance/openstack/compute/v2/rescueunrescue_test.go +++ b/internal/acceptance/openstack/compute/v2/rescueunrescue_test.go @@ -6,7 +6,7 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/compute/v2/secgroup_test.go b/internal/acceptance/openstack/compute/v2/secgroup_test.go similarity index 96% rename from acceptance/openstack/compute/v2/secgroup_test.go rename to internal/acceptance/openstack/compute/v2/secgroup_test.go index 174c3f418f..aaa2595443 100644 --- a/acceptance/openstack/compute/v2/secgroup_test.go +++ b/internal/acceptance/openstack/compute/v2/secgroup_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/secgroups" "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/compute/v2/servergroup_test.go b/internal/acceptance/openstack/compute/v2/servergroup_test.go similarity index 95% rename from acceptance/openstack/compute/v2/servergroup_test.go rename to internal/acceptance/openstack/compute/v2/servergroup_test.go index fe11c28a3f..2ee3a1494c 100644 --- a/acceptance/openstack/compute/v2/servergroup_test.go +++ b/internal/acceptance/openstack/compute/v2/servergroup_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/servergroups" "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/compute/v2/servers_test.go b/internal/acceptance/openstack/compute/v2/servers_test.go similarity index 98% rename from acceptance/openstack/compute/v2/servers_test.go rename to internal/acceptance/openstack/compute/v2/servers_test.go index 953cb05720..0f32a4ea17 100644 --- a/acceptance/openstack/compute/v2/servers_test.go +++ b/internal/acceptance/openstack/compute/v2/servers_test.go @@ -8,9 +8,9 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/clients" - networks "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + networks "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/attachinterfaces" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/availabilityzones" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/extendedserverattributes" diff --git a/acceptance/openstack/compute/v2/services_test.go b/internal/acceptance/openstack/compute/v2/services_test.go similarity index 95% rename from acceptance/openstack/compute/v2/services_test.go rename to internal/acceptance/openstack/compute/v2/services_test.go index d7d36d7f2c..fbd8b760cf 100644 --- a/acceptance/openstack/compute/v2/services_test.go +++ b/internal/acceptance/openstack/compute/v2/services_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/services" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/compute/v2/tenantnetworks_test.go b/internal/acceptance/openstack/compute/v2/tenantnetworks_test.go similarity index 90% rename from acceptance/openstack/compute/v2/tenantnetworks_test.go rename to internal/acceptance/openstack/compute/v2/tenantnetworks_test.go index f404663472..3700d5f38c 100644 --- a/acceptance/openstack/compute/v2/tenantnetworks_test.go +++ b/internal/acceptance/openstack/compute/v2/tenantnetworks_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/tenantnetworks" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/compute/v2/usage_test.go b/internal/acceptance/openstack/compute/v2/usage_test.go similarity index 93% rename from acceptance/openstack/compute/v2/usage_test.go rename to internal/acceptance/openstack/compute/v2/usage_test.go index c4874a68c6..4ad35aa599 100644 --- a/acceptance/openstack/compute/v2/usage_test.go +++ b/internal/acceptance/openstack/compute/v2/usage_test.go @@ -8,8 +8,8 @@ import ( "testing" "time" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/usage" "github.com/gophercloud/gophercloud/pagination" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/compute/v2/volumeattach_test.go b/internal/acceptance/openstack/compute/v2/volumeattach_test.go similarity index 81% rename from acceptance/openstack/compute/v2/volumeattach_test.go rename to internal/acceptance/openstack/compute/v2/volumeattach_test.go index 1d3dac08f8..11f5328e1f 100644 --- a/acceptance/openstack/compute/v2/volumeattach_test.go +++ b/internal/acceptance/openstack/compute/v2/volumeattach_test.go @@ -6,9 +6,9 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - bs "github.com/gophercloud/gophercloud/acceptance/openstack/blockstorage/v2" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + bs "github.com/gophercloud/gophercloud/internal/acceptance/openstack/blockstorage/v2" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/container/v1/capsules.go b/internal/acceptance/openstack/container/v1/capsules.go similarity index 94% rename from acceptance/openstack/container/v1/capsules.go rename to internal/acceptance/openstack/container/v1/capsules.go index 08467ce2b9..7b4cdcd095 100644 --- a/acceptance/openstack/container/v1/capsules.go +++ b/internal/acceptance/openstack/container/v1/capsules.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/container/v1/capsules" ) diff --git a/acceptance/openstack/container/v1/capsules_test.go b/internal/acceptance/openstack/container/v1/capsules_test.go similarity index 97% rename from acceptance/openstack/container/v1/capsules_test.go rename to internal/acceptance/openstack/container/v1/capsules_test.go index 451d5e2853..4ebda2bbfd 100644 --- a/acceptance/openstack/container/v1/capsules_test.go +++ b/internal/acceptance/openstack/container/v1/capsules_test.go @@ -6,7 +6,7 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" "github.com/gophercloud/gophercloud/openstack/container/v1/capsules" "github.com/gophercloud/gophercloud/pagination" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/container/v1/fixtures.go b/internal/acceptance/openstack/container/v1/fixtures.go similarity index 100% rename from acceptance/openstack/container/v1/fixtures.go rename to internal/acceptance/openstack/container/v1/fixtures.go diff --git a/acceptance/openstack/containerinfra/v1/certificates_test.go b/internal/acceptance/openstack/containerinfra/v1/certificates_test.go similarity index 96% rename from acceptance/openstack/containerinfra/v1/certificates_test.go rename to internal/acceptance/openstack/containerinfra/v1/certificates_test.go index b83f1ac28d..b1d1911cb6 100644 --- a/acceptance/openstack/containerinfra/v1/certificates_test.go +++ b/internal/acceptance/openstack/containerinfra/v1/certificates_test.go @@ -6,7 +6,7 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" "github.com/gophercloud/gophercloud/openstack/containerinfra/v1/certificates" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/containerinfra/v1/clusters_test.go b/internal/acceptance/openstack/containerinfra/v1/clusters_test.go similarity index 94% rename from acceptance/openstack/containerinfra/v1/clusters_test.go rename to internal/acceptance/openstack/containerinfra/v1/clusters_test.go index 67eca18c53..1e2fbb6184 100644 --- a/acceptance/openstack/containerinfra/v1/clusters_test.go +++ b/internal/acceptance/openstack/containerinfra/v1/clusters_test.go @@ -7,8 +7,8 @@ import ( "testing" "time" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/containerinfra/v1/clusters" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/containerinfra/v1/clustertemplates_test.go b/internal/acceptance/openstack/containerinfra/v1/clustertemplates_test.go similarity index 93% rename from acceptance/openstack/containerinfra/v1/clustertemplates_test.go rename to internal/acceptance/openstack/containerinfra/v1/clustertemplates_test.go index 87994c5c20..67843c1c4c 100644 --- a/acceptance/openstack/containerinfra/v1/clustertemplates_test.go +++ b/internal/acceptance/openstack/containerinfra/v1/clustertemplates_test.go @@ -6,8 +6,8 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/containerinfra/v1/clustertemplates" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/containerinfra/v1/containerinfra.go b/internal/acceptance/openstack/containerinfra/v1/containerinfra.go similarity index 97% rename from acceptance/openstack/containerinfra/v1/containerinfra.go rename to internal/acceptance/openstack/containerinfra/v1/containerinfra.go index 796c0149ff..28127195f0 100644 --- a/acceptance/openstack/containerinfra/v1/containerinfra.go +++ b/internal/acceptance/openstack/containerinfra/v1/containerinfra.go @@ -8,9 +8,9 @@ import ( "time" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/clients" - idv3 "github.com/gophercloud/gophercloud/acceptance/openstack/identity/v3" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + idv3 "github.com/gophercloud/gophercloud/internal/acceptance/openstack/identity/v3" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/containerinfra/v1/clusters" "github.com/gophercloud/gophercloud/openstack/containerinfra/v1/clustertemplates" "github.com/gophercloud/gophercloud/openstack/containerinfra/v1/quotas" diff --git a/acceptance/openstack/containerinfra/v1/nodegroups_test.go b/internal/acceptance/openstack/containerinfra/v1/nodegroups_test.go similarity index 97% rename from acceptance/openstack/containerinfra/v1/nodegroups_test.go rename to internal/acceptance/openstack/containerinfra/v1/nodegroups_test.go index 7537d1d436..acbde956a5 100644 --- a/acceptance/openstack/containerinfra/v1/nodegroups_test.go +++ b/internal/acceptance/openstack/containerinfra/v1/nodegroups_test.go @@ -9,8 +9,8 @@ import ( "time" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/containerinfra/v1/nodegroups" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/containerinfra/v1/pkg.go b/internal/acceptance/openstack/containerinfra/v1/pkg.go similarity index 100% rename from acceptance/openstack/containerinfra/v1/pkg.go rename to internal/acceptance/openstack/containerinfra/v1/pkg.go diff --git a/acceptance/openstack/containerinfra/v1/quotas_test.go b/internal/acceptance/openstack/containerinfra/v1/quotas_test.go similarity index 74% rename from acceptance/openstack/containerinfra/v1/quotas_test.go rename to internal/acceptance/openstack/containerinfra/v1/quotas_test.go index 5783d9195b..64169babca 100644 --- a/acceptance/openstack/containerinfra/v1/quotas_test.go +++ b/internal/acceptance/openstack/containerinfra/v1/quotas_test.go @@ -6,8 +6,8 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/db/v1/configurations_test.go b/internal/acceptance/openstack/db/v1/configurations_test.go similarity index 94% rename from acceptance/openstack/db/v1/configurations_test.go rename to internal/acceptance/openstack/db/v1/configurations_test.go index 02472cc8fb..ae108aace3 100644 --- a/acceptance/openstack/db/v1/configurations_test.go +++ b/internal/acceptance/openstack/db/v1/configurations_test.go @@ -6,8 +6,8 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/db/v1/configurations" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/db/v1/databases_test.go b/internal/acceptance/openstack/db/v1/databases_test.go similarity index 90% rename from acceptance/openstack/db/v1/databases_test.go rename to internal/acceptance/openstack/db/v1/databases_test.go index 854ca0bc0f..f8ca7d2250 100644 --- a/acceptance/openstack/db/v1/databases_test.go +++ b/internal/acceptance/openstack/db/v1/databases_test.go @@ -6,8 +6,8 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/db/v1/databases" ) diff --git a/acceptance/openstack/db/v1/db.go b/internal/acceptance/openstack/db/v1/db.go similarity index 97% rename from acceptance/openstack/db/v1/db.go rename to internal/acceptance/openstack/db/v1/db.go index f5e637f3d9..1a1e39758e 100644 --- a/acceptance/openstack/db/v1/db.go +++ b/internal/acceptance/openstack/db/v1/db.go @@ -7,8 +7,8 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/db/v1/databases" "github.com/gophercloud/gophercloud/openstack/db/v1/instances" "github.com/gophercloud/gophercloud/openstack/db/v1/users" diff --git a/acceptance/openstack/db/v1/flavors_test.go b/internal/acceptance/openstack/db/v1/flavors_test.go similarity index 90% rename from acceptance/openstack/db/v1/flavors_test.go rename to internal/acceptance/openstack/db/v1/flavors_test.go index 0c51565b60..2183e60f7a 100644 --- a/acceptance/openstack/db/v1/flavors_test.go +++ b/internal/acceptance/openstack/db/v1/flavors_test.go @@ -6,8 +6,8 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/db/v1/flavors" ) diff --git a/acceptance/openstack/db/v1/instances_test.go b/internal/acceptance/openstack/db/v1/instances_test.go similarity index 92% rename from acceptance/openstack/db/v1/instances_test.go rename to internal/acceptance/openstack/db/v1/instances_test.go index 0d9ccdf08f..16a5d2d6df 100644 --- a/acceptance/openstack/db/v1/instances_test.go +++ b/internal/acceptance/openstack/db/v1/instances_test.go @@ -6,8 +6,8 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/db/v1/instances" ) diff --git a/acceptance/openstack/db/v1/pkg.go b/internal/acceptance/openstack/db/v1/pkg.go similarity index 100% rename from acceptance/openstack/db/v1/pkg.go rename to internal/acceptance/openstack/db/v1/pkg.go diff --git a/acceptance/openstack/db/v1/users_test.go b/internal/acceptance/openstack/db/v1/users_test.go similarity index 89% rename from acceptance/openstack/db/v1/users_test.go rename to internal/acceptance/openstack/db/v1/users_test.go index 6bdc00bbad..c9417c06e8 100644 --- a/acceptance/openstack/db/v1/users_test.go +++ b/internal/acceptance/openstack/db/v1/users_test.go @@ -6,8 +6,8 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/db/v1/users" ) diff --git a/acceptance/openstack/dns/v2/dns.go b/internal/acceptance/openstack/dns/v2/dns.go similarity index 99% rename from acceptance/openstack/dns/v2/dns.go rename to internal/acceptance/openstack/dns/v2/dns.go index 7fc34b70e0..d61588895f 100644 --- a/acceptance/openstack/dns/v2/dns.go +++ b/internal/acceptance/openstack/dns/v2/dns.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets" transferAccepts "github.com/gophercloud/gophercloud/openstack/dns/v2/transfer/accept" transferRequests "github.com/gophercloud/gophercloud/openstack/dns/v2/transfer/request" diff --git a/acceptance/openstack/dns/v2/recordsets_test.go b/internal/acceptance/openstack/dns/v2/recordsets_test.go similarity index 94% rename from acceptance/openstack/dns/v2/recordsets_test.go rename to internal/acceptance/openstack/dns/v2/recordsets_test.go index 67b1f706ce..38aadcd6e8 100644 --- a/acceptance/openstack/dns/v2/recordsets_test.go +++ b/internal/acceptance/openstack/dns/v2/recordsets_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets" "github.com/gophercloud/gophercloud/pagination" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/dns/v2/transfers_test.go b/internal/acceptance/openstack/dns/v2/transfers_test.go similarity index 92% rename from acceptance/openstack/dns/v2/transfers_test.go rename to internal/acceptance/openstack/dns/v2/transfers_test.go index 341aec6415..7cbcf4aa72 100644 --- a/acceptance/openstack/dns/v2/transfers_test.go +++ b/internal/acceptance/openstack/dns/v2/transfers_test.go @@ -6,9 +6,9 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - identity "github.com/gophercloud/gophercloud/acceptance/openstack/identity/v3" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + identity "github.com/gophercloud/gophercloud/internal/acceptance/openstack/identity/v3" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" transferAccepts "github.com/gophercloud/gophercloud/openstack/dns/v2/transfer/accept" transferRequests "github.com/gophercloud/gophercloud/openstack/dns/v2/transfer/request" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/dns/v2/zones_test.go b/internal/acceptance/openstack/dns/v2/zones_test.go similarity index 88% rename from acceptance/openstack/dns/v2/zones_test.go rename to internal/acceptance/openstack/dns/v2/zones_test.go index e21b96d27c..b8edc55b10 100644 --- a/acceptance/openstack/dns/v2/zones_test.go +++ b/internal/acceptance/openstack/dns/v2/zones_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/dns/v2/zones" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/identity/v2/extension_test.go b/internal/acceptance/openstack/identity/v2/extension_test.go similarity index 88% rename from acceptance/openstack/identity/v2/extension_test.go rename to internal/acceptance/openstack/identity/v2/extension_test.go index 7077c08a84..ed4202c372 100644 --- a/acceptance/openstack/identity/v2/extension_test.go +++ b/internal/acceptance/openstack/identity/v2/extension_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/identity/v2/extensions" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/identity/v2/identity.go b/internal/acceptance/openstack/identity/v2/identity.go similarity index 98% rename from acceptance/openstack/identity/v2/identity.go rename to internal/acceptance/openstack/identity/v2/identity.go index f74812193b..6666e2e950 100644 --- a/acceptance/openstack/identity/v2/identity.go +++ b/internal/acceptance/openstack/identity/v2/identity.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/identity/v2/extensions/admin/roles" "github.com/gophercloud/gophercloud/openstack/identity/v2/tenants" "github.com/gophercloud/gophercloud/openstack/identity/v2/users" diff --git a/acceptance/openstack/identity/v2/pkg.go b/internal/acceptance/openstack/identity/v2/pkg.go similarity index 100% rename from acceptance/openstack/identity/v2/pkg.go rename to internal/acceptance/openstack/identity/v2/pkg.go diff --git a/acceptance/openstack/identity/v2/role_test.go b/internal/acceptance/openstack/identity/v2/role_test.go similarity index 92% rename from acceptance/openstack/identity/v2/role_test.go rename to internal/acceptance/openstack/identity/v2/role_test.go index 4c40e70162..573209f4b8 100644 --- a/acceptance/openstack/identity/v2/role_test.go +++ b/internal/acceptance/openstack/identity/v2/role_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/identity/v2/extensions/admin/roles" "github.com/gophercloud/gophercloud/openstack/identity/v2/users" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/identity/v2/tenant_test.go b/internal/acceptance/openstack/identity/v2/tenant_test.go similarity index 91% rename from acceptance/openstack/identity/v2/tenant_test.go rename to internal/acceptance/openstack/identity/v2/tenant_test.go index df2dcb7eb0..0b108f6733 100644 --- a/acceptance/openstack/identity/v2/tenant_test.go +++ b/internal/acceptance/openstack/identity/v2/tenant_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/identity/v2/tenants" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/identity/v2/token_test.go b/internal/acceptance/openstack/identity/v2/token_test.go similarity index 91% rename from acceptance/openstack/identity/v2/token_test.go rename to internal/acceptance/openstack/identity/v2/token_test.go index cf758c60e2..085a3a5066 100644 --- a/acceptance/openstack/identity/v2/token_test.go +++ b/internal/acceptance/openstack/identity/v2/token_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack" "github.com/gophercloud/gophercloud/openstack/identity/v2/tokens" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/identity/v2/user_test.go b/internal/acceptance/openstack/identity/v2/user_test.go similarity index 90% rename from acceptance/openstack/identity/v2/user_test.go rename to internal/acceptance/openstack/identity/v2/user_test.go index e700cdd3ec..d014fc9698 100644 --- a/acceptance/openstack/identity/v2/user_test.go +++ b/internal/acceptance/openstack/identity/v2/user_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/identity/v2/users" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/identity/v3/applicationcredentials_test.go b/internal/acceptance/openstack/identity/v3/applicationcredentials_test.go similarity index 98% rename from acceptance/openstack/identity/v3/applicationcredentials_test.go rename to internal/acceptance/openstack/identity/v3/applicationcredentials_test.go index e1758c5b2f..e2c5d6580d 100644 --- a/acceptance/openstack/identity/v3/applicationcredentials_test.go +++ b/internal/acceptance/openstack/identity/v3/applicationcredentials_test.go @@ -7,8 +7,8 @@ import ( "testing" "time" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack" "github.com/gophercloud/gophercloud/openstack/identity/v3/applicationcredentials" "github.com/gophercloud/gophercloud/openstack/identity/v3/tokens" diff --git a/acceptance/openstack/identity/v3/catalog_test.go b/internal/acceptance/openstack/identity/v3/catalog_test.go similarity index 79% rename from acceptance/openstack/identity/v3/catalog_test.go rename to internal/acceptance/openstack/identity/v3/catalog_test.go index 11542c58e6..c366b40793 100644 --- a/acceptance/openstack/identity/v3/catalog_test.go +++ b/internal/acceptance/openstack/identity/v3/catalog_test.go @@ -3,8 +3,8 @@ package v3 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/identity/v3/catalog" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/identity/v3/credentials_test.go b/internal/acceptance/openstack/identity/v3/credentials_test.go similarity index 97% rename from acceptance/openstack/identity/v3/credentials_test.go rename to internal/acceptance/openstack/identity/v3/credentials_test.go index acb5cd94f1..a0a6d675e6 100644 --- a/acceptance/openstack/identity/v3/credentials_test.go +++ b/internal/acceptance/openstack/identity/v3/credentials_test.go @@ -6,8 +6,8 @@ package v3 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack" "github.com/gophercloud/gophercloud/openstack/identity/v3/credentials" "github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/ec2tokens" diff --git a/acceptance/openstack/identity/v3/domains_test.go b/internal/acceptance/openstack/identity/v3/domains_test.go similarity index 94% rename from acceptance/openstack/identity/v3/domains_test.go rename to internal/acceptance/openstack/identity/v3/domains_test.go index 5e9d06b266..0a096ea7d9 100644 --- a/acceptance/openstack/identity/v3/domains_test.go +++ b/internal/acceptance/openstack/identity/v3/domains_test.go @@ -6,8 +6,8 @@ package v3 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/identity/v3/domains" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/identity/v3/ec2credentials_test.go b/internal/acceptance/openstack/identity/v3/ec2credentials_test.go similarity index 95% rename from acceptance/openstack/identity/v3/ec2credentials_test.go rename to internal/acceptance/openstack/identity/v3/ec2credentials_test.go index 5c19459f9f..36977de3e7 100644 --- a/acceptance/openstack/identity/v3/ec2credentials_test.go +++ b/internal/acceptance/openstack/identity/v3/ec2credentials_test.go @@ -6,8 +6,8 @@ package v3 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack" "github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/ec2credentials" "github.com/gophercloud/gophercloud/openstack/identity/v3/tokens" diff --git a/acceptance/openstack/identity/v3/endpoint_test.go b/internal/acceptance/openstack/identity/v3/endpoint_test.go similarity index 93% rename from acceptance/openstack/identity/v3/endpoint_test.go rename to internal/acceptance/openstack/identity/v3/endpoint_test.go index eac753d217..f0dbd37737 100644 --- a/acceptance/openstack/identity/v3/endpoint_test.go +++ b/internal/acceptance/openstack/identity/v3/endpoint_test.go @@ -8,8 +8,8 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/identity/v3/endpoints" "github.com/gophercloud/gophercloud/openstack/identity/v3/services" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/identity/v3/federation_test.go b/internal/acceptance/openstack/identity/v3/federation_test.go similarity index 95% rename from acceptance/openstack/identity/v3/federation_test.go rename to internal/acceptance/openstack/identity/v3/federation_test.go index a1b286b9f0..eb84beda31 100644 --- a/acceptance/openstack/identity/v3/federation_test.go +++ b/internal/acceptance/openstack/identity/v3/federation_test.go @@ -7,8 +7,8 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/federation" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/identity/v3/groups_test.go b/internal/acceptance/openstack/identity/v3/groups_test.go similarity index 95% rename from acceptance/openstack/identity/v3/groups_test.go rename to internal/acceptance/openstack/identity/v3/groups_test.go index b07d7d1b6c..ee16600be4 100644 --- a/acceptance/openstack/identity/v3/groups_test.go +++ b/internal/acceptance/openstack/identity/v3/groups_test.go @@ -6,8 +6,8 @@ package v3 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/identity/v3/groups" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/identity/v3/identity.go b/internal/acceptance/openstack/identity/v3/identity.go similarity index 99% rename from acceptance/openstack/identity/v3/identity.go rename to internal/acceptance/openstack/identity/v3/identity.go index 3824b2aa0a..c4c5282280 100644 --- a/acceptance/openstack/identity/v3/identity.go +++ b/internal/acceptance/openstack/identity/v3/identity.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/identity/v3/domains" "github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/trusts" "github.com/gophercloud/gophercloud/openstack/identity/v3/groups" diff --git a/acceptance/openstack/identity/v3/limits_test.go b/internal/acceptance/openstack/identity/v3/limits_test.go similarity index 97% rename from acceptance/openstack/identity/v3/limits_test.go rename to internal/acceptance/openstack/identity/v3/limits_test.go index 05ef790829..af36e3b420 100644 --- a/acceptance/openstack/identity/v3/limits_test.go +++ b/internal/acceptance/openstack/identity/v3/limits_test.go @@ -7,8 +7,8 @@ import ( "os" "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/identity/v3/limits" "github.com/gophercloud/gophercloud/openstack/identity/v3/registeredlimits" "github.com/gophercloud/gophercloud/openstack/identity/v3/services" diff --git a/acceptance/openstack/identity/v3/oauth1_test.go b/internal/acceptance/openstack/identity/v3/oauth1_test.go similarity index 98% rename from acceptance/openstack/identity/v3/oauth1_test.go rename to internal/acceptance/openstack/identity/v3/oauth1_test.go index 0a8dd3c0ee..7270518478 100644 --- a/acceptance/openstack/identity/v3/oauth1_test.go +++ b/internal/acceptance/openstack/identity/v3/oauth1_test.go @@ -7,8 +7,8 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack" "github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/oauth1" "github.com/gophercloud/gophercloud/openstack/identity/v3/tokens" diff --git a/acceptance/openstack/identity/v3/osinherit_test.go b/internal/acceptance/openstack/identity/v3/osinherit_test.go similarity index 99% rename from acceptance/openstack/identity/v3/osinherit_test.go rename to internal/acceptance/openstack/identity/v3/osinherit_test.go index 6ac777c0ec..b75171e08b 100644 --- a/acceptance/openstack/identity/v3/osinherit_test.go +++ b/internal/acceptance/openstack/identity/v3/osinherit_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" "github.com/gophercloud/gophercloud/openstack/identity/v3/domains" "github.com/gophercloud/gophercloud/openstack/identity/v3/groups" "github.com/gophercloud/gophercloud/openstack/identity/v3/osinherit" diff --git a/acceptance/openstack/identity/v3/pkg.go b/internal/acceptance/openstack/identity/v3/pkg.go similarity index 100% rename from acceptance/openstack/identity/v3/pkg.go rename to internal/acceptance/openstack/identity/v3/pkg.go diff --git a/acceptance/openstack/identity/v3/policies_test.go b/internal/acceptance/openstack/identity/v3/policies_test.go similarity index 96% rename from acceptance/openstack/identity/v3/policies_test.go rename to internal/acceptance/openstack/identity/v3/policies_test.go index 01367018b8..39d43e08a9 100644 --- a/acceptance/openstack/identity/v3/policies_test.go +++ b/internal/acceptance/openstack/identity/v3/policies_test.go @@ -6,8 +6,8 @@ package v3 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/identity/v3/policies" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/identity/v3/projectendpoint_test.go b/internal/acceptance/openstack/identity/v3/projectendpoint_test.go similarity index 91% rename from acceptance/openstack/identity/v3/projectendpoint_test.go rename to internal/acceptance/openstack/identity/v3/projectendpoint_test.go index e8c5770a72..af4542d553 100644 --- a/acceptance/openstack/identity/v3/projectendpoint_test.go +++ b/internal/acceptance/openstack/identity/v3/projectendpoint_test.go @@ -6,8 +6,8 @@ package v3 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/identity/v3/endpoints" "github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/projectendpoints" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/identity/v3/projects_test.go b/internal/acceptance/openstack/identity/v3/projects_test.go similarity index 98% rename from acceptance/openstack/identity/v3/projects_test.go rename to internal/acceptance/openstack/identity/v3/projects_test.go index 4c23a45988..08265e1595 100644 --- a/acceptance/openstack/identity/v3/projects_test.go +++ b/internal/acceptance/openstack/identity/v3/projects_test.go @@ -6,8 +6,8 @@ package v3 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/identity/v3/projects" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/identity/v3/reauth_test.go b/internal/acceptance/openstack/identity/v3/reauth_test.go similarity index 92% rename from acceptance/openstack/identity/v3/reauth_test.go rename to internal/acceptance/openstack/identity/v3/reauth_test.go index f34a997adb..0c1b74991d 100644 --- a/acceptance/openstack/identity/v3/reauth_test.go +++ b/internal/acceptance/openstack/identity/v3/reauth_test.go @@ -6,7 +6,7 @@ package v3 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" "github.com/gophercloud/gophercloud/openstack" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/identity/v3/regions_test.go b/internal/acceptance/openstack/identity/v3/regions_test.go similarity index 94% rename from acceptance/openstack/identity/v3/regions_test.go rename to internal/acceptance/openstack/identity/v3/regions_test.go index 8bc9d41f02..3b1173555d 100644 --- a/acceptance/openstack/identity/v3/regions_test.go +++ b/internal/acceptance/openstack/identity/v3/regions_test.go @@ -6,8 +6,8 @@ package v3 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/identity/v3/regions" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/identity/v3/registeredlimits_test.go b/internal/acceptance/openstack/identity/v3/registeredlimits_test.go similarity index 96% rename from acceptance/openstack/identity/v3/registeredlimits_test.go rename to internal/acceptance/openstack/identity/v3/registeredlimits_test.go index 8fd24f4a5a..fa3f910559 100644 --- a/acceptance/openstack/identity/v3/registeredlimits_test.go +++ b/internal/acceptance/openstack/identity/v3/registeredlimits_test.go @@ -7,8 +7,8 @@ import ( "os" "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/identity/v3/registeredlimits" "github.com/gophercloud/gophercloud/openstack/identity/v3/services" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/identity/v3/roles_test.go b/internal/acceptance/openstack/identity/v3/roles_test.go similarity index 99% rename from acceptance/openstack/identity/v3/roles_test.go rename to internal/acceptance/openstack/identity/v3/roles_test.go index f61bddf0a4..cd8f6c5523 100644 --- a/acceptance/openstack/identity/v3/roles_test.go +++ b/internal/acceptance/openstack/identity/v3/roles_test.go @@ -7,8 +7,8 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/identity/v3/domains" "github.com/gophercloud/gophercloud/openstack/identity/v3/groups" "github.com/gophercloud/gophercloud/openstack/identity/v3/roles" diff --git a/acceptance/openstack/identity/v3/service_test.go b/internal/acceptance/openstack/identity/v3/service_test.go similarity index 92% rename from acceptance/openstack/identity/v3/service_test.go rename to internal/acceptance/openstack/identity/v3/service_test.go index 246d9d8ec3..38eee8a4b9 100644 --- a/acceptance/openstack/identity/v3/service_test.go +++ b/internal/acceptance/openstack/identity/v3/service_test.go @@ -6,8 +6,8 @@ package v3 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/identity/v3/services" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/identity/v3/token_test.go b/internal/acceptance/openstack/identity/v3/token_test.go similarity index 89% rename from acceptance/openstack/identity/v3/token_test.go rename to internal/acceptance/openstack/identity/v3/token_test.go index 85ae0eff67..e2d052d4d2 100644 --- a/acceptance/openstack/identity/v3/token_test.go +++ b/internal/acceptance/openstack/identity/v3/token_test.go @@ -6,8 +6,8 @@ package v3 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack" "github.com/gophercloud/gophercloud/openstack/identity/v3/tokens" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/identity/v3/trusts_test.go b/internal/acceptance/openstack/identity/v3/trusts_test.go similarity index 96% rename from acceptance/openstack/identity/v3/trusts_test.go rename to internal/acceptance/openstack/identity/v3/trusts_test.go index 66dd42d08c..63b5c1afb7 100644 --- a/acceptance/openstack/identity/v3/trusts_test.go +++ b/internal/acceptance/openstack/identity/v3/trusts_test.go @@ -7,8 +7,8 @@ import ( "testing" "time" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack" "github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/trusts" "github.com/gophercloud/gophercloud/openstack/identity/v3/roles" diff --git a/acceptance/openstack/identity/v3/users_test.go b/internal/acceptance/openstack/identity/v3/users_test.go similarity index 98% rename from acceptance/openstack/identity/v3/users_test.go rename to internal/acceptance/openstack/identity/v3/users_test.go index a5edb00854..9379a20930 100644 --- a/acceptance/openstack/identity/v3/users_test.go +++ b/internal/acceptance/openstack/identity/v3/users_test.go @@ -6,8 +6,8 @@ package v3 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/identity/v3/groups" "github.com/gophercloud/gophercloud/openstack/identity/v3/projects" "github.com/gophercloud/gophercloud/openstack/identity/v3/users" diff --git a/acceptance/openstack/imageservice/v2/imagedata_test.go b/internal/acceptance/openstack/imageservice/v2/imagedata_test.go similarity index 82% rename from acceptance/openstack/imageservice/v2/imagedata_test.go rename to internal/acceptance/openstack/imageservice/v2/imagedata_test.go index d19c38d4a9..d5c1c6f260 100644 --- a/acceptance/openstack/imageservice/v2/imagedata_test.go +++ b/internal/acceptance/openstack/imageservice/v2/imagedata_test.go @@ -3,8 +3,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/imageservice/v2/imageimport_test.go b/internal/acceptance/openstack/imageservice/v2/imageimport_test.go similarity index 84% rename from acceptance/openstack/imageservice/v2/imageimport_test.go rename to internal/acceptance/openstack/imageservice/v2/imageimport_test.go index 53dbea4d3d..4d032dbfb3 100644 --- a/acceptance/openstack/imageservice/v2/imageimport_test.go +++ b/internal/acceptance/openstack/imageservice/v2/imageimport_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/imageservice/v2/images_test.go b/internal/acceptance/openstack/imageservice/v2/images_test.go similarity index 97% rename from acceptance/openstack/imageservice/v2/images_test.go rename to internal/acceptance/openstack/imageservice/v2/images_test.go index ac6008cef8..a904471c5d 100644 --- a/acceptance/openstack/imageservice/v2/images_test.go +++ b/internal/acceptance/openstack/imageservice/v2/images_test.go @@ -8,8 +8,8 @@ import ( "testing" "time" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/imageservice/v2/images" "github.com/gophercloud/gophercloud/pagination" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/imageservice/v2/imageservice.go b/internal/acceptance/openstack/imageservice/v2/imageservice.go similarity index 98% rename from acceptance/openstack/imageservice/v2/imageservice.go rename to internal/acceptance/openstack/imageservice/v2/imageservice.go index fd55741aa6..f093fe3123 100644 --- a/acceptance/openstack/imageservice/v2/imageservice.go +++ b/internal/acceptance/openstack/imageservice/v2/imageservice.go @@ -9,7 +9,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/imageservice/v2/imagedata" "github.com/gophercloud/gophercloud/openstack/imageservice/v2/imageimport" "github.com/gophercloud/gophercloud/openstack/imageservice/v2/images" diff --git a/acceptance/openstack/imageservice/v2/tasks_test.go b/internal/acceptance/openstack/imageservice/v2/tasks_test.go similarity index 91% rename from acceptance/openstack/imageservice/v2/tasks_test.go rename to internal/acceptance/openstack/imageservice/v2/tasks_test.go index b06980c761..e751118797 100644 --- a/acceptance/openstack/imageservice/v2/tasks_test.go +++ b/internal/acceptance/openstack/imageservice/v2/tasks_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/imageservice/v2/tasks" "github.com/gophercloud/gophercloud/pagination" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/keymanager/v1/acls_test.go b/internal/acceptance/openstack/keymanager/v1/acls_test.go similarity index 96% rename from acceptance/openstack/keymanager/v1/acls_test.go rename to internal/acceptance/openstack/keymanager/v1/acls_test.go index 5defa5b78e..5638443078 100644 --- a/acceptance/openstack/keymanager/v1/acls_test.go +++ b/internal/acceptance/openstack/keymanager/v1/acls_test.go @@ -6,8 +6,8 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/keymanager/v1/acls" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/keymanager/v1/containers_test.go b/internal/acceptance/openstack/keymanager/v1/containers_test.go similarity index 97% rename from acceptance/openstack/keymanager/v1/containers_test.go rename to internal/acceptance/openstack/keymanager/v1/containers_test.go index b4699b3dee..cf7e162f8f 100644 --- a/acceptance/openstack/keymanager/v1/containers_test.go +++ b/internal/acceptance/openstack/keymanager/v1/containers_test.go @@ -6,8 +6,8 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/keymanager/v1/containers" "github.com/gophercloud/gophercloud/openstack/keymanager/v1/secrets" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/keymanager/v1/keymanager.go b/internal/acceptance/openstack/keymanager/v1/keymanager.go similarity index 99% rename from acceptance/openstack/keymanager/v1/keymanager.go rename to internal/acceptance/openstack/keymanager/v1/keymanager.go index e4b6f95015..c0e9dd2728 100644 --- a/acceptance/openstack/keymanager/v1/keymanager.go +++ b/internal/acceptance/openstack/keymanager/v1/keymanager.go @@ -15,7 +15,7 @@ import ( "time" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/keymanager/v1/containers" "github.com/gophercloud/gophercloud/openstack/keymanager/v1/orders" "github.com/gophercloud/gophercloud/openstack/keymanager/v1/secrets" diff --git a/acceptance/openstack/keymanager/v1/orders_test.go b/internal/acceptance/openstack/keymanager/v1/orders_test.go similarity index 94% rename from acceptance/openstack/keymanager/v1/orders_test.go rename to internal/acceptance/openstack/keymanager/v1/orders_test.go index cb9095af4f..f300f8fa7e 100644 --- a/acceptance/openstack/keymanager/v1/orders_test.go +++ b/internal/acceptance/openstack/keymanager/v1/orders_test.go @@ -6,8 +6,8 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/keymanager/v1/containers" "github.com/gophercloud/gophercloud/openstack/keymanager/v1/orders" "github.com/gophercloud/gophercloud/openstack/keymanager/v1/secrets" diff --git a/acceptance/openstack/keymanager/v1/secrets_test.go b/internal/acceptance/openstack/keymanager/v1/secrets_test.go similarity index 98% rename from acceptance/openstack/keymanager/v1/secrets_test.go rename to internal/acceptance/openstack/keymanager/v1/secrets_test.go index 761ffc1338..59c989bb2e 100644 --- a/acceptance/openstack/keymanager/v1/secrets_test.go +++ b/internal/acceptance/openstack/keymanager/v1/secrets_test.go @@ -7,8 +7,8 @@ import ( "testing" "time" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/keymanager/v1/secrets" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/loadbalancer/v2/amphorae_test.go b/internal/acceptance/openstack/loadbalancer/v2/amphorae_test.go similarity index 84% rename from acceptance/openstack/loadbalancer/v2/amphorae_test.go rename to internal/acceptance/openstack/loadbalancer/v2/amphorae_test.go index 42c14300bb..b2ec529e3f 100644 --- a/acceptance/openstack/loadbalancer/v2/amphorae_test.go +++ b/internal/acceptance/openstack/loadbalancer/v2/amphorae_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/amphorae" ) diff --git a/internal/acceptance/openstack/loadbalancer/v2/flavorprofiles_test.go b/internal/acceptance/openstack/loadbalancer/v2/flavorprofiles_test.go new file mode 100644 index 0000000000..bde7dbec77 --- /dev/null +++ b/internal/acceptance/openstack/loadbalancer/v2/flavorprofiles_test.go @@ -0,0 +1,53 @@ +//go:build acceptance || networking || loadbalancer || flavorprofiles +// +build acceptance networking loadbalancer flavorprofiles + +package v2 + +import ( + "testing" + + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" + "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/flavorprofiles" + + th "github.com/gophercloud/gophercloud/testhelper" +) + +func TestFlavorProfilesList(t *testing.T) { + client, err := clients.NewLoadBalancerV2Client() + th.AssertNoErr(t, err) + + allPages, err := flavorprofiles.List(client, nil).AllPages() + th.AssertNoErr(t, err) + + allFlavorProfiles, err := flavorprofiles.ExtractFlavorProfiles(allPages) + th.AssertNoErr(t, err) + + for _, flavorprofile := range allFlavorProfiles { + tools.PrintResource(t, flavorprofile) + } +} + +func TestFlavorProfilesCRUD(t *testing.T) { + lbClient, err := clients.NewLoadBalancerV2Client() + th.AssertNoErr(t, err) + + flavorProfile, err := CreateFlavorProfile(t, lbClient) + th.AssertNoErr(t, err) + defer DeleteFlavorProfile(t, lbClient, flavorProfile) + + tools.PrintResource(t, flavorProfile) + + th.AssertEquals(t, "amphora", flavorProfile.ProviderName) + + flavorProfileUpdateOpts := flavorprofiles.UpdateOpts{ + Name: tools.RandomString("TESTACCTUP-", 8), + } + + flavorProfileUpdated, err := flavorprofiles.Update(lbClient, flavorProfile.ID, flavorProfileUpdateOpts).Extract() + th.AssertNoErr(t, err) + + th.AssertEquals(t, flavorProfileUpdateOpts.Name, flavorProfileUpdated.Name) + + t.Logf("Successfully updated flavorprofile %s", flavorProfileUpdated.Name) +} diff --git a/internal/acceptance/openstack/loadbalancer/v2/flavors_test.go b/internal/acceptance/openstack/loadbalancer/v2/flavors_test.go new file mode 100644 index 0000000000..f45b4c20a6 --- /dev/null +++ b/internal/acceptance/openstack/loadbalancer/v2/flavors_test.go @@ -0,0 +1,66 @@ +//go:build acceptance || networking || loadbalancer || flavors +// +build acceptance networking loadbalancer flavors + +package v2 + +import ( + "testing" + + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" + "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/flavors" + th "github.com/gophercloud/gophercloud/testhelper" +) + +func TestFlavorsList(t *testing.T) { + client, err := clients.NewLoadBalancerV2Client() + if err != nil { + t.Fatalf("Unable to create a loadbalancer client: %v", err) + } + + allPages, err := flavors.List(client, nil).AllPages() + if err != nil { + t.Fatalf("Unable to list flavors: %v", err) + } + + allFlavors, err := flavors.ExtractFlavors(allPages) + if err != nil { + t.Fatalf("Unable to extract flavors: %v", err) + } + + for _, flavor := range allFlavors { + tools.PrintResource(t, flavor) + } +} + +func TestFlavorsCRUD(t *testing.T) { + lbClient, err := clients.NewLoadBalancerV2Client() + th.AssertNoErr(t, err) + + flavorProfile, err := CreateFlavorProfile(t, lbClient) + th.AssertNoErr(t, err) + defer DeleteFlavorProfile(t, lbClient, flavorProfile) + + tools.PrintResource(t, flavorProfile) + + th.AssertEquals(t, "amphora", flavorProfile.ProviderName) + + flavor, err := CreateFlavor(t, lbClient, flavorProfile) + th.AssertNoErr(t, err) + defer DeleteFlavor(t, lbClient, flavor) + + tools.PrintResource(t, flavor) + + th.AssertEquals(t, flavor.FlavorProfileId, flavorProfile.ID) + + flavorUpdateOpts := flavors.UpdateOpts{ + Name: tools.RandomString("TESTACCTUP-", 8), + } + + flavorUpdated, err := flavors.Update(lbClient, flavor.ID, flavorUpdateOpts).Extract() + th.AssertNoErr(t, err) + + th.AssertEquals(t, flavorUpdateOpts.Name, flavorUpdated.Name) + + t.Logf("Successfully updated flavor %s", flavorUpdated.Name) +} diff --git a/acceptance/openstack/loadbalancer/v2/l7policies_test.go b/internal/acceptance/openstack/loadbalancer/v2/l7policies_test.go similarity index 85% rename from acceptance/openstack/loadbalancer/v2/l7policies_test.go rename to internal/acceptance/openstack/loadbalancer/v2/l7policies_test.go index 3ad3c9755b..66c6422d6e 100644 --- a/acceptance/openstack/loadbalancer/v2/l7policies_test.go +++ b/internal/acceptance/openstack/loadbalancer/v2/l7policies_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/l7policies" ) diff --git a/acceptance/openstack/loadbalancer/v2/listeners_test.go b/internal/acceptance/openstack/loadbalancer/v2/listeners_test.go similarity index 85% rename from acceptance/openstack/loadbalancer/v2/listeners_test.go rename to internal/acceptance/openstack/loadbalancer/v2/listeners_test.go index ff06f4af41..a760224ee8 100644 --- a/acceptance/openstack/loadbalancer/v2/listeners_test.go +++ b/internal/acceptance/openstack/loadbalancer/v2/listeners_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners" ) diff --git a/acceptance/openstack/loadbalancer/v2/loadbalancer.go b/internal/acceptance/openstack/loadbalancer/v2/loadbalancer.go similarity index 90% rename from acceptance/openstack/loadbalancer/v2/loadbalancer.go rename to internal/acceptance/openstack/loadbalancer/v2/loadbalancer.go index 8d5efb011d..b5eda52e18 100644 --- a/acceptance/openstack/loadbalancer/v2/loadbalancer.go +++ b/internal/acceptance/openstack/loadbalancer/v2/loadbalancer.go @@ -6,8 +6,10 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" + "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/flavorprofiles" + "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/flavors" "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/l7policies" "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners" "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers" @@ -71,7 +73,7 @@ func CreateListenerHTTP(t *testing.T, client *gophercloud.ServiceClient, lb *loa } // tls_version is only supported in microversion v2.17 introduced in victoria - if clients.IsReleasesAbove(t, "stable/ussuri") { + if clients.IsCurrentAbove(t, "stable/ussuri") { tlsVersions = []listeners.TLSVersion{"TLSv1.2", "TLSv1.3"} tlsVersionsExp = []string{"TLSv1.2", "TLSv1.3"} } @@ -676,3 +678,72 @@ func WaitForLoadBalancerState(client *gophercloud.ServiceClient, lbID, status st return false, nil }) } + +func CreateFlavorProfile(t *testing.T, client *gophercloud.ServiceClient) (*flavorprofiles.FlavorProfile, error) { + flavorProfileName := tools.RandomString("TESTACCT-", 8) + flavorProfileDriver := "amphora" + flavorProfileData := "{\"loadbalancer_topology\": \"SINGLE\"}" + + createOpts := flavorprofiles.CreateOpts{ + Name: flavorProfileName, + ProviderName: flavorProfileDriver, + FlavorData: flavorProfileData, + } + + flavorProfile, err := flavorprofiles.Create(client, createOpts).Extract() + if err != nil { + return flavorProfile, err + } + + t.Logf("Successfully created flavorprofile %s", flavorProfileName) + + th.AssertEquals(t, flavorProfileName, flavorProfile.Name) + th.AssertEquals(t, flavorProfileDriver, flavorProfile.ProviderName) + th.AssertEquals(t, flavorProfileData, flavorProfile.FlavorData) + + return flavorProfile, nil +} + +func DeleteFlavorProfile(t *testing.T, client *gophercloud.ServiceClient, flavorProfile *flavorprofiles.FlavorProfile) { + err := flavorprofiles.Delete(client, flavorProfile.ID).ExtractErr() + if err != nil { + t.Fatalf("Unable to delete flavorprofile: %v", err) + } + + t.Logf("Successfully deleted flavorprofile %s", flavorProfile.Name) +} + +func CreateFlavor(t *testing.T, client *gophercloud.ServiceClient, flavorProfile *flavorprofiles.FlavorProfile) (*flavors.Flavor, error) { + flavorName := tools.RandomString("TESTACCT-", 8) + description := tools.RandomString("TESTACCT-desc-", 32) + + createOpts := flavors.CreateOpts{ + Name: flavorName, + Description: description, + FlavorProfileId: flavorProfile.ID, + Enabled: true, + } + + flavor, err := flavors.Create(client, createOpts).Extract() + if err != nil { + return flavor, err + } + + t.Logf("Successfully created flavor %s with flavorprofile %s", flavor.Name, flavorProfile.Name) + + th.AssertEquals(t, flavorName, flavor.Name) + th.AssertEquals(t, description, flavor.Description) + th.AssertEquals(t, flavorProfile.ID, flavor.FlavorProfileId) + th.AssertEquals(t, true, flavor.Enabled) + + return flavor, nil +} + +func DeleteFlavor(t *testing.T, client *gophercloud.ServiceClient, flavor *flavors.Flavor) { + err := flavors.Delete(client, flavor.ID).ExtractErr() + if err != nil { + t.Fatalf("Unable to delete flavor: %v", err) + } + + t.Logf("Successfully deleted flavor %s", flavor.Name) +} diff --git a/acceptance/openstack/loadbalancer/v2/loadbalancers_test.go b/internal/acceptance/openstack/loadbalancer/v2/loadbalancers_test.go similarity index 98% rename from acceptance/openstack/loadbalancer/v2/loadbalancers_test.go rename to internal/acceptance/openstack/loadbalancer/v2/loadbalancers_test.go index 2a987bd9b9..f18f0abdae 100644 --- a/acceptance/openstack/loadbalancer/v2/loadbalancers_test.go +++ b/internal/acceptance/openstack/loadbalancer/v2/loadbalancers_test.go @@ -6,10 +6,10 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - networking "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2" - "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2/extensions/qos/policies" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + networking "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2" + "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2/extensions/qos/policies" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/l7policies" "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners" "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers" diff --git a/acceptance/openstack/loadbalancer/v2/monitors_test.go b/internal/acceptance/openstack/loadbalancer/v2/monitors_test.go similarity index 84% rename from acceptance/openstack/loadbalancer/v2/monitors_test.go rename to internal/acceptance/openstack/loadbalancer/v2/monitors_test.go index a721f51438..483b0cef51 100644 --- a/acceptance/openstack/loadbalancer/v2/monitors_test.go +++ b/internal/acceptance/openstack/loadbalancer/v2/monitors_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors" ) diff --git a/acceptance/openstack/loadbalancer/v2/pkg.go b/internal/acceptance/openstack/loadbalancer/v2/pkg.go similarity index 100% rename from acceptance/openstack/loadbalancer/v2/pkg.go rename to internal/acceptance/openstack/loadbalancer/v2/pkg.go diff --git a/acceptance/openstack/loadbalancer/v2/pools_test.go b/internal/acceptance/openstack/loadbalancer/v2/pools_test.go similarity index 84% rename from acceptance/openstack/loadbalancer/v2/pools_test.go rename to internal/acceptance/openstack/loadbalancer/v2/pools_test.go index 8a9724dd94..9ae691f9e8 100644 --- a/acceptance/openstack/loadbalancer/v2/pools_test.go +++ b/internal/acceptance/openstack/loadbalancer/v2/pools_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools" ) diff --git a/acceptance/openstack/loadbalancer/v2/providers_test.go b/internal/acceptance/openstack/loadbalancer/v2/providers_test.go similarity index 85% rename from acceptance/openstack/loadbalancer/v2/providers_test.go rename to internal/acceptance/openstack/loadbalancer/v2/providers_test.go index c65511bbf9..f71cb191c9 100644 --- a/acceptance/openstack/loadbalancer/v2/providers_test.go +++ b/internal/acceptance/openstack/loadbalancer/v2/providers_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/providers" ) diff --git a/acceptance/openstack/loadbalancer/v2/quotas_test.go b/internal/acceptance/openstack/loadbalancer/v2/quotas_test.go similarity index 91% rename from acceptance/openstack/loadbalancer/v2/quotas_test.go rename to internal/acceptance/openstack/loadbalancer/v2/quotas_test.go index 4e174642c4..e88dca5b44 100644 --- a/acceptance/openstack/loadbalancer/v2/quotas_test.go +++ b/internal/acceptance/openstack/loadbalancer/v2/quotas_test.go @@ -10,8 +10,8 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/quotas" th "github.com/gophercloud/gophercloud/testhelper" ) @@ -45,7 +45,7 @@ func TestQuotasUpdate(t *testing.T) { Healthmonitor: gophercloud.IntToPointer(5), } // L7 parameters are only supported in microversion v2.19 introduced in victoria - if clients.IsReleasesAbove(t, "stable/ussuri") { + if clients.IsCurrentAbove(t, "stable/ussuri") { quotaUpdateOpts.L7Policy = gophercloud.IntToPointer(55) quotaUpdateOpts.L7Rule = gophercloud.IntToPointer(105) } @@ -67,7 +67,7 @@ func TestQuotasUpdate(t *testing.T) { Healthmonitor: &originalQuotas.Healthmonitor, } // L7 parameters are only supported in microversion v2.19 introduced in victoria - if clients.IsReleasesAbove(t, "stable/ussuri") { + if clients.IsCurrentAbove(t, "stable/ussuri") { restoredQuotaUpdate.L7Policy = &originalQuotas.L7Policy restoredQuotaUpdate.L7Rule = &originalQuotas.L7Rule } diff --git a/acceptance/openstack/messaging/v2/claims_test.go b/internal/acceptance/openstack/messaging/v2/claims_test.go similarity index 92% rename from acceptance/openstack/messaging/v2/claims_test.go rename to internal/acceptance/openstack/messaging/v2/claims_test.go index 32fa87862f..d08ed61b2a 100644 --- a/acceptance/openstack/messaging/v2/claims_test.go +++ b/internal/acceptance/openstack/messaging/v2/claims_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/messaging/v2/claims" ) diff --git a/acceptance/openstack/messaging/v2/message_test.go b/internal/acceptance/openstack/messaging/v2/message_test.go similarity index 98% rename from acceptance/openstack/messaging/v2/message_test.go rename to internal/acceptance/openstack/messaging/v2/message_test.go index b562023c61..bef7c4b94a 100644 --- a/acceptance/openstack/messaging/v2/message_test.go +++ b/internal/acceptance/openstack/messaging/v2/message_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/messaging/v2/messages" "github.com/gophercloud/gophercloud/pagination" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/messaging/v2/messaging.go b/internal/acceptance/openstack/messaging/v2/messaging.go similarity index 98% rename from acceptance/openstack/messaging/v2/messaging.go rename to internal/acceptance/openstack/messaging/v2/messaging.go index 09f2641e09..00513b7e24 100644 --- a/acceptance/openstack/messaging/v2/messaging.go +++ b/internal/acceptance/openstack/messaging/v2/messaging.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/messaging/v2/claims" "github.com/gophercloud/gophercloud/openstack/messaging/v2/messages" "github.com/gophercloud/gophercloud/openstack/messaging/v2/queues" diff --git a/acceptance/openstack/messaging/v2/queue_test.go b/internal/acceptance/openstack/messaging/v2/queue_test.go similarity index 96% rename from acceptance/openstack/messaging/v2/queue_test.go rename to internal/acceptance/openstack/messaging/v2/queue_test.go index c34d104ef5..bdbc5885ec 100644 --- a/acceptance/openstack/messaging/v2/queue_test.go +++ b/internal/acceptance/openstack/messaging/v2/queue_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/messaging/v2/queues" "github.com/gophercloud/gophercloud/pagination" ) diff --git a/acceptance/openstack/networking/v2/apiversion_test.go b/internal/acceptance/openstack/networking/v2/apiversion_test.go similarity index 90% rename from acceptance/openstack/networking/v2/apiversion_test.go rename to internal/acceptance/openstack/networking/v2/apiversion_test.go index 9ad3e9212b..ab89b438fd 100644 --- a/acceptance/openstack/networking/v2/apiversion_test.go +++ b/internal/acceptance/openstack/networking/v2/apiversion_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/apiversions" ) diff --git a/acceptance/openstack/networking/v2/extension_test.go b/internal/acceptance/openstack/networking/v2/extension_test.go similarity index 88% rename from acceptance/openstack/networking/v2/extension_test.go rename to internal/acceptance/openstack/networking/v2/extension_test.go index 4fed3e1fd9..06c6c632c1 100644 --- a/acceptance/openstack/networking/v2/extension_test.go +++ b/internal/acceptance/openstack/networking/v2/extension_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/common/extensions" ) diff --git a/acceptance/openstack/networking/v2/extensions/agents/agents_test.go b/internal/acceptance/openstack/networking/v2/extensions/agents/agents_test.go similarity index 94% rename from acceptance/openstack/networking/v2/extensions/agents/agents_test.go rename to internal/acceptance/openstack/networking/v2/extensions/agents/agents_test.go index db34e75a1c..b9186e3bde 100644 --- a/acceptance/openstack/networking/v2/extensions/agents/agents_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/agents/agents_test.go @@ -7,10 +7,10 @@ import ( "testing" "time" - "github.com/gophercloud/gophercloud/acceptance/clients" - networking "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2" - spk "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2/extensions/bgp/speakers" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + networking "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2" + spk "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2/extensions/bgp/speakers" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/agents" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/bgp/speakers" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/networking/v2/extensions/agents/doc.go b/internal/acceptance/openstack/networking/v2/extensions/agents/doc.go similarity index 100% rename from acceptance/openstack/networking/v2/extensions/agents/doc.go rename to internal/acceptance/openstack/networking/v2/extensions/agents/doc.go diff --git a/acceptance/openstack/networking/v2/extensions/attributestags_test.go b/internal/acceptance/openstack/networking/v2/extensions/attributestags_test.go similarity index 95% rename from acceptance/openstack/networking/v2/extensions/attributestags_test.go rename to internal/acceptance/openstack/networking/v2/extensions/attributestags_test.go index b30a10e894..f9843281a9 100644 --- a/acceptance/openstack/networking/v2/extensions/attributestags_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/attributestags_test.go @@ -9,9 +9,9 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/clients" - networking "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + networking "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/attributestags" "github.com/gophercloud/gophercloud/openstack/networking/v2/networks" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/networking/v2/extensions/bgp/peers/bgppeers_test.go b/internal/acceptance/openstack/networking/v2/extensions/bgp/peers/bgppeers_test.go similarity index 92% rename from acceptance/openstack/networking/v2/extensions/bgp/peers/bgppeers_test.go rename to internal/acceptance/openstack/networking/v2/extensions/bgp/peers/bgppeers_test.go index 37a2e7f94a..28e790b901 100644 --- a/acceptance/openstack/networking/v2/extensions/bgp/peers/bgppeers_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/bgp/peers/bgppeers_test.go @@ -3,8 +3,8 @@ package peers import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/bgp/peers" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/networking/v2/extensions/bgp/peers/doc.go b/internal/acceptance/openstack/networking/v2/extensions/bgp/peers/doc.go similarity index 100% rename from acceptance/openstack/networking/v2/extensions/bgp/peers/doc.go rename to internal/acceptance/openstack/networking/v2/extensions/bgp/peers/doc.go diff --git a/acceptance/openstack/networking/v2/extensions/bgp/peers/peers.go b/internal/acceptance/openstack/networking/v2/extensions/bgp/peers/peers.go similarity index 93% rename from acceptance/openstack/networking/v2/extensions/bgp/peers/peers.go rename to internal/acceptance/openstack/networking/v2/extensions/bgp/peers/peers.go index cd0b102dab..b92a488edf 100644 --- a/acceptance/openstack/networking/v2/extensions/bgp/peers/peers.go +++ b/internal/acceptance/openstack/networking/v2/extensions/bgp/peers/peers.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/bgp/peers" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/networking/v2/extensions/bgp/speakers/bgpspeakers_test.go b/internal/acceptance/openstack/networking/v2/extensions/bgp/speakers/bgpspeakers_test.go similarity index 92% rename from acceptance/openstack/networking/v2/extensions/bgp/speakers/bgpspeakers_test.go rename to internal/acceptance/openstack/networking/v2/extensions/bgp/speakers/bgpspeakers_test.go index 9a7a9f3cde..2f45251cf7 100644 --- a/acceptance/openstack/networking/v2/extensions/bgp/speakers/bgpspeakers_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/bgp/speakers/bgpspeakers_test.go @@ -3,10 +3,10 @@ package speakers import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - networking "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2" - ap "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2/extensions/bgp/peers" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + networking "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2" + ap "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2/extensions/bgp/peers" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/bgp/peers" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/bgp/speakers" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/networking/v2/extensions/bgp/speakers/doc.go b/internal/acceptance/openstack/networking/v2/extensions/bgp/speakers/doc.go similarity index 100% rename from acceptance/openstack/networking/v2/extensions/bgp/speakers/doc.go rename to internal/acceptance/openstack/networking/v2/extensions/bgp/speakers/doc.go diff --git a/acceptance/openstack/networking/v2/extensions/bgp/speakers/speakers.go b/internal/acceptance/openstack/networking/v2/extensions/bgp/speakers/speakers.go similarity index 95% rename from acceptance/openstack/networking/v2/extensions/bgp/speakers/speakers.go rename to internal/acceptance/openstack/networking/v2/extensions/bgp/speakers/speakers.go index 00b706c53e..9a04eae2a9 100644 --- a/acceptance/openstack/networking/v2/extensions/bgp/speakers/speakers.go +++ b/internal/acceptance/openstack/networking/v2/extensions/bgp/speakers/speakers.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/bgp/speakers" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/internal/acceptance/openstack/networking/v2/extensions/bgpvpns/bgpvpns.go b/internal/acceptance/openstack/networking/v2/extensions/bgpvpns/bgpvpns.go new file mode 100644 index 0000000000..e7dca49b80 --- /dev/null +++ b/internal/acceptance/openstack/networking/v2/extensions/bgpvpns/bgpvpns.go @@ -0,0 +1,27 @@ +package bgpvpns + +import ( + "testing" + + "github.com/gophercloud/gophercloud" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" + "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/bgpvpns" + th "github.com/gophercloud/gophercloud/testhelper" +) + +func CreateBGPVPN(t *testing.T, client *gophercloud.ServiceClient) (*bgpvpns.BGPVPN, error) { + opts := bgpvpns.CreateOpts{ + Name: tools.RandomString("TESTACC-BGPVPN-", 10), + } + + t.Logf("Attempting to create BGP VPN: %s", opts.Name) + bgpVpn, err := bgpvpns.Create(client, opts).Extract() + if err != nil { + return bgpVpn, err + } + + th.AssertEquals(t, bgpVpn.Name, opts.Name) + t.Logf("Successfully created BGP VPN") + tools.PrintResource(t, bgpVpn) + return bgpVpn, err +} diff --git a/internal/acceptance/openstack/networking/v2/extensions/bgpvpns/bgpvpns_test.go b/internal/acceptance/openstack/networking/v2/extensions/bgpvpns/bgpvpns_test.go new file mode 100644 index 0000000000..4232812a94 --- /dev/null +++ b/internal/acceptance/openstack/networking/v2/extensions/bgpvpns/bgpvpns_test.go @@ -0,0 +1,246 @@ +//go:build acceptance || networking || bgp || bgpvpns + +package bgpvpns + +import ( + "testing" + + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + networking "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2" + "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2/extensions/layer3" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" + "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/bgpvpns" + th "github.com/gophercloud/gophercloud/testhelper" +) + +func TestBGPVPNCRUD(t *testing.T) { + clients.RequireAdmin(t) + + client, err := clients.NewNetworkV2Client() + th.AssertNoErr(t, err) + + // Create a BGP VPN + bgpVpnCreated, err := CreateBGPVPN(t, client) + th.AssertNoErr(t, err) + + // Get a BGP VPN + bgpVpnGot, err := bgpvpns.Get(client, bgpVpnCreated.ID).Extract() + th.AssertNoErr(t, err) + th.AssertEquals(t, bgpVpnCreated.ID, bgpVpnGot.ID) + th.AssertEquals(t, bgpVpnCreated.Name, bgpVpnGot.Name) + + // Update a BGP VPN + newBGPVPNName := tools.RandomString("TESTACC-BGPVPN-", 10) + updateBGPOpts := bgpvpns.UpdateOpts{ + Name: &newBGPVPNName, + } + bgpVpnUpdated, err := bgpvpns.Update(client, bgpVpnGot.ID, updateBGPOpts).Extract() + th.AssertNoErr(t, err) + th.AssertEquals(t, newBGPVPNName, bgpVpnUpdated.Name) + t.Logf("Update BGP VPN, renamed from %s to %s", bgpVpnGot.Name, bgpVpnUpdated.Name) + + // List all BGP VPNs + allPages, err := bgpvpns.List(client, bgpvpns.ListOpts{}).AllPages() + th.AssertNoErr(t, err) + allVPNs, err := bgpvpns.ExtractBGPVPNs(allPages) + th.AssertNoErr(t, err) + + t.Logf("Retrieved BGP VPNs") + tools.PrintResource(t, allVPNs) + th.AssertIntGreaterOrEqual(t, len(allVPNs), 1) + + // Delete a BGP VPN + t.Logf("Attempting to delete BGP VPN: %s", bgpVpnUpdated.Name) + err = bgpvpns.Delete(client, bgpVpnUpdated.ID).ExtractErr() + th.AssertNoErr(t, err) + + _, err = bgpvpns.Get(client, bgpVpnGot.ID).Extract() + th.AssertErr(t, err) + t.Logf("BGP VPN %s deleted", bgpVpnUpdated.Name) +} + +func TestBGPVPNNetworkAssociationCRD(t *testing.T) { + clients.RequireAdmin(t) + + client, err := clients.NewNetworkV2Client() + th.AssertNoErr(t, err) + + // Create a BGP VPN + bgpVpnCreated, err := CreateBGPVPN(t, client) + th.AssertNoErr(t, err) + defer func() { + err = bgpvpns.Delete(client, bgpVpnCreated.ID).ExtractErr() + th.AssertNoErr(t, err) + }() + + // Create a Network + network, err := networking.CreateNetwork(t, client) + th.AssertNoErr(t, err) + defer networking.DeleteNetwork(t, client, network.ID) + + // Associate a Network with a BGP VPN + assocOpts := bgpvpns.CreateNetworkAssociationOpts{ + NetworkID: network.ID, + } + assoc, err := bgpvpns.CreateNetworkAssociation(client, bgpVpnCreated.ID, assocOpts).Extract() + th.AssertNoErr(t, err) + defer func() { + err = bgpvpns.DeleteNetworkAssociation(client, bgpVpnCreated.ID, assoc.ID).ExtractErr() + th.AssertNoErr(t, err) + }() + th.AssertEquals(t, network.ID, assoc.NetworkID) + + // Get a Network Association + assocGot, err := bgpvpns.GetNetworkAssociation(client, bgpVpnCreated.ID, assoc.ID).Extract() + th.AssertNoErr(t, err) + th.AssertEquals(t, network.ID, assocGot.NetworkID) + + // List all Network Associations + allPages, err := bgpvpns.ListNetworkAssociations(client, bgpVpnCreated.ID, bgpvpns.ListNetworkAssociationsOpts{}).AllPages() + th.AssertNoErr(t, err) + allAssocs, err := bgpvpns.ExtractNetworkAssociations(allPages) + th.AssertNoErr(t, err) + t.Logf("Retrieved Network Associations") + tools.PrintResource(t, allAssocs) + th.AssertIntGreaterOrEqual(t, len(allAssocs), 1) + + // Get BGP VPN with associations + getBgpVpn, err := bgpvpns.Get(client, bgpVpnCreated.ID).Extract() + th.AssertNoErr(t, err) + tools.PrintResource(t, getBgpVpn) +} + +func TestBGPVPNRouterAssociationCRUD(t *testing.T) { + clients.RequireAdmin(t) + + client, err := clients.NewNetworkV2Client() + th.AssertNoErr(t, err) + + // Create a BGP VPN + bgpVpnCreated, err := CreateBGPVPN(t, client) + th.AssertNoErr(t, err) + defer func() { + err = bgpvpns.Delete(client, bgpVpnCreated.ID).ExtractErr() + th.AssertNoErr(t, err) + }() + + // Create a Network + network, err := networking.CreateNetwork(t, client) + th.AssertNoErr(t, err) + defer networking.DeleteNetwork(t, client, network.ID) + + // Create a Router + routerCreated, err := layer3.CreateRouter(t, client, network.ID) + th.AssertNoErr(t, err) + defer layer3.DeleteRouter(t, client, routerCreated.ID) + + // Associate a Router with a BGP VPN + assocOpts := bgpvpns.CreateRouterAssociationOpts{ + RouterID: routerCreated.ID, + } + assoc, err := bgpvpns.CreateRouterAssociation(client, bgpVpnCreated.ID, assocOpts).Extract() + th.AssertNoErr(t, err) + defer func() { + err = bgpvpns.DeleteRouterAssociation(client, bgpVpnCreated.ID, assoc.ID).ExtractErr() + th.AssertNoErr(t, err) + }() + th.AssertEquals(t, routerCreated.ID, assoc.RouterID) + + // Get a Router Association + assocGot, err := bgpvpns.GetRouterAssociation(client, bgpVpnCreated.ID, assoc.ID).Extract() + th.AssertNoErr(t, err) + th.AssertEquals(t, routerCreated.ID, assocGot.RouterID) + + // Update a Router Association + assocUpdOpts := bgpvpns.UpdateRouterAssociationOpts{ + AdvertiseExtraRoutes: new(bool), + } + assocUpdate, err := bgpvpns.UpdateRouterAssociation(client, bgpVpnCreated.ID, assoc.ID, assocUpdOpts).Extract() + th.AssertNoErr(t, err) + th.AssertEquals(t, routerCreated.ID, assocUpdate.RouterID) + th.AssertEquals(t, false, assocUpdate.AdvertiseExtraRoutes) + + // List all Router Associations + allPages, err := bgpvpns.ListRouterAssociations(client, bgpVpnCreated.ID, bgpvpns.ListRouterAssociationsOpts{}).AllPages() + th.AssertNoErr(t, err) + allAssocs, err := bgpvpns.ExtractRouterAssociations(allPages) + th.AssertNoErr(t, err) + t.Logf("Retrieved Router Associations") + tools.PrintResource(t, allAssocs) + th.AssertIntGreaterOrEqual(t, len(allAssocs), 1) + + // Get BGP VPN with associations + getBgpVpn, err := bgpvpns.Get(client, bgpVpnCreated.ID).Extract() + th.AssertNoErr(t, err) + tools.PrintResource(t, getBgpVpn) +} + +func TestBGPVPNPortAssociationCRUD(t *testing.T) { + clients.RequireAdmin(t) + + client, err := clients.NewNetworkV2Client() + th.AssertNoErr(t, err) + + // Create a BGP VPN + bgpVpnCreated, err := CreateBGPVPN(t, client) + th.AssertNoErr(t, err) + defer func() { + err = bgpvpns.Delete(client, bgpVpnCreated.ID).ExtractErr() + th.AssertNoErr(t, err) + }() + + // Create a Network + network, err := networking.CreateNetwork(t, client) + th.AssertNoErr(t, err) + defer networking.DeleteNetwork(t, client, network.ID) + + // Create Subnet + subnet, err := networking.CreateSubnet(t, client, network.ID) + th.AssertNoErr(t, err) + defer networking.DeleteSubnet(t, client, subnet.ID) + + // Create port + port, err := networking.CreatePort(t, client, network.ID, subnet.ID) + th.AssertNoErr(t, err) + defer networking.DeletePort(t, client, port.ID) + + // Associate a Port with a BGP VPN + assocOpts := bgpvpns.CreatePortAssociationOpts{ + PortID: port.ID, + } + assoc, err := bgpvpns.CreatePortAssociation(client, bgpVpnCreated.ID, assocOpts).Extract() + th.AssertNoErr(t, err) + defer func() { + err = bgpvpns.DeletePortAssociation(client, bgpVpnCreated.ID, assoc.ID).ExtractErr() + th.AssertNoErr(t, err) + }() + th.AssertEquals(t, port.ID, assoc.PortID) + + // Get a Port Association + assocGot, err := bgpvpns.GetPortAssociation(client, bgpVpnCreated.ID, assoc.ID).Extract() + th.AssertNoErr(t, err) + th.AssertEquals(t, port.ID, assocGot.PortID) + + // Update a Port Association + assocUpdOpts := bgpvpns.UpdatePortAssociationOpts{ + AdvertiseFixedIPs: new(bool), + } + assocUpdate, err := bgpvpns.UpdatePortAssociation(client, bgpVpnCreated.ID, assoc.ID, assocUpdOpts).Extract() + th.AssertNoErr(t, err) + th.AssertEquals(t, port.ID, assocUpdate.PortID) + th.AssertEquals(t, false, assocUpdate.AdvertiseFixedIPs) + + // List all Port Associations + allPages, err := bgpvpns.ListPortAssociations(client, bgpVpnCreated.ID, bgpvpns.ListPortAssociationsOpts{}).AllPages() + th.AssertNoErr(t, err) + allAssocs, err := bgpvpns.ExtractPortAssociations(allPages) + th.AssertNoErr(t, err) + t.Logf("Retrieved Port Associations") + tools.PrintResource(t, allAssocs) + th.AssertIntGreaterOrEqual(t, len(allAssocs), 1) + + // Get BGP VPN with associations + getBgpVpn, err := bgpvpns.Get(client, bgpVpnCreated.ID).Extract() + th.AssertNoErr(t, err) + tools.PrintResource(t, getBgpVpn) +} diff --git a/internal/acceptance/openstack/networking/v2/extensions/bgpvpns/doc.go b/internal/acceptance/openstack/networking/v2/extensions/bgpvpns/doc.go new file mode 100644 index 0000000000..d6db7c50b2 --- /dev/null +++ b/internal/acceptance/openstack/networking/v2/extensions/bgpvpns/doc.go @@ -0,0 +1,2 @@ +// BGP VPN acceptance tests +package bgpvpns diff --git a/acceptance/openstack/networking/v2/extensions/dns/dns.go b/internal/acceptance/openstack/networking/v2/extensions/dns/dns.go similarity index 98% rename from acceptance/openstack/networking/v2/extensions/dns/dns.go rename to internal/acceptance/openstack/networking/v2/extensions/dns/dns.go index e6f5b2e20e..72fc944ecf 100644 --- a/acceptance/openstack/networking/v2/extensions/dns/dns.go +++ b/internal/acceptance/openstack/networking/v2/extensions/dns/dns.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/dns" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips" "github.com/gophercloud/gophercloud/openstack/networking/v2/networks" diff --git a/acceptance/openstack/networking/v2/extensions/dns/dns_test.go b/internal/acceptance/openstack/networking/v2/extensions/dns/dns_test.go similarity index 95% rename from acceptance/openstack/networking/v2/extensions/dns/dns_test.go rename to internal/acceptance/openstack/networking/v2/extensions/dns/dns_test.go index 005d470b23..654112fe74 100644 --- a/acceptance/openstack/networking/v2/extensions/dns/dns_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/dns/dns_test.go @@ -7,10 +7,10 @@ import ( "os" "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - networking "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2" - "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2/extensions/layer3" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + networking "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2" + "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2/extensions/layer3" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/common/extensions" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/dns" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips" diff --git a/acceptance/openstack/networking/v2/extensions/extensions.go b/internal/acceptance/openstack/networking/v2/extensions/extensions.go similarity index 98% rename from acceptance/openstack/networking/v2/extensions/extensions.go rename to internal/acceptance/openstack/networking/v2/extensions/extensions.go index fe2999d066..83f64bd6ad 100644 --- a/acceptance/openstack/networking/v2/extensions/extensions.go +++ b/internal/acceptance/openstack/networking/v2/extensions/extensions.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/external" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules" diff --git a/acceptance/openstack/networking/v2/extensions/fwaas/firewall_test.go b/internal/acceptance/openstack/networking/v2/extensions/fwaas/firewall_test.go similarity index 95% rename from acceptance/openstack/networking/v2/extensions/fwaas/firewall_test.go rename to internal/acceptance/openstack/networking/v2/extensions/fwaas/firewall_test.go index 95533af241..2a1079c8ed 100644 --- a/acceptance/openstack/networking/v2/extensions/fwaas/firewall_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/fwaas/firewall_test.go @@ -6,9 +6,9 @@ package fwaas import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - layer3 "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2/extensions/layer3" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + layer3 "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2/extensions/layer3" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/fwaas/routerinsertion" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/networking/v2/extensions/fwaas/fwaas.go b/internal/acceptance/openstack/networking/v2/extensions/fwaas/fwaas.go similarity index 99% rename from acceptance/openstack/networking/v2/extensions/fwaas/fwaas.go rename to internal/acceptance/openstack/networking/v2/extensions/fwaas/fwaas.go index 5f5bde95ff..4169e84288 100644 --- a/acceptance/openstack/networking/v2/extensions/fwaas/fwaas.go +++ b/internal/acceptance/openstack/networking/v2/extensions/fwaas/fwaas.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/fwaas/policies" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/fwaas/routerinsertion" diff --git a/acceptance/openstack/networking/v2/extensions/fwaas/policy_test.go b/internal/acceptance/openstack/networking/v2/extensions/fwaas/policy_test.go similarity index 91% rename from acceptance/openstack/networking/v2/extensions/fwaas/policy_test.go rename to internal/acceptance/openstack/networking/v2/extensions/fwaas/policy_test.go index a10839b8f4..1a474e83cc 100644 --- a/acceptance/openstack/networking/v2/extensions/fwaas/policy_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/fwaas/policy_test.go @@ -6,8 +6,8 @@ package fwaas import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/fwaas/policies" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/networking/v2/extensions/fwaas/rule_test.go b/internal/acceptance/openstack/networking/v2/extensions/fwaas/rule_test.go similarity index 90% rename from acceptance/openstack/networking/v2/extensions/fwaas/rule_test.go rename to internal/acceptance/openstack/networking/v2/extensions/fwaas/rule_test.go index 343211990e..59a4ad19f5 100644 --- a/acceptance/openstack/networking/v2/extensions/fwaas/rule_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/fwaas/rule_test.go @@ -6,8 +6,8 @@ package fwaas import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/fwaas/rules" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/networking/v2/extensions/fwaas_v2/fwaas_v2.go b/internal/acceptance/openstack/networking/v2/extensions/fwaas_v2/fwaas_v2.go similarity index 98% rename from acceptance/openstack/networking/v2/extensions/fwaas_v2/fwaas_v2.go rename to internal/acceptance/openstack/networking/v2/extensions/fwaas_v2/fwaas_v2.go index 57a621a8bd..d99106bf35 100644 --- a/acceptance/openstack/networking/v2/extensions/fwaas_v2/fwaas_v2.go +++ b/internal/acceptance/openstack/networking/v2/extensions/fwaas_v2/fwaas_v2.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/fwaas_v2/groups" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/fwaas_v2/policies" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/fwaas_v2/rules" diff --git a/acceptance/openstack/networking/v2/extensions/fwaas_v2/groups_test.go b/internal/acceptance/openstack/networking/v2/extensions/fwaas_v2/groups_test.go similarity index 96% rename from acceptance/openstack/networking/v2/extensions/fwaas_v2/groups_test.go rename to internal/acceptance/openstack/networking/v2/extensions/fwaas_v2/groups_test.go index 0183f3c8ab..c09f3ab130 100644 --- a/acceptance/openstack/networking/v2/extensions/fwaas_v2/groups_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/fwaas_v2/groups_test.go @@ -6,8 +6,8 @@ package fwaas_v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/fwaas_v2/groups" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/networking/v2/extensions/fwaas_v2/policy_test.go b/internal/acceptance/openstack/networking/v2/extensions/fwaas_v2/policy_test.go similarity index 94% rename from acceptance/openstack/networking/v2/extensions/fwaas_v2/policy_test.go rename to internal/acceptance/openstack/networking/v2/extensions/fwaas_v2/policy_test.go index b2cc55ae64..2a375f2584 100644 --- a/acceptance/openstack/networking/v2/extensions/fwaas_v2/policy_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/fwaas_v2/policy_test.go @@ -6,8 +6,8 @@ package fwaas_v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/fwaas_v2/policies" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/networking/v2/extensions/fwaas_v2/rule_test.go b/internal/acceptance/openstack/networking/v2/extensions/fwaas_v2/rule_test.go similarity index 93% rename from acceptance/openstack/networking/v2/extensions/fwaas_v2/rule_test.go rename to internal/acceptance/openstack/networking/v2/extensions/fwaas_v2/rule_test.go index 43549fd622..c6eb6d2332 100644 --- a/acceptance/openstack/networking/v2/extensions/fwaas_v2/rule_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/fwaas_v2/rule_test.go @@ -8,8 +8,8 @@ import ( "strconv" "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/fwaas_v2/rules" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/networking/v2/extensions/layer3/addressscopes_test.go b/internal/acceptance/openstack/networking/v2/extensions/layer3/addressscopes_test.go similarity index 91% rename from acceptance/openstack/networking/v2/extensions/layer3/addressscopes_test.go rename to internal/acceptance/openstack/networking/v2/extensions/layer3/addressscopes_test.go index 1687b148b3..6b4384422d 100644 --- a/acceptance/openstack/networking/v2/extensions/layer3/addressscopes_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/layer3/addressscopes_test.go @@ -6,8 +6,8 @@ package layer3 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/addressscopes" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/networking/v2/extensions/layer3/extraroutes_test.go b/internal/acceptance/openstack/networking/v2/extensions/layer3/extraroutes_test.go similarity index 92% rename from acceptance/openstack/networking/v2/extensions/layer3/extraroutes_test.go rename to internal/acceptance/openstack/networking/v2/extensions/layer3/extraroutes_test.go index b5b4c9180e..ccf1e545be 100644 --- a/acceptance/openstack/networking/v2/extensions/layer3/extraroutes_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/layer3/extraroutes_test.go @@ -8,9 +8,9 @@ import ( "net" "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - networking "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + networking "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/extraroutes" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/networking/v2/extensions/layer3/floatingips_test.go b/internal/acceptance/openstack/networking/v2/extensions/layer3/floatingips_test.go similarity index 96% rename from acceptance/openstack/networking/v2/extensions/layer3/floatingips_test.go rename to internal/acceptance/openstack/networking/v2/extensions/layer3/floatingips_test.go index 81d1d18f05..93dec689fa 100644 --- a/acceptance/openstack/networking/v2/extensions/layer3/floatingips_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/layer3/floatingips_test.go @@ -6,9 +6,9 @@ package layer3 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - networking "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + networking "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips" "github.com/gophercloud/gophercloud/openstack/networking/v2/subnets" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/networking/v2/extensions/layer3/l3_scheduling_test.go b/internal/acceptance/openstack/networking/v2/extensions/layer3/l3_scheduling_test.go similarity index 92% rename from acceptance/openstack/networking/v2/extensions/layer3/l3_scheduling_test.go rename to internal/acceptance/openstack/networking/v2/extensions/layer3/l3_scheduling_test.go index ec32dfda11..34d91ca29c 100644 --- a/acceptance/openstack/networking/v2/extensions/layer3/l3_scheduling_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/layer3/l3_scheduling_test.go @@ -6,9 +6,9 @@ package layer3 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - networking "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + networking "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/common/extensions" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/agents" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers" diff --git a/acceptance/openstack/networking/v2/extensions/layer3/layer3.go b/internal/acceptance/openstack/networking/v2/extensions/layer3/layer3.go similarity index 98% rename from acceptance/openstack/networking/v2/extensions/layer3/layer3.go rename to internal/acceptance/openstack/networking/v2/extensions/layer3/layer3.go index 6c1cdca080..b00b86b2a6 100644 --- a/acceptance/openstack/networking/v2/extensions/layer3/layer3.go +++ b/internal/acceptance/openstack/networking/v2/extensions/layer3/layer3.go @@ -6,8 +6,8 @@ import ( "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/addressscopes" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/portforwarding" @@ -73,7 +73,9 @@ func CreatePortForwarding(t *testing.T, client *gophercloud.ServiceClient, fipID fixedIP := portFixedIPs[0] internalIP := fixedIP.IPAddress + pfDescription := "Test description" createOpts := &portforwarding.CreateOpts{ + Description: pfDescription, Protocol: "tcp", InternalPort: 25, ExternalPort: 2230, diff --git a/acceptance/openstack/networking/v2/extensions/layer3/portforwardings_test.go b/internal/acceptance/openstack/networking/v2/extensions/layer3/portforwardings_test.go similarity index 87% rename from acceptance/openstack/networking/v2/extensions/layer3/portforwardings_test.go rename to internal/acceptance/openstack/networking/v2/extensions/layer3/portforwardings_test.go index 0aa35e0d3b..e495ef37ce 100644 --- a/acceptance/openstack/networking/v2/extensions/layer3/portforwardings_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/layer3/portforwardings_test.go @@ -3,9 +3,9 @@ package layer3 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - networking "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + networking "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/portforwarding" th "github.com/gophercloud/gophercloud/testhelper" @@ -53,6 +53,7 @@ func TestLayer3PortForwardingsCreateDelete(t *testing.T) { pf, err := CreatePortForwarding(t, client, fip.ID, port.ID, port.FixedIPs) th.AssertNoErr(t, err) + th.AssertEquals(t, pf.Description, "Test description") defer DeletePortForwarding(t, client, fip.ID, pf.ID) tools.PrintResource(t, pf) @@ -60,6 +61,7 @@ func TestLayer3PortForwardingsCreateDelete(t *testing.T) { th.AssertNoErr(t, err) updateOpts := portforwarding.UpdateOpts{ + Description: new(string), Protocol: "udp", InternalPort: 30, ExternalPort: 678, @@ -70,6 +72,7 @@ func TestLayer3PortForwardingsCreateDelete(t *testing.T) { newPf, err = portforwarding.Get(client, fip.ID, pf.ID).Extract() th.AssertNoErr(t, err) + th.AssertEquals(t, newPf.Description, "") allPages, err := portforwarding.List(client, portforwarding.ListOpts{}, fip.ID).AllPages() th.AssertNoErr(t, err) diff --git a/acceptance/openstack/networking/v2/extensions/layer3/routers_test.go b/internal/acceptance/openstack/networking/v2/extensions/layer3/routers_test.go similarity index 96% rename from acceptance/openstack/networking/v2/extensions/layer3/routers_test.go rename to internal/acceptance/openstack/networking/v2/extensions/layer3/routers_test.go index c4bb5eb40e..91e5af616a 100644 --- a/acceptance/openstack/networking/v2/extensions/layer3/routers_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/layer3/routers_test.go @@ -6,9 +6,9 @@ package layer3 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - networking "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + networking "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/networking/v2/extensions/lbaas/lbaas.go b/internal/acceptance/openstack/networking/v2/extensions/lbaas/lbaas.go similarity index 98% rename from acceptance/openstack/networking/v2/extensions/lbaas/lbaas.go rename to internal/acceptance/openstack/networking/v2/extensions/lbaas/lbaas.go index b31d3e5b42..90b54ef253 100644 --- a/acceptance/openstack/networking/v2/extensions/lbaas/lbaas.go +++ b/internal/acceptance/openstack/networking/v2/extensions/lbaas/lbaas.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas/members" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas/monitors" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas/pools" diff --git a/acceptance/openstack/networking/v2/extensions/lbaas/members_test.go b/internal/acceptance/openstack/networking/v2/extensions/lbaas/members_test.go similarity index 90% rename from acceptance/openstack/networking/v2/extensions/lbaas/members_test.go rename to internal/acceptance/openstack/networking/v2/extensions/lbaas/members_test.go index 78be8832d4..93cdfe4984 100644 --- a/acceptance/openstack/networking/v2/extensions/lbaas/members_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/lbaas/members_test.go @@ -7,9 +7,9 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/clients" - networking "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + networking "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas/members" ) diff --git a/acceptance/openstack/networking/v2/extensions/lbaas/monitors_test.go b/internal/acceptance/openstack/networking/v2/extensions/lbaas/monitors_test.go similarity index 92% rename from acceptance/openstack/networking/v2/extensions/lbaas/monitors_test.go rename to internal/acceptance/openstack/networking/v2/extensions/lbaas/monitors_test.go index 27ea62158b..e871065e6c 100644 --- a/acceptance/openstack/networking/v2/extensions/lbaas/monitors_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/lbaas/monitors_test.go @@ -6,8 +6,8 @@ package lbaas import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas/monitors" ) diff --git a/acceptance/openstack/networking/v2/extensions/lbaas/pools_test.go b/internal/acceptance/openstack/networking/v2/extensions/lbaas/pools_test.go similarity index 93% rename from acceptance/openstack/networking/v2/extensions/lbaas/pools_test.go rename to internal/acceptance/openstack/networking/v2/extensions/lbaas/pools_test.go index 0c8ba65d0c..4019b08ba3 100644 --- a/acceptance/openstack/networking/v2/extensions/lbaas/pools_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/lbaas/pools_test.go @@ -6,9 +6,9 @@ package lbaas import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - networking "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + networking "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas/pools" ) diff --git a/acceptance/openstack/networking/v2/extensions/lbaas/vips_test.go b/internal/acceptance/openstack/networking/v2/extensions/lbaas/vips_test.go similarity index 90% rename from acceptance/openstack/networking/v2/extensions/lbaas/vips_test.go rename to internal/acceptance/openstack/networking/v2/extensions/lbaas/vips_test.go index a954f25e28..3ae32d445e 100644 --- a/acceptance/openstack/networking/v2/extensions/lbaas/vips_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/lbaas/vips_test.go @@ -6,9 +6,9 @@ package lbaas import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - networking "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + networking "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas/vips" ) diff --git a/acceptance/openstack/networking/v2/extensions/lbaas_v2/l7policies_test.go b/internal/acceptance/openstack/networking/v2/extensions/lbaas_v2/l7policies_test.go similarity index 86% rename from acceptance/openstack/networking/v2/extensions/lbaas_v2/l7policies_test.go rename to internal/acceptance/openstack/networking/v2/extensions/lbaas_v2/l7policies_test.go index aa69b9e448..4aa1fa9aea 100644 --- a/acceptance/openstack/networking/v2/extensions/lbaas_v2/l7policies_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/lbaas_v2/l7policies_test.go @@ -6,8 +6,8 @@ package lbaas_v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas_v2/l7policies" ) diff --git a/acceptance/openstack/networking/v2/extensions/lbaas_v2/lbaas_v2.go b/internal/acceptance/openstack/networking/v2/extensions/lbaas_v2/lbaas_v2.go similarity index 99% rename from acceptance/openstack/networking/v2/extensions/lbaas_v2/lbaas_v2.go rename to internal/acceptance/openstack/networking/v2/extensions/lbaas_v2/lbaas_v2.go index 13fddaf803..897d66c568 100644 --- a/acceptance/openstack/networking/v2/extensions/lbaas_v2/lbaas_v2.go +++ b/internal/acceptance/openstack/networking/v2/extensions/lbaas_v2/lbaas_v2.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas_v2/l7policies" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas_v2/listeners" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas_v2/loadbalancers" diff --git a/acceptance/openstack/networking/v2/extensions/lbaas_v2/listeners_test.go b/internal/acceptance/openstack/networking/v2/extensions/lbaas_v2/listeners_test.go similarity index 86% rename from acceptance/openstack/networking/v2/extensions/lbaas_v2/listeners_test.go rename to internal/acceptance/openstack/networking/v2/extensions/lbaas_v2/listeners_test.go index 72d4b72282..2feb6d9ace 100644 --- a/acceptance/openstack/networking/v2/extensions/lbaas_v2/listeners_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/lbaas_v2/listeners_test.go @@ -6,8 +6,8 @@ package lbaas_v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas_v2/listeners" ) diff --git a/acceptance/openstack/networking/v2/extensions/lbaas_v2/loadbalancers_test.go b/internal/acceptance/openstack/networking/v2/extensions/lbaas_v2/loadbalancers_test.go similarity index 97% rename from acceptance/openstack/networking/v2/extensions/lbaas_v2/loadbalancers_test.go rename to internal/acceptance/openstack/networking/v2/extensions/lbaas_v2/loadbalancers_test.go index 8529deb957..11ee1f8ce0 100644 --- a/acceptance/openstack/networking/v2/extensions/lbaas_v2/loadbalancers_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/lbaas_v2/loadbalancers_test.go @@ -6,9 +6,9 @@ package lbaas_v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - networking "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + networking "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas_v2/l7policies" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas_v2/listeners" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas_v2/loadbalancers" diff --git a/acceptance/openstack/networking/v2/extensions/lbaas_v2/monitors_test.go b/internal/acceptance/openstack/networking/v2/extensions/lbaas_v2/monitors_test.go similarity index 86% rename from acceptance/openstack/networking/v2/extensions/lbaas_v2/monitors_test.go rename to internal/acceptance/openstack/networking/v2/extensions/lbaas_v2/monitors_test.go index 18e145bc90..2450bfd687 100644 --- a/acceptance/openstack/networking/v2/extensions/lbaas_v2/monitors_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/lbaas_v2/monitors_test.go @@ -6,8 +6,8 @@ package lbaas_v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas_v2/monitors" ) diff --git a/acceptance/openstack/networking/v2/extensions/lbaas_v2/pools_test.go b/internal/acceptance/openstack/networking/v2/extensions/lbaas_v2/pools_test.go similarity index 86% rename from acceptance/openstack/networking/v2/extensions/lbaas_v2/pools_test.go rename to internal/acceptance/openstack/networking/v2/extensions/lbaas_v2/pools_test.go index 69c4f6e1fc..efc2978cbd 100644 --- a/acceptance/openstack/networking/v2/extensions/lbaas_v2/pools_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/lbaas_v2/pools_test.go @@ -6,8 +6,8 @@ package lbaas_v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas_v2/pools" ) diff --git a/acceptance/openstack/networking/v2/extensions/mtu/mtu.go b/internal/acceptance/openstack/networking/v2/extensions/mtu/mtu.go similarity index 96% rename from acceptance/openstack/networking/v2/extensions/mtu/mtu.go rename to internal/acceptance/openstack/networking/v2/extensions/mtu/mtu.go index 36c06f9e8d..a02053f724 100644 --- a/acceptance/openstack/networking/v2/extensions/mtu/mtu.go +++ b/internal/acceptance/openstack/networking/v2/extensions/mtu/mtu.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/mtu" "github.com/gophercloud/gophercloud/openstack/networking/v2/networks" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/networking/v2/extensions/mtu/mtu_test.go b/internal/acceptance/openstack/networking/v2/extensions/mtu/mtu_test.go similarity index 94% rename from acceptance/openstack/networking/v2/extensions/mtu/mtu_test.go rename to internal/acceptance/openstack/networking/v2/extensions/mtu/mtu_test.go index 8264d2d504..7b10c99434 100644 --- a/acceptance/openstack/networking/v2/extensions/mtu/mtu_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/mtu/mtu_test.go @@ -6,9 +6,9 @@ package mtu import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - networking "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + networking "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/common/extensions" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/mtu" "github.com/gophercloud/gophercloud/openstack/networking/v2/networks" diff --git a/acceptance/openstack/networking/v2/extensions/networkipavailabilities/networkipavailabilities_test.go b/internal/acceptance/openstack/networking/v2/extensions/networkipavailabilities/networkipavailabilities_test.go similarity index 87% rename from acceptance/openstack/networking/v2/extensions/networkipavailabilities/networkipavailabilities_test.go rename to internal/acceptance/openstack/networking/v2/extensions/networkipavailabilities/networkipavailabilities_test.go index 14b7106e29..e0bcebc1f7 100644 --- a/acceptance/openstack/networking/v2/extensions/networkipavailabilities/networkipavailabilities_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/networkipavailabilities/networkipavailabilities_test.go @@ -6,8 +6,8 @@ package networkipavailabilities import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/networkipavailabilities" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/networking/v2/extensions/portsbinding/portsbinding.go b/internal/acceptance/openstack/networking/v2/extensions/portsbinding/portsbinding.go similarity index 96% rename from acceptance/openstack/networking/v2/extensions/portsbinding/portsbinding.go rename to internal/acceptance/openstack/networking/v2/extensions/portsbinding/portsbinding.go index 2957176311..607cf1cd9c 100644 --- a/acceptance/openstack/networking/v2/extensions/portsbinding/portsbinding.go +++ b/internal/acceptance/openstack/networking/v2/extensions/portsbinding/portsbinding.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/portsbinding" "github.com/gophercloud/gophercloud/openstack/networking/v2/ports" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/networking/v2/extensions/portsbinding/portsbinding_test.go b/internal/acceptance/openstack/networking/v2/extensions/portsbinding/portsbinding_test.go similarity index 73% rename from acceptance/openstack/networking/v2/extensions/portsbinding/portsbinding_test.go rename to internal/acceptance/openstack/networking/v2/extensions/portsbinding/portsbinding_test.go index 8ab86b9ca9..e4e851fe28 100644 --- a/acceptance/openstack/networking/v2/extensions/portsbinding/portsbinding_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/portsbinding/portsbinding_test.go @@ -6,9 +6,9 @@ package portsbinding import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - networking "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + networking "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/portsbinding" "github.com/gophercloud/gophercloud/openstack/networking/v2/ports" th "github.com/gophercloud/gophercloud/testhelper" @@ -40,9 +40,9 @@ func TestPortsbindingCRUD(t *testing.T) { defer networking.DeletePort(t, client, port.ID) tools.PrintResource(t, port) - th.AssertEquals(t, port.HostID, hostID) - th.AssertEquals(t, port.VNICType, "normal") - th.AssertDeepEquals(t, port.Profile, profile) + th.AssertEquals(t, hostID, port.HostID) + th.AssertEquals(t, "normal", port.VNICType) + th.AssertDeepEquals(t, profile, port.Profile) // Update port newPortName := "" @@ -59,7 +59,6 @@ func TestPortsbindingCRUD(t *testing.T) { finalUpdateOpts = portsbinding.UpdateOptsExt{ UpdateOptsBuilder: updateOpts, HostID: &newHostID, - VNICType: "baremetal", Profile: newProfile, } @@ -73,9 +72,9 @@ func TestPortsbindingCRUD(t *testing.T) { th.AssertNoErr(t, err) tools.PrintResource(t, newPort) - th.AssertEquals(t, newPort.Description, newPortName) - th.AssertEquals(t, newPort.Description, newPortDescription) - th.AssertEquals(t, newPort.HostID, newHostID) - th.AssertEquals(t, newPort.VNICType, "baremetal") - th.AssertDeepEquals(t, newPort.Profile, newProfile) + th.AssertEquals(t, newPortName, newPort.Description) + th.AssertEquals(t, newPortDescription, newPort.Description) + th.AssertEquals(t, newHostID, newPort.HostID) + th.AssertEquals(t, "normal", newPort.VNICType) + th.AssertDeepEquals(t, newProfile, newPort.Profile) } diff --git a/acceptance/openstack/networking/v2/extensions/provider_test.go b/internal/acceptance/openstack/networking/v2/extensions/provider_test.go similarity index 75% rename from acceptance/openstack/networking/v2/extensions/provider_test.go rename to internal/acceptance/openstack/networking/v2/extensions/provider_test.go index 9e8f622d47..6b21141b9a 100644 --- a/acceptance/openstack/networking/v2/extensions/provider_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/provider_test.go @@ -6,9 +6,9 @@ package extensions import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - networking "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + networking "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/networks" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/networking/v2/extensions/qos/policies/policies.go b/internal/acceptance/openstack/networking/v2/extensions/qos/policies/policies.go similarity index 95% rename from acceptance/openstack/networking/v2/extensions/qos/policies/policies.go rename to internal/acceptance/openstack/networking/v2/extensions/qos/policies/policies.go index 88b3228df9..91d4a398bc 100644 --- a/acceptance/openstack/networking/v2/extensions/qos/policies/policies.go +++ b/internal/acceptance/openstack/networking/v2/extensions/qos/policies/policies.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/qos/policies" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/networking/v2/extensions/qos/policies/policies_test.go b/internal/acceptance/openstack/networking/v2/extensions/qos/policies/policies_test.go similarity index 92% rename from acceptance/openstack/networking/v2/extensions/qos/policies/policies_test.go rename to internal/acceptance/openstack/networking/v2/extensions/qos/policies/policies_test.go index 7dcbd68f1c..4bda08b2d0 100644 --- a/acceptance/openstack/networking/v2/extensions/qos/policies/policies_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/qos/policies/policies_test.go @@ -6,8 +6,8 @@ package policies import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/common/extensions" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/qos/policies" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/networking/v2/extensions/qos/rules/rules.go b/internal/acceptance/openstack/networking/v2/extensions/qos/rules/rules.go similarity index 100% rename from acceptance/openstack/networking/v2/extensions/qos/rules/rules.go rename to internal/acceptance/openstack/networking/v2/extensions/qos/rules/rules.go diff --git a/acceptance/openstack/networking/v2/extensions/qos/rules/rules_test.go b/internal/acceptance/openstack/networking/v2/extensions/qos/rules/rules_test.go similarity index 94% rename from acceptance/openstack/networking/v2/extensions/qos/rules/rules_test.go rename to internal/acceptance/openstack/networking/v2/extensions/qos/rules/rules_test.go index 43cfaaedea..8c88e31b0f 100644 --- a/acceptance/openstack/networking/v2/extensions/qos/rules/rules_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/qos/rules/rules_test.go @@ -3,9 +3,9 @@ package rules import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - accpolicies "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2/extensions/qos/policies" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + accpolicies "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2/extensions/qos/policies" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/common/extensions" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/qos/policies" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/qos/rules" diff --git a/acceptance/openstack/networking/v2/extensions/qos/ruletypes/ruletypes_test.go b/internal/acceptance/openstack/networking/v2/extensions/qos/ruletypes/ruletypes_test.go similarity index 89% rename from acceptance/openstack/networking/v2/extensions/qos/ruletypes/ruletypes_test.go rename to internal/acceptance/openstack/networking/v2/extensions/qos/ruletypes/ruletypes_test.go index baa44ca05f..df89bff06e 100644 --- a/acceptance/openstack/networking/v2/extensions/qos/ruletypes/ruletypes_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/qos/ruletypes/ruletypes_test.go @@ -3,8 +3,8 @@ package ruletypes import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/common/extensions" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/qos/ruletypes" ) diff --git a/acceptance/openstack/networking/v2/extensions/quotas/quotas.go b/internal/acceptance/openstack/networking/v2/extensions/quotas/quotas.go similarity index 100% rename from acceptance/openstack/networking/v2/extensions/quotas/quotas.go rename to internal/acceptance/openstack/networking/v2/extensions/quotas/quotas.go diff --git a/acceptance/openstack/networking/v2/extensions/quotas/quotas_test.go b/internal/acceptance/openstack/networking/v2/extensions/quotas/quotas_test.go similarity index 93% rename from acceptance/openstack/networking/v2/extensions/quotas/quotas_test.go rename to internal/acceptance/openstack/networking/v2/extensions/quotas/quotas_test.go index c462cd3338..5749c90433 100644 --- a/acceptance/openstack/networking/v2/extensions/quotas/quotas_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/quotas/quotas_test.go @@ -9,8 +9,8 @@ import ( "reflect" "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/quotas" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/networking/v2/extensions/rbacpolicies/rbacpolicies.go b/internal/acceptance/openstack/networking/v2/extensions/rbacpolicies/rbacpolicies.go similarity index 100% rename from acceptance/openstack/networking/v2/extensions/rbacpolicies/rbacpolicies.go rename to internal/acceptance/openstack/networking/v2/extensions/rbacpolicies/rbacpolicies.go diff --git a/acceptance/openstack/networking/v2/extensions/rbacpolicies/rbacpolicies_test.go b/internal/acceptance/openstack/networking/v2/extensions/rbacpolicies/rbacpolicies_test.go similarity index 87% rename from acceptance/openstack/networking/v2/extensions/rbacpolicies/rbacpolicies_test.go rename to internal/acceptance/openstack/networking/v2/extensions/rbacpolicies/rbacpolicies_test.go index 7b071cb304..8015610a67 100644 --- a/acceptance/openstack/networking/v2/extensions/rbacpolicies/rbacpolicies_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/rbacpolicies/rbacpolicies_test.go @@ -6,10 +6,10 @@ package rbacpolicies import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - projects "github.com/gophercloud/gophercloud/acceptance/openstack/identity/v3" - networking "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + projects "github.com/gophercloud/gophercloud/internal/acceptance/openstack/identity/v3" + networking "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/rbacpolicies" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/networking/v2/extensions/security_test.go b/internal/acceptance/openstack/networking/v2/extensions/security_test.go similarity index 86% rename from acceptance/openstack/networking/v2/extensions/security_test.go rename to internal/acceptance/openstack/networking/v2/extensions/security_test.go index 967177b8cb..dcbc68a255 100644 --- a/acceptance/openstack/networking/v2/extensions/security_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/security_test.go @@ -6,9 +6,9 @@ package extensions import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - networking "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + networking "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups" th "github.com/gophercloud/gophercloud/testhelper" ) @@ -20,6 +20,7 @@ func TestSecurityGroupsCreateUpdateDelete(t *testing.T) { group, err := CreateSecurityGroup(t, client) th.AssertNoErr(t, err) defer DeleteSecurityGroup(t, client, group.ID) + th.AssertEquals(t, group.Stateful, true) rule, err := CreateSecurityGroupRule(t, client, group.ID) th.AssertNoErr(t, err) @@ -32,6 +33,7 @@ func TestSecurityGroupsCreateUpdateDelete(t *testing.T) { updateOpts := groups.UpdateOpts{ Name: name, Description: &description, + Stateful: new(bool), } newGroup, err := groups.Update(client, group.ID, updateOpts).Extract() @@ -40,6 +42,7 @@ func TestSecurityGroupsCreateUpdateDelete(t *testing.T) { tools.PrintResource(t, newGroup) th.AssertEquals(t, newGroup.Name, name) th.AssertEquals(t, newGroup.Description, description) + th.AssertEquals(t, newGroup.Stateful, false) listOpts := groups.ListOpts{} allPages, err := groups.List(client, listOpts).AllPages() diff --git a/acceptance/openstack/networking/v2/extensions/subnetpools/subnetpools.go b/internal/acceptance/openstack/networking/v2/extensions/subnetpools/subnetpools.go similarity index 96% rename from acceptance/openstack/networking/v2/extensions/subnetpools/subnetpools.go rename to internal/acceptance/openstack/networking/v2/extensions/subnetpools/subnetpools.go index 6380264b10..a7370cc3d5 100644 --- a/acceptance/openstack/networking/v2/extensions/subnetpools/subnetpools.go +++ b/internal/acceptance/openstack/networking/v2/extensions/subnetpools/subnetpools.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/subnetpools" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/networking/v2/extensions/subnetpools/subnetpools_test.go b/internal/acceptance/openstack/networking/v2/extensions/subnetpools/subnetpools_test.go similarity index 91% rename from acceptance/openstack/networking/v2/extensions/subnetpools/subnetpools_test.go rename to internal/acceptance/openstack/networking/v2/extensions/subnetpools/subnetpools_test.go index 0989300019..12301d2b07 100644 --- a/acceptance/openstack/networking/v2/extensions/subnetpools/subnetpools_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/subnetpools/subnetpools_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/subnetpools" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/networking/v2/extensions/trunk_details/trunks_test.go b/internal/acceptance/openstack/networking/v2/extensions/trunk_details/trunks_test.go similarity index 93% rename from acceptance/openstack/networking/v2/extensions/trunk_details/trunks_test.go rename to internal/acceptance/openstack/networking/v2/extensions/trunk_details/trunks_test.go index 309d090ffa..d2d5855540 100644 --- a/acceptance/openstack/networking/v2/extensions/trunk_details/trunks_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/trunk_details/trunks_test.go @@ -6,9 +6,9 @@ package trunk_details import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - v2 "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2" - v2Trunks "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2/extensions/trunks" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + v2 "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2" + v2Trunks "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2/extensions/trunks" "github.com/gophercloud/gophercloud/openstack/common/extensions" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/trunk_details" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/trunks" diff --git a/acceptance/openstack/networking/v2/extensions/trunks/trunks.go b/internal/acceptance/openstack/networking/v2/extensions/trunks/trunks.go similarity index 95% rename from acceptance/openstack/networking/v2/extensions/trunks/trunks.go rename to internal/acceptance/openstack/networking/v2/extensions/trunks/trunks.go index 18fc920fd6..215120dae8 100644 --- a/acceptance/openstack/networking/v2/extensions/trunks/trunks.go +++ b/internal/acceptance/openstack/networking/v2/extensions/trunks/trunks.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/trunks" ) diff --git a/acceptance/openstack/networking/v2/extensions/trunks/trunks_test.go b/internal/acceptance/openstack/networking/v2/extensions/trunks/trunks_test.go similarity index 97% rename from acceptance/openstack/networking/v2/extensions/trunks/trunks_test.go rename to internal/acceptance/openstack/networking/v2/extensions/trunks/trunks_test.go index 0e62059278..a41209c95c 100644 --- a/acceptance/openstack/networking/v2/extensions/trunks/trunks_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/trunks/trunks_test.go @@ -7,9 +7,9 @@ import ( "sort" "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - v2 "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + v2 "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/common/extensions" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/attributestags" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/trunks" diff --git a/acceptance/openstack/networking/v2/extensions/vlantransparent/vlantransparent.go b/internal/acceptance/openstack/networking/v2/extensions/vlantransparent/vlantransparent.go similarity index 97% rename from acceptance/openstack/networking/v2/extensions/vlantransparent/vlantransparent.go rename to internal/acceptance/openstack/networking/v2/extensions/vlantransparent/vlantransparent.go index e91ada32d6..e061ea3813 100644 --- a/acceptance/openstack/networking/v2/extensions/vlantransparent/vlantransparent.go +++ b/internal/acceptance/openstack/networking/v2/extensions/vlantransparent/vlantransparent.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/vlantransparent" "github.com/gophercloud/gophercloud/openstack/networking/v2/networks" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/networking/v2/extensions/vlantransparent/vlantransparent_test.go b/internal/acceptance/openstack/networking/v2/extensions/vlantransparent/vlantransparent_test.go similarity index 85% rename from acceptance/openstack/networking/v2/extensions/vlantransparent/vlantransparent_test.go rename to internal/acceptance/openstack/networking/v2/extensions/vlantransparent/vlantransparent_test.go index ff5692752a..c919866309 100644 --- a/acceptance/openstack/networking/v2/extensions/vlantransparent/vlantransparent_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/vlantransparent/vlantransparent_test.go @@ -6,9 +6,9 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - networkingv2 "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + networkingv2 "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/common/extensions" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/networking/v2/extensions/vpnaas/group_test.go b/internal/acceptance/openstack/networking/v2/extensions/vpnaas/group_test.go similarity index 91% rename from acceptance/openstack/networking/v2/extensions/vpnaas/group_test.go rename to internal/acceptance/openstack/networking/v2/extensions/vpnaas/group_test.go index fafd6df496..b65c356e81 100644 --- a/acceptance/openstack/networking/v2/extensions/vpnaas/group_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/vpnaas/group_test.go @@ -6,8 +6,8 @@ package vpnaas import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/vpnaas/endpointgroups" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/networking/v2/extensions/vpnaas/ikepolicy_test.go b/internal/acceptance/openstack/networking/v2/extensions/vpnaas/ikepolicy_test.go similarity index 91% rename from acceptance/openstack/networking/v2/extensions/vpnaas/ikepolicy_test.go rename to internal/acceptance/openstack/networking/v2/extensions/vpnaas/ikepolicy_test.go index 0c2715d9ab..f203c2f42e 100644 --- a/acceptance/openstack/networking/v2/extensions/vpnaas/ikepolicy_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/vpnaas/ikepolicy_test.go @@ -6,8 +6,8 @@ package vpnaas import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/vpnaas/ikepolicies" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/networking/v2/extensions/vpnaas/ipsecpolicy_test.go b/internal/acceptance/openstack/networking/v2/extensions/vpnaas/ipsecpolicy_test.go similarity index 90% rename from acceptance/openstack/networking/v2/extensions/vpnaas/ipsecpolicy_test.go rename to internal/acceptance/openstack/networking/v2/extensions/vpnaas/ipsecpolicy_test.go index d0d5729693..d36e1bff48 100644 --- a/acceptance/openstack/networking/v2/extensions/vpnaas/ipsecpolicy_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/vpnaas/ipsecpolicy_test.go @@ -6,8 +6,8 @@ package vpnaas import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/vpnaas/ipsecpolicies" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/networking/v2/extensions/vpnaas/service_test.go b/internal/acceptance/openstack/networking/v2/extensions/vpnaas/service_test.go similarity index 83% rename from acceptance/openstack/networking/v2/extensions/vpnaas/service_test.go rename to internal/acceptance/openstack/networking/v2/extensions/vpnaas/service_test.go index d8b7daa42b..17de845fa9 100644 --- a/acceptance/openstack/networking/v2/extensions/vpnaas/service_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/vpnaas/service_test.go @@ -6,9 +6,9 @@ package vpnaas import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - layer3 "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2/extensions/layer3" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + layer3 "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2/extensions/layer3" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/vpnaas/services" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/networking/v2/extensions/vpnaas/siteconnection_test.go b/internal/acceptance/openstack/networking/v2/extensions/vpnaas/siteconnection_test.go similarity index 89% rename from acceptance/openstack/networking/v2/extensions/vpnaas/siteconnection_test.go rename to internal/acceptance/openstack/networking/v2/extensions/vpnaas/siteconnection_test.go index 5f8bf4bea0..9dab42c48c 100644 --- a/acceptance/openstack/networking/v2/extensions/vpnaas/siteconnection_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/vpnaas/siteconnection_test.go @@ -6,10 +6,10 @@ package vpnaas import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - networks "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2" - layer3 "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2/extensions/layer3" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + networks "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2" + layer3 "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2/extensions/layer3" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/vpnaas/siteconnections" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/networking/v2/extensions/vpnaas/vpnaas.go b/internal/acceptance/openstack/networking/v2/extensions/vpnaas/vpnaas.go similarity index 99% rename from acceptance/openstack/networking/v2/extensions/vpnaas/vpnaas.go rename to internal/acceptance/openstack/networking/v2/extensions/vpnaas/vpnaas.go index 2ba6a09050..a165aa328a 100644 --- a/acceptance/openstack/networking/v2/extensions/vpnaas/vpnaas.go +++ b/internal/acceptance/openstack/networking/v2/extensions/vpnaas/vpnaas.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/vpnaas/endpointgroups" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/vpnaas/ikepolicies" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/vpnaas/ipsecpolicies" diff --git a/acceptance/openstack/networking/v2/networking.go b/internal/acceptance/openstack/networking/v2/networking.go similarity index 99% rename from acceptance/openstack/networking/v2/networking.go rename to internal/acceptance/openstack/networking/v2/networking.go index aae456b198..6777b39dcb 100644 --- a/acceptance/openstack/networking/v2/networking.go +++ b/internal/acceptance/openstack/networking/v2/networking.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/extradhcpopts" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/portsecurity" "github.com/gophercloud/gophercloud/openstack/networking/v2/networks" diff --git a/acceptance/openstack/networking/v2/networks_test.go b/internal/acceptance/openstack/networking/v2/networks_test.go similarity index 97% rename from acceptance/openstack/networking/v2/networks_test.go rename to internal/acceptance/openstack/networking/v2/networks_test.go index cf8a88e60d..1208e058c8 100644 --- a/acceptance/openstack/networking/v2/networks_test.go +++ b/internal/acceptance/openstack/networking/v2/networks_test.go @@ -7,8 +7,8 @@ import ( "strings" "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/external" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/portsecurity" "github.com/gophercloud/gophercloud/openstack/networking/v2/networks" diff --git a/acceptance/openstack/networking/v2/ports_test.go b/internal/acceptance/openstack/networking/v2/ports_test.go similarity index 98% rename from acceptance/openstack/networking/v2/ports_test.go rename to internal/acceptance/openstack/networking/v2/ports_test.go index 815a5c53b7..19151c2fe3 100644 --- a/acceptance/openstack/networking/v2/ports_test.go +++ b/internal/acceptance/openstack/networking/v2/ports_test.go @@ -7,9 +7,9 @@ import ( "strings" "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - extensions "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2/extensions" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + extensions "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2/extensions" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/extradhcpopts" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/portsecurity" "github.com/gophercloud/gophercloud/openstack/networking/v2/ports" diff --git a/acceptance/openstack/networking/v2/subnets_test.go b/internal/acceptance/openstack/networking/v2/subnets_test.go similarity index 97% rename from acceptance/openstack/networking/v2/subnets_test.go rename to internal/acceptance/openstack/networking/v2/subnets_test.go index 6b45d7c6a0..e7f3b71ebb 100644 --- a/acceptance/openstack/networking/v2/subnets_test.go +++ b/internal/acceptance/openstack/networking/v2/subnets_test.go @@ -8,9 +8,9 @@ import ( "strings" "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - subnetpools "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2/extensions/subnetpools" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + subnetpools "github.com/gophercloud/gophercloud/internal/acceptance/openstack/networking/v2/extensions/subnetpools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/networking/v2/subnets" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/objectstorage/v1/accounts_test.go b/internal/acceptance/openstack/objectstorage/v1/accounts_test.go similarity index 95% rename from acceptance/openstack/objectstorage/v1/accounts_test.go rename to internal/acceptance/openstack/objectstorage/v1/accounts_test.go index a484dc1601..b6792ce9f5 100644 --- a/acceptance/openstack/objectstorage/v1/accounts_test.go +++ b/internal/acceptance/openstack/objectstorage/v1/accounts_test.go @@ -7,7 +7,7 @@ import ( "strings" "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" "github.com/gophercloud/gophercloud/openstack/objectstorage/v1/accounts" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/objectstorage/v1/containers_test.go b/internal/acceptance/openstack/objectstorage/v1/containers_test.go similarity index 98% rename from acceptance/openstack/objectstorage/v1/containers_test.go rename to internal/acceptance/openstack/objectstorage/v1/containers_test.go index d754fe3a59..314b8019e7 100644 --- a/acceptance/openstack/objectstorage/v1/containers_test.go +++ b/internal/acceptance/openstack/objectstorage/v1/containers_test.go @@ -7,8 +7,8 @@ import ( "strings" "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers" "github.com/gophercloud/gophercloud/pagination" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/objectstorage/v1/objects_test.go b/internal/acceptance/openstack/objectstorage/v1/objects_test.go similarity index 97% rename from acceptance/openstack/objectstorage/v1/objects_test.go rename to internal/acceptance/openstack/objectstorage/v1/objects_test.go index 0569428f3d..86db2c6575 100644 --- a/acceptance/openstack/objectstorage/v1/objects_test.go +++ b/internal/acceptance/openstack/objectstorage/v1/objects_test.go @@ -11,8 +11,8 @@ import ( "testing" "time" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers" "github.com/gophercloud/gophercloud/openstack/objectstorage/v1/objects" th "github.com/gophercloud/gophercloud/testhelper" @@ -22,6 +22,7 @@ import ( var numObjects = 2 func TestObjects(t *testing.T) { + numObjects := numObjects + 1 client, err := clients.NewObjectStorageV1Client() if err != nil { t.Fatalf("Unable to create client: %v", err) @@ -29,9 +30,10 @@ func TestObjects(t *testing.T) { // Make a slice of length numObjects to hold the random object names. oNames := make([]string, numObjects) - for i := 0; i < len(oNames); i++ { + for i := 0; i < len(oNames)-1; i++ { oNames[i] = tools.RandomString("test-object-", 8) } + oNames[len(oNames)-1] = "test-object-with-/v1/-in-the-name" // Create a container to hold the test objects. cName := tools.RandomString("test-container-", 8) diff --git a/acceptance/openstack/objectstorage/v1/pkg.go b/internal/acceptance/openstack/objectstorage/v1/pkg.go similarity index 100% rename from acceptance/openstack/objectstorage/v1/pkg.go rename to internal/acceptance/openstack/objectstorage/v1/pkg.go diff --git a/acceptance/openstack/objectstorage/v1/versioning_test.go b/internal/acceptance/openstack/objectstorage/v1/versioning_test.go similarity index 97% rename from acceptance/openstack/objectstorage/v1/versioning_test.go rename to internal/acceptance/openstack/objectstorage/v1/versioning_test.go index 30ebadecc6..2c90f09ec9 100644 --- a/acceptance/openstack/objectstorage/v1/versioning_test.go +++ b/internal/acceptance/openstack/objectstorage/v1/versioning_test.go @@ -7,8 +7,8 @@ import ( "strings" "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers" "github.com/gophercloud/gophercloud/openstack/objectstorage/v1/objects" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/orchestration/v1/buildinfo_test.go b/internal/acceptance/openstack/orchestration/v1/buildinfo_test.go similarity index 86% rename from acceptance/openstack/orchestration/v1/buildinfo_test.go rename to internal/acceptance/openstack/orchestration/v1/buildinfo_test.go index cec6376f80..0bbea7be74 100644 --- a/acceptance/openstack/orchestration/v1/buildinfo_test.go +++ b/internal/acceptance/openstack/orchestration/v1/buildinfo_test.go @@ -6,7 +6,7 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" "github.com/gophercloud/gophercloud/openstack/orchestration/v1/buildinfo" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/orchestration/v1/orchestration.go b/internal/acceptance/openstack/orchestration/v1/orchestration.go similarity index 98% rename from acceptance/openstack/orchestration/v1/orchestration.go rename to internal/acceptance/openstack/orchestration/v1/orchestration.go index b26b9a8c19..48c155505d 100644 --- a/acceptance/openstack/orchestration/v1/orchestration.go +++ b/internal/acceptance/openstack/orchestration/v1/orchestration.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/orchestration/v1/stacks" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/orchestration/v1/stackevents_test.go b/internal/acceptance/openstack/orchestration/v1/stackevents_test.go similarity index 93% rename from acceptance/openstack/orchestration/v1/stackevents_test.go rename to internal/acceptance/openstack/orchestration/v1/stackevents_test.go index 150d51c9d8..a5de54486d 100644 --- a/acceptance/openstack/orchestration/v1/stackevents_test.go +++ b/internal/acceptance/openstack/orchestration/v1/stackevents_test.go @@ -6,7 +6,7 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" "github.com/gophercloud/gophercloud/openstack/orchestration/v1/stackevents" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/orchestration/v1/stackresources_test.go b/internal/acceptance/openstack/orchestration/v1/stackresources_test.go similarity index 92% rename from acceptance/openstack/orchestration/v1/stackresources_test.go rename to internal/acceptance/openstack/orchestration/v1/stackresources_test.go index 29c20e92e7..2033419a1c 100644 --- a/acceptance/openstack/orchestration/v1/stackresources_test.go +++ b/internal/acceptance/openstack/orchestration/v1/stackresources_test.go @@ -6,8 +6,8 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/orchestration/v1/stackresources" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/orchestration/v1/stacks_test.go b/internal/acceptance/openstack/orchestration/v1/stacks_test.go similarity index 90% rename from acceptance/openstack/orchestration/v1/stacks_test.go rename to internal/acceptance/openstack/orchestration/v1/stacks_test.go index f49818e4c3..02e4d57299 100644 --- a/acceptance/openstack/orchestration/v1/stacks_test.go +++ b/internal/acceptance/openstack/orchestration/v1/stacks_test.go @@ -6,8 +6,8 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/orchestration/v1/stacks" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/orchestration/v1/stacktemplates_test.go b/internal/acceptance/openstack/orchestration/v1/stacktemplates_test.go similarity index 90% rename from acceptance/openstack/orchestration/v1/stacktemplates_test.go rename to internal/acceptance/openstack/orchestration/v1/stacktemplates_test.go index 7513bcb43f..738d3fda44 100644 --- a/acceptance/openstack/orchestration/v1/stacktemplates_test.go +++ b/internal/acceptance/openstack/orchestration/v1/stacktemplates_test.go @@ -6,8 +6,8 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/orchestration/v1/stacktemplates" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/orchestration/v1/testdata/samplefile b/internal/acceptance/openstack/orchestration/v1/testdata/samplefile similarity index 100% rename from acceptance/openstack/orchestration/v1/testdata/samplefile rename to internal/acceptance/openstack/orchestration/v1/testdata/samplefile diff --git a/acceptance/openstack/pkg.go b/internal/acceptance/openstack/pkg.go similarity index 100% rename from acceptance/openstack/pkg.go rename to internal/acceptance/openstack/pkg.go diff --git a/acceptance/openstack/placement/v1/pkg.go b/internal/acceptance/openstack/placement/v1/pkg.go similarity index 100% rename from acceptance/openstack/placement/v1/pkg.go rename to internal/acceptance/openstack/placement/v1/pkg.go diff --git a/acceptance/openstack/placement/v1/placement.go b/internal/acceptance/openstack/placement/v1/placement.go similarity index 97% rename from acceptance/openstack/placement/v1/placement.go rename to internal/acceptance/openstack/placement/v1/placement.go index 3ae96328b6..3fc3cf9397 100644 --- a/acceptance/openstack/placement/v1/placement.go +++ b/internal/acceptance/openstack/placement/v1/placement.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/placement/v1/resourceproviders" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/placement/v1/resourceproviders_test.go b/internal/acceptance/openstack/placement/v1/resourceproviders_test.go similarity index 96% rename from acceptance/openstack/placement/v1/resourceproviders_test.go rename to internal/acceptance/openstack/placement/v1/resourceproviders_test.go index ee915ea035..52c1140ff3 100644 --- a/acceptance/openstack/placement/v1/resourceproviders_test.go +++ b/internal/acceptance/openstack/placement/v1/resourceproviders_test.go @@ -3,8 +3,8 @@ package v1 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/placement/v1/resourceproviders" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/sharedfilesystems/v2/availabilityzones_test.go b/internal/acceptance/openstack/sharedfilesystems/v2/availabilityzones_test.go similarity index 91% rename from acceptance/openstack/sharedfilesystems/v2/availabilityzones_test.go rename to internal/acceptance/openstack/sharedfilesystems/v2/availabilityzones_test.go index ed42cdfef9..acb85406a0 100644 --- a/acceptance/openstack/sharedfilesystems/v2/availabilityzones_test.go +++ b/internal/acceptance/openstack/sharedfilesystems/v2/availabilityzones_test.go @@ -6,7 +6,7 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" "github.com/gophercloud/gophercloud/openstack/sharedfilesystems/v2/availabilityzones" ) diff --git a/acceptance/openstack/sharedfilesystems/v2/messages/messages.go b/internal/acceptance/openstack/sharedfilesystems/v2/messages/messages.go similarity index 100% rename from acceptance/openstack/sharedfilesystems/v2/messages/messages.go rename to internal/acceptance/openstack/sharedfilesystems/v2/messages/messages.go diff --git a/acceptance/openstack/sharedfilesystems/v2/messages/messages_test.go b/internal/acceptance/openstack/sharedfilesystems/v2/messages/messages_test.go similarity index 95% rename from acceptance/openstack/sharedfilesystems/v2/messages/messages_test.go rename to internal/acceptance/openstack/sharedfilesystems/v2/messages/messages_test.go index d3e65603d9..e3e92b0da0 100644 --- a/acceptance/openstack/sharedfilesystems/v2/messages/messages_test.go +++ b/internal/acceptance/openstack/sharedfilesystems/v2/messages/messages_test.go @@ -3,8 +3,8 @@ package messages import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/sharedfilesystems/v2/messages" ) diff --git a/acceptance/openstack/sharedfilesystems/v2/messages/pkg.go b/internal/acceptance/openstack/sharedfilesystems/v2/messages/pkg.go similarity index 100% rename from acceptance/openstack/sharedfilesystems/v2/messages/pkg.go rename to internal/acceptance/openstack/sharedfilesystems/v2/messages/pkg.go diff --git a/acceptance/openstack/sharedfilesystems/v2/pkg.go b/internal/acceptance/openstack/sharedfilesystems/v2/pkg.go similarity index 100% rename from acceptance/openstack/sharedfilesystems/v2/pkg.go rename to internal/acceptance/openstack/sharedfilesystems/v2/pkg.go diff --git a/acceptance/openstack/sharedfilesystems/v2/replicas.go b/internal/acceptance/openstack/sharedfilesystems/v2/replicas.go similarity index 98% rename from acceptance/openstack/sharedfilesystems/v2/replicas.go rename to internal/acceptance/openstack/sharedfilesystems/v2/replicas.go index 5756986c78..3c08152250 100644 --- a/acceptance/openstack/sharedfilesystems/v2/replicas.go +++ b/internal/acceptance/openstack/sharedfilesystems/v2/replicas.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud" "github.com/gophercloud/gophercloud/openstack/sharedfilesystems/v2/replicas" diff --git a/acceptance/openstack/sharedfilesystems/v2/replicas_test.go b/internal/acceptance/openstack/sharedfilesystems/v2/replicas_test.go similarity index 93% rename from acceptance/openstack/sharedfilesystems/v2/replicas_test.go rename to internal/acceptance/openstack/sharedfilesystems/v2/replicas_test.go index d3179b199f..1b54d79b60 100644 --- a/acceptance/openstack/sharedfilesystems/v2/replicas_test.go +++ b/internal/acceptance/openstack/sharedfilesystems/v2/replicas_test.go @@ -7,14 +7,15 @@ import ( "testing" "time" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/sharedfilesystems/v2/replicas" th "github.com/gophercloud/gophercloud/testhelper" ) +// 2.56 is required for a /v2/replicas/XXX URL support // otherwise we need to set "X-OpenStack-Manila-API-Experimental: true" -const replicasMicroversion = "2.60" +const replicasPathMicroversion = "2.56" func TestReplicaCreate(t *testing.T) { clients.RequireManilaReplicas(t) @@ -23,7 +24,7 @@ func TestReplicaCreate(t *testing.T) { if err != nil { t.Fatalf("Unable to create a shared file system client: %v", err) } - client.Microversion = replicasMicroversion + client.Microversion = replicasPathMicroversion share, err := CreateShare(t, client) if err != nil { @@ -60,7 +61,7 @@ func TestReplicaPromote(t *testing.T) { if err != nil { t.Fatalf("Unable to create a shared file system client: %v", err) } - client.Microversion = replicasMicroversion + client.Microversion = replicasPathMicroversion share, err := CreateShare(t, client) if err != nil { @@ -136,7 +137,7 @@ func TestReplicaExportLocations(t *testing.T) { if err != nil { t.Fatalf("Unable to create a shared file system client: %v", err) } - client.Microversion = replicasMicroversion + client.Microversion = replicasPathMicroversion share, err := CreateShare(t, client) if err != nil { @@ -203,7 +204,7 @@ func TestReplicaListDetail(t *testing.T) { if err != nil { t.Fatalf("Unable to create a shared file system client: %v", err) } - client.Microversion = replicasMicroversion + client.Microversion = replicasPathMicroversion share, err := CreateShare(t, client) if err != nil { @@ -236,7 +237,7 @@ func TestReplicaResetStatus(t *testing.T) { if err != nil { t.Fatalf("Unable to create a shared file system client: %v", err) } - client.Microversion = replicasMicroversion + client.Microversion = replicasPathMicroversion share, err := CreateShare(t, client) if err != nil { @@ -278,7 +279,7 @@ func TestReplicaForceDelete(t *testing.T) { if err != nil { t.Fatalf("Unable to create a shared file system client: %v", err) } - client.Microversion = replicasMicroversion + client.Microversion = replicasPathMicroversion share, err := CreateShare(t, client) if err != nil { diff --git a/acceptance/openstack/sharedfilesystems/v2/schedulerstats_test.go b/internal/acceptance/openstack/sharedfilesystems/v2/schedulerstats_test.go similarity index 82% rename from acceptance/openstack/sharedfilesystems/v2/schedulerstats_test.go rename to internal/acceptance/openstack/sharedfilesystems/v2/schedulerstats_test.go index aebe388672..2d51348cab 100644 --- a/acceptance/openstack/sharedfilesystems/v2/schedulerstats_test.go +++ b/internal/acceptance/openstack/sharedfilesystems/v2/schedulerstats_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/sharedfilesystems/v2/schedulerstats" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/sharedfilesystems/v2/securityservices.go b/internal/acceptance/openstack/sharedfilesystems/v2/securityservices.go similarity index 96% rename from acceptance/openstack/sharedfilesystems/v2/securityservices.go rename to internal/acceptance/openstack/sharedfilesystems/v2/securityservices.go index 342a91789e..47b93afb98 100644 --- a/acceptance/openstack/sharedfilesystems/v2/securityservices.go +++ b/internal/acceptance/openstack/sharedfilesystems/v2/securityservices.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/sharedfilesystems/v2/securityservices" ) diff --git a/acceptance/openstack/sharedfilesystems/v2/securityservices_test.go b/internal/acceptance/openstack/sharedfilesystems/v2/securityservices_test.go similarity index 97% rename from acceptance/openstack/sharedfilesystems/v2/securityservices_test.go rename to internal/acceptance/openstack/sharedfilesystems/v2/securityservices_test.go index e0e1b16f68..e578c52e3e 100644 --- a/acceptance/openstack/sharedfilesystems/v2/securityservices_test.go +++ b/internal/acceptance/openstack/sharedfilesystems/v2/securityservices_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/sharedfilesystems/v2/securityservices" ) diff --git a/acceptance/openstack/sharedfilesystems/v2/services_test.go b/internal/acceptance/openstack/sharedfilesystems/v2/services_test.go similarity index 83% rename from acceptance/openstack/sharedfilesystems/v2/services_test.go rename to internal/acceptance/openstack/sharedfilesystems/v2/services_test.go index b1340e8752..a0745ab795 100644 --- a/acceptance/openstack/sharedfilesystems/v2/services_test.go +++ b/internal/acceptance/openstack/sharedfilesystems/v2/services_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/sharedfilesystems/v2/services" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/sharedfilesystems/v2/shareaccessrules.go b/internal/acceptance/openstack/sharedfilesystems/v2/shareaccessrules.go similarity index 97% rename from acceptance/openstack/sharedfilesystems/v2/shareaccessrules.go rename to internal/acceptance/openstack/sharedfilesystems/v2/shareaccessrules.go index 2345924e8c..2659cc9834 100644 --- a/acceptance/openstack/sharedfilesystems/v2/shareaccessrules.go +++ b/internal/acceptance/openstack/sharedfilesystems/v2/shareaccessrules.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/sharedfilesystems/v2/shareaccessrules" "github.com/gophercloud/gophercloud/openstack/sharedfilesystems/v2/shares" ) diff --git a/acceptance/openstack/sharedfilesystems/v2/shareaccessrules_test.go b/internal/acceptance/openstack/sharedfilesystems/v2/shareaccessrules_test.go similarity index 96% rename from acceptance/openstack/sharedfilesystems/v2/shareaccessrules_test.go rename to internal/acceptance/openstack/sharedfilesystems/v2/shareaccessrules_test.go index 6670c22ebe..d5a279a923 100644 --- a/acceptance/openstack/sharedfilesystems/v2/shareaccessrules_test.go +++ b/internal/acceptance/openstack/sharedfilesystems/v2/shareaccessrules_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/sharedfilesystems/v2/sharenetworks.go b/internal/acceptance/openstack/sharedfilesystems/v2/sharenetworks.go similarity index 92% rename from acceptance/openstack/sharedfilesystems/v2/sharenetworks.go rename to internal/acceptance/openstack/sharedfilesystems/v2/sharenetworks.go index 55aad83eee..3a269df8b5 100644 --- a/acceptance/openstack/sharedfilesystems/v2/sharenetworks.go +++ b/internal/acceptance/openstack/sharedfilesystems/v2/sharenetworks.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/sharedfilesystems/v2/sharenetworks" ) diff --git a/acceptance/openstack/sharedfilesystems/v2/sharenetworks_test.go b/internal/acceptance/openstack/sharedfilesystems/v2/sharenetworks_test.go similarity index 98% rename from acceptance/openstack/sharedfilesystems/v2/sharenetworks_test.go rename to internal/acceptance/openstack/sharedfilesystems/v2/sharenetworks_test.go index bcd3f78a89..2b75e52300 100644 --- a/acceptance/openstack/sharedfilesystems/v2/sharenetworks_test.go +++ b/internal/acceptance/openstack/sharedfilesystems/v2/sharenetworks_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/sharedfilesystems/v2/sharenetworks" "github.com/gophercloud/gophercloud/pagination" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/sharedfilesystems/v2/shares.go b/internal/acceptance/openstack/sharedfilesystems/v2/shares.go similarity index 98% rename from acceptance/openstack/sharedfilesystems/v2/shares.go rename to internal/acceptance/openstack/sharedfilesystems/v2/shares.go index 9179a30cf1..cce4f7feb1 100644 --- a/acceptance/openstack/sharedfilesystems/v2/shares.go +++ b/internal/acceptance/openstack/sharedfilesystems/v2/shares.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud" "github.com/gophercloud/gophercloud/openstack/sharedfilesystems/v2/messages" diff --git a/acceptance/openstack/sharedfilesystems/v2/shares_test.go b/internal/acceptance/openstack/sharedfilesystems/v2/shares_test.go similarity index 99% rename from acceptance/openstack/sharedfilesystems/v2/shares_test.go rename to internal/acceptance/openstack/sharedfilesystems/v2/shares_test.go index b1c14d02b0..e05e1b090c 100644 --- a/acceptance/openstack/sharedfilesystems/v2/shares_test.go +++ b/internal/acceptance/openstack/sharedfilesystems/v2/shares_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/sharedfilesystems/v2/shares" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/sharedfilesystems/v2/sharetransfers.go b/internal/acceptance/openstack/sharedfilesystems/v2/sharetransfers.go similarity index 100% rename from acceptance/openstack/sharedfilesystems/v2/sharetransfers.go rename to internal/acceptance/openstack/sharedfilesystems/v2/sharetransfers.go diff --git a/acceptance/openstack/sharedfilesystems/v2/sharetransfers_test.go b/internal/acceptance/openstack/sharedfilesystems/v2/sharetransfers_test.go similarity index 93% rename from acceptance/openstack/sharedfilesystems/v2/sharetransfers_test.go rename to internal/acceptance/openstack/sharedfilesystems/v2/sharetransfers_test.go index 8e3b70df48..09a188682c 100644 --- a/acceptance/openstack/sharedfilesystems/v2/sharetransfers_test.go +++ b/internal/acceptance/openstack/sharedfilesystems/v2/sharetransfers_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" th "github.com/gophercloud/gophercloud/testhelper" "github.com/gophercloud/gophercloud/openstack/sharedfilesystems/v2/sharetransfers" diff --git a/acceptance/openstack/sharedfilesystems/v2/sharetypes.go b/internal/acceptance/openstack/sharedfilesystems/v2/sharetypes.go similarity index 95% rename from acceptance/openstack/sharedfilesystems/v2/sharetypes.go rename to internal/acceptance/openstack/sharedfilesystems/v2/sharetypes.go index 4debc1fd33..791f34a08b 100644 --- a/acceptance/openstack/sharedfilesystems/v2/sharetypes.go +++ b/internal/acceptance/openstack/sharedfilesystems/v2/sharetypes.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/sharedfilesystems/v2/sharetypes" ) diff --git a/acceptance/openstack/sharedfilesystems/v2/sharetypes_test.go b/internal/acceptance/openstack/sharedfilesystems/v2/sharetypes_test.go similarity index 97% rename from acceptance/openstack/sharedfilesystems/v2/sharetypes_test.go rename to internal/acceptance/openstack/sharedfilesystems/v2/sharetypes_test.go index 0fa951d701..bfaa8c2eda 100644 --- a/acceptance/openstack/sharedfilesystems/v2/sharetypes_test.go +++ b/internal/acceptance/openstack/sharedfilesystems/v2/sharetypes_test.go @@ -6,8 +6,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/sharedfilesystems/v2/sharetypes" ) diff --git a/acceptance/openstack/sharedfilesystems/v2/snapshots.go b/internal/acceptance/openstack/sharedfilesystems/v2/snapshots.go similarity index 95% rename from acceptance/openstack/sharedfilesystems/v2/snapshots.go rename to internal/acceptance/openstack/sharedfilesystems/v2/snapshots.go index 62e607d229..641b6440df 100644 --- a/acceptance/openstack/sharedfilesystems/v2/snapshots.go +++ b/internal/acceptance/openstack/sharedfilesystems/v2/snapshots.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/sharedfilesystems/v2/snapshots" ) @@ -54,6 +54,9 @@ func ListSnapshots(t *testing.T, client *gophercloud.ServiceClient) ([]snapshots func DeleteSnapshot(t *testing.T, client *gophercloud.ServiceClient, snapshot *snapshots.Snapshot) { err := snapshots.Delete(client, snapshot.ID).ExtractErr() if err != nil { + if _, ok := err.(gophercloud.ErrDefault404); ok { + return + } t.Errorf("Unable to delete snapshot %s: %v", snapshot.ID, err) } diff --git a/acceptance/openstack/sharedfilesystems/v2/snapshots_test.go b/internal/acceptance/openstack/sharedfilesystems/v2/snapshots_test.go similarity index 56% rename from acceptance/openstack/sharedfilesystems/v2/snapshots_test.go rename to internal/acceptance/openstack/sharedfilesystems/v2/snapshots_test.go index a30bad98bb..cb5a7f9b33 100644 --- a/acceptance/openstack/sharedfilesystems/v2/snapshots_test.go +++ b/internal/acceptance/openstack/sharedfilesystems/v2/snapshots_test.go @@ -6,12 +6,16 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/sharedfilesystems/v2/snapshots" th "github.com/gophercloud/gophercloud/testhelper" ) +// 2.7 is required for a /v2/snapshots/XXX/action URL support +// otherwise we need to set "X-OpenStack-Manila-API-Experimental: true" +const snapshotsPathMicroversion = "2.7" + func TestSnapshotCreate(t *testing.T) { client, err := clients.NewSharedFileSystemV2Client() if err != nil { @@ -119,3 +123,74 @@ func TestSnapshotListDetail(t *testing.T) { tools.PrintResource(t, &ss[i]) } } + +func TestSnapshotResetStatus(t *testing.T) { + client, err := clients.NewSharedFileSystemV2Client() + if err != nil { + t.Fatalf("Unable to create a shared file system client: %v", err) + } + client.Microversion = snapshotsPathMicroversion + + share, err := CreateShare(t, client) + if err != nil { + t.Fatalf("Unable to create a share: %v", err) + } + + defer DeleteShare(t, client, share) + + snapshot, err := CreateSnapshot(t, client, share.ID) + if err != nil { + t.Fatalf("Unable to create a snapshot: %v", err) + } + + defer DeleteSnapshot(t, client, snapshot) + + resetStatusOpts := &snapshots.ResetStatusOpts{ + Status: "error", + } + err = snapshots.ResetStatus(client, snapshot.ID, resetStatusOpts).ExtractErr() + if err != nil { + t.Fatalf("Unable to reset a snapshot status: %v", err) + } + + err = waitForSnapshotStatus(t, client, snapshot.ID, "error") + if err != nil { + t.Fatalf("Snapshot status error: %v", err) + } + + t.Logf("Snapshot %s status successfuly reset", snapshot.ID) +} + +func TestSnapshotForceDelete(t *testing.T) { + client, err := clients.NewSharedFileSystemV2Client() + if err != nil { + t.Fatalf("Unable to create a shared file system client: %v", err) + } + client.Microversion = snapshotsPathMicroversion + + share, err := CreateShare(t, client) + if err != nil { + t.Fatalf("Unable to create a share: %v", err) + } + + defer DeleteShare(t, client, share) + + snapshot, err := CreateSnapshot(t, client, share.ID) + if err != nil { + t.Fatalf("Unable to create a snapshot: %v", err) + } + + defer DeleteSnapshot(t, client, snapshot) + + err = snapshots.ForceDelete(client, snapshot.ID).ExtractErr() + if err != nil { + t.Fatalf("Unable to force delete a snapshot: %v", err) + } + + err = waitForSnapshotStatus(t, client, snapshot.ID, "deleted") + if err != nil { + t.Fatalf("Snapshot status error: %v", err) + } + + t.Logf("Snapshot %s was successfuly deleted", snapshot.ID) +} diff --git a/acceptance/openstack/workflow/v2/crontrigger.go b/internal/acceptance/openstack/workflow/v2/crontrigger.go similarity index 97% rename from acceptance/openstack/workflow/v2/crontrigger.go rename to internal/acceptance/openstack/workflow/v2/crontrigger.go index 20a7fd653e..cdd5045133 100644 --- a/acceptance/openstack/workflow/v2/crontrigger.go +++ b/internal/acceptance/openstack/workflow/v2/crontrigger.go @@ -5,7 +5,7 @@ import ( "time" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/workflow/v2/crontriggers" "github.com/gophercloud/gophercloud/openstack/workflow/v2/workflows" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/workflow/v2/crontriggers_test.go b/internal/acceptance/openstack/workflow/v2/crontriggers_test.go similarity index 91% rename from acceptance/openstack/workflow/v2/crontriggers_test.go rename to internal/acceptance/openstack/workflow/v2/crontriggers_test.go index 48642cd5f2..97c0703771 100644 --- a/acceptance/openstack/workflow/v2/crontriggers_test.go +++ b/internal/acceptance/openstack/workflow/v2/crontriggers_test.go @@ -4,8 +4,8 @@ import ( "testing" "time" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/workflow/v2/crontriggers" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/workflow/v2/execution.go b/internal/acceptance/openstack/workflow/v2/execution.go similarity index 97% rename from acceptance/openstack/workflow/v2/execution.go rename to internal/acceptance/openstack/workflow/v2/execution.go index 6eb6d048da..359275e1da 100644 --- a/acceptance/openstack/workflow/v2/execution.go +++ b/internal/acceptance/openstack/workflow/v2/execution.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/workflow/v2/executions" "github.com/gophercloud/gophercloud/openstack/workflow/v2/workflows" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/acceptance/openstack/workflow/v2/executions_test.go b/internal/acceptance/openstack/workflow/v2/executions_test.go similarity index 90% rename from acceptance/openstack/workflow/v2/executions_test.go rename to internal/acceptance/openstack/workflow/v2/executions_test.go index 86c0dd858b..098f3dadb2 100644 --- a/acceptance/openstack/workflow/v2/executions_test.go +++ b/internal/acceptance/openstack/workflow/v2/executions_test.go @@ -3,8 +3,8 @@ package v2 import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/workflow/v2/executions" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/workflow/v2/workflow.go b/internal/acceptance/openstack/workflow/v2/workflow.go similarity index 97% rename from acceptance/openstack/workflow/v2/workflow.go rename to internal/acceptance/openstack/workflow/v2/workflow.go index de95d0ca60..b81b69902e 100644 --- a/acceptance/openstack/workflow/v2/workflow.go +++ b/internal/acceptance/openstack/workflow/v2/workflow.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/workflow/v2/workflows" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/openstack/workflow/v2/workflows_test.go b/internal/acceptance/openstack/workflow/v2/workflows_test.go similarity index 89% rename from acceptance/openstack/workflow/v2/workflows_test.go rename to internal/acceptance/openstack/workflow/v2/workflows_test.go index a5fdde6413..163a52b40b 100644 --- a/acceptance/openstack/workflow/v2/workflows_test.go +++ b/internal/acceptance/openstack/workflow/v2/workflows_test.go @@ -4,8 +4,8 @@ import ( "testing" "time" - "github.com/gophercloud/gophercloud/acceptance/clients" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/clients" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/workflow/v2/workflows" th "github.com/gophercloud/gophercloud/testhelper" ) diff --git a/acceptance/tools/pkg.go b/internal/acceptance/tools/pkg.go similarity index 100% rename from acceptance/tools/pkg.go rename to internal/acceptance/tools/pkg.go diff --git a/acceptance/tools/tools.go b/internal/acceptance/tools/tools.go similarity index 100% rename from acceptance/tools/tools.go rename to internal/acceptance/tools/tools.go diff --git a/openstack/auth_env.go b/openstack/auth_env.go index 7c6d06f0c3..79b73022ff 100644 --- a/openstack/auth_env.go +++ b/openstack/auth_env.go @@ -24,8 +24,8 @@ OS_PROJECT_NAME and the latter are expected against a v3 auth api. If OS_PROJECT_ID and OS_PROJECT_NAME are set, they will still be referred as "tenant" in Gophercloud. -If OS_PROJECT_NAME is set, it requires OS_PROJECT_ID to be set as well to -handle projects not on the default domain. +If OS_PROJECT_NAME is set, it requires OS_DOMAIN_ID or OS_DOMAIN_NAME to be +set as well to handle projects not on the default domain. To use this function, first set the OS_* environment variables (for example, by sourcing an `openrc` file), then: diff --git a/openstack/baremetal/apiversions/testing/fixtures.go b/openstack/baremetal/apiversions/testing/fixtures_test.go similarity index 100% rename from openstack/baremetal/apiversions/testing/fixtures.go rename to openstack/baremetal/apiversions/testing/fixtures_test.go diff --git a/openstack/baremetal/v1/allocations/requests.go b/openstack/baremetal/v1/allocations/requests.go index dfb04ba942..1f0dd3bb86 100644 --- a/openstack/baremetal/v1/allocations/requests.go +++ b/openstack/baremetal/v1/allocations/requests.go @@ -80,7 +80,7 @@ type ListOpts struct { State AllocationState `q:"state"` // One or more fields to be returned in the response. - Fields []string `q:"fields"` + Fields []string `q:"fields" format:"comma-separated"` // Requests a page size of items. Limit int `q:"limit"` diff --git a/openstack/baremetal/v1/allocations/testing/fixtures.go b/openstack/baremetal/v1/allocations/testing/fixtures_test.go similarity index 100% rename from openstack/baremetal/v1/allocations/testing/fixtures.go rename to openstack/baremetal/v1/allocations/testing/fixtures_test.go diff --git a/openstack/baremetal/v1/conductors/doc.go b/openstack/baremetal/v1/conductors/doc.go new file mode 100644 index 0000000000..904910044c --- /dev/null +++ b/openstack/baremetal/v1/conductors/doc.go @@ -0,0 +1,46 @@ +/* +Package conductors provides information and interaction with the conductors API +resource in the OpenStack Bare Metal service. + +Example to List Conductors with Detail + + conductors.List(client, conductors.ListOpts{Detail: true}).EachPage(func(page pagination.Page) (bool, error) { + conductorList, err := conductors.ExtractConductors(page) + if err != nil { + return false, err + } + + for _, n := range conductorList { + // Do something + } + + return true, nil + }) + +Example to List Conductors + + listOpts := conductors.ListOpts{ + Fields: []string{"hostname"}, + } + + conductors.List(client, listOpts).EachPage(func(page pagination.Page) (bool, error) { + conductorList, err := conductors.ExtractConductors(page) + if err != nil { + return false, err + } + + for _, n := range conductorList { + // Do something + } + + return true, nil + }) + +Example to Get Conductor + + showConductor, err := conductors.Get(client, "compute2.localdomain").Extract() + if err != nil { + panic(err) + } +*/ +package conductors diff --git a/openstack/baremetal/v1/conductors/requests.go b/openstack/baremetal/v1/conductors/requests.go new file mode 100644 index 0000000000..1e3541065c --- /dev/null +++ b/openstack/baremetal/v1/conductors/requests.go @@ -0,0 +1,72 @@ +package conductors + +import ( + "fmt" + + "github.com/gophercloud/gophercloud" + "github.com/gophercloud/gophercloud/pagination" +) + +// ListOptsBuilder allows extensions to add additional parameters to the +// List request. +type ListOptsBuilder interface { + ToConductorListQuery() (string, error) +} + +// ListOpts allows the filtering and sorting of paginated collections through +// the API. Filtering is achieved by passing in struct field values that map to +// the conductor attributes you want to see returned. Marker and Limit are used +// for pagination. +type ListOpts struct { + // One or more fields to be returned in the response. + Fields []string `q:"fields" format:"comma-separated"` + + // Requests a page size of items. + Limit int `q:"limit"` + + // The ID of the last-seen item. + Marker string `q:"marker"` + + // Sorts the response by the requested sort direction. + SortDir string `q:"sort_dir"` + + // Sorts the response by the this attribute value. + SortKey string `q:"sort_key"` + + // Provide additional information for the BIOS Settings + Detail bool `q:"detail"` +} + +// ToConductorListQuery formats a ListOpts into a query string. +func (opts ListOpts) ToConductorListQuery() (string, error) { + if opts.Detail == true && len(opts.Fields) > 0 { + return "", fmt.Errorf("cannot have both fields and detail options for conductors") + } + + q, err := gophercloud.BuildQueryString(opts) + return q.String(), err +} + +// List makes a request against the API to list conductors accessible to you. +func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { + url := listURL(client) + if opts != nil { + query, err := opts.ToConductorListQuery() + if err != nil { + return pagination.Pager{Err: err} + } + url += query + } + return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { + return ConductorPage{pagination.LinkedPageBase{PageResult: r}} + }) +} + +// Get requests details on a single conductor by hostname +func Get(client *gophercloud.ServiceClient, name string) (r GetResult) { + resp, err := client.Get(getURL(client, name), &r.Body, &gophercloud.RequestOpts{ + OkCodes: []int{200}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} diff --git a/openstack/baremetal/v1/conductors/results.go b/openstack/baremetal/v1/conductors/results.go new file mode 100644 index 0000000000..9dd4e963c3 --- /dev/null +++ b/openstack/baremetal/v1/conductors/results.go @@ -0,0 +1,93 @@ +package conductors + +import ( + "time" + + "github.com/gophercloud/gophercloud" + "github.com/gophercloud/gophercloud/pagination" +) + +type conductorResult struct { + gophercloud.Result +} + +// Extract interprets any conductorResult as a Conductor, if possible. +func (r conductorResult) Extract() (*Conductor, error) { + var s Conductor + err := r.ExtractInto(&s) + return &s, err +} + +func (r conductorResult) ExtractInto(v interface{}) error { + return r.Result.ExtractIntoStructPtr(v, "") +} + +func ExtractConductorInto(r pagination.Page, v interface{}) error { + return r.(ConductorPage).Result.ExtractIntoSlicePtr(v, "conductors") +} + +// Conductor represents a conductor in the OpenStack Bare Metal API. +type Conductor struct { + // Whether or not this Conductor is alive or not + Alive bool `json:"alive"` + + // Hostname of this conductor + Hostname string `json:"hostname"` + + // Array of drivers for this conductor. + Drivers []string `json:"drivers"` + + // Conductor group for a conductor. Case-insensitive string up to 255 characters, containing a-z, 0-9, _, -, and .. + ConductorGroup string `json:"conductor_group"` + + // The UTC date and time when the resource was created, ISO 8601 format. + CreatedAt time.Time `json:"created_at"` + + // The UTC date and time when the resource was updated, ISO 8601 format. May be “null”. + UpdatedAt time.Time `json:"updated_at"` +} + +// ConductorPage abstracts the raw results of making a List() request against +// the API. As OpenStack extensions may freely alter the response bodies of +// structures returned to the client, you may only safely access the data +// provided through the ExtractConductor call. +type ConductorPage struct { + pagination.LinkedPageBase +} + +// IsEmpty returns true if a page contains no conductor results. +func (r ConductorPage) IsEmpty() (bool, error) { + if r.StatusCode == 204 { + return true, nil + } + + s, err := ExtractConductors(r) + return len(s) == 0, err +} + +// NextPageURL uses the response's embedded link reference to navigate to the +// next page of results. +func (r ConductorPage) NextPageURL() (string, error) { + var s struct { + Links []gophercloud.Link `json:"conductor_links"` + } + err := r.ExtractInto(&s) + if err != nil { + return "", err + } + return gophercloud.ExtractNextURL(s.Links) +} + +// ExtractConductors interprets the results of a single page from a List() call, +// producing a slice of Conductor entities. +func ExtractConductors(r pagination.Page) ([]Conductor, error) { + var s []Conductor + err := ExtractConductorInto(r, &s) + return s, err +} + +// GetResult is the response from a Get operation. Call its Extract +// method to interpret it as a Conductor. +type GetResult struct { + conductorResult +} diff --git a/openstack/baremetal/v1/conductors/testing/doc.go b/openstack/baremetal/v1/conductors/testing/doc.go new file mode 100644 index 0000000000..9cc2466b89 --- /dev/null +++ b/openstack/baremetal/v1/conductors/testing/doc.go @@ -0,0 +1,2 @@ +// conductors unit tests +package testing diff --git a/openstack/baremetal/v1/conductors/testing/fixtures_test.go b/openstack/baremetal/v1/conductors/testing/fixtures_test.go new file mode 100644 index 0000000000..02e671aa28 --- /dev/null +++ b/openstack/baremetal/v1/conductors/testing/fixtures_test.go @@ -0,0 +1,181 @@ +package testing + +import ( + "fmt" + "net/http" + "testing" + "time" + + "github.com/gophercloud/gophercloud/openstack/baremetal/v1/conductors" + th "github.com/gophercloud/gophercloud/testhelper" + "github.com/gophercloud/gophercloud/testhelper/client" +) + +// ConductorListBody contains the canned body of a conductor.List response, without detail. +const ConductorListBody = ` + { + "conductors": [ + { + "hostname": "compute1.localdomain", + "conductor_group": "", + "links": [ + { + "href": "http://127.0.0.1:6385/v1/conductors/compute1.localdomain", + "rel": "self" + }, + { + "href": "http://127.0.0.1:6385/conductors/compute1.localdomain", + "rel": "bookmark" + } + ], + "alive": false + }, + { + "hostname": "compute2.localdomain", + "conductor_group": "", + "links": [ + { + "href": "http://127.0.0.1:6385/v1/conductors/compute2.localdomain", + "rel": "self" + }, + { + "href": "http://127.0.0.1:6385/conductors/compute2.localdomain", + "rel": "bookmark" + } + ], + "alive": true + } + ] + } +` + +// ConductorListDetailBody contains the canned body of a conductor.ListDetail response. +const ConductorListDetailBody = ` +{ + "conductors": [ + { + "links": [ + { + "href": "http://127.0.0.1:6385/v1/conductors/compute1.localdomain", + "rel": "self" + }, + { + "href": "http://127.0.0.1:6385/conductors/compute1.localdomain", + "rel": "bookmark" + } + ], + "created_at": "2018-08-07T08:39:21+00:00", + "hostname": "compute1.localdomain", + "conductor_group": "", + "updated_at": "2018-11-30T07:07:23+00:00", + "alive": false, + "drivers": [ + "ipmi" + ] + }, + { + "links": [ + { + "href": "http://127.0.0.1:6385/v1/conductors/compute2.localdomain", + "rel": "self" + }, + { + "href": "http://127.0.0.1:6385/conductors/compute2.localdomain", + "rel": "bookmark" + } + ], + "created_at": "2018-12-05T07:03:19+00:00", + "hostname": "compute2.localdomain", + "conductor_group": "", + "updated_at": "2018-12-05T07:03:21+00:00", + "alive": true, + "drivers": [ + "ipmi" + ] + } + ] +} +` + +// SingleConductorBody is the canned body of a Get request on an existing conductor. +const SingleConductorBody = ` +{ + "links": [ + { + "href": "http://127.0.0.1:6385/v1/conductors/compute2.localdomain", + "rel": "self" + }, + { + "href": "http://127.0.0.1:6385/conductors/compute2.localdomain", + "rel": "bookmark" + } + ], + "created_at": "2018-12-05T07:03:19+00:00", + "hostname": "compute2.localdomain", + "conductor_group": "", + "updated_at": "2018-12-05T07:03:21+00:00", + "alive": true, + "drivers": [ + "ipmi" + ] +} +` + +var ( + createdAtFoo, _ = time.Parse(time.RFC3339, "2018-12-05T07:03:19+00:00") + updatedAt, _ = time.Parse(time.RFC3339, "2018-12-05T07:03:21+00:00") + + ConductorFoo = conductors.Conductor{ + CreatedAt: createdAtFoo, + UpdatedAt: updatedAt, + Hostname: "compute2.localdomain", + ConductorGroup: "", + Alive: true, + Drivers: []string{ + "ipmi", + }, + } +) + +// HandleConductorListSuccessfully sets up the test server to respond to a server List request. +func HandleConductorListSuccessfully(t *testing.T) { + th.Mux.HandleFunc("/conductors", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "GET") + th.TestHeader(t, r, "X-Auth-Token", client.TokenID) + w.Header().Add("Content-Type", "application/json") + r.ParseForm() + + marker := r.Form.Get("marker") + switch marker { + case "": + fmt.Fprintf(w, ConductorListBody) + + case "9e5476bd-a4ec-4653-93d6-72c93aa682ba": + fmt.Fprintf(w, `{ "servers": [] }`) + default: + t.Fatalf("/conductors invoked with unexpected marker=[%s]", marker) + } + }) +} + +// HandleConductorListDetailSuccessfully sets up the test server to respond to a server List request. +func HandleConductorListDetailSuccessfully(t *testing.T) { + th.Mux.HandleFunc("/conductors", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "GET") + th.TestHeader(t, r, "X-Auth-Token", client.TokenID) + w.Header().Add("Content-Type", "application/json") + r.ParseForm() + + fmt.Fprintf(w, ConductorListDetailBody) + }) +} + +func HandleConductorGetSuccessfully(t *testing.T) { + th.Mux.HandleFunc("/conductors/1234asdf", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "GET") + th.TestHeader(t, r, "X-Auth-Token", client.TokenID) + th.TestHeader(t, r, "Accept", "application/json") + + fmt.Fprintf(w, SingleConductorBody) + }) +} diff --git a/openstack/baremetal/v1/conductors/testing/requests_test.go b/openstack/baremetal/v1/conductors/testing/requests_test.go new file mode 100644 index 0000000000..9d9e5aa0d4 --- /dev/null +++ b/openstack/baremetal/v1/conductors/testing/requests_test.go @@ -0,0 +1,106 @@ +package testing + +import ( + "testing" + + "github.com/gophercloud/gophercloud/openstack/baremetal/v1/conductors" + "github.com/gophercloud/gophercloud/pagination" + th "github.com/gophercloud/gophercloud/testhelper" + "github.com/gophercloud/gophercloud/testhelper/client" +) + +func TestListConductors(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + HandleConductorListSuccessfully(t) + + pages := 0 + err := conductors.List(client.ServiceClient(), conductors.ListOpts{}).EachPage(func(page pagination.Page) (bool, error) { + pages++ + + actual, err := conductors.ExtractConductors(page) + if err != nil { + return false, err + } + + if len(actual) != 2 { + t.Fatalf("Expected 2 conductors, got %d", len(actual)) + } + th.AssertEquals(t, "compute1.localdomain", actual[0].Hostname) + th.AssertEquals(t, "compute2.localdomain", actual[1].Hostname) + + return true, nil + }) + + th.AssertNoErr(t, err) + + if pages != 1 { + t.Errorf("Expected 1 page, saw %d", pages) + } +} + +func TestListDetailConductors(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + HandleConductorListDetailSuccessfully(t) + + pages := 0 + err := conductors.List(client.ServiceClient(), conductors.ListOpts{Detail: true}).EachPage(func(page pagination.Page) (bool, error) { + pages++ + + actual, err := conductors.ExtractConductors(page) + if err != nil { + return false, err + } + + if len(actual) != 2 { + t.Fatalf("Expected 2 conductors, got %d", len(actual)) + } + th.AssertEquals(t, "compute1.localdomain", actual[0].Hostname) + th.AssertEquals(t, false, actual[0].Alive) + th.AssertEquals(t, "compute2.localdomain", actual[1].Hostname) + th.AssertEquals(t, true, actual[1].Alive) + + return true, nil + }) + + th.AssertNoErr(t, err) + + if pages != 1 { + t.Errorf("Expected 1 page, saw %d", pages) + } +} + +func TestListOpts(t *testing.T) { + // Detail cannot take Fields + optsDetail := conductors.ListOpts{ + Fields: []string{"hostname", "alive"}, + Detail: true, + } + + opts := conductors.ListOpts{ + Fields: []string{"hostname", "alive"}, + } + + _, err := optsDetail.ToConductorListQuery() + th.AssertEquals(t, err.Error(), "cannot have both fields and detail options for conductors") + + // Regular ListOpts can + query, err := opts.ToConductorListQuery() + th.AssertEquals(t, "?fields=hostname%2Calive", query) + th.AssertNoErr(t, err) +} + +func TestGetConductor(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + HandleConductorGetSuccessfully(t) + + c := client.ServiceClient() + actual, err := conductors.Get(c, "1234asdf").Extract() + if err != nil { + t.Fatalf("Unexpected Get error: %v", err) + } + + th.CheckDeepEquals(t, ConductorFoo, *actual) +} diff --git a/openstack/baremetal/v1/conductors/urls.go b/openstack/baremetal/v1/conductors/urls.go new file mode 100644 index 0000000000..a52e1e5ca5 --- /dev/null +++ b/openstack/baremetal/v1/conductors/urls.go @@ -0,0 +1,11 @@ +package conductors + +import "github.com/gophercloud/gophercloud" + +func listURL(client *gophercloud.ServiceClient) string { + return client.ServiceURL("conductors") +} + +func getURL(client *gophercloud.ServiceClient, id string) string { + return client.ServiceURL("conductors", id) +} diff --git a/openstack/baremetal/v1/drivers/testing/fixtures.go b/openstack/baremetal/v1/drivers/testing/fixtures_test.go similarity index 100% rename from openstack/baremetal/v1/drivers/testing/fixtures.go rename to openstack/baremetal/v1/drivers/testing/fixtures_test.go diff --git a/openstack/baremetal/v1/nodes/requests.go b/openstack/baremetal/v1/nodes/requests.go index 2515bf1587..ffe98ee6de 100644 --- a/openstack/baremetal/v1/nodes/requests.go +++ b/openstack/baremetal/v1/nodes/requests.go @@ -97,7 +97,7 @@ type ListOpts struct { Fault string `q:"fault"` // One or more fields to be returned in the response. - Fields []string `q:"fields"` + Fields []string `q:"fields" format:"comma-separated"` // Requests a page size of items. Limit int `q:"limit"` @@ -653,7 +653,7 @@ type ListBIOSSettingsOpts struct { Detail bool `q:"detail"` // One or more fields to be returned in the response. - Fields []string `q:"fields"` + Fields []string `q:"fields" format:"comma-separated"` } // ToListBIOSSettingsOptsQuery formats a ListBIOSSettingsOpts into a query string diff --git a/openstack/baremetal/v1/nodes/testing/fixtures.go b/openstack/baremetal/v1/nodes/testing/fixtures_test.go similarity index 100% rename from openstack/baremetal/v1/nodes/testing/fixtures.go rename to openstack/baremetal/v1/nodes/testing/fixtures_test.go diff --git a/openstack/baremetal/v1/nodes/testing/requests_test.go b/openstack/baremetal/v1/nodes/testing/requests_test.go index ba9e8f3ceb..815e7b28fc 100644 --- a/openstack/baremetal/v1/nodes/testing/requests_test.go +++ b/openstack/baremetal/v1/nodes/testing/requests_test.go @@ -83,7 +83,7 @@ func TestListOpts(t *testing.T) { // Regular ListOpts can query, err := opts.ToNodeListQuery() - th.AssertEquals(t, query, "?fields=name&fields=uuid") + th.AssertEquals(t, "?fields=name%2Cuuid", query) th.AssertNoErr(t, err) } diff --git a/openstack/baremetal/v1/ports/requests.go b/openstack/baremetal/v1/ports/requests.go index ed191649d6..33c872ef47 100644 --- a/openstack/baremetal/v1/ports/requests.go +++ b/openstack/baremetal/v1/ports/requests.go @@ -32,7 +32,7 @@ type ListOpts struct { Address string `q:"address"` // One or more fields to be returned in the response. - Fields []string `q:"fields"` + Fields []string `q:"fields" format:"comma-separated"` // Requests a page size of items. Limit int `q:"limit"` diff --git a/openstack/baremetal/v1/ports/testing/fixtures.go b/openstack/baremetal/v1/ports/testing/fixtures_test.go similarity index 100% rename from openstack/baremetal/v1/ports/testing/fixtures.go rename to openstack/baremetal/v1/ports/testing/fixtures_test.go diff --git a/openstack/baremetal/v1/ports/testing/requests_test.go b/openstack/baremetal/v1/ports/testing/requests_test.go index cf9519b53d..06118bf2bf 100644 --- a/openstack/baremetal/v1/ports/testing/requests_test.go +++ b/openstack/baremetal/v1/ports/testing/requests_test.go @@ -80,7 +80,7 @@ func TestListOpts(t *testing.T) { // Regular ListOpts can query, err := opts.ToPortListQuery() - th.AssertEquals(t, query, "?fields=uuid&fields=address") + th.AssertEquals(t, "?fields=uuid%2Caddress", query) th.AssertNoErr(t, err) } diff --git a/openstack/baremetalintrospection/v1/introspection/testing/fixtures.go b/openstack/baremetalintrospection/v1/introspection/testing/fixtures_test.go similarity index 100% rename from openstack/baremetalintrospection/v1/introspection/testing/fixtures.go rename to openstack/baremetalintrospection/v1/introspection/testing/fixtures_test.go diff --git a/openstack/blockstorage/apiversions/testing/fixtures.go b/openstack/blockstorage/apiversions/testing/fixtures_test.go similarity index 100% rename from openstack/blockstorage/apiversions/testing/fixtures.go rename to openstack/blockstorage/apiversions/testing/fixtures_test.go diff --git a/openstack/blockstorage/extensions/availabilityzones/testing/fixtures.go b/openstack/blockstorage/extensions/availabilityzones/testing/fixtures_test.go similarity index 100% rename from openstack/blockstorage/extensions/availabilityzones/testing/fixtures.go rename to openstack/blockstorage/extensions/availabilityzones/testing/fixtures_test.go diff --git a/openstack/blockstorage/extensions/backups/testing/fixtures.go b/openstack/blockstorage/extensions/backups/testing/fixtures_test.go similarity index 100% rename from openstack/blockstorage/extensions/backups/testing/fixtures.go rename to openstack/blockstorage/extensions/backups/testing/fixtures_test.go diff --git a/openstack/blockstorage/extensions/limits/testing/fixtures.go b/openstack/blockstorage/extensions/limits/testing/fixtures_test.go similarity index 100% rename from openstack/blockstorage/extensions/limits/testing/fixtures.go rename to openstack/blockstorage/extensions/limits/testing/fixtures_test.go diff --git a/openstack/blockstorage/extensions/quotasets/testing/fixtures.go b/openstack/blockstorage/extensions/quotasets/testing/fixtures_test.go similarity index 100% rename from openstack/blockstorage/extensions/quotasets/testing/fixtures.go rename to openstack/blockstorage/extensions/quotasets/testing/fixtures_test.go diff --git a/openstack/blockstorage/extensions/schedulerstats/testing/fixtures.go b/openstack/blockstorage/extensions/schedulerstats/testing/fixtures_test.go similarity index 100% rename from openstack/blockstorage/extensions/schedulerstats/testing/fixtures.go rename to openstack/blockstorage/extensions/schedulerstats/testing/fixtures_test.go diff --git a/openstack/blockstorage/extensions/services/testing/fixtures.go b/openstack/blockstorage/extensions/services/testing/fixtures_test.go similarity index 100% rename from openstack/blockstorage/extensions/services/testing/fixtures.go rename to openstack/blockstorage/extensions/services/testing/fixtures_test.go diff --git a/openstack/blockstorage/extensions/volumeactions/requests.go b/openstack/blockstorage/extensions/volumeactions/requests.go index 09dfb9ed2f..03fb724a9f 100644 --- a/openstack/blockstorage/extensions/volumeactions/requests.go +++ b/openstack/blockstorage/extensions/volumeactions/requests.go @@ -418,3 +418,43 @@ func ReImage(client *gophercloud.ServiceClient, id string, opts ReImageOpts) (r _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } + +// ResetStatusOptsBuilder allows extensions to add additional parameters to the +// ResetStatus request. +type ResetStatusOptsBuilder interface { + ToResetStatusMap() (map[string]interface{}, error) +} + +// ResetStatusOpts contains options for resetting a Volume status. +// For more information about these parameters, please, refer to the Block Storage API V3, +// Volume Actions, ResetStatus volume documentation. +type ResetStatusOpts struct { + // Status is a volume status to reset to. + Status string `json:"status"` + // MigrationStatus is a volume migration status to reset to. + MigrationStatus string `json:"migration_status,omitempty"` + // AttachStatus is a volume attach status to reset to. + AttachStatus string `json:"attach_status,omitempty"` +} + +// ToResetStatusMap assembles a request body based on the contents of a +// ResetStatusOpts. +func (opts ResetStatusOpts) ToResetStatusMap() (map[string]interface{}, error) { + return gophercloud.BuildRequestBody(opts, "os-reset_status") +} + +// ResetStatus will reset the existing volume status. ResetStatusResult contains only the error. +// To extract it, call the ExtractErr method on the ResetStatusResult. +func ResetStatus(client *gophercloud.ServiceClient, id string, opts ResetStatusOptsBuilder) (r ResetStatusResult) { + b, err := opts.ToResetStatusMap() + if err != nil { + r.Err = err + return + } + + resp, err := client.Post(actionURL(client, id), b, nil, &gophercloud.RequestOpts{ + OkCodes: []int{202}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} diff --git a/openstack/blockstorage/extensions/volumeactions/results.go b/openstack/blockstorage/extensions/volumeactions/results.go index 95b5bac1cb..34f64e18e8 100644 --- a/openstack/blockstorage/extensions/volumeactions/results.go +++ b/openstack/blockstorage/extensions/volumeactions/results.go @@ -219,3 +219,8 @@ type ChangeTypeResult struct { type ReImageResult struct { gophercloud.ErrResult } + +// ResetStatusResult contains the response error from a ResetStatus request. +type ResetStatusResult struct { + gophercloud.ErrResult +} diff --git a/openstack/blockstorage/extensions/volumeactions/testing/fixtures.go b/openstack/blockstorage/extensions/volumeactions/testing/fixtures_test.go similarity index 95% rename from openstack/blockstorage/extensions/volumeactions/testing/fixtures.go rename to openstack/blockstorage/extensions/volumeactions/testing/fixtures_test.go index 378a120bc6..eef61d477a 100644 --- a/openstack/blockstorage/extensions/volumeactions/testing/fixtures.go +++ b/openstack/blockstorage/extensions/volumeactions/testing/fixtures_test.go @@ -370,3 +370,24 @@ func MockChangeTypeResponse(t *testing.T) { fmt.Fprintf(w, `{}`) }) } + +func MockResetStatusResponse(t *testing.T) { + th.Mux.HandleFunc("/volumes/cd281d77-8217-4830-be95-9528227c105c/action", + func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "POST") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + th.TestHeader(t, r, "Content-Type", "application/json") + th.TestJSONRequest(t, r, ` +{ + "os-reset_status": + { + "status": "error", + "attach_status": "detached", + "migration_status": "migrating" + } +} + `) + + w.WriteHeader(http.StatusAccepted) + }) +} diff --git a/openstack/blockstorage/extensions/volumeactions/testing/requests_test.go b/openstack/blockstorage/extensions/volumeactions/testing/requests_test.go index 2191a8a788..bb5d02e926 100644 --- a/openstack/blockstorage/extensions/volumeactions/testing/requests_test.go +++ b/openstack/blockstorage/extensions/volumeactions/testing/requests_test.go @@ -224,3 +224,19 @@ func TestChangeType(t *testing.T) { err := volumeactions.ChangeType(client.ServiceClient(), "cd281d77-8217-4830-be95-9528227c105c", options).ExtractErr() th.AssertNoErr(t, err) } + +func TestResetStatus(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + MockResetStatusResponse(t) + + options := &volumeactions.ResetStatusOpts{ + Status: "error", + AttachStatus: "detached", + MigrationStatus: "migrating", + } + + err := volumeactions.ResetStatus(client.ServiceClient(), "cd281d77-8217-4830-be95-9528227c105c", options).ExtractErr() + th.AssertNoErr(t, err) +} diff --git a/openstack/blockstorage/extensions/volumetransfers/testing/fixtures.go b/openstack/blockstorage/extensions/volumetransfers/testing/fixtures_test.go similarity index 100% rename from openstack/blockstorage/extensions/volumetransfers/testing/fixtures.go rename to openstack/blockstorage/extensions/volumetransfers/testing/fixtures_test.go diff --git a/openstack/blockstorage/noauth/testing/fixtures.go b/openstack/blockstorage/noauth/testing/fixtures_test.go similarity index 100% rename from openstack/blockstorage/noauth/testing/fixtures.go rename to openstack/blockstorage/noauth/testing/fixtures_test.go diff --git a/openstack/blockstorage/v1/apiversions/testing/fixtures.go b/openstack/blockstorage/v1/apiversions/testing/fixtures_test.go similarity index 100% rename from openstack/blockstorage/v1/apiversions/testing/fixtures.go rename to openstack/blockstorage/v1/apiversions/testing/fixtures_test.go diff --git a/openstack/blockstorage/v1/snapshots/testing/fixtures.go b/openstack/blockstorage/v1/snapshots/testing/fixtures_test.go similarity index 100% rename from openstack/blockstorage/v1/snapshots/testing/fixtures.go rename to openstack/blockstorage/v1/snapshots/testing/fixtures_test.go diff --git a/openstack/blockstorage/v1/volumes/testing/fixtures.go b/openstack/blockstorage/v1/volumes/testing/fixtures_test.go similarity index 100% rename from openstack/blockstorage/v1/volumes/testing/fixtures.go rename to openstack/blockstorage/v1/volumes/testing/fixtures_test.go diff --git a/openstack/blockstorage/v1/volumetypes/testing/fixtures.go b/openstack/blockstorage/v1/volumetypes/testing/fixtures_test.go similarity index 100% rename from openstack/blockstorage/v1/volumetypes/testing/fixtures.go rename to openstack/blockstorage/v1/volumetypes/testing/fixtures_test.go diff --git a/openstack/blockstorage/v2/snapshots/testing/fixtures.go b/openstack/blockstorage/v2/snapshots/testing/fixtures_test.go similarity index 100% rename from openstack/blockstorage/v2/snapshots/testing/fixtures.go rename to openstack/blockstorage/v2/snapshots/testing/fixtures_test.go diff --git a/openstack/blockstorage/v2/volumes/testing/fixtures.go b/openstack/blockstorage/v2/volumes/testing/fixtures_test.go similarity index 100% rename from openstack/blockstorage/v2/volumes/testing/fixtures.go rename to openstack/blockstorage/v2/volumes/testing/fixtures_test.go diff --git a/openstack/blockstorage/v3/attachments/testing/fixtures.go b/openstack/blockstorage/v3/attachments/testing/fixtures_test.go similarity index 100% rename from openstack/blockstorage/v3/attachments/testing/fixtures.go rename to openstack/blockstorage/v3/attachments/testing/fixtures_test.go diff --git a/openstack/blockstorage/v3/qos/testing/fixtures.go b/openstack/blockstorage/v3/qos/testing/fixtures_test.go similarity index 100% rename from openstack/blockstorage/v3/qos/testing/fixtures.go rename to openstack/blockstorage/v3/qos/testing/fixtures_test.go diff --git a/openstack/blockstorage/v3/snapshots/requests.go b/openstack/blockstorage/v3/snapshots/requests.go index 7dcfed7946..9bbec339ec 100644 --- a/openstack/blockstorage/v3/snapshots/requests.go +++ b/openstack/blockstorage/v3/snapshots/requests.go @@ -189,3 +189,90 @@ func UpdateMetadata(client *gophercloud.ServiceClient, id string, opts UpdateMet _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } + +// ResetStatusOptsBuilder allows extensions to add additional parameters to the +// ResetStatus request. +type ResetStatusOptsBuilder interface { + ToSnapshotResetStatusMap() (map[string]interface{}, error) +} + +// ResetStatusOpts contains options for resetting a Snapshot status. +// For more information about these parameters, please, refer to the Block Storage API V3, +// Snapshot Actions, ResetStatus snapshot documentation. +type ResetStatusOpts struct { + // Status is a snapshot status to reset to. + Status string `json:"status"` +} + +// ToSnapshotResetStatusMap assembles a request body based on the contents of a +// ResetStatusOpts. +func (opts ResetStatusOpts) ToSnapshotResetStatusMap() (map[string]interface{}, error) { + return gophercloud.BuildRequestBody(opts, "os-reset_status") +} + +// ResetStatus will reset the existing snapshot status. ResetStatusResult contains only the error. +// To extract it, call the ExtractErr method on the ResetStatusResult. +func ResetStatus(client *gophercloud.ServiceClient, id string, opts ResetStatusOptsBuilder) (r ResetStatusResult) { + b, err := opts.ToSnapshotResetStatusMap() + if err != nil { + r.Err = err + return + } + + resp, err := client.Post(resetStatusURL(client, id), b, nil, &gophercloud.RequestOpts{ + OkCodes: []int{202}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// UpdateStatusOptsBuilder allows extensions to add additional parameters to the +// UpdateStatus request. +type UpdateStatusOptsBuilder interface { + ToSnapshotUpdateStatusMap() (map[string]interface{}, error) +} + +// UpdateStatusOpts contains options for resetting a Snapshot status. +// For more information about these parameters, please, refer to the Block Storage API V3, +// Snapshot Actions, UpdateStatus snapshot documentation. +type UpdateStatusOpts struct { + // Status is a snapshot status to update to. + Status string `json:"status"` + // A progress percentage value for snapshot build progress. + Progress string `json:"progress,omitempty"` +} + +// ToSnapshotUpdateStatusMap assembles a request body based on the contents of a +// UpdateStatusOpts. +func (opts UpdateStatusOpts) ToSnapshotUpdateStatusMap() (map[string]interface{}, error) { + return gophercloud.BuildRequestBody(opts, "os-update_snapshot_status") +} + +// UpdateStatus will reset the existing snapshot status. UpdateStatusResult contains only the error. +// To extract it, call the ExtractErr method on the UpdateStatusResult. +func UpdateStatus(client *gophercloud.ServiceClient, id string, opts UpdateStatusOptsBuilder) (r UpdateStatusResult) { + b, err := opts.ToSnapshotUpdateStatusMap() + if err != nil { + r.Err = err + return + } + + resp, err := client.Post(resetStatusURL(client, id), b, nil, &gophercloud.RequestOpts{ + OkCodes: []int{202}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// ForceDelete will delete the existing snapshot in any state. ForceDeleteResult contains only the error. +// To extract it, call the ExtractErr method on the ForceDeleteResult. +func ForceDelete(client *gophercloud.ServiceClient, id string) (r ForceDeleteResult) { + b := map[string]interface{}{ + "os-force_delete": struct{}{}, + } + resp, err := client.Post(forceDeleteURL(client, id), b, nil, &gophercloud.RequestOpts{ + OkCodes: []int{202}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} diff --git a/openstack/blockstorage/v3/snapshots/results.go b/openstack/blockstorage/v3/snapshots/results.go index d058b22172..23c7a506d8 100644 --- a/openstack/blockstorage/v3/snapshots/results.go +++ b/openstack/blockstorage/v3/snapshots/results.go @@ -141,3 +141,18 @@ func (r commonResult) Extract() (*Snapshot, error) { err := r.ExtractInto(&s) return s.Snapshot, err } + +// ResetStatusResult contains the response error from a ResetStatus request. +type ResetStatusResult struct { + gophercloud.ErrResult +} + +// UpdateStatusResult contains the response error from an UpdateStatus request. +type UpdateStatusResult struct { + gophercloud.ErrResult +} + +// ForceDeleteResult contains the response error from a ForceDelete request. +type ForceDeleteResult struct { + gophercloud.ErrResult +} diff --git a/openstack/blockstorage/v3/snapshots/testing/fixtures.go b/openstack/blockstorage/v3/snapshots/testing/fixtures_test.go similarity index 69% rename from openstack/blockstorage/v3/snapshots/testing/fixtures.go rename to openstack/blockstorage/v3/snapshots/testing/fixtures_test.go index 3ae3bb86d2..be48c50048 100644 --- a/openstack/blockstorage/v3/snapshots/testing/fixtures.go +++ b/openstack/blockstorage/v3/snapshots/testing/fixtures_test.go @@ -9,7 +9,7 @@ import ( fake "github.com/gophercloud/gophercloud/testhelper/client" ) -// MockListResponse provides mock responce for list snapshot API call +// MockListResponse provides mock response for list snapshot API call func MockListResponse(t *testing.T) { th.Mux.HandleFunc("/snapshots", func(w http.ResponseWriter, r *http.Request) { th.TestMethod(t, r, "GET") @@ -59,7 +59,7 @@ func MockListResponse(t *testing.T) { }) } -// MockGetResponse provides mock responce for get snapshot API call +// MockGetResponse provides mock response for get snapshot API call func MockGetResponse(t *testing.T) { th.Mux.HandleFunc("/snapshots/d32019d3-bc6e-4319-9c1d-6722fc136a22", func(w http.ResponseWriter, r *http.Request) { th.TestMethod(t, r, "GET") @@ -83,7 +83,7 @@ func MockGetResponse(t *testing.T) { }) } -// MockCreateResponse provides mock responce for create snapshot API call +// MockCreateResponse provides mock response for create snapshot API call func MockCreateResponse(t *testing.T) { th.Mux.HandleFunc("/snapshots", func(w http.ResponseWriter, r *http.Request) { th.TestMethod(t, r, "POST") @@ -119,7 +119,7 @@ func MockCreateResponse(t *testing.T) { }) } -// MockUpdateMetadataResponse provides mock responce for update metadata snapshot API call +// MockUpdateMetadataResponse provides mock response for update metadata snapshot API call func MockUpdateMetadataResponse(t *testing.T) { th.Mux.HandleFunc("/snapshots/123/metadata", func(w http.ResponseWriter, r *http.Request) { th.TestMethod(t, r, "PUT") @@ -143,7 +143,7 @@ func MockUpdateMetadataResponse(t *testing.T) { }) } -// MockDeleteResponse provides mock responce for delete snapshot API call +// MockDeleteResponse provides mock response for delete snapshot API call func MockDeleteResponse(t *testing.T) { th.Mux.HandleFunc("/snapshots/d32019d3-bc6e-4319-9c1d-6722fc136a22", func(w http.ResponseWriter, r *http.Request) { th.TestMethod(t, r, "DELETE") @@ -152,7 +152,7 @@ func MockDeleteResponse(t *testing.T) { }) } -// MockUpdateResponse provides mock responce for update snapshot API call +// MockUpdateResponse provides mock response for update snapshot API call func MockUpdateResponse(t *testing.T) { th.Mux.HandleFunc("/snapshots/d32019d3-bc6e-4319-9c1d-6722fc136a22", func(w http.ResponseWriter, r *http.Request) { th.TestMethod(t, r, "PUT") @@ -176,3 +176,53 @@ func MockUpdateResponse(t *testing.T) { `) }) } + +// MockResetStatusResponse provides mock response for reset snapshot status API call +func MockResetStatusResponse(t *testing.T) { + th.Mux.HandleFunc("/snapshots/d32019d3-bc6e-4319-9c1d-6722fc136a22/action", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "POST") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + th.TestHeader(t, r, "Content-Type", "application/json") + th.TestJSONRequest(t, r, ` +{ + "os-reset_status": { + "status": "error" + } +} + `) + w.WriteHeader(http.StatusAccepted) + }) +} + +// MockUpdateStatusResponse provides mock response for update snapshot status API call +func MockUpdateStatusResponse(t *testing.T) { + th.Mux.HandleFunc("/snapshots/d32019d3-bc6e-4319-9c1d-6722fc136a22/action", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "POST") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + th.TestHeader(t, r, "Content-Type", "application/json") + th.TestJSONRequest(t, r, ` +{ + "os-update_snapshot_status": { + "status": "error", + "progress": "80%" + } +} + `) + w.WriteHeader(http.StatusAccepted) + }) +} + +// MockForceDeleteResponse provides mock response for force delete snapshot API call +func MockForceDeleteResponse(t *testing.T) { + th.Mux.HandleFunc("/snapshots/d32019d3-bc6e-4319-9c1d-6722fc136a22/action", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "POST") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + th.TestHeader(t, r, "Content-Type", "application/json") + th.TestJSONRequest(t, r, ` +{ + "os-force_delete": {} +} + `) + w.WriteHeader(http.StatusAccepted) + }) +} diff --git a/openstack/blockstorage/v3/snapshots/testing/requests_test.go b/openstack/blockstorage/v3/snapshots/testing/requests_test.go index a787928ba9..862b25e010 100644 --- a/openstack/blockstorage/v3/snapshots/testing/requests_test.go +++ b/openstack/blockstorage/v3/snapshots/testing/requests_test.go @@ -129,3 +129,40 @@ func TestUpdate(t *testing.T) { th.CheckEquals(t, "snapshot-002", v.Name) th.CheckEquals(t, "Daily backup 002", v.Description) } + +func TestResetStatus(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + MockResetStatusResponse(t) + + opts := &snapshots.ResetStatusOpts{ + Status: "error", + } + res := snapshots.ResetStatus(client.ServiceClient(), "d32019d3-bc6e-4319-9c1d-6722fc136a22", opts) + th.AssertNoErr(t, res.Err) +} + +func TestUpdateStatus(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + MockUpdateStatusResponse(t) + + opts := &snapshots.UpdateStatusOpts{ + Status: "error", + Progress: "80%", + } + res := snapshots.UpdateStatus(client.ServiceClient(), "d32019d3-bc6e-4319-9c1d-6722fc136a22", opts) + th.AssertNoErr(t, res.Err) +} + +func TestForceDelete(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + MockForceDeleteResponse(t) + + res := snapshots.ForceDelete(client.ServiceClient(), "d32019d3-bc6e-4319-9c1d-6722fc136a22") + th.AssertNoErr(t, res.Err) +} diff --git a/openstack/blockstorage/v3/snapshots/urls.go b/openstack/blockstorage/v3/snapshots/urls.go index d0bcbfb98c..605b3cf5ec 100644 --- a/openstack/blockstorage/v3/snapshots/urls.go +++ b/openstack/blockstorage/v3/snapshots/urls.go @@ -29,3 +29,15 @@ func metadataURL(c *gophercloud.ServiceClient, id string) string { func updateMetadataURL(c *gophercloud.ServiceClient, id string) string { return metadataURL(c, id) } + +func resetStatusURL(c *gophercloud.ServiceClient, id string) string { + return c.ServiceURL("snapshots", id, "action") +} + +func updateStatusURL(c *gophercloud.ServiceClient, id string) string { + return c.ServiceURL("snapshots", id, "action") +} + +func forceDeleteURL(c *gophercloud.ServiceClient, id string) string { + return c.ServiceURL("snapshots", id, "action") +} diff --git a/openstack/blockstorage/v3/volumes/testing/fixtures.go b/openstack/blockstorage/v3/volumes/testing/fixtures_test.go similarity index 100% rename from openstack/blockstorage/v3/volumes/testing/fixtures.go rename to openstack/blockstorage/v3/volumes/testing/fixtures_test.go diff --git a/openstack/blockstorage/v3/volumetypes/doc.go b/openstack/blockstorage/v3/volumetypes/doc.go index 55a2170bc2..03cad7ecbd 100644 --- a/openstack/blockstorage/v3/volumetypes/doc.go +++ b/openstack/blockstorage/v3/volumetypes/doc.go @@ -160,5 +160,61 @@ Example to Remove/Revoke Access to a Volume Type if err != nil { panic(err) } + +Example to Create the Encryption of a Volume Type + + typeID := "7ffaca22-f646-41d4-b79d-d7e4452ef8cc" + volumeType, err := volumetypes.CreateEncryption(client, typeID, .CreateEncryptionOpts{ + KeySize: 256, + Provider: "luks", + ControlLocation: "front-end", + Cipher: "aes-xts-plain64", + }).Extract() + if err != nil{ + panic(err) + } + fmt.Println(volumeType) + +Example to Delete the Encryption of a Volume Type + + typeID := "7ffaca22-f646-41d4-b79d-d7e4452ef8cc" + encryptionID := ""81e069c6-7394-4856-8df7-3b237ca61f74 + err := volumetypes.DeleteEncryption(client, typeID, encryptionID).ExtractErr() + if err != nil{ + panic(err) + } + +Example to Update the Encryption of a Volume Type + + typeID := "7ffaca22-f646-41d4-b79d-d7e4452ef8cc" + volumetype, err = volumetypes.UpdateEncryption(client, typeID, volumetypes.UpdateEncryptionOpts{ + KeySize: 256, + Provider: "luks", + ControlLocation: "front-end", + Cipher: "aes-xts-plain64", + }).Extract() + if err != nil{ + panic(err) + } + fmt.Println(volumetype) + +Example to Show an Encryption of a Volume Type + + typeID := "7ffaca22-f646-41d4-b79d-d7e4452ef8cc" + volumeType, err := volumetypes.GetEncrytpion(client, typeID).Extract() + if err != nil{ + panic(err) + } + fmt.Println(volumeType) + +Example to Show an Encryption Spec of a Volume Type + + typeID := "7ffaca22-f646-41d4-b79d-d7e4452ef8cc" + key := "cipher" + volumeType, err := volumetypes.GetEncrytpionSpec(client, typeID).Extract() + if err != nil{ + panic(err) + } + fmt.Println(volumeType) */ package volumetypes diff --git a/openstack/blockstorage/v3/volumetypes/requests.go b/openstack/blockstorage/v3/volumetypes/requests.go index 5b272bf05b..e06f7a4638 100644 --- a/openstack/blockstorage/v3/volumetypes/requests.go +++ b/openstack/blockstorage/v3/volumetypes/requests.go @@ -304,3 +304,108 @@ func RemoveAccess(client *gophercloud.ServiceClient, id string, opts RemoveAcces _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } + +// CreateEncryptionOptsBuilder allows extensions to add additional parameters to the +// Create Encryption request. +type CreateEncryptionOptsBuilder interface { + ToEncryptionCreateMap() (map[string]interface{}, error) +} + +// CreateEncryptionOpts contains options for creating an Encryption Type object. +// This object is passed to the volumetypes.CreateEncryption function. +// For more information about these parameters,see the Encryption Type object. +type CreateEncryptionOpts struct { + // The size of the encryption key. + KeySize int `json:"key_size"` + // The class of that provides the encryption support. + Provider string `json:"provider" required:"true"` + // Notional service where encryption is performed. + ControlLocation string `json:"control_location"` + // The encryption algorithm or mode. + Cipher string `json:"cipher"` +} + +// ToEncryptionCreateMap assembles a request body based on the contents of a +// CreateEncryptionOpts. +func (opts CreateEncryptionOpts) ToEncryptionCreateMap() (map[string]interface{}, error) { + return gophercloud.BuildRequestBody(opts, "encryption") +} + +// CreateEncryption will creates an Encryption Type object based on the CreateEncryptionOpts. +// To extract the Encryption Type object from the response, call the Extract method on the +// EncryptionCreateResult. +func CreateEncryption(client *gophercloud.ServiceClient, id string, opts CreateEncryptionOptsBuilder) (r CreateEncryptionResult) { + b, err := opts.ToEncryptionCreateMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Post(createEncryptionURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ + OkCodes: []int{200}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// Delete will delete an encryption type for an existing Volume Type with the provided ID. +func DeleteEncryption(client *gophercloud.ServiceClient, id, encryptionID string) (r DeleteEncryptionResult) { + resp, err := client.Delete(deleteEncryptionURL(client, id, encryptionID), nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// GetEncryption retrieves the encryption type for an existing VolumeType with the provided ID. +func GetEncryption(client *gophercloud.ServiceClient, id string) (r GetEncryptionResult) { + resp, err := client.Get(getEncryptionURL(client, id), &r.Body, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// GetEncryptionSpecs retrieves the encryption type specs for an existing VolumeType with the provided ID. +func GetEncryptionSpec(client *gophercloud.ServiceClient, id, key string) (r GetEncryptionSpecResult) { + resp, err := client.Get(getEncryptionSpecURL(client, id, key), &r.Body, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// UpdateEncryptionOptsBuilder allows extensions to add additional parameters to the +// Update encryption request. +type UpdateEncryptionOptsBuilder interface { + ToUpdateEncryptionMap() (map[string]interface{}, error) +} + +// Update Encryption Opts contains options for creating an Update Encryption Type. This object is passed to +// the volumetypes.UpdateEncryption function. For more information about these parameters, +// see the Update Encryption Type object. +type UpdateEncryptionOpts struct { + // The size of the encryption key. + KeySize int `json:"key_size"` + // The class of that provides the encryption support. + Provider string `json:"provider"` + // Notional service where encryption is performed. + ControlLocation string `json:"control_location"` + // The encryption algorithm or mode. + Cipher string `json:"cipher"` +} + +// ToEncryptionCreateMap assembles a request body based on the contents of a +// UpdateEncryptionOpts. +func (opts UpdateEncryptionOpts) ToUpdateEncryptionMap() (map[string]interface{}, error) { + return gophercloud.BuildRequestBody(opts, "encryption") +} + +// Update will update an existing encryption for a Volume Type based on the values in UpdateEncryptionOpts. +// To extract the UpdateEncryption Type object from the response, call the Extract method on the +// UpdateEncryptionResult. +func UpdateEncryption(client *gophercloud.ServiceClient, id, encryptionID string, opts UpdateEncryptionOptsBuilder) (r UpdateEncryptionResult) { + b, err := opts.ToUpdateEncryptionMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Put(updateEncryptionURL(client, id, encryptionID), b, &r.Body, &gophercloud.RequestOpts{ + OkCodes: []int{200}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} diff --git a/openstack/blockstorage/v3/volumetypes/results.go b/openstack/blockstorage/v3/volumetypes/results.go index 916b476da5..4d1d1cf2df 100644 --- a/openstack/blockstorage/v3/volumetypes/results.go +++ b/openstack/blockstorage/v3/volumetypes/results.go @@ -200,3 +200,100 @@ type AddAccessResult struct { type RemoveAccessResult struct { gophercloud.ErrResult } + +type EncryptionType struct { + // Unique identifier for the volume type. + VolumeTypeID string `json:"volume_type_id"` + // Notional service where encryption is performed. + ControlLocation string `json:"control_location"` + // Unique identifier for encryption type. + EncryptionID string `json:"encryption_id"` + // Size of encryption key. + KeySize int `json:"key_size"` + // Class that provides encryption support. + Provider string `json:"provider"` + // The encryption algorithm or mode. + Cipher string `json:"cipher"` +} + +type encryptionResult struct { + gophercloud.Result +} + +func (r encryptionResult) Extract() (*EncryptionType, error) { + var s EncryptionType + err := r.ExtractInto(&s) + return &s, err +} + +// ExtractInto converts our response data into a volume type struct +func (r encryptionResult) ExtractInto(v interface{}) error { + return r.Result.ExtractIntoStructPtr(v, "encryption") +} + +type CreateEncryptionResult struct { + encryptionResult +} + +// UpdateResult contains the response body and error from an UpdateEncryption request. +type UpdateEncryptionResult struct { + encryptionResult +} + +// DeleteEncryptionResult contains the response body and error from a DeleteEncryprion request. +type DeleteEncryptionResult struct { + gophercloud.ErrResult +} + +type GetEncryptionType struct { + // Unique identifier for the volume type. + VolumeTypeID string `json:"volume_type_id"` + // Notional service where encryption is performed. + ControlLocation string `json:"control_location"` + // Shows if the resource is deleted or Notional + Deleted bool `json:"deleted"` + // Shows the date and time the resource was created. + CreatedAt string `json:"created_at"` + // Shows the date and time when resource was updated. + UpdatedAt string `json:"updated_at"` + // Unique identifier for encryption type. + EncryptionID string `json:"encryption_id"` + // Size of encryption key. + KeySize int `json:"key_size"` + // Class that provides encryption support. + Provider string `json:"provider"` + // Shows the date and time the reousrce was deleted. + DeletedAt string `json:"deleted_at"` + // The encryption algorithm or mode. + Cipher string `json:"cipher"` +} + +type encryptionShowResult struct { + gophercloud.Result +} + +// Extract interprets any extraSpecResult as an ExtraSpec, if possible. +func (r encryptionShowResult) Extract() (*GetEncryptionType, error) { + var s GetEncryptionType + err := r.ExtractInto(&s) + return &s, err +} + +type GetEncryptionResult struct { + encryptionShowResult +} + +type encryptionShowSpecResult struct { + gophercloud.Result +} + +// Extract interprets any empty interface Result as an empty interface. +func (r encryptionShowSpecResult) Extract() (map[string]interface{}, error) { + var s map[string]interface{} + err := r.ExtractInto(&s) + return s, err +} + +type GetEncryptionSpecResult struct { + encryptionShowSpecResult +} diff --git a/openstack/blockstorage/v3/volumetypes/testing/fixtures.go b/openstack/blockstorage/v3/volumetypes/testing/fixtures_test.go similarity index 68% rename from openstack/blockstorage/v3/volumetypes/testing/fixtures.go rename to openstack/blockstorage/v3/volumetypes/testing/fixtures_test.go index eb617f19e5..a8cb0345cc 100644 --- a/openstack/blockstorage/v3/volumetypes/testing/fixtures.go +++ b/openstack/blockstorage/v3/volumetypes/testing/fixtures_test.go @@ -258,3 +258,120 @@ func HandleExtraSpecDeleteSuccessfully(t *testing.T) { w.WriteHeader(http.StatusAccepted) }) } + +func MockEncryptionCreateResponse(t *testing.T) { + th.Mux.HandleFunc("/types/a5082c24-2a27-43a4-b48e-fcec1240e36b/encryption", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "POST") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + th.TestHeader(t, r, "Content-Type", "application/json") + th.TestHeader(t, r, "Accept", "application/json") + th.TestJSONRequest(t, r, ` +{ + "encryption": { + "key_size": 256, + "provider": "luks", + "control_location": "front-end", + "cipher": "aes-xts-plain64" + } +} + `) + + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + + fmt.Fprintf(w, ` +{ + "encryption": { + "volume_type_id": "a5082c24-2a27-43a4-b48e-fcec1240e36b", + "control_location": "front-end", + "encryption_id": "81e069c6-7394-4856-8df7-3b237ca61f74", + "key_size": 256, + "provider": "luks", + "cipher": "aes-xts-plain64" + } +} + `) + }) +} + +func MockDeleteEncryptionResponse(t *testing.T) { + th.Mux.HandleFunc("/types/a5082c24-2a27-43a4-b48e-fcec1240e36b/encryption/81e069c6-7394-4856-8df7-3b237ca61f74", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "DELETE") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + w.WriteHeader(http.StatusAccepted) + }) +} + +func MockEncryptionUpdateResponse(t *testing.T) { + th.Mux.HandleFunc("/types/a5082c24-2a27-43a4-b48e-fcec1240e36b/encryption/81e069c6-7394-4856-8df7-3b237ca61f74", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "PUT") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + th.TestHeader(t, r, "Content-Type", "application/json") + th.TestHeader(t, r, "Accept", "application/json") + th.TestJSONRequest(t, r, ` +{ + "encryption": { + "key_size": 256, + "provider": "luks", + "control_location": "front-end", + "cipher": "aes-xts-plain64" + } +} + `) + + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + + fmt.Fprintf(w, ` +{ + "encryption": { + "control_location": "front-end", + "key_size": 256, + "provider": "luks", + "cipher": "aes-xts-plain64" + } +} + `) + }) +} + +func MockEncryptionGetResponse(t *testing.T) { + th.Mux.HandleFunc("/types/a5082c24-2a27-43a4-b48e-fcec1240e36b/encryption", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "GET") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + + fmt.Fprintf(w, ` +{ + "volume_type_id": "a5082c24-2a27-43a4-b48e-fcec1240e36b", + "control_location": "front-end", + "deleted": false, + "created_at": "2016-12-28T02:32:25.000000", + "updated_at": null, + "encryption_id": "81e069c6-7394-4856-8df7-3b237ca61f74", + "key_size": 256, + "provider": "luks", + "deleted_at": null, + "cipher": "aes-xts-plain64" +} + `) + }) +} + +func MockEncryptionGetSpecResponse(t *testing.T) { + th.Mux.HandleFunc("/types/a5082c24-2a27-43a4-b48e-fcec1240e36b/encryption/cipher", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "GET") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + + fmt.Fprintf(w, ` +{ + "cipher": "aes-xts-plain64" +} + `) + }) +} diff --git a/openstack/blockstorage/v3/volumetypes/testing/requests_test.go b/openstack/blockstorage/v3/volumetypes/testing/requests_test.go index eb6f2e7c0e..033158df55 100644 --- a/openstack/blockstorage/v3/volumetypes/testing/requests_test.go +++ b/openstack/blockstorage/v3/volumetypes/testing/requests_test.go @@ -276,3 +276,99 @@ func TestVolumeTypeRemoveAccess(t *testing.T) { th.AssertNoErr(t, err) } + +func TestCreateEncryption(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + MockEncryptionCreateResponse(t) + + options := &volumetypes.CreateEncryptionOpts{ + KeySize: 256, + Provider: "luks", + ControlLocation: "front-end", + Cipher: "aes-xts-plain64", + } + id := "a5082c24-2a27-43a4-b48e-fcec1240e36b" + n, err := volumetypes.CreateEncryption(client.ServiceClient(), id, options).Extract() + th.AssertNoErr(t, err) + + th.AssertEquals(t, "a5082c24-2a27-43a4-b48e-fcec1240e36b", n.VolumeTypeID) + th.AssertEquals(t, "front-end", n.ControlLocation) + th.AssertEquals(t, "81e069c6-7394-4856-8df7-3b237ca61f74", n.EncryptionID) + th.AssertEquals(t, 256, n.KeySize) + th.AssertEquals(t, "luks", n.Provider) + th.AssertEquals(t, "aes-xts-plain64", n.Cipher) +} + +func TestDeleteEncryption(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + MockDeleteEncryptionResponse(t) + + res := volumetypes.DeleteEncryption(client.ServiceClient(), "a5082c24-2a27-43a4-b48e-fcec1240e36b", "81e069c6-7394-4856-8df7-3b237ca61f74") + th.AssertNoErr(t, res.Err) +} + +func TestUpdateEncryption(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + MockEncryptionUpdateResponse(t) + + options := &volumetypes.UpdateEncryptionOpts{ + KeySize: 256, + Provider: "luks", + ControlLocation: "front-end", + Cipher: "aes-xts-plain64", + } + id := "a5082c24-2a27-43a4-b48e-fcec1240e36b" + encryptionID := "81e069c6-7394-4856-8df7-3b237ca61f74" + n, err := volumetypes.UpdateEncryption(client.ServiceClient(), id, encryptionID, options).Extract() + th.AssertNoErr(t, err) + + th.AssertEquals(t, "front-end", n.ControlLocation) + th.AssertEquals(t, 256, n.KeySize) + th.AssertEquals(t, "luks", n.Provider) + th.AssertEquals(t, "aes-xts-plain64", n.Cipher) +} + +func TestGetEncryption(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + MockEncryptionGetResponse(t) + id := "a5082c24-2a27-43a4-b48e-fcec1240e36b" + n, err := volumetypes.GetEncryption(client.ServiceClient(), id).Extract() + th.AssertNoErr(t, err) + + th.AssertEquals(t, "a5082c24-2a27-43a4-b48e-fcec1240e36b", n.VolumeTypeID) + th.AssertEquals(t, "front-end", n.ControlLocation) + th.AssertEquals(t, false, n.Deleted) + th.AssertEquals(t, "2016-12-28T02:32:25.000000", n.CreatedAt) + th.AssertEquals(t, "", n.UpdatedAt) + th.AssertEquals(t, "81e069c6-7394-4856-8df7-3b237ca61f74", n.EncryptionID) + th.AssertEquals(t, 256, n.KeySize) + th.AssertEquals(t, "luks", n.Provider) + th.AssertEquals(t, "", n.DeletedAt) + th.AssertEquals(t, "aes-xts-plain64", n.Cipher) +} + +func TestGetEncryptionSpec(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + MockEncryptionGetSpecResponse(t) + id := "a5082c24-2a27-43a4-b48e-fcec1240e36b" + n, err := volumetypes.GetEncryptionSpec(client.ServiceClient(), id, "cipher").Extract() + th.AssertNoErr(t, err) + + key := "cipher" + testVar, exists := n[key] + if exists { + th.AssertEquals(t, "aes-xts-plain64", testVar) + } else { + t.Fatalf("Key %s does not exist in map.", key) + } +} diff --git a/openstack/blockstorage/v3/volumetypes/urls.go b/openstack/blockstorage/v3/volumetypes/urls.go index c63ee47e62..c65478e684 100644 --- a/openstack/blockstorage/v3/volumetypes/urls.go +++ b/openstack/blockstorage/v3/volumetypes/urls.go @@ -49,3 +49,23 @@ func accessURL(client *gophercloud.ServiceClient, id string) string { func accessActionURL(client *gophercloud.ServiceClient, id string) string { return client.ServiceURL("types", id, "action") } + +func createEncryptionURL(client *gophercloud.ServiceClient, id string) string { + return client.ServiceURL("types", id, "encryption") +} + +func deleteEncryptionURL(client *gophercloud.ServiceClient, id, encryptionID string) string { + return client.ServiceURL("types", id, "encryption", encryptionID) +} + +func getEncryptionURL(client *gophercloud.ServiceClient, id string) string { + return client.ServiceURL("types", id, "encryption") +} + +func getEncryptionSpecURL(client *gophercloud.ServiceClient, id, key string) string { + return client.ServiceURL("types", id, "encryption", key) +} + +func updateEncryptionURL(client *gophercloud.ServiceClient, id, encryptionID string) string { + return client.ServiceURL("types", id, "encryption", encryptionID) +} diff --git a/openstack/cdn/v1/base/testing/fixtures.go b/openstack/cdn/v1/base/testing/fixtures_test.go similarity index 100% rename from openstack/cdn/v1/base/testing/fixtures.go rename to openstack/cdn/v1/base/testing/fixtures_test.go diff --git a/openstack/cdn/v1/flavors/testing/fixtures.go b/openstack/cdn/v1/flavors/testing/fixtures_test.go similarity index 100% rename from openstack/cdn/v1/flavors/testing/fixtures.go rename to openstack/cdn/v1/flavors/testing/fixtures_test.go diff --git a/openstack/cdn/v1/serviceassets/testing/fixtures.go b/openstack/cdn/v1/serviceassets/testing/fixtures_test.go similarity index 100% rename from openstack/cdn/v1/serviceassets/testing/fixtures.go rename to openstack/cdn/v1/serviceassets/testing/fixtures_test.go diff --git a/openstack/cdn/v1/services/testing/fixtures.go b/openstack/cdn/v1/services/testing/fixtures_test.go similarity index 100% rename from openstack/cdn/v1/services/testing/fixtures.go rename to openstack/cdn/v1/services/testing/fixtures_test.go diff --git a/openstack/clustering/v1/actions/testing/fixtures.go b/openstack/clustering/v1/actions/testing/fixtures_test.go similarity index 100% rename from openstack/clustering/v1/actions/testing/fixtures.go rename to openstack/clustering/v1/actions/testing/fixtures_test.go diff --git a/openstack/clustering/v1/clusters/testing/fixtures.go b/openstack/clustering/v1/clusters/testing/fixtures_test.go similarity index 100% rename from openstack/clustering/v1/clusters/testing/fixtures.go rename to openstack/clustering/v1/clusters/testing/fixtures_test.go diff --git a/openstack/clustering/v1/events/testing/fixtures.go b/openstack/clustering/v1/events/testing/fixtures_test.go similarity index 100% rename from openstack/clustering/v1/events/testing/fixtures.go rename to openstack/clustering/v1/events/testing/fixtures_test.go diff --git a/openstack/clustering/v1/nodes/testing/fixtures.go b/openstack/clustering/v1/nodes/testing/fixtures_test.go similarity index 100% rename from openstack/clustering/v1/nodes/testing/fixtures.go rename to openstack/clustering/v1/nodes/testing/fixtures_test.go diff --git a/openstack/clustering/v1/policies/testing/fixtures.go b/openstack/clustering/v1/policies/testing/fixtures_test.go similarity index 100% rename from openstack/clustering/v1/policies/testing/fixtures.go rename to openstack/clustering/v1/policies/testing/fixtures_test.go diff --git a/openstack/clustering/v1/policytypes/testing/fixtures.go b/openstack/clustering/v1/policytypes/testing/fixtures_test.go similarity index 100% rename from openstack/clustering/v1/policytypes/testing/fixtures.go rename to openstack/clustering/v1/policytypes/testing/fixtures_test.go diff --git a/openstack/clustering/v1/profiles/testing/fixtures.go b/openstack/clustering/v1/profiles/testing/fixtures_test.go similarity index 100% rename from openstack/clustering/v1/profiles/testing/fixtures.go rename to openstack/clustering/v1/profiles/testing/fixtures_test.go diff --git a/openstack/clustering/v1/profiletypes/testing/fixtures.go b/openstack/clustering/v1/profiletypes/testing/fixtures_test.go similarity index 100% rename from openstack/clustering/v1/profiletypes/testing/fixtures.go rename to openstack/clustering/v1/profiletypes/testing/fixtures_test.go diff --git a/openstack/clustering/v1/profiletypes/testing/requests_test.go b/openstack/clustering/v1/profiletypes/testing/requests_test.go index c4f379b645..3bac5ab349 100644 --- a/openstack/clustering/v1/profiletypes/testing/requests_test.go +++ b/openstack/clustering/v1/profiletypes/testing/requests_test.go @@ -3,7 +3,7 @@ package testing import ( "testing" - "github.com/gophercloud/gophercloud/acceptance/tools" + "github.com/gophercloud/gophercloud/internal/acceptance/tools" "github.com/gophercloud/gophercloud/openstack/clustering/v1/profiletypes" "github.com/gophercloud/gophercloud/pagination" th "github.com/gophercloud/gophercloud/testhelper" diff --git a/openstack/clustering/v1/receivers/testing/fixtures.go b/openstack/clustering/v1/receivers/testing/fixtures_test.go similarity index 100% rename from openstack/clustering/v1/receivers/testing/fixtures.go rename to openstack/clustering/v1/receivers/testing/fixtures_test.go diff --git a/openstack/compute/apiversions/testing/fixtures.go b/openstack/compute/apiversions/testing/fixtures_test.go similarity index 100% rename from openstack/compute/apiversions/testing/fixtures.go rename to openstack/compute/apiversions/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/aggregates/testing/fixtures.go b/openstack/compute/v2/extensions/aggregates/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/aggregates/testing/fixtures.go rename to openstack/compute/v2/extensions/aggregates/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/attachinterfaces/testing/fixtures.go b/openstack/compute/v2/extensions/attachinterfaces/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/attachinterfaces/testing/fixtures.go rename to openstack/compute/v2/extensions/attachinterfaces/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/availabilityzones/testing/fixtures.go b/openstack/compute/v2/extensions/availabilityzones/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/availabilityzones/testing/fixtures.go rename to openstack/compute/v2/extensions/availabilityzones/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/bootfromvolume/requests.go b/openstack/compute/v2/extensions/bootfromvolume/requests.go index 096d8be7ef..05f45aeceb 100644 --- a/openstack/compute/v2/extensions/bootfromvolume/requests.go +++ b/openstack/compute/v2/extensions/bootfromvolume/requests.go @@ -62,6 +62,9 @@ type BlockDevice struct { DestinationType DestinationType `json:"destination_type,omitempty"` // GuestFormat specifies the format of the block device. + // Not specifying this will cause the device to be formatted to the default in Nova + // which is currently vfat. + // https://opendev.org/openstack/nova/src/commit/d0b459423dd81644e8d9382b6c87fabaa4f03ad4/nova/privsep/fs.py#L257 GuestFormat string `json:"guest_format,omitempty"` // VolumeSize is the size of the volume to create (in gigabytes). This can be @@ -79,6 +82,12 @@ type BlockDevice struct { // VolumeType is the volume type of the block device. // This requires Compute API microversion 2.67 or later. VolumeType string `json:"volume_type,omitempty"` + + // Tag is an arbitrary string that can be applied to a block device. + // Information about the device tags can be obtained from the metadata API + // and the config drive, allowing devices to be easily identified. + // This requires Compute API microversion 2.42 or later. + Tag string `json:"tag,omitempty"` } // CreateOptsExt is a structure that extends the server `CreateOpts` structure diff --git a/openstack/compute/v2/extensions/bootfromvolume/testing/fixtures.go b/openstack/compute/v2/extensions/bootfromvolume/testing/fixtures_test.go similarity index 85% rename from openstack/compute/v2/extensions/bootfromvolume/testing/fixtures.go rename to openstack/compute/v2/extensions/bootfromvolume/testing/fixtures_test.go index cb89173aaa..39b09c7fe7 100644 --- a/openstack/compute/v2/extensions/bootfromvolume/testing/fixtures.go +++ b/openstack/compute/v2/extensions/bootfromvolume/testing/fixtures_test.go @@ -308,3 +308,53 @@ var NewVolumeTypeRequest = bootfromvolume.CreateOptsExt{ }, }, } + +const ExpectedImageAndExistingVolumeWithTagRequest = ` +{ + "server": { + "name": "createdserver", + "imageRef": "asdfasdfasdf", + "flavorRef": "performance1-1", + "block_device_mapping_v2":[ + { + "boot_index": 0, + "delete_on_termination": true, + "destination_type":"local", + "source_type":"image", + "uuid":"asdfasdfasdf" + }, + { + "boot_index": -1, + "delete_on_termination": true, + "destination_type":"volume", + "source_type":"volume", + "tag": "volume-tag", + "uuid":"123456", + "volume_size": 1 + } + ] + } +} +` + +var ImageAndExistingVolumeWithTagRequest = bootfromvolume.CreateOptsExt{ + CreateOptsBuilder: BaseCreateOptsWithImageRef, + BlockDevice: []bootfromvolume.BlockDevice{ + { + BootIndex: 0, + DeleteOnTermination: true, + DestinationType: bootfromvolume.DestinationLocal, + SourceType: bootfromvolume.SourceImage, + UUID: "asdfasdfasdf", + }, + { + BootIndex: -1, + DeleteOnTermination: true, + DestinationType: bootfromvolume.DestinationVolume, + SourceType: bootfromvolume.SourceVolume, + Tag: "volume-tag", + UUID: "123456", + VolumeSize: 1, + }, + }, +} diff --git a/openstack/compute/v2/extensions/bootfromvolume/testing/requests_test.go b/openstack/compute/v2/extensions/bootfromvolume/testing/requests_test.go index 69afc865c9..22d11cc823 100644 --- a/openstack/compute/v2/extensions/bootfromvolume/testing/requests_test.go +++ b/openstack/compute/v2/extensions/bootfromvolume/testing/requests_test.go @@ -47,3 +47,9 @@ func TestBootFromNewVolumeType(t *testing.T) { th.AssertNoErr(t, err) th.CheckJSONEquals(t, ExpectedNewVolumeTypeRequest, actual) } + +func TestAttachExistingVolumeWithTag(t *testing.T) { + actual, err := ImageAndExistingVolumeWithTagRequest.ToServerCreateMap() + th.AssertNoErr(t, err) + th.CheckJSONEquals(t, ExpectedImageAndExistingVolumeWithTagRequest, actual) +} diff --git a/openstack/compute/v2/extensions/defsecrules/testing/fixtures.go b/openstack/compute/v2/extensions/defsecrules/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/defsecrules/testing/fixtures.go rename to openstack/compute/v2/extensions/defsecrules/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/diagnostics/testing/fixtures.go b/openstack/compute/v2/extensions/diagnostics/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/diagnostics/testing/fixtures.go rename to openstack/compute/v2/extensions/diagnostics/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/evacuate/testing/fixtures.go b/openstack/compute/v2/extensions/evacuate/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/evacuate/testing/fixtures.go rename to openstack/compute/v2/extensions/evacuate/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/extendedserverattributes/testing/fixtures.go b/openstack/compute/v2/extensions/extendedserverattributes/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/extendedserverattributes/testing/fixtures.go rename to openstack/compute/v2/extensions/extendedserverattributes/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/floatingips/testing/fixtures.go b/openstack/compute/v2/extensions/floatingips/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/floatingips/testing/fixtures.go rename to openstack/compute/v2/extensions/floatingips/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/hypervisors/testing/fixtures.go b/openstack/compute/v2/extensions/hypervisors/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/hypervisors/testing/fixtures.go rename to openstack/compute/v2/extensions/hypervisors/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/injectnetworkinfo/testing/fixtures.go b/openstack/compute/v2/extensions/injectnetworkinfo/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/injectnetworkinfo/testing/fixtures.go rename to openstack/compute/v2/extensions/injectnetworkinfo/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/instanceactions/testing/fixtures.go b/openstack/compute/v2/extensions/instanceactions/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/instanceactions/testing/fixtures.go rename to openstack/compute/v2/extensions/instanceactions/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/keypairs/testing/fixtures.go b/openstack/compute/v2/extensions/keypairs/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/keypairs/testing/fixtures.go rename to openstack/compute/v2/extensions/keypairs/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/limits/testing/fixtures.go b/openstack/compute/v2/extensions/limits/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/limits/testing/fixtures.go rename to openstack/compute/v2/extensions/limits/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/lockunlock/testing/fixtures.go b/openstack/compute/v2/extensions/lockunlock/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/lockunlock/testing/fixtures.go rename to openstack/compute/v2/extensions/lockunlock/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/migrate/testing/fixtures.go b/openstack/compute/v2/extensions/migrate/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/migrate/testing/fixtures.go rename to openstack/compute/v2/extensions/migrate/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/networks/testing/fixtures.go b/openstack/compute/v2/extensions/networks/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/networks/testing/fixtures.go rename to openstack/compute/v2/extensions/networks/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/pauseunpause/testing/fixtures.go b/openstack/compute/v2/extensions/pauseunpause/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/pauseunpause/testing/fixtures.go rename to openstack/compute/v2/extensions/pauseunpause/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/quotasets/testing/fixtures.go b/openstack/compute/v2/extensions/quotasets/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/quotasets/testing/fixtures.go rename to openstack/compute/v2/extensions/quotasets/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/remoteconsoles/testing/fixtures.go b/openstack/compute/v2/extensions/remoteconsoles/testing/fixtures_test.go similarity index 88% rename from openstack/compute/v2/extensions/remoteconsoles/testing/fixtures.go rename to openstack/compute/v2/extensions/remoteconsoles/testing/fixtures_test.go index 9644a4895e..53b9f5b88b 100644 --- a/openstack/compute/v2/extensions/remoteconsoles/testing/fixtures.go +++ b/openstack/compute/v2/extensions/remoteconsoles/testing/fixtures_test.go @@ -10,7 +10,7 @@ const RemoteConsoleCreateRequest = ` } ` -// RemoteConsoleCreateResult represents a raw server responce to the RemoteConsoleCreateRequest. +// RemoteConsoleCreateResult represents a raw server response to the RemoteConsoleCreateRequest. const RemoteConsoleCreateResult = ` { "remote_console": { diff --git a/openstack/compute/v2/extensions/rescueunrescue/testing/fixtures.go b/openstack/compute/v2/extensions/rescueunrescue/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/rescueunrescue/testing/fixtures.go rename to openstack/compute/v2/extensions/rescueunrescue/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/resetnetwork/testing/fixtures.go b/openstack/compute/v2/extensions/resetnetwork/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/resetnetwork/testing/fixtures.go rename to openstack/compute/v2/extensions/resetnetwork/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/resetstate/testing/fixtures.go b/openstack/compute/v2/extensions/resetstate/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/resetstate/testing/fixtures.go rename to openstack/compute/v2/extensions/resetstate/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/secgroups/testing/fixtures.go b/openstack/compute/v2/extensions/secgroups/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/secgroups/testing/fixtures.go rename to openstack/compute/v2/extensions/secgroups/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/servergroups/testing/fixtures.go b/openstack/compute/v2/extensions/servergroups/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/servergroups/testing/fixtures.go rename to openstack/compute/v2/extensions/servergroups/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/serverusage/testing/fixtures.go b/openstack/compute/v2/extensions/serverusage/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/serverusage/testing/fixtures.go rename to openstack/compute/v2/extensions/serverusage/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/services/testing/fixtures.go b/openstack/compute/v2/extensions/services/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/services/testing/fixtures.go rename to openstack/compute/v2/extensions/services/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/shelveunshelve/testing/fixtures.go b/openstack/compute/v2/extensions/shelveunshelve/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/shelveunshelve/testing/fixtures.go rename to openstack/compute/v2/extensions/shelveunshelve/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/startstop/testing/fixtures.go b/openstack/compute/v2/extensions/startstop/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/startstop/testing/fixtures.go rename to openstack/compute/v2/extensions/startstop/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/suspendresume/testing/fixtures.go b/openstack/compute/v2/extensions/suspendresume/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/suspendresume/testing/fixtures.go rename to openstack/compute/v2/extensions/suspendresume/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/tags/testing/fixtures.go b/openstack/compute/v2/extensions/tags/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/tags/testing/fixtures.go rename to openstack/compute/v2/extensions/tags/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/tenantnetworks/testing/fixtures.go b/openstack/compute/v2/extensions/tenantnetworks/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/tenantnetworks/testing/fixtures.go rename to openstack/compute/v2/extensions/tenantnetworks/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/testing/fixtures.go b/openstack/compute/v2/extensions/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/testing/fixtures.go rename to openstack/compute/v2/extensions/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/usage/testing/fixtures.go b/openstack/compute/v2/extensions/usage/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/usage/testing/fixtures.go rename to openstack/compute/v2/extensions/usage/testing/fixtures_test.go diff --git a/openstack/compute/v2/extensions/volumeattach/doc.go b/openstack/compute/v2/extensions/volumeattach/doc.go index 484eb20000..857ab19cc5 100644 --- a/openstack/compute/v2/extensions/volumeattach/doc.go +++ b/openstack/compute/v2/extensions/volumeattach/doc.go @@ -20,9 +20,9 @@ Example to Attach a Volume Example to Detach a Volume serverID := "7ac8686c-de71-4acb-9600-ec18b1a1ed6d" - attachmentID := "ed081613-1c9b-4231-aa5e-ebfd4d87f983" + volumeID := "ed081613-1c9b-4231-aa5e-ebfd4d87f983" - err := volumeattach.Delete(computeClient, serverID, attachmentID).ExtractErr() + err := volumeattach.Delete(computeClient, serverID, volumeID).ExtractErr() if err != nil { panic(err) } diff --git a/openstack/compute/v2/extensions/volumeattach/requests.go b/openstack/compute/v2/extensions/volumeattach/requests.go index 8c5a2ba03e..fe0b1075d6 100644 --- a/openstack/compute/v2/extensions/volumeattach/requests.go +++ b/openstack/compute/v2/extensions/volumeattach/requests.go @@ -56,16 +56,16 @@ func Create(client *gophercloud.ServiceClient, serverID string, opts CreateOptsB } // Get returns public data about a previously created VolumeAttachment. -func Get(client *gophercloud.ServiceClient, serverID, attachmentID string) (r GetResult) { - resp, err := client.Get(getURL(client, serverID, attachmentID), &r.Body, nil) +func Get(client *gophercloud.ServiceClient, serverID, volumeID string) (r GetResult) { + resp, err := client.Get(getURL(client, serverID, volumeID), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } // Delete requests the deletion of a previous stored VolumeAttachment from // the server. -func Delete(client *gophercloud.ServiceClient, serverID, attachmentID string) (r DeleteResult) { - resp, err := client.Delete(deleteURL(client, serverID, attachmentID), nil) +func Delete(client *gophercloud.ServiceClient, serverID, volumeID string) (r DeleteResult) { + resp, err := client.Delete(deleteURL(client, serverID, volumeID), nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } diff --git a/openstack/compute/v2/extensions/volumeattach/testing/fixtures.go b/openstack/compute/v2/extensions/volumeattach/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/extensions/volumeattach/testing/fixtures.go rename to openstack/compute/v2/extensions/volumeattach/testing/fixtures_test.go diff --git a/openstack/compute/v2/flavors/testing/fixtures.go b/openstack/compute/v2/flavors/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/flavors/testing/fixtures.go rename to openstack/compute/v2/flavors/testing/fixtures_test.go diff --git a/openstack/compute/v2/servers/testing/fixtures.go b/openstack/compute/v2/servers/testing/fixtures_test.go similarity index 100% rename from openstack/compute/v2/servers/testing/fixtures.go rename to openstack/compute/v2/servers/testing/fixtures_test.go diff --git a/openstack/container/v1/capsules/testing/fixtures.go b/openstack/container/v1/capsules/testing/fixtures_test.go similarity index 100% rename from openstack/container/v1/capsules/testing/fixtures.go rename to openstack/container/v1/capsules/testing/fixtures_test.go diff --git a/openstack/containerinfra/apiversions/testing/fixtures.go b/openstack/containerinfra/apiversions/testing/fixtures_test.go similarity index 100% rename from openstack/containerinfra/apiversions/testing/fixtures.go rename to openstack/containerinfra/apiversions/testing/fixtures_test.go diff --git a/openstack/containerinfra/v1/certificates/testing/fixtures.go b/openstack/containerinfra/v1/certificates/testing/fixtures_test.go similarity index 100% rename from openstack/containerinfra/v1/certificates/testing/fixtures.go rename to openstack/containerinfra/v1/certificates/testing/fixtures_test.go diff --git a/openstack/containerinfra/v1/clusters/testing/fixtures.go b/openstack/containerinfra/v1/clusters/testing/fixtures_test.go similarity index 100% rename from openstack/containerinfra/v1/clusters/testing/fixtures.go rename to openstack/containerinfra/v1/clusters/testing/fixtures_test.go diff --git a/openstack/containerinfra/v1/clustertemplates/testing/fixtures.go b/openstack/containerinfra/v1/clustertemplates/testing/fixtures_test.go similarity index 100% rename from openstack/containerinfra/v1/clustertemplates/testing/fixtures.go rename to openstack/containerinfra/v1/clustertemplates/testing/fixtures_test.go diff --git a/openstack/containerinfra/v1/nodegroups/testing/fixtures.go b/openstack/containerinfra/v1/nodegroups/testing/fixtures_test.go similarity index 100% rename from openstack/containerinfra/v1/nodegroups/testing/fixtures.go rename to openstack/containerinfra/v1/nodegroups/testing/fixtures_test.go diff --git a/openstack/containerinfra/v1/quotas/testing/fixtures.go b/openstack/containerinfra/v1/quotas/testing/fixtures_test.go similarity index 100% rename from openstack/containerinfra/v1/quotas/testing/fixtures.go rename to openstack/containerinfra/v1/quotas/testing/fixtures_test.go diff --git a/openstack/db/v1/configurations/testing/fixtures.go b/openstack/db/v1/configurations/testing/fixtures_test.go similarity index 100% rename from openstack/db/v1/configurations/testing/fixtures.go rename to openstack/db/v1/configurations/testing/fixtures_test.go diff --git a/openstack/db/v1/databases/testing/fixtures.go b/openstack/db/v1/databases/testing/fixtures_test.go similarity index 100% rename from openstack/db/v1/databases/testing/fixtures.go rename to openstack/db/v1/databases/testing/fixtures_test.go diff --git a/openstack/db/v1/datastores/testing/fixtures.go b/openstack/db/v1/datastores/testing/fixtures_test.go similarity index 100% rename from openstack/db/v1/datastores/testing/fixtures.go rename to openstack/db/v1/datastores/testing/fixtures_test.go diff --git a/openstack/db/v1/flavors/testing/fixtures.go b/openstack/db/v1/flavors/testing/fixtures_test.go similarity index 100% rename from openstack/db/v1/flavors/testing/fixtures.go rename to openstack/db/v1/flavors/testing/fixtures_test.go diff --git a/openstack/db/v1/instances/requests.go b/openstack/db/v1/instances/requests.go index 73c7acc74e..26638157ca 100644 --- a/openstack/db/v1/instances/requests.go +++ b/openstack/db/v1/instances/requests.go @@ -47,6 +47,8 @@ func (opts NetworkOpts) ToMap() (map[string]interface{}, error) { // CreateOpts is the struct responsible for configuring a new database instance. type CreateOpts struct { + // The availability zone of the instance. + AvailabilityZone string `json:"availability_zone,omitempty"` // Either the integer UUID (in string form) of the flavor, or its URI // reference as specified in the response from the List() call. Required. FlavorRef string @@ -87,6 +89,10 @@ func (opts CreateOpts) ToInstanceCreateMap() (map[string]interface{}, error) { "flavorRef": opts.FlavorRef, } + if opts.AvailabilityZone != "" { + instance["availability_zone"] = opts.AvailabilityZone + } + if opts.Name != "" { instance["name"] = opts.Name } diff --git a/openstack/db/v1/instances/testing/fixtures.go b/openstack/db/v1/instances/testing/fixtures_test.go similarity index 99% rename from openstack/db/v1/instances/testing/fixtures.go rename to openstack/db/v1/instances/testing/fixtures_test.go index 782c048dc3..7abd42e3e7 100644 --- a/openstack/db/v1/instances/testing/fixtures.go +++ b/openstack/db/v1/instances/testing/fixtures_test.go @@ -104,6 +104,7 @@ var instanceGet = ` var createReq = ` { "instance": { + "availability_zone": "us-east1", "databases": [ { "character_set": "utf8", diff --git a/openstack/db/v1/instances/testing/requests_test.go b/openstack/db/v1/instances/testing/requests_test.go index a1575a4bb1..62d615d7a9 100644 --- a/openstack/db/v1/instances/testing/requests_test.go +++ b/openstack/db/v1/instances/testing/requests_test.go @@ -17,8 +17,9 @@ func TestCreate(t *testing.T) { HandleCreate(t) opts := instances.CreateOpts{ - Name: "json_rack_instance", - FlavorRef: "1", + AvailabilityZone: "us-east1", + Name: "json_rack_instance", + FlavorRef: "1", Databases: db.BatchCreateOpts{ {CharSet: "utf8", Collate: "utf8_general_ci", Name: "sampledb"}, {Name: "nextround"}, @@ -48,8 +49,9 @@ func TestCreateWithFault(t *testing.T) { HandleCreateWithFault(t) opts := instances.CreateOpts{ - Name: "json_rack_instance", - FlavorRef: "1", + AvailabilityZone: "us-east1", + Name: "json_rack_instance", + FlavorRef: "1", Databases: db.BatchCreateOpts{ {CharSet: "utf8", Collate: "utf8_general_ci", Name: "sampledb"}, {Name: "nextround"}, diff --git a/openstack/db/v1/users/testing/fixtures.go b/openstack/db/v1/users/testing/fixtures_test.go similarity index 100% rename from openstack/db/v1/users/testing/fixtures.go rename to openstack/db/v1/users/testing/fixtures_test.go diff --git a/openstack/dns/v2/recordsets/testing/fixtures.go b/openstack/dns/v2/recordsets/testing/fixtures_test.go similarity index 100% rename from openstack/dns/v2/recordsets/testing/fixtures.go rename to openstack/dns/v2/recordsets/testing/fixtures_test.go diff --git a/openstack/dns/v2/transfer/accept/testing/fixtures.go b/openstack/dns/v2/transfer/accept/testing/fixtures_test.go similarity index 100% rename from openstack/dns/v2/transfer/accept/testing/fixtures.go rename to openstack/dns/v2/transfer/accept/testing/fixtures_test.go diff --git a/openstack/dns/v2/transfer/request/testing/fixtures.go b/openstack/dns/v2/transfer/request/testing/fixtures_test.go similarity index 100% rename from openstack/dns/v2/transfer/request/testing/fixtures.go rename to openstack/dns/v2/transfer/request/testing/fixtures_test.go diff --git a/openstack/dns/v2/zones/testing/fixtures.go b/openstack/dns/v2/zones/testing/fixtures_test.go similarity index 100% rename from openstack/dns/v2/zones/testing/fixtures.go rename to openstack/dns/v2/zones/testing/fixtures_test.go diff --git a/openstack/identity/v2/extensions/admin/roles/testing/fixtures.go b/openstack/identity/v2/extensions/admin/roles/testing/fixtures_test.go similarity index 100% rename from openstack/identity/v2/extensions/admin/roles/testing/fixtures.go rename to openstack/identity/v2/extensions/admin/roles/testing/fixtures_test.go diff --git a/openstack/identity/v2/extensions/testing/fixtures.go b/openstack/identity/v2/extensions/testing/fixtures_test.go similarity index 100% rename from openstack/identity/v2/extensions/testing/fixtures.go rename to openstack/identity/v2/extensions/testing/fixtures_test.go diff --git a/openstack/identity/v2/tenants/testing/fixtures.go b/openstack/identity/v2/tenants/testing/fixtures_test.go similarity index 100% rename from openstack/identity/v2/tenants/testing/fixtures.go rename to openstack/identity/v2/tenants/testing/fixtures_test.go diff --git a/openstack/identity/v2/tokens/testing/fixtures.go b/openstack/identity/v2/tokens/testing/fixtures_test.go similarity index 100% rename from openstack/identity/v2/tokens/testing/fixtures.go rename to openstack/identity/v2/tokens/testing/fixtures_test.go diff --git a/openstack/identity/v2/users/testing/fixtures.go b/openstack/identity/v2/users/testing/fixtures_test.go similarity index 100% rename from openstack/identity/v2/users/testing/fixtures.go rename to openstack/identity/v2/users/testing/fixtures_test.go diff --git a/openstack/identity/v3/applicationcredentials/testing/fixtures.go b/openstack/identity/v3/applicationcredentials/testing/fixtures_test.go similarity index 100% rename from openstack/identity/v3/applicationcredentials/testing/fixtures.go rename to openstack/identity/v3/applicationcredentials/testing/fixtures_test.go diff --git a/openstack/identity/v3/catalog/testing/fixtures.go b/openstack/identity/v3/catalog/testing/fixtures_test.go similarity index 100% rename from openstack/identity/v3/catalog/testing/fixtures.go rename to openstack/identity/v3/catalog/testing/fixtures_test.go diff --git a/openstack/identity/v3/credentials/testing/fixtures.go b/openstack/identity/v3/credentials/testing/fixtures_test.go similarity index 100% rename from openstack/identity/v3/credentials/testing/fixtures.go rename to openstack/identity/v3/credentials/testing/fixtures_test.go diff --git a/openstack/identity/v3/domains/testing/fixtures.go b/openstack/identity/v3/domains/testing/fixtures_test.go similarity index 100% rename from openstack/identity/v3/domains/testing/fixtures.go rename to openstack/identity/v3/domains/testing/fixtures_test.go diff --git a/openstack/identity/v3/extensions/ec2credentials/testing/fixtures.go b/openstack/identity/v3/extensions/ec2credentials/testing/fixtures_test.go similarity index 100% rename from openstack/identity/v3/extensions/ec2credentials/testing/fixtures.go rename to openstack/identity/v3/extensions/ec2credentials/testing/fixtures_test.go diff --git a/openstack/identity/v3/extensions/federation/testing/fixtures.go b/openstack/identity/v3/extensions/federation/testing/fixtures_test.go similarity index 100% rename from openstack/identity/v3/extensions/federation/testing/fixtures.go rename to openstack/identity/v3/extensions/federation/testing/fixtures_test.go diff --git a/openstack/identity/v3/extensions/oauth1/testing/fixtures.go b/openstack/identity/v3/extensions/oauth1/testing/fixtures_test.go similarity index 100% rename from openstack/identity/v3/extensions/oauth1/testing/fixtures.go rename to openstack/identity/v3/extensions/oauth1/testing/fixtures_test.go diff --git a/openstack/identity/v3/extensions/trusts/testing/fixtures.go b/openstack/identity/v3/extensions/trusts/testing/fixtures_test.go similarity index 100% rename from openstack/identity/v3/extensions/trusts/testing/fixtures.go rename to openstack/identity/v3/extensions/trusts/testing/fixtures_test.go diff --git a/openstack/identity/v3/groups/testing/fixtures.go b/openstack/identity/v3/groups/testing/fixtures_test.go similarity index 100% rename from openstack/identity/v3/groups/testing/fixtures.go rename to openstack/identity/v3/groups/testing/fixtures_test.go diff --git a/openstack/identity/v3/limits/testing/fixtures.go b/openstack/identity/v3/limits/testing/fixtures_test.go similarity index 100% rename from openstack/identity/v3/limits/testing/fixtures.go rename to openstack/identity/v3/limits/testing/fixtures_test.go diff --git a/openstack/identity/v3/osinherit/testing/fixtures.go b/openstack/identity/v3/osinherit/testing/fixtures_test.go similarity index 100% rename from openstack/identity/v3/osinherit/testing/fixtures.go rename to openstack/identity/v3/osinherit/testing/fixtures_test.go diff --git a/openstack/identity/v3/policies/testing/fixtures.go b/openstack/identity/v3/policies/testing/fixtures_test.go similarity index 100% rename from openstack/identity/v3/policies/testing/fixtures.go rename to openstack/identity/v3/policies/testing/fixtures_test.go diff --git a/openstack/identity/v3/projects/testing/fixtures.go b/openstack/identity/v3/projects/testing/fixtures_test.go similarity index 100% rename from openstack/identity/v3/projects/testing/fixtures.go rename to openstack/identity/v3/projects/testing/fixtures_test.go diff --git a/openstack/identity/v3/regions/testing/fixtures.go b/openstack/identity/v3/regions/testing/fixtures_test.go similarity index 100% rename from openstack/identity/v3/regions/testing/fixtures.go rename to openstack/identity/v3/regions/testing/fixtures_test.go diff --git a/openstack/identity/v3/registeredlimits/testing/fixtures.go b/openstack/identity/v3/registeredlimits/testing/fixtures_test.go similarity index 100% rename from openstack/identity/v3/registeredlimits/testing/fixtures.go rename to openstack/identity/v3/registeredlimits/testing/fixtures_test.go diff --git a/openstack/identity/v3/roles/testing/fixtures.go b/openstack/identity/v3/roles/testing/fixtures_test.go similarity index 100% rename from openstack/identity/v3/roles/testing/fixtures.go rename to openstack/identity/v3/roles/testing/fixtures_test.go diff --git a/openstack/identity/v3/services/testing/fixtures.go b/openstack/identity/v3/services/testing/fixtures_test.go similarity index 100% rename from openstack/identity/v3/services/testing/fixtures.go rename to openstack/identity/v3/services/testing/fixtures_test.go diff --git a/openstack/identity/v3/users/testing/fixtures.go b/openstack/identity/v3/users/testing/fixtures_test.go similarity index 100% rename from openstack/identity/v3/users/testing/fixtures.go rename to openstack/identity/v3/users/testing/fixtures_test.go diff --git a/openstack/imageservice/v2/imagedata/testing/fixtures.go b/openstack/imageservice/v2/imagedata/testing/fixtures_test.go similarity index 100% rename from openstack/imageservice/v2/imagedata/testing/fixtures.go rename to openstack/imageservice/v2/imagedata/testing/fixtures_test.go diff --git a/openstack/imageservice/v2/imageimport/testing/fixtures.go b/openstack/imageservice/v2/imageimport/testing/fixtures_test.go similarity index 100% rename from openstack/imageservice/v2/imageimport/testing/fixtures.go rename to openstack/imageservice/v2/imageimport/testing/fixtures_test.go diff --git a/openstack/imageservice/v2/images/results.go b/openstack/imageservice/v2/images/results.go index 1b27a15495..96fd91a2ca 100644 --- a/openstack/imageservice/v2/images/results.go +++ b/openstack/imageservice/v2/images/results.go @@ -76,7 +76,7 @@ type Image struct { CreatedAt time.Time `json:"created_at"` // UpdatedAt is the date when the last change has been made to the image or - // it's properties. + // its properties. UpdatedAt time.Time `json:"updated_at"` // File is the trailing path after the glance endpoint that represent the diff --git a/openstack/imageservice/v2/images/testing/fixtures.go b/openstack/imageservice/v2/images/testing/fixtures_test.go similarity index 100% rename from openstack/imageservice/v2/images/testing/fixtures.go rename to openstack/imageservice/v2/images/testing/fixtures_test.go diff --git a/openstack/imageservice/v2/members/testing/fixtures.go b/openstack/imageservice/v2/members/testing/fixtures_test.go similarity index 100% rename from openstack/imageservice/v2/members/testing/fixtures.go rename to openstack/imageservice/v2/members/testing/fixtures_test.go diff --git a/openstack/imageservice/v2/tasks/testing/fixtures.go b/openstack/imageservice/v2/tasks/testing/fixtures_test.go similarity index 100% rename from openstack/imageservice/v2/tasks/testing/fixtures.go rename to openstack/imageservice/v2/tasks/testing/fixtures_test.go diff --git a/openstack/keymanager/v1/acls/testing/fixtures.go b/openstack/keymanager/v1/acls/testing/fixtures_test.go similarity index 100% rename from openstack/keymanager/v1/acls/testing/fixtures.go rename to openstack/keymanager/v1/acls/testing/fixtures_test.go diff --git a/openstack/keymanager/v1/containers/testing/fixtures.go b/openstack/keymanager/v1/containers/testing/fixtures_test.go similarity index 100% rename from openstack/keymanager/v1/containers/testing/fixtures.go rename to openstack/keymanager/v1/containers/testing/fixtures_test.go diff --git a/openstack/keymanager/v1/orders/testing/fixtures.go b/openstack/keymanager/v1/orders/testing/fixtures_test.go similarity index 100% rename from openstack/keymanager/v1/orders/testing/fixtures.go rename to openstack/keymanager/v1/orders/testing/fixtures_test.go diff --git a/openstack/keymanager/v1/secrets/results.go b/openstack/keymanager/v1/secrets/results.go index f76b977520..46e6860098 100644 --- a/openstack/keymanager/v1/secrets/results.go +++ b/openstack/keymanager/v1/secrets/results.go @@ -93,14 +93,14 @@ type CreateResult struct { commonResult } -// UpdateResult is the response from an Update operation. Call its ExtractErr to -// determine if the request succeeded or failed. +// UpdateResult is the response from an Update operation. Call its ExtractErr +// method to determine if the request succeeded or failed. type UpdateResult struct { gophercloud.ErrResult } -// DeleteResult is the response from a Delete operation. Call its ExtractErr to -// determine if the request succeeded or failed. +// DeleteResult is the response from a Delete operation. Call its ExtractErr +// method to determine if the request succeeded or failed. type DeleteResult struct { gophercloud.ErrResult } @@ -112,11 +112,11 @@ type PayloadResult struct { Body io.ReadCloser } -// Extract is a function that takes a PayloadResult's io.Reader body -// and reads all available data into a slice of bytes. Please be aware that due -// to the nature of io.Reader is forward-only - meaning that it can only be read -// once and not rewound. You can recreate a reader from the output of this -// function by using bytes.NewReader(downloadBytes) +// Extract is a method that takes a PayloadResult's io.Reader body and reads +// all available data into a slice of bytes. Please be aware that its io.Reader +// is forward-only - meaning that it can only be read once and not rewound. You +// can recreate a reader from the output of this function by using +// bytes.NewReader(downloadBytes) func (r PayloadResult) Extract() ([]byte, error) { if r.Err != nil { return nil, r.Err @@ -215,7 +215,7 @@ func (r MetadatumResult) Extract() (*Metadatum, error) { } // MetadatumCreateResult is the response from a metadata Create operation. Call -// it's ExtractErr to determine if the request succeeded or failed. +// its ExtractErr method to determine if the request succeeded or failed. // // NOTE: This could be a MetadatumResponse but, at the time of testing, it looks // like Barbican was returning errneous JSON in the response. @@ -224,7 +224,7 @@ type MetadatumCreateResult struct { } // MetadatumDeleteResult is the response from a metadatum Delete operation. Call -// its ExtractErr to determine if the request succeeded or failed. +// its ExtractErr method to determine if the request succeeded or failed. type MetadatumDeleteResult struct { gophercloud.ErrResult } diff --git a/openstack/keymanager/v1/secrets/testing/fixtures.go b/openstack/keymanager/v1/secrets/testing/fixtures_test.go similarity index 100% rename from openstack/keymanager/v1/secrets/testing/fixtures.go rename to openstack/keymanager/v1/secrets/testing/fixtures_test.go diff --git a/openstack/loadbalancer/v2/amphorae/testing/fixtures.go b/openstack/loadbalancer/v2/amphorae/testing/fixtures_test.go similarity index 100% rename from openstack/loadbalancer/v2/amphorae/testing/fixtures.go rename to openstack/loadbalancer/v2/amphorae/testing/fixtures_test.go diff --git a/openstack/loadbalancer/v2/apiversions/results.go b/openstack/loadbalancer/v2/apiversions/results.go index dce4aa5d14..a363e0d5bb 100644 --- a/openstack/loadbalancer/v2/apiversions/results.go +++ b/openstack/loadbalancer/v2/apiversions/results.go @@ -5,7 +5,7 @@ import "github.com/gophercloud/gophercloud/pagination" // APIVersion represents an API version for load balancer. It contains // the status of the API, and its unique ID. type APIVersion struct { - Status string `son:"status"` + Status string `json:"status"` ID string `json:"id"` } diff --git a/openstack/loadbalancer/v2/flavorprofiles/doc.go b/openstack/loadbalancer/v2/flavorprofiles/doc.go new file mode 100644 index 0000000000..fcf846f3c3 --- /dev/null +++ b/openstack/loadbalancer/v2/flavorprofiles/doc.go @@ -0,0 +1,57 @@ +/* +Package flavorprofiles provides information and interaction +with FlavorProfiles for the OpenStack Load-balancing service. + +Example to List FlavorProfiles + + listOpts := flavorprofiles.ListOpts{} + + allPages, err := flavorprofiles.List(octaviaClient, listOpts).AllPages() + if err != nil { + panic(err) + } + + allFlavorProfiles, err := flavorprofiles.ExtractFlavorProfiles(allPages) + if err != nil { + panic(err) + } + + for _, flavorProfile := range allFlavorProfiles { + fmt.Printf("%+v\n", flavorProfile) + } + +Example to Create a FlavorProfile + + createOpts := flavorprofiles.CreateOpts{ + Name: "amphora-single", + ProviderName: "amphora", + FlavorData: "{\"loadbalancer_topology\": \"SINGLE\"}", + } + + flavorProfile, err := flavorprofiles.Create(octaviaClient, createOpts).Extract() + if err != nil { + panic(err) + } + +Example to Update a FlavorProfile + + flavorProfileID := "dd6a26af-8085-4047-a62b-3080f4c76521" + + updateOpts := flavorprofiles.UpdateOpts{ + Name: "amphora-single-updated", + } + + flavorProfile, err := flavorprofiles.Update(octaviaClient, flavorProfileID, updateOpts).Extract() + if err != nil { + panic(err) + } + +Example to Delete a FlavorProfile + + flavorProfileID := "dd6a26af-8085-4047-a62b-3080f4c76521" + err := flavorprofiles.Delete(octaviaClient, flavorProfileID).ExtractErr() + if err != nil { + panic(err) + } +*/ +package flavorprofiles diff --git a/openstack/loadbalancer/v2/flavorprofiles/requests.go b/openstack/loadbalancer/v2/flavorprofiles/requests.go new file mode 100644 index 0000000000..886fb5450d --- /dev/null +++ b/openstack/loadbalancer/v2/flavorprofiles/requests.go @@ -0,0 +1,137 @@ +package flavorprofiles + +import ( + "github.com/gophercloud/gophercloud" + "github.com/gophercloud/gophercloud/pagination" +) + +// ListOptsBuilder allows extensions to add additional parameters to the +// List request. +type ListOptsBuilder interface { + ToFlavorProfileListQuery() (string, error) +} + +// ListOpts allows to manage the output of the request. +type ListOpts struct { + // The fields that you want the server to return + Fields []string `q:"fields"` +} + +// ToFlavorProfileListQuery formats a ListOpts into a query string. +func (opts ListOpts) ToFlavorProfileListQuery() (string, error) { + q, err := gophercloud.BuildQueryString(opts) + return q.String(), err +} + +// List returns a Pager which allows you to iterate over a collection of +// FlavorProfiles. It accepts a ListOpts struct, which allows you to filter +// and sort the returned collection for greater efficiency. +func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { + url := rootURL(c) + if opts != nil { + query, err := opts.ToFlavorProfileListQuery() + if err != nil { + return pagination.Pager{Err: err} + } + url += query + } + return pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page { + return FlavorProfilePage{pagination.LinkedPageBase{PageResult: r}} + }) +} + +// CreateOptsBuilder allows extensions to add additional parameters to the +// Create request. +type CreateOptsBuilder interface { + ToFlavorProfileCreateMap() (map[string]interface{}, error) +} + +// CreateOpts is the common options struct used in this package's Create +// operation. +type CreateOpts struct { + // Human-readable name for the Loadbalancer. Does not have to be unique. + Name string `json:"name" required:"true"` + + // Providing the name of the provider supported by the Octavia installation. + ProviderName string `json:"provider_name" required:"true"` + + // Providing the json string containing the flavor metadata. + FlavorData string `json:"flavor_data" required:"true"` +} + +// ToFlavorProfileCreateMap builds a request body from CreateOpts. +func (opts CreateOpts) ToFlavorProfileCreateMap() (map[string]interface{}, error) { + return gophercloud.BuildRequestBody(opts, "flavorprofile") +} + +// Create is and operation which add a new FlavorProfile into the database. +// CreateResult will be returned. +func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { + b, err := opts.ToFlavorProfileCreateMap() + if err != nil { + r.Err = err + return + } + resp, err := c.Post(rootURL(c), b, &r.Body, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// Get retrieves a particular FlavorProfile based on its unique ID. +func Get(c *gophercloud.ServiceClient, id string) (r GetResult) { + resp, err := c.Get(resourceURL(c, id), &r.Body, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// UpdateOptsBuilder allows extensions to add additional parameters to the +// Update request. +type UpdateOptsBuilder interface { + ToFlavorProfileUpdateMap() (map[string]interface{}, error) +} + +// UpdateOpts is the common options struct used in this package's Update +// operation. +type UpdateOpts struct { + // Human-readable name for the Loadbalancer. Does not have to be unique. + Name string `json:"name,omitempty"` + + // Providing the name of the provider supported by the Octavia installation. + ProviderName string `json:"provider_name,omitempty"` + + // Providing the json string containing the flavor metadata. + FlavorData string `json:"flavor_data,omitempty"` +} + +// ToFlavorProfileUpdateMap builds a request body from UpdateOpts. +func (opts UpdateOpts) ToFlavorProfileUpdateMap() (map[string]interface{}, error) { + b, err := gophercloud.BuildRequestBody(opts, "flavorprofile") + if err != nil { + return nil, err + } + + return b, nil +} + +// Update is an operation which modifies the attributes of the specified +// FlavorProfile. +func Update(c *gophercloud.ServiceClient, id string, opts UpdateOpts) (r UpdateResult) { + b, err := opts.ToFlavorProfileUpdateMap() + if err != nil { + r.Err = err + return + } + resp, err := c.Put(resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{ + OkCodes: []int{200, 202}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// Delete will permanently delete a particular FlavorProfile based on its +// unique ID. +func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) { + resp, err := c.Delete(resourceURL(c, id), nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} diff --git a/openstack/loadbalancer/v2/flavorprofiles/results.go b/openstack/loadbalancer/v2/flavorprofiles/results.go new file mode 100644 index 0000000000..a4d7c11c19 --- /dev/null +++ b/openstack/loadbalancer/v2/flavorprofiles/results.go @@ -0,0 +1,95 @@ +package flavorprofiles + +import ( + "github.com/gophercloud/gophercloud" + "github.com/gophercloud/gophercloud/pagination" +) + +// FlavorProfile provide metadata such as provider, toplogy and instance flavor. +type FlavorProfile struct { + // The unique ID for the Flavor + ID string `json:"id"` + + // Human-readable name for the Flavor. Does not have to be unique. + Name string `json:"name"` + + // Name of the provider + ProviderName string `json:"provider_name"` + + // Flavor data + FlavorData string `json:"flavor_data"` +} + +// FlavorProfilePage is the page returned by a pager when traversing over a +// collection of flavor profiles. +type FlavorProfilePage struct { + pagination.LinkedPageBase +} + +// NextPageURL is invoked when a paginated collection of flavor profiles has +// reached the end of a page and the pager seeks to traverse over a new one. +// In order to do this, it needs to construct the next page's URL. +func (r FlavorProfilePage) NextPageURL() (string, error) { + var s struct { + Links []gophercloud.Link `json:"flavorprofiles_links"` + } + err := r.ExtractInto(&s) + if err != nil { + return "", err + } + return gophercloud.ExtractNextURL(s.Links) +} + +// IsEmpty checks whether a FlavorProfilePage struct is empty. +func (r FlavorProfilePage) IsEmpty() (bool, error) { + is, err := ExtractFlavorProfiles(r) + return len(is) == 0, err +} + +// ExtractFlavorProfiles accepts a Page struct, specifically a FlavorProfilePage +// struct, and extracts the elements into a slice of FlavorProfile structs. In +// other words, a generic collection is mapped into a relevant slice. +func ExtractFlavorProfiles(r pagination.Page) ([]FlavorProfile, error) { + var s struct { + FlavorProfiles []FlavorProfile `json:"flavorprofiles"` + } + err := (r.(FlavorProfilePage)).ExtractInto(&s) + return s.FlavorProfiles, err +} + +type commonResult struct { + gophercloud.Result +} + +// Extract is a function that accepts a result and extracts a flavor profile. +func (r commonResult) Extract() (*FlavorProfile, error) { + var s struct { + FlavorProfile *FlavorProfile `json:"flavorprofile"` + } + err := r.ExtractInto(&s) + return s.FlavorProfile, err +} + +// CreateResult represents the result of a create operation. Call its Extract +// method to interpret it as a FlavorProfile. +type CreateResult struct { + commonResult +} + +// GetResult represents the result of a get operation. Call its Extract +// method to interpret it as a FlavorProfile. +type GetResult struct { + commonResult +} + +// UpdateResult represents the result of an update operation. Call its Extract +// method to interpret it as a FlavorProfile. +type UpdateResult struct { + commonResult +} + +// DeleteResult represents the result of a delete operation. Call its +// ExtractErr method to determine if the request succeeded or failed. +type DeleteResult struct { + gophercloud.ErrResult +} diff --git a/openstack/loadbalancer/v2/flavorprofiles/testing/doc.go b/openstack/loadbalancer/v2/flavorprofiles/testing/doc.go new file mode 100644 index 0000000000..7603f836a0 --- /dev/null +++ b/openstack/loadbalancer/v2/flavorprofiles/testing/doc.go @@ -0,0 +1 @@ +package testing diff --git a/openstack/loadbalancer/v2/flavorprofiles/testing/fixtures.go b/openstack/loadbalancer/v2/flavorprofiles/testing/fixtures.go new file mode 100644 index 0000000000..35c341c576 --- /dev/null +++ b/openstack/loadbalancer/v2/flavorprofiles/testing/fixtures.go @@ -0,0 +1,157 @@ +package testing + +import ( + "fmt" + "net/http" + "testing" + + "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/flavorprofiles" + + th "github.com/gophercloud/gophercloud/testhelper" + "github.com/gophercloud/gophercloud/testhelper/client" +) + +const FlavorProfilesListBody = ` +{ + "flavorprofiles": [ + { + "id": "c55d080d-af45-47ee-b48c-4caa5e87724f", + "name": "amphora-single", + "provider_name": "amphora", + "flavor_data": "{\"loadbalancer_topology\": \"SINGLE\"}" + }, + { + "id": "f78d2815-3714-4b6e-91d8-cf821ba01017", + "name": "amphora-act-stdby", + "provider_name": "amphora", + "flavor_data": "{\"loadbalancer_topology\": \"ACTIVE_STANDBY\"}" + } + ] +} +` + +const SingleFlavorProfileBody = ` +{ + "flavorprofile": { + "id": "dcd65be5-f117-4260-ab3d-b32cc5bd1272", + "name": "amphora-test", + "provider_name": "amphora", + "flavor_data": "{\"loadbalancer_topology\": \"ACTIVE_STANDBY\"}" + } +} +` + +const PostUpdateFlavorBody = ` +{ + "flavorprofile": { + "id": "dcd65be5-f117-4260-ab3d-b32cc5bd1272", + "name": "amphora-test-updated", + "provider_name": "amphora", + "flavor_data": "{\"loadbalancer_topology\": \"SINGLE\"}" + } +} +` + +var ( + FlavorProfileSingle = flavorprofiles.FlavorProfile{ + ID: "c55d080d-af45-47ee-b48c-4caa5e87724f", + Name: "amphora-single", + ProviderName: "amphora", + FlavorData: "{\"loadbalancer_topology\": \"SINGLE\"}", + } + + FlavorProfileAct = flavorprofiles.FlavorProfile{ + ID: "f78d2815-3714-4b6e-91d8-cf821ba01017", + Name: "amphora-act-stdby", + ProviderName: "amphora", + FlavorData: "{\"loadbalancer_topology\": \"ACTIVE_STANDBY\"}", + } + + FlavorDb = flavorprofiles.FlavorProfile{ + ID: "dcd65be5-f117-4260-ab3d-b32cc5bd1272", + Name: "amphora-test", + ProviderName: "amphora", + FlavorData: "{\"loadbalancer_topology\": \"ACTIVE_STANDBY\"}", + } + + FlavorUpdated = flavorprofiles.FlavorProfile{ + ID: "dcd65be5-f117-4260-ab3d-b32cc5bd1272", + Name: "amphora-test-updated", + ProviderName: "amphora", + FlavorData: "{\"loadbalancer_topology\": \"SINGLE\"}", + } +) + +func HandleFlavorProfileListSuccessfully(t *testing.T) { + th.Mux.HandleFunc("/v2.0/lbaas/flavorprofiles", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "GET") + th.TestHeader(t, r, "X-Auth-Token", client.TokenID) + + w.Header().Add("Content-Type", "application/json") + r.ParseForm() + marker := r.Form.Get("marker") + switch marker { + case "": + fmt.Fprintf(w, FlavorProfilesListBody) + case "3a0d060b-fcec-4250-9ab6-940b806a12dd": + fmt.Fprintf(w, `{ "flavors": [] }`) + default: + t.Fatalf("/v2.0/lbaas/flavors invoked with unexpected marker=[%s]", marker) + } + }) +} + +func HandleFlavorProfileCreationSuccessfully(t *testing.T, response string) { + th.Mux.HandleFunc("/v2.0/lbaas/flavorprofiles", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "POST") + th.TestHeader(t, r, "X-Auth-Token", client.TokenID) + th.TestJSONRequest(t, r, `{ + "flavorprofile": { + "name": "amphora-test", + "provider_name": "amphora", + "flavor_data": "{\"loadbalancer_topology\": \"ACTIVE_STANDBY\"}" + } + }`) + + w.WriteHeader(http.StatusAccepted) + w.Header().Add("Content-Type", "application/json") + fmt.Fprintf(w, response) + }) +} + +func HandleFlavorProfileGetSuccessfully(t *testing.T) { + th.Mux.HandleFunc("/v2.0/lbaas/flavorprofiles/dcd65be5-f117-4260-ab3d-b32cc5bd1272", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "GET") + th.TestHeader(t, r, "X-Auth-Token", client.TokenID) + th.TestHeader(t, r, "Accept", "application/json") + + fmt.Fprintf(w, SingleFlavorProfileBody) + }) +} + +func HandleFlavorProfileDeletionSuccessfully(t *testing.T) { + th.Mux.HandleFunc("/v2.0/lbaas/flavorprofiles/dcd65be5-f117-4260-ab3d-b32cc5bd1272", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "DELETE") + th.TestHeader(t, r, "X-Auth-Token", client.TokenID) + + w.WriteHeader(http.StatusNoContent) + }) +} + +func HandleFlavorProfileUpdateSuccessfully(t *testing.T) { + th.Mux.HandleFunc("/v2.0/lbaas/flavorprofiles/dcd65be5-f117-4260-ab3d-b32cc5bd1272", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "PUT") + th.TestHeader(t, r, "X-Auth-Token", client.TokenID) + th.TestHeader(t, r, "Accept", "application/json") + th.TestHeader(t, r, "Content-Type", "application/json") + th.TestJSONRequest(t, r, `{ + "flavorprofile": { + "name": "amphora-test-updated", + "provider_name": "amphora", + "flavor_data": "{\"loadbalancer_topology\": \"SINGLE\"}" + } + }`) + + fmt.Fprintf(w, PostUpdateFlavorBody) + }) +} diff --git a/openstack/loadbalancer/v2/flavorprofiles/testing/requests_test.go b/openstack/loadbalancer/v2/flavorprofiles/testing/requests_test.go new file mode 100644 index 0000000000..1b30e2ff07 --- /dev/null +++ b/openstack/loadbalancer/v2/flavorprofiles/testing/requests_test.go @@ -0,0 +1,117 @@ +package testing + +import ( + "testing" + + "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/flavorprofiles" + "github.com/gophercloud/gophercloud/pagination" + + fake "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/testhelper" + th "github.com/gophercloud/gophercloud/testhelper" +) + +func TestListFlavorProfiles(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + HandleFlavorProfileListSuccessfully(t) + + pages := 0 + err := flavorprofiles.List(fake.ServiceClient(), flavorprofiles.ListOpts{}).EachPage(func(page pagination.Page) (bool, error) { + pages++ + + actual, err := flavorprofiles.ExtractFlavorProfiles(page) + if err != nil { + return false, err + } + + if len(actual) != 2 { + t.Fatalf("Expected 2 flavors, got %d", len(actual)) + } + th.CheckDeepEquals(t, FlavorProfileSingle, actual[0]) + th.CheckDeepEquals(t, FlavorProfileAct, actual[1]) + + return true, nil + }) + + th.AssertNoErr(t, err) + + if pages != 1 { + t.Errorf("Expected 1 page, saw %d", pages) + } +} + +func TestListAllFlavorProfiles(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + HandleFlavorProfileListSuccessfully(t) + + allPages, err := flavorprofiles.List(fake.ServiceClient(), flavorprofiles.ListOpts{}).AllPages() + th.AssertNoErr(t, err) + actual, err := flavorprofiles.ExtractFlavorProfiles(allPages) + th.AssertNoErr(t, err) + th.CheckDeepEquals(t, FlavorProfileSingle, actual[0]) + th.CheckDeepEquals(t, FlavorProfileAct, actual[1]) +} + +func TestCreateFlavorProfile(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + HandleFlavorProfileCreationSuccessfully(t, SingleFlavorProfileBody) + + actual, err := flavorprofiles.Create(fake.ServiceClient(), flavorprofiles.CreateOpts{ + Name: "amphora-test", + ProviderName: "amphora", + FlavorData: "{\"loadbalancer_topology\": \"ACTIVE_STANDBY\"}", + }).Extract() + th.AssertNoErr(t, err) + + th.CheckDeepEquals(t, FlavorDb, *actual) +} + +func TestRequiredCreateOpts(t *testing.T) { + res := flavorprofiles.Create(fake.ServiceClient(), flavorprofiles.CreateOpts{}) + if res.Err == nil { + t.Fatalf("Expected error, got none") + } +} + +func TestGetFlavorProfiles(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + HandleFlavorProfileGetSuccessfully(t) + + client := fake.ServiceClient() + actual, err := flavorprofiles.Get(client, "dcd65be5-f117-4260-ab3d-b32cc5bd1272").Extract() + if err != nil { + t.Fatalf("Unexpected Get error: %v", err) + } + + th.CheckDeepEquals(t, FlavorDb, *actual) +} + +func TestDeleteFlavorProfile(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + HandleFlavorProfileDeletionSuccessfully(t) + + res := flavorprofiles.Delete(fake.ServiceClient(), "dcd65be5-f117-4260-ab3d-b32cc5bd1272") + th.AssertNoErr(t, res.Err) +} + +func TestUpdateFlavorProfile(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + HandleFlavorProfileUpdateSuccessfully(t) + + client := fake.ServiceClient() + actual, err := flavorprofiles.Update(client, "dcd65be5-f117-4260-ab3d-b32cc5bd1272", flavorprofiles.UpdateOpts{ + Name: "amphora-test-updated", + ProviderName: "amphora", + FlavorData: "{\"loadbalancer_topology\": \"SINGLE\"}", + }).Extract() + if err != nil { + t.Fatalf("Unexpected Update error: %v", err) + } + + th.CheckDeepEquals(t, FlavorUpdated, *actual) +} diff --git a/openstack/loadbalancer/v2/flavorprofiles/urls.go b/openstack/loadbalancer/v2/flavorprofiles/urls.go new file mode 100644 index 0000000000..6125d77923 --- /dev/null +++ b/openstack/loadbalancer/v2/flavorprofiles/urls.go @@ -0,0 +1,16 @@ +package flavorprofiles + +import "github.com/gophercloud/gophercloud" + +const ( + rootPath = "lbaas" + resourcePath = "flavorprofiles" +) + +func rootURL(c *gophercloud.ServiceClient) string { + return c.ServiceURL(rootPath, resourcePath) +} + +func resourceURL(c *gophercloud.ServiceClient, id string) string { + return c.ServiceURL(rootPath, resourcePath, id) +} diff --git a/openstack/loadbalancer/v2/flavors/doc.go b/openstack/loadbalancer/v2/flavors/doc.go new file mode 100644 index 0000000000..cbdd127f55 --- /dev/null +++ b/openstack/loadbalancer/v2/flavors/doc.go @@ -0,0 +1,58 @@ +/* +Package flavors provides information and interaction with Flavors +for the OpenStack Load-balancing service. + +Example to List Flavors + + listOpts := flavors.ListOpts{} + + allPages, err := flavors.List(octaviaClient, listOpts).AllPages() + if err != nil { + panic(err) + } + + allFlavors, err := flavors.ExtractFlavors(allPages) + if err != nil { + panic(err) + } + + for _, flavor := range allFlavors { + fmt.Printf("%+v\n", flavor) + } + +Example to Create a Flavor + + createOpts := flavors.CreateOpts{ + Name: "Flavor name", + Description: "My flavor description", + Enable: true, + FlavorProfileId: "9daa2768-74e7-4d13-bf5d-1b8e0dc239e1", + } + + flavor, err := flavors.Create(octaviaClient, createOpts).Extract() + if err != nil { + panic(err) + } + +Example to Update a Flavor + + flavorID := "d67d56a6-4a86-4688-a282-f46444705c64" + + updateOpts := flavors.UpdateOpts{ + Name: "New name", + } + + flavor, err := flavors.Update(octaviaClient, flavorID, updateOpts).Extract() + if err != nil { + panic(err) + } + +Example to Delete a Flavor + + flavorID := "d67d56a6-4a86-4688-a282-f46444705c64" + err := flavors.Delete(octaviaClient, flavorID).ExtractErr() + if err != nil { + panic(err) + } +*/ +package flavors diff --git a/openstack/loadbalancer/v2/flavors/requests.go b/openstack/loadbalancer/v2/flavors/requests.go new file mode 100644 index 0000000000..0b9509c320 --- /dev/null +++ b/openstack/loadbalancer/v2/flavors/requests.go @@ -0,0 +1,141 @@ +package flavors + +import ( + "github.com/gophercloud/gophercloud" + "github.com/gophercloud/gophercloud/pagination" +) + +// ListOptsBuilder allows extensions to add additional parameters to the +// List request. +type ListOptsBuilder interface { + ToFlavorListQuery() (string, error) +} + +// ListOpts allows to manage the output of the request. +type ListOpts struct { + // The fields that you want the server to return + Fields []string `q:"fields"` +} + +// ToFlavorListQuery formats a ListOpts into a query string. +func (opts ListOpts) ToFlavorListQuery() (string, error) { + q, err := gophercloud.BuildQueryString(opts) + return q.String(), err +} + +// List returns a Pager which allows you to iterate over a collection of +// Flavor. It accepts a ListOpts struct, which allows you to filter +// and sort the returned collection for greater efficiency. +func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { + url := rootURL(c) + if opts != nil { + query, err := opts.ToFlavorListQuery() + if err != nil { + return pagination.Pager{Err: err} + } + url += query + } + return pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page { + return FlavorPage{pagination.LinkedPageBase{PageResult: r}} + }) +} + +// CreateOptsBuilder allows extensions to add additional parameters to the +// Create request. +type CreateOptsBuilder interface { + ToFlavorCreateMap() (map[string]interface{}, error) +} + +// CreateOpts is the common options struct used in this package's Create +// operation. +type CreateOpts struct { + // Human-readable name for the Loadbalancer. Does not have to be unique. + Name string `json:"name" required:"true"` + + // Human-readable description for the Flavor. + Description string `json:"description,omitempty"` + + // The ID of the FlavorProfile which give the metadata for the creation of + // a LoadBalancer. + FlavorProfileId string `json:"flavor_profile_id" required:"true"` + + // If the resource is available for use. The default is True. + Enabled bool `json:"enabled,omitempty"` +} + +// ToFlavorCreateMap builds a request body from CreateOpts. +func (opts CreateOpts) ToFlavorCreateMap() (map[string]interface{}, error) { + return gophercloud.BuildRequestBody(opts, "flavor") +} + +// Create is and operation which add a new Flavor into the database. +// CreateResult will be returned. +func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { + b, err := opts.ToFlavorCreateMap() + if err != nil { + r.Err = err + return + } + resp, err := c.Post(rootURL(c), b, &r.Body, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// Get retrieves a particular Flavor based on its unique ID. +func Get(c *gophercloud.ServiceClient, id string) (r GetResult) { + resp, err := c.Get(resourceURL(c, id), &r.Body, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// UpdateOptsBuilder allows extensions to add additional parameters to the +// Update request. +type UpdateOptsBuilder interface { + ToFlavorUpdateMap() (map[string]interface{}, error) +} + +// UpdateOpts is the common options struct used in this package's Update +// operation. +type UpdateOpts struct { + // Human-readable name for the Loadbalancer. Does not have to be unique. + Name string `json:"name,omitempty"` + + // Human-readable description for the Flavor. + Description string `json:"description,omitempty"` + + // If the resource is available for use. + Enabled bool `json:"enabled,omitempty"` +} + +// ToFlavorUpdateMap builds a request body from UpdateOpts. +func (opts UpdateOpts) ToFlavorUpdateMap() (map[string]interface{}, error) { + b, err := gophercloud.BuildRequestBody(opts, "flavor") + if err != nil { + return nil, err + } + + return b, nil +} + +// Update is an operation which modifies the attributes of the specified +// Flavor. +func Update(c *gophercloud.ServiceClient, id string, opts UpdateOpts) (r UpdateResult) { + b, err := opts.ToFlavorUpdateMap() + if err != nil { + r.Err = err + return + } + resp, err := c.Put(resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{ + OkCodes: []int{200}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// Delete will permanently delete a particular Flavor based on its +// unique ID. +func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) { + resp, err := c.Delete(resourceURL(c, id), nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} diff --git a/openstack/loadbalancer/v2/flavors/results.go b/openstack/loadbalancer/v2/flavors/results.go new file mode 100644 index 0000000000..21c517154d --- /dev/null +++ b/openstack/loadbalancer/v2/flavors/results.go @@ -0,0 +1,98 @@ +package flavors + +import ( + "github.com/gophercloud/gophercloud" + "github.com/gophercloud/gophercloud/pagination" +) + +// Flavor provide specs for the creation of a load balancer. +type Flavor struct { + // The unique ID for the Flavor + ID string `json:"id"` + + // Human-readable name for the Flavor. Does not have to be unique. + Name string `json:"name"` + + // Human-readable description for the Flavor. + Description string `json:"description"` + + // Status of the Flavor. + Enabled bool `json:"enabled"` + + // Flavor Profile apply to this Flavor. + FlavorProfileId string `json:"flavor_profile_id"` +} + +// FlavorPage is the page returned by a pager when traversing over a +// collection of flavors. +type FlavorPage struct { + pagination.LinkedPageBase +} + +// NextPageURL is invoked when a paginated collection of flavors has +// reached the end of a page and the pager seeks to traverse over a new one. +// In order to do this, it needs to construct the next page's URL. +func (r FlavorPage) NextPageURL() (string, error) { + var s struct { + Links []gophercloud.Link `json:"flavors_links"` + } + err := r.ExtractInto(&s) + if err != nil { + return "", err + } + return gophercloud.ExtractNextURL(s.Links) +} + +// IsEmpty checks whether a FlavorPage struct is empty. +func (r FlavorPage) IsEmpty() (bool, error) { + is, err := ExtractFlavors(r) + return len(is) == 0, err +} + +// ExtractFlavors accepts a Page struct, specifically a FlavorPage +// struct, and extracts the elements into a slice of Flavor structs. In +// other words, a generic collection is mapped into a relevant slice. +func ExtractFlavors(r pagination.Page) ([]Flavor, error) { + var s struct { + Flavors []Flavor `json:"flavors"` + } + err := (r.(FlavorPage)).ExtractInto(&s) + return s.Flavors, err +} + +type commonResult struct { + gophercloud.Result +} + +// Extract is a function that accepts a result and extracts a flavor. +func (r commonResult) Extract() (*Flavor, error) { + var s struct { + Flavor *Flavor `json:"flavor"` + } + err := r.ExtractInto(&s) + return s.Flavor, err +} + +// CreateResult represents the result of a create operation. Call its Extract +// method to interpret it as a Flavor. +type CreateResult struct { + commonResult +} + +// GetResult represents the result of a get operation. Call its Extract +// method to interpret it as a Flavor. +type GetResult struct { + commonResult +} + +// UpdateResult represents the result of an update operation. Call its Extract +// method to interpret it as a Flavor. +type UpdateResult struct { + commonResult +} + +// DeleteResult represents the result of a delete operation. Call its +// ExtractErr method to determine if the request succeeded or failed. +type DeleteResult struct { + gophercloud.ErrResult +} diff --git a/openstack/loadbalancer/v2/flavors/testing/doc.go b/openstack/loadbalancer/v2/flavors/testing/doc.go new file mode 100644 index 0000000000..7603f836a0 --- /dev/null +++ b/openstack/loadbalancer/v2/flavors/testing/doc.go @@ -0,0 +1 @@ +package testing diff --git a/openstack/loadbalancer/v2/flavors/testing/fixtures.go b/openstack/loadbalancer/v2/flavors/testing/fixtures.go new file mode 100644 index 0000000000..42e2fc96a0 --- /dev/null +++ b/openstack/loadbalancer/v2/flavors/testing/fixtures.go @@ -0,0 +1,166 @@ +package testing + +import ( + "fmt" + "net/http" + "testing" + + "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/flavors" + + th "github.com/gophercloud/gophercloud/testhelper" + "github.com/gophercloud/gophercloud/testhelper/client" +) + +const FlavorsListBody = ` +{ + "flavors": [ + { + "id": "4c82a610-8c7f-4a72-8cca-42f584e3f6d1", + "name": "Basic", + "description": "A basic standalone Octavia load balancer.", + "enabled": true, + "flavor_profile_id": "bdba88c7-beab-4fc9-a5dd-3635de59185b" + }, + { + "id": "0af3b9cc-9284-44c2-9494-0ec337fa31bb", + "name": "Advance", + "description": "A advance standalone Octavia load balancer.", + "enabled": false, + "flavor_profile_id": "c221abc6-a845-45a0-925c-27110c9d7bdc" + } + ] +} +` + +const SingleFlavorBody = ` +{ + "flavor": { + "id": "5548c807-e6e8-43d7-9ea4-b38d34dd74a0", + "name": "Basic", + "description": "A basic standalone Octavia load balancer.", + "enabled": true, + "flavor_profile_id": "9daa2768-74e7-4d13-bf5d-1b8e0dc239e1" + } +} +` + +const PostUpdateFlavorBody = ` +{ + "flavor": { + "id": "5548c807-e6e8-43d7-9ea4-b38d34dd74a0", + "name": "Basic v2", + "description": "Rename flavor", + "enabled": false, + "flavor_profile_id": "9daa2768-74e7-4d13-bf5d-1b8e0dc239e1" + } +} +` + +var ( + FlavorBasic = flavors.Flavor{ + ID: "4c82a610-8c7f-4a72-8cca-42f584e3f6d1", + Name: "Basic", + Description: "A basic standalone Octavia load balancer.", + Enabled: true, + FlavorProfileId: "bdba88c7-beab-4fc9-a5dd-3635de59185b", + } + + FlavorAdvance = flavors.Flavor{ + ID: "0af3b9cc-9284-44c2-9494-0ec337fa31bb", + Name: "Advance", + Description: "A advance standalone Octavia load balancer.", + Enabled: false, + FlavorProfileId: "c221abc6-a845-45a0-925c-27110c9d7bdc", + } + + FlavorDb = flavors.Flavor{ + ID: "5548c807-e6e8-43d7-9ea4-b38d34dd74a0", + Name: "Basic", + Description: "A basic standalone Octavia load balancer.", + Enabled: true, + FlavorProfileId: "9daa2768-74e7-4d13-bf5d-1b8e0dc239e1", + } + + FlavorUpdated = flavors.Flavor{ + ID: "5548c807-e6e8-43d7-9ea4-b38d34dd74a0", + Name: "Basic v2", + Description: "Rename flavor", + Enabled: false, + FlavorProfileId: "9daa2768-74e7-4d13-bf5d-1b8e0dc239e1", + } +) + +func HandleFlavorListSuccessfully(t *testing.T) { + th.Mux.HandleFunc("/v2.0/lbaas/flavors", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "GET") + th.TestHeader(t, r, "X-Auth-Token", client.TokenID) + + w.Header().Add("Content-Type", "application/json") + r.ParseForm() + marker := r.Form.Get("marker") + switch marker { + case "": + fmt.Fprintf(w, FlavorsListBody) + case "3a0d060b-fcec-4250-9ab6-940b806a12dd": + fmt.Fprintf(w, `{ "flavors": [] }`) + default: + t.Fatalf("/v2.0/lbaas/flavors invoked with unexpected marker=[%s]", marker) + } + }) +} + +func HandleFlavorCreationSuccessfully(t *testing.T, response string) { + th.Mux.HandleFunc("/v2.0/lbaas/flavors", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "POST") + th.TestHeader(t, r, "X-Auth-Token", client.TokenID) + th.TestJSONRequest(t, r, `{ + "flavor": { + "name": "Basic", + "description": "A basic standalone Octavia load balancer.", + "enabled": true, + "flavor_profile_id": "9daa2768-74e7-4d13-bf5d-1b8e0dc239e1" + } + }`) + + w.WriteHeader(http.StatusAccepted) + w.Header().Add("Content-Type", "application/json") + fmt.Fprintf(w, response) + }) +} + +func HandleFlavorGetSuccessfully(t *testing.T) { + th.Mux.HandleFunc("/v2.0/lbaas/flavors/5548c807-e6e8-43d7-9ea4-b38d34dd74a0", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "GET") + th.TestHeader(t, r, "X-Auth-Token", client.TokenID) + th.TestHeader(t, r, "Accept", "application/json") + + fmt.Fprintf(w, SingleFlavorBody) + }) +} + +func HandleFlavorDeletionSuccessfully(t *testing.T) { + th.Mux.HandleFunc("/v2.0/lbaas/flavors/5548c807-e6e8-43d7-9ea4-b38d34dd74a0", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "DELETE") + th.TestHeader(t, r, "X-Auth-Token", client.TokenID) + + w.WriteHeader(http.StatusNoContent) + }) +} + +func HandleFlavorUpdateSuccessfully(t *testing.T) { + th.Mux.HandleFunc("/v2.0/lbaas/flavors/5548c807-e6e8-43d7-9ea4-b38d34dd74a0", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "PUT") + th.TestHeader(t, r, "X-Auth-Token", client.TokenID) + th.TestHeader(t, r, "Accept", "application/json") + th.TestHeader(t, r, "Content-Type", "application/json") + th.TestJSONRequest(t, r, `{ + "flavor": { + "name": "Basic v2", + "description": "Rename flavor", + "enabled": true + } + }`) + + fmt.Fprintf(w, PostUpdateFlavorBody) + }) +} diff --git a/openstack/loadbalancer/v2/flavors/testing/requests_test.go b/openstack/loadbalancer/v2/flavors/testing/requests_test.go new file mode 100644 index 0000000000..b04f3056f8 --- /dev/null +++ b/openstack/loadbalancer/v2/flavors/testing/requests_test.go @@ -0,0 +1,118 @@ +package testing + +import ( + "testing" + + "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/flavors" + "github.com/gophercloud/gophercloud/pagination" + + fake "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/testhelper" + th "github.com/gophercloud/gophercloud/testhelper" +) + +func TestListFlavors(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + HandleFlavorListSuccessfully(t) + + pages := 0 + err := flavors.List(fake.ServiceClient(), flavors.ListOpts{}).EachPage(func(page pagination.Page) (bool, error) { + pages++ + + actual, err := flavors.ExtractFlavors(page) + if err != nil { + return false, err + } + + if len(actual) != 2 { + t.Fatalf("Expected 2 flavors, got %d", len(actual)) + } + th.CheckDeepEquals(t, FlavorBasic, actual[0]) + th.CheckDeepEquals(t, FlavorAdvance, actual[1]) + + return true, nil + }) + + th.AssertNoErr(t, err) + + if pages != 1 { + t.Errorf("Expected 1 page, saw %d", pages) + } +} + +func TestListAllFlavors(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + HandleFlavorListSuccessfully(t) + + allPages, err := flavors.List(fake.ServiceClient(), flavors.ListOpts{}).AllPages() + th.AssertNoErr(t, err) + actual, err := flavors.ExtractFlavors(allPages) + th.AssertNoErr(t, err) + th.CheckDeepEquals(t, FlavorBasic, actual[0]) + th.CheckDeepEquals(t, FlavorAdvance, actual[1]) +} + +func TestCreateFlavor(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + HandleFlavorCreationSuccessfully(t, SingleFlavorBody) + + actual, err := flavors.Create(fake.ServiceClient(), flavors.CreateOpts{ + Name: "Basic", + Description: "A basic standalone Octavia load balancer.", + Enabled: true, + FlavorProfileId: "9daa2768-74e7-4d13-bf5d-1b8e0dc239e1", + }).Extract() + th.AssertNoErr(t, err) + + th.CheckDeepEquals(t, FlavorDb, *actual) +} + +func TestRequiredCreateOpts(t *testing.T) { + res := flavors.Create(fake.ServiceClient(), flavors.CreateOpts{}) + if res.Err == nil { + t.Fatalf("Expected error, got none") + } +} + +func TestGetFlavor(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + HandleFlavorGetSuccessfully(t) + + client := fake.ServiceClient() + actual, err := flavors.Get(client, "5548c807-e6e8-43d7-9ea4-b38d34dd74a0").Extract() + if err != nil { + t.Fatalf("Unexpected Get error: %v", err) + } + + th.CheckDeepEquals(t, FlavorDb, *actual) +} + +func TestDeleteFlavor(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + HandleFlavorDeletionSuccessfully(t) + + res := flavors.Delete(fake.ServiceClient(), "5548c807-e6e8-43d7-9ea4-b38d34dd74a0") + th.AssertNoErr(t, res.Err) +} + +func TestUpdateFlavor(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + HandleFlavorUpdateSuccessfully(t) + + client := fake.ServiceClient() + actual, err := flavors.Update(client, "5548c807-e6e8-43d7-9ea4-b38d34dd74a0", flavors.UpdateOpts{ + Name: "Basic v2", + Description: "Rename flavor", + Enabled: true, + }).Extract() + if err != nil { + t.Fatalf("Unexpected Update error: %v", err) + } + + th.CheckDeepEquals(t, FlavorUpdated, *actual) +} diff --git a/openstack/loadbalancer/v2/flavors/urls.go b/openstack/loadbalancer/v2/flavors/urls.go new file mode 100644 index 0000000000..5d9a84b1ff --- /dev/null +++ b/openstack/loadbalancer/v2/flavors/urls.go @@ -0,0 +1,16 @@ +package flavors + +import "github.com/gophercloud/gophercloud" + +const ( + rootPath = "lbaas" + resourcePath = "flavors" +) + +func rootURL(c *gophercloud.ServiceClient) string { + return c.ServiceURL(rootPath, resourcePath) +} + +func resourceURL(c *gophercloud.ServiceClient, id string) string { + return c.ServiceURL(rootPath, resourcePath, id) +} diff --git a/openstack/loadbalancer/v2/l7policies/testing/fixtures.go b/openstack/loadbalancer/v2/l7policies/testing/fixtures_test.go similarity index 100% rename from openstack/loadbalancer/v2/l7policies/testing/fixtures.go rename to openstack/loadbalancer/v2/l7policies/testing/fixtures_test.go diff --git a/openstack/loadbalancer/v2/listeners/testing/fixtures.go b/openstack/loadbalancer/v2/listeners/testing/fixtures_test.go similarity index 100% rename from openstack/loadbalancer/v2/listeners/testing/fixtures.go rename to openstack/loadbalancer/v2/listeners/testing/fixtures_test.go diff --git a/openstack/loadbalancer/v2/loadbalancers/testing/fixtures.go b/openstack/loadbalancer/v2/loadbalancers/testing/fixtures_test.go similarity index 100% rename from openstack/loadbalancer/v2/loadbalancers/testing/fixtures.go rename to openstack/loadbalancer/v2/loadbalancers/testing/fixtures_test.go diff --git a/openstack/loadbalancer/v2/monitors/testing/fixtures.go b/openstack/loadbalancer/v2/monitors/testing/fixtures_test.go similarity index 100% rename from openstack/loadbalancer/v2/monitors/testing/fixtures.go rename to openstack/loadbalancer/v2/monitors/testing/fixtures_test.go diff --git a/openstack/loadbalancer/v2/pools/testing/fixtures.go b/openstack/loadbalancer/v2/pools/testing/fixtures_test.go similarity index 100% rename from openstack/loadbalancer/v2/pools/testing/fixtures.go rename to openstack/loadbalancer/v2/pools/testing/fixtures_test.go diff --git a/openstack/loadbalancer/v2/providers/testing/fixtures.go b/openstack/loadbalancer/v2/providers/testing/fixtures_test.go similarity index 100% rename from openstack/loadbalancer/v2/providers/testing/fixtures.go rename to openstack/loadbalancer/v2/providers/testing/fixtures_test.go diff --git a/openstack/loadbalancer/v2/quotas/testing/fixtures.go b/openstack/loadbalancer/v2/quotas/testing/fixtures_test.go similarity index 100% rename from openstack/loadbalancer/v2/quotas/testing/fixtures.go rename to openstack/loadbalancer/v2/quotas/testing/fixtures_test.go diff --git a/openstack/messaging/v2/claims/testing/fixtures.go b/openstack/messaging/v2/claims/testing/fixtures_test.go similarity index 100% rename from openstack/messaging/v2/claims/testing/fixtures.go rename to openstack/messaging/v2/claims/testing/fixtures_test.go diff --git a/openstack/messaging/v2/messages/testing/fixtures.go b/openstack/messaging/v2/messages/testing/fixtures_test.go similarity index 100% rename from openstack/messaging/v2/messages/testing/fixtures.go rename to openstack/messaging/v2/messages/testing/fixtures_test.go diff --git a/openstack/messaging/v2/queues/testing/fixtures.go b/openstack/messaging/v2/queues/testing/fixtures_test.go similarity index 100% rename from openstack/messaging/v2/queues/testing/fixtures.go rename to openstack/messaging/v2/queues/testing/fixtures_test.go diff --git a/openstack/networking/v2/apiversions/results.go b/openstack/networking/v2/apiversions/results.go index ad9d092fa0..93163047ae 100644 --- a/openstack/networking/v2/apiversions/results.go +++ b/openstack/networking/v2/apiversions/results.go @@ -7,7 +7,7 @@ import ( // APIVersion represents an API version for Neutron. It contains the status of // the API, and its unique ID. type APIVersion struct { - Status string `son:"status"` + Status string `json:"status"` ID string `json:"id"` } diff --git a/openstack/networking/v2/extensions/agents/testing/fixtures.go b/openstack/networking/v2/extensions/agents/testing/fixtures_test.go similarity index 100% rename from openstack/networking/v2/extensions/agents/testing/fixtures.go rename to openstack/networking/v2/extensions/agents/testing/fixtures_test.go diff --git a/openstack/networking/v2/extensions/attributestags/testing/fixtures.go b/openstack/networking/v2/extensions/attributestags/testing/fixtures_test.go similarity index 100% rename from openstack/networking/v2/extensions/attributestags/testing/fixtures.go rename to openstack/networking/v2/extensions/attributestags/testing/fixtures_test.go diff --git a/openstack/networking/v2/extensions/bgpvpns/doc.go b/openstack/networking/v2/extensions/bgpvpns/doc.go new file mode 100644 index 0000000000..cdb85dc101 --- /dev/null +++ b/openstack/networking/v2/extensions/bgpvpns/doc.go @@ -0,0 +1,66 @@ +package bgpvpns + +/* +Package bgpvpns contains the functionality for working with Neutron BGP VPNs. + +1. List BGP VPNs, a.k.a. GET /bgpvpn/bgpvpns + +Example: + + pages, err := bgpvpns.List(client).AllPages(context.TODO()) + if err != nil { + log.Panic(err) + } + allVPNs, err := bgpvpns.ExtractBGPVPNs(pages) + if err != nil { + log.Panic(err) + } + + for _, bgpvpn := range allVPNs { + log.Printf("%+v", bgpvpn) + } + +2. Get BGP VPN, a.k.a. GET /bgpvpn/bgpvpns/{id} + +Example: + p, err := bgpvpns.Get(context.TODO(), client, id).Extract() + if err != nil { + log.Panic(err) + } + log.Printf("%+v", *p) + +3. Create BGP VPN, a.k.a. POST /bgpvpn/bgpvpns + +Example: + opts := bgpvpns.CreateOpts{ + name: "gophercloud-testing-bgpvpn". + } + r, err := bgpvpns.Create(context.TODO(), client, opts).Extract() + if err != nil { + log.Panic(err) + } + log.Printf("%+v", *r) + +4. Delete BGP VPN, a.k.a. DELETE /bgpvpn/bgpvpns/{id} + +Example: + err := bgpvpns.Delete(context.TODO(), client, bgpVpnID).ExtractErr() + if err != nil { + log.Panic(err) + } + log.Printf("BGP VPN deleted") + + +5. Update BGP VPN, a.k.a. PUT /bgpvpn/bgpvpns/{id} + +Example: + nameUpdated := "bgpvpn-name-updated" + opts := bgpvpns.UpdateOpts{ + name: &nameUpdated, + } + p, err := bgpvpns.Update(context.TODO(), client, id, opts).Extract() + if err != nil { + log.Panic(err) + } + log.Printf("%+v", p) +*/ diff --git a/openstack/networking/v2/extensions/bgpvpns/requests.go b/openstack/networking/v2/extensions/bgpvpns/requests.go new file mode 100644 index 0000000000..dce09fde1b --- /dev/null +++ b/openstack/networking/v2/extensions/bgpvpns/requests.go @@ -0,0 +1,476 @@ +package bgpvpns + +import ( + "github.com/gophercloud/gophercloud" + "github.com/gophercloud/gophercloud/pagination" +) + +// ListOptsBuilder allows extensions to add additional parameters to the List +// request. +type ListOptsBuilder interface { + ToBGPVPNListQuery() (string, error) +} + +// ListOpts allows the filtering and sorting of paginated collections through the API. +type ListOpts struct { + Fields []string `q:"fields"` + ProjectID string `q:"project_id"` + Networks []string `q:"networks"` + Routers []string `q:"routers"` + Ports []string `q:"ports"` + Limit int `q:"limit"` + Marker string `q:"marker"` +} + +// ToBGPVPNListQuery formats a ListOpts into a query string. +func (opts ListOpts) ToBGPVPNListQuery() (string, error) { + q, err := gophercloud.BuildQueryString(opts) + if err != nil { + return "", err + } + return q.String(), nil +} + +// List the BGP VPNs +func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { + url := listURL(c) + query, err := opts.ToBGPVPNListQuery() + if err != nil { + return pagination.Pager{Err: err} + } + url += query + return pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page { + p := BGPVPNPage{pagination.MarkerPageBase{PageResult: r}} + p.MarkerPageBase.Owner = p + return p + }) +} + +// Get retrieve the specific BGP VPN by its uuid +func Get(c *gophercloud.ServiceClient, id string) (r GetResult) { + resp, err := c.Get(getURL(c, id), &r.Body, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// CreateOptsBuilder allows extensions to add additional parameters to the +// Create request. +type CreateOptsBuilder interface { + ToBGPVPNCreateMap() (map[string]interface{}, error) +} + +// CreateOpts represents options used to create a BGP VPN. +type CreateOpts struct { + Name string `json:"name,omitempty"` + RouteDistinguishers []string `json:"route_distinguishers,omitempty"` + RouteTargets []string `json:"route_targets,omitempty"` + ImportTargets []string `json:"import_targets,omitempty"` + ExportTargets []string `json:"export_targets,omitempty"` + LocalPref int `json:"local_pref,omitempty"` + VNI int `json:"vni,omitempty"` + TenantID string `json:"tenant_id,omitempty"` + ProjectID string `json:"project_id,omitempty"` + Type string `json:"type,omitempty"` +} + +// ToBGPVPNCreateMap builds a request body from CreateOpts. +func (opts CreateOpts) ToBGPVPNCreateMap() (map[string]interface{}, error) { + return gophercloud.BuildRequestBody(opts, "bgpvpn") +} + +// Create a BGP VPN +func Create(c *gophercloud.ServiceClient, opts CreateOpts) (r CreateResult) { + b, err := opts.ToBGPVPNCreateMap() + if err != nil { + r.Err = err + return + } + resp, err := c.Post(createURL(c), b, &r.Body, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// Delete accepts a unique ID and deletes the BGP VPN associated with it. +func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) { + resp, err := c.Delete(deleteURL(c, id), nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// UpdateOptsBuilder allows extensions to add additional parameters to the +// Update request. +type UpdateOptsBuilder interface { + ToBGPVPNUpdateMap() (map[string]interface{}, error) +} + +// UpdateOpts represents options used to update a BGP VPN. +type UpdateOpts struct { + Name *string `json:"name,omitempty"` + RouteDistinguishers *[]string `json:"route_distinguishers,omitempty"` + RouteTargets *[]string `json:"route_targets,omitempty"` + ImportTargets *[]string `json:"import_targets,omitempty"` + ExportTargets *[]string `json:"export_targets,omitempty"` + LocalPref *int `json:"local_pref,omitempty"` +} + +// ToBGPVPNUpdateMap builds a request body from UpdateOpts. +func (opts UpdateOpts) ToBGPVPNUpdateMap() (map[string]interface{}, error) { + return gophercloud.BuildRequestBody(opts, "bgpvpn") +} + +// Update accept a BGP VPN ID and an UpdateOpts and update the BGP VPN +func Update(c *gophercloud.ServiceClient, id string, opts UpdateOpts) (r UpdateResult) { + b, err := opts.ToBGPVPNUpdateMap() + if err != nil { + r.Err = err + return + } + resp, err := c.Put(updateURL(c, id), b, &r.Body, &gophercloud.RequestOpts{ + OkCodes: []int{200}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// ListNetworkAssociationsOptsBuilder allows extensions to add additional +// parameters to the ListNetworkAssociations request. +type ListNetworkAssociationsOptsBuilder interface { + ToNetworkAssociationsListQuery() (string, error) +} + +// ListNetworkAssociationsOpts allows the filtering and sorting of paginated +// collections through the API. +type ListNetworkAssociationsOpts struct { + Fields []string `q:"fields"` + Limit int `q:"limit"` + Marker string `q:"marker"` +} + +// ToNetworkAssociationsListQuery formats a ListNetworkAssociationsOpts into a +// query string. +func (opts ListNetworkAssociationsOpts) ToNetworkAssociationsListQuery() (string, error) { + q, err := gophercloud.BuildQueryString(opts) + if err != nil { + return "", err + } + return q.String(), nil +} + +// ListNetworkAssociations pages over the network associations of a specified +// BGP VPN. +func ListNetworkAssociations(c *gophercloud.ServiceClient, id string, opts ListNetworkAssociationsOptsBuilder) pagination.Pager { + url := listNetworkAssociationsURL(c, id) + query, err := opts.ToNetworkAssociationsListQuery() + if err != nil { + return pagination.Pager{Err: err} + } + url += query + return pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page { + p := NetworkAssociationPage{pagination.MarkerPageBase{PageResult: r}} + p.MarkerPageBase.Owner = p + return p + }) +} + +// CreateNetworkAssociationOptsBuilder allows extensions to add additional +// parameters to the CreateNetworkAssociation request. +type CreateNetworkAssociationOptsBuilder interface { + ToNetworkAssociationCreateMap() (map[string]interface{}, error) +} + +// CreateNetworkAssociationOpts represents options used to create a BGP VPN +// network association. +type CreateNetworkAssociationOpts struct { + NetworkID string `json:"network_id" required:"true"` + TenantID string `json:"tenant_id,omitempty"` + ProjectID string `json:"project_id,omitempty"` +} + +// ToNetworkAssociationCreateMap builds a request body from +// CreateNetworkAssociationOpts. +func (opts CreateNetworkAssociationOpts) ToNetworkAssociationCreateMap() (map[string]interface{}, error) { + return gophercloud.BuildRequestBody(opts, "network_association") +} + +// CreateNetworkAssociation creates a new network association for a specified +// BGP VPN. +func CreateNetworkAssociation(client *gophercloud.ServiceClient, id string, opts CreateNetworkAssociationOptsBuilder) (r CreateNetworkAssociationResult) { + b, err := opts.ToNetworkAssociationCreateMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Post(createNetworkAssociationURL(client, id), b, &r.Body, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// GetNetworkAssociation retrieves a specific network association by BGP VPN id +// and network association id. +func GetNetworkAssociation(c *gophercloud.ServiceClient, bgpVpnID string, id string) (r GetNetworkAssociationResult) { + resp, err := c.Get(getNetworkAssociationURL(c, bgpVpnID, id), &r.Body, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// DeleteNetworkAssociation deletes a specific network association by BGP VPN id +// and network association id. +func DeleteNetworkAssociation(c *gophercloud.ServiceClient, bgpVpnID string, id string) (r DeleteNetworkAssociationResult) { + resp, err := c.Delete(deleteNetworkAssociationURL(c, bgpVpnID, id), nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// ListRouterAssociationsOptsBuilder allows extensions to add additional +// parameters to the ListRouterAssociations request. +type ListRouterAssociationsOptsBuilder interface { + ToRouterAssociationsListQuery() (string, error) +} + +// ListRouterAssociationsOpts allows the filtering and sorting of paginated +// collections through the API. +type ListRouterAssociationsOpts struct { + Fields []string `q:"fields"` + Limit int `q:"limit"` + Marker string `q:"marker"` +} + +// ToRouterAssociationsListQuery formats a ListRouterAssociationsOpts into a +// query string. +func (opts ListRouterAssociationsOpts) ToRouterAssociationsListQuery() (string, error) { + q, err := gophercloud.BuildQueryString(opts) + if err != nil { + return "", err + } + return q.String(), nil +} + +// ListRouterAssociations pages over the router associations of a specified +// BGP VPN. +func ListRouterAssociations(c *gophercloud.ServiceClient, id string, opts ListRouterAssociationsOptsBuilder) pagination.Pager { + url := listRouterAssociationsURL(c, id) + query, err := opts.ToRouterAssociationsListQuery() + if err != nil { + return pagination.Pager{Err: err} + } + url += query + return pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page { + p := RouterAssociationPage{pagination.MarkerPageBase{PageResult: r}} + p.MarkerPageBase.Owner = p + return p + }) +} + +// CreateRouterAssociationOptsBuilder allows extensions to add additional +// parameters to the CreateRouterAssociation request. +type CreateRouterAssociationOptsBuilder interface { + ToRouterAssociationCreateMap() (map[string]interface{}, error) +} + +// CreateRouterAssociationOpts represents options used to create a BGP VPN +// router association. +type CreateRouterAssociationOpts struct { + RouterID string `json:"router_id" required:"true"` + AdvertiseExtraRoutes *bool `json:"advertise_extra_routes,omitempty"` + TenantID string `json:"tenant_id,omitempty"` + ProjectID string `json:"project_id,omitempty"` +} + +// ToRouterAssociationCreateMap builds a request body from +// CreateRouterAssociationOpts. +func (opts CreateRouterAssociationOpts) ToRouterAssociationCreateMap() (map[string]interface{}, error) { + return gophercloud.BuildRequestBody(opts, "router_association") +} + +// CreateRouterAssociation creates a new router association for a specified +// BGP VPN. +func CreateRouterAssociation(client *gophercloud.ServiceClient, id string, opts CreateRouterAssociationOptsBuilder) (r CreateRouterAssociationResult) { + b, err := opts.ToRouterAssociationCreateMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Post(createRouterAssociationURL(client, id), b, &r.Body, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// GetRouterAssociation retrieves a specific router association by BGP VPN id +// and router association id. +func GetRouterAssociation(c *gophercloud.ServiceClient, bgpVpnID string, id string) (r GetRouterAssociationResult) { + resp, err := c.Get(getRouterAssociationURL(c, bgpVpnID, id), &r.Body, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// DeleteRouterAssociation deletes a specific router association by BGP VPN id +// and router association id. +func DeleteRouterAssociation(c *gophercloud.ServiceClient, bgpVpnID string, id string) (r DeleteRouterAssociationResult) { + resp, err := c.Delete(deleteRouterAssociationURL(c, bgpVpnID, id), nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// UpdateRouterAssociationOptsBuilder allows extensions to add additional +// parameters to the UpdateRouterAssociation request. +type UpdateRouterAssociationOptsBuilder interface { + ToRouterAssociationUpdateMap() (map[string]interface{}, error) +} + +// UpdateRouterAssociationOpts represents options used to update a BGP VPN +// router association. +type UpdateRouterAssociationOpts struct { + AdvertiseExtraRoutes *bool `json:"advertise_extra_routes,omitempty"` +} + +// ToRouterAssociationUpdateMap builds a request body from +// UpdateRouterAssociationOpts. +func (opts UpdateRouterAssociationOpts) ToRouterAssociationUpdateMap() (map[string]interface{}, error) { + return gophercloud.BuildRequestBody(opts, "router_association") +} + +// UpdateRouterAssociation updates a router association for a specified BGP VPN. +func UpdateRouterAssociation(client *gophercloud.ServiceClient, bgpVpnID string, id string, opts UpdateRouterAssociationOptsBuilder) (r UpdateRouterAssociationResult) { + b, err := opts.ToRouterAssociationUpdateMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Put(updateRouterAssociationURL(client, bgpVpnID, id), b, &r.Body, &gophercloud.RequestOpts{ + OkCodes: []int{200}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// ListPortAssociationsOptsBuilder allows extensions to add additional +// parameters to the ListPortAssociations request. +type ListPortAssociationsOptsBuilder interface { + ToPortAssociationsListQuery() (string, error) +} + +// ListPortAssociationsOpts allows the filtering and sorting of paginated +// collections through the API. +type ListPortAssociationsOpts struct { + Fields []string `q:"fields"` + Limit int `q:"limit"` + Marker string `q:"marker"` +} + +// ToPortAssociationsListQuery formats a ListPortAssociationsOpts into a +// query string. +func (opts ListPortAssociationsOpts) ToPortAssociationsListQuery() (string, error) { + q, err := gophercloud.BuildQueryString(opts) + if err != nil { + return "", err + } + return q.String(), nil +} + +// ListPortAssociations pages over the port associations of a specified +// BGP VPN. +func ListPortAssociations(c *gophercloud.ServiceClient, id string, opts ListPortAssociationsOptsBuilder) pagination.Pager { + url := listPortAssociationsURL(c, id) + query, err := opts.ToPortAssociationsListQuery() + if err != nil { + return pagination.Pager{Err: err} + } + url += query + return pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page { + p := PortAssociationPage{pagination.MarkerPageBase{PageResult: r}} + p.MarkerPageBase.Owner = p + return p + }) +} + +// PortRoutes represents the routes to be advertised by a BGP VPN port +type PortRoutes struct { + Type string `json:"type" required:"true"` + Prefix string `json:"prefix,omitempty"` + BGPVPNID string `json:"bgpvpn_id,omitempty"` + LocalPref *int `json:"local_pref,omitempty"` +} + +// CreatePortAssociationOptsBuilder allows extensions to add additional +// parameters to the CreatePortAssociation request. +type CreatePortAssociationOptsBuilder interface { + ToPortAssociationCreateMap() (map[string]interface{}, error) +} + +// CreatePortAssociationOpts represents options used to create a BGP VPN +// port association. +type CreatePortAssociationOpts struct { + PortID string `json:"port_id" required:"true"` + Routes []PortRoutes `json:"routes,omitempty"` + AdvertiseFixedIPs *bool `json:"advertise_fixed_ips,omitempty"` + TenantID string `json:"tenant_id,omitempty"` + ProjectID string `json:"project_id,omitempty"` +} + +// ToPortAssociationCreateMap builds a request body from +// CreatePortAssociationOpts. +func (opts CreatePortAssociationOpts) ToPortAssociationCreateMap() (map[string]interface{}, error) { + return gophercloud.BuildRequestBody(opts, "port_association") +} + +// CreatePortAssociation creates a new port association for a specified +// BGP VPN. +func CreatePortAssociation(client *gophercloud.ServiceClient, id string, opts CreatePortAssociationOptsBuilder) (r CreatePortAssociationResult) { + b, err := opts.ToPortAssociationCreateMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Post(createPortAssociationURL(client, id), b, &r.Body, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// GetPortAssociation retrieves a specific port association by BGP VPN id +// and port association id. +func GetPortAssociation(c *gophercloud.ServiceClient, bgpVpnID string, id string) (r GetPortAssociationResult) { + resp, err := c.Get(getPortAssociationURL(c, bgpVpnID, id), &r.Body, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// DeletePortAssociation deletes a specific port association by BGP VPN id +// and port association id. +func DeletePortAssociation(c *gophercloud.ServiceClient, bgpVpnID string, id string) (r DeletePortAssociationResult) { + resp, err := c.Delete(deletePortAssociationURL(c, bgpVpnID, id), nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// UpdatePortAssociationOptsBuilder allows extensions to add additional +// parameters to the UpdatePortAssociation request. +type UpdatePortAssociationOptsBuilder interface { + ToPortAssociationUpdateMap() (map[string]interface{}, error) +} + +// UpdatePortAssociationOpts represents options used to update a BGP VPN +// port association. +type UpdatePortAssociationOpts struct { + Routes *[]PortRoutes `json:"routes,omitempty"` + AdvertiseFixedIPs *bool `json:"advertise_fixed_ips,omitempty"` +} + +// ToPortAssociationUpdateMap builds a request body from +// UpdatePortAssociationOpts. +func (opts UpdatePortAssociationOpts) ToPortAssociationUpdateMap() (map[string]interface{}, error) { + return gophercloud.BuildRequestBody(opts, "port_association") +} + +// UpdatePortAssociation updates a port association for a specified BGP VPN. +func UpdatePortAssociation(client *gophercloud.ServiceClient, bgpVpnID string, id string, opts UpdatePortAssociationOptsBuilder) (r UpdatePortAssociationResult) { + b, err := opts.ToPortAssociationUpdateMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Put(updatePortAssociationURL(client, bgpVpnID, id), b, &r.Body, &gophercloud.RequestOpts{ + OkCodes: []int{200}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} diff --git a/openstack/networking/v2/extensions/bgpvpns/results.go b/openstack/networking/v2/extensions/bgpvpns/results.go new file mode 100644 index 0000000000..ae6512edca --- /dev/null +++ b/openstack/networking/v2/extensions/bgpvpns/results.go @@ -0,0 +1,517 @@ +package bgpvpns + +import ( + "net/url" + + "github.com/gophercloud/gophercloud" + "github.com/gophercloud/gophercloud/pagination" +) + +const ( + invalidMarker = "-1" +) + +type commonResult struct { + gophercloud.Result +} + +// Extract is a function that accepts a result and extracts a BGP VPN resource. +func (r commonResult) Extract() (*BGPVPN, error) { + var s BGPVPN + err := r.ExtractInto(&s) + return &s, err +} + +func (r commonResult) ExtractInto(v interface{}) error { + return r.Result.ExtractIntoStructPtr(v, "bgpvpn") +} + +// BGPVPN represents an MPLS network with which Neutron routers and/or networks +// may be associated +type BGPVPN struct { + // The ID of the BGP VPN. + ID string `json:"id"` + + // The user meaningful name of the BGP VPN. + Name string `json:"name"` + + // Selection of the type of VPN and the technology behind it. Allowed + // values are l2 or l3. + Type string `json:"type"` + + // Indicates whether this BGP VPN is shared across tenants. + Shared bool `json:"shared"` + + // List of route distinguisher strings. If this parameter is specified, + // one of these RDs will be used to advertise VPN routes. + RouteDistinguishers []string `json:"route_distinguishers"` + + // Route Targets that will be both imported and used for export. + RouteTargets []string `json:"route_targets"` + + // Additional Route Targets that will be imported. + ImportTargets []string `json:"import_targets"` + + // Additional Route Targets that will be used for export. + ExportTargets []string `json:"export_targets"` + + // This read-only list of network IDs reflects the associations defined + // by Network association API resources. + Networks []string `json:"networks"` + + // This read-only list of router IDs reflects the associations defined + // by Router association API resources. + Routers []string `json:"routers"` + + // This read-only list of port IDs reflects the associations defined by + // Port association API resources (only present if the + // bgpvpn-routes-control API extension is enabled). + Ports []string `json:"ports"` + + // The default BGP LOCAL_PREF of routes that will be advertised to the + // BGPVPN (unless overridden per-route). + LocalPref *int `json:"local_pref"` + + // The globally-assigned VXLAN vni for the BGP VPN. + VNI int `json:"vni"` + + // The ID of the project. + TenantID string `json:"tenant_id"` + + // The ID of the project. + ProjectID string `json:"project_id"` +} + +// BGPVPNPage is the page returned by a pager when traversing over a +// collection of BGP VPNs. +type BGPVPNPage struct { + pagination.MarkerPageBase +} + +// NextPageURL generates the URL for the page of results after this one. +func (r BGPVPNPage) NextPageURL() (string, error) { + currentURL := r.URL + mark, err := r.Owner.LastMarker() + if err != nil { + return "", err + } + if mark == invalidMarker { + return "", nil + } + + q := currentURL.Query() + q.Set("marker", mark) + currentURL.RawQuery = q.Encode() + return currentURL.String(), nil +} + +// LastMarker returns the last offset in a ListResult. +func (r BGPVPNPage) LastMarker() (string, error) { + results, err := ExtractBGPVPNs(r) + if err != nil { + return invalidMarker, err + } + if len(results) == 0 { + return invalidMarker, nil + } + + u, err := url.Parse(r.URL.String()) + if err != nil { + return invalidMarker, err + } + queryParams := u.Query() + limit := queryParams.Get("limit") + + // Limit is not present, only one page required + if limit == "" { + return invalidMarker, nil + } + + return results[len(results)-1].ID, nil +} + +// IsEmpty checks whether a BGPPage struct is empty. +func (r BGPVPNPage) IsEmpty() (bool, error) { + if r.StatusCode == 204 { + return true, nil + } + + is, err := ExtractBGPVPNs(r) + return len(is) == 0, err +} + +// ExtractBGPVPNs accepts a Page struct, specifically a BGPVPNPage struct, +// and extracts the elements into a slice of BGPVPN structs. In other words, +// a generic collection is mapped into a relevant slice. +func ExtractBGPVPNs(r pagination.Page) ([]BGPVPN, error) { + var s []BGPVPN + err := ExtractBGPVPNsInto(r, &s) + return s, err +} + +func ExtractBGPVPNsInto(r pagination.Page, v interface{}) error { + return r.(BGPVPNPage).Result.ExtractIntoSlicePtr(v, "bgpvpns") +} + +// GetResult represents the result of a get operation. Call its Extract +// method to interpret it as a BGPVPN. +type GetResult struct { + commonResult +} + +// CreateResult represents the result of a create operation. Call its Extract +// method to intepret it as a BGPVPN. +type CreateResult struct { + commonResult +} + +// DeleteResult represents the result of a delete operation. Call its +// ExtractErr method to determine if the request succeeded or failed. +type DeleteResult struct { + gophercloud.ErrResult +} + +// UpdateResult represents the result of an update operation. Call its Extract +// method to interpret it as a BGPVPN. +type UpdateResult struct { + commonResult +} + +type commonNetworkAssociationResult struct { + gophercloud.Result +} + +// Extract is a function that accepts a result and extracts a BGP VPN resource. +func (r commonNetworkAssociationResult) Extract() (*NetworkAssociation, error) { + var s NetworkAssociation + err := r.ExtractInto(&s) + return &s, err +} + +func (r commonNetworkAssociationResult) ExtractInto(v interface{}) error { + return r.Result.ExtractIntoStructPtr(v, "network_association") +} + +// NetworkAssociation represents a BGP VPN network association object. +type NetworkAssociation struct { + ID string `json:"id"` + NetworkID string `json:"network_id"` + TenantID string `json:"tenant_id"` + ProjectID string `json:"project_id"` +} + +// NetworkAssociationPage is the page returned by a pager when traversing over a +// collection of network associations. +type NetworkAssociationPage struct { + pagination.MarkerPageBase +} + +// NextPageURL generates the URL for the page of results after this one. +func (r NetworkAssociationPage) NextPageURL() (string, error) { + currentURL := r.URL + mark, err := r.Owner.LastMarker() + if err != nil { + return "", err + } + if mark == invalidMarker { + return "", nil + } + + q := currentURL.Query() + q.Set("marker", mark) + currentURL.RawQuery = q.Encode() + return currentURL.String(), nil +} + +// LastMarker returns the last offset in a ListResult. +func (r NetworkAssociationPage) LastMarker() (string, error) { + results, err := ExtractNetworkAssociations(r) + if err != nil { + return invalidMarker, err + } + if len(results) == 0 { + return invalidMarker, nil + } + + u, err := url.Parse(r.URL.String()) + if err != nil { + return invalidMarker, err + } + queryParams := u.Query() + limit := queryParams.Get("limit") + + // Limit is not present, only one page required + if limit == "" { + return invalidMarker, nil + } + + return results[len(results)-1].ID, nil +} + +// IsEmpty checks whether a NetworkAssociationPage struct is empty. +func (r NetworkAssociationPage) IsEmpty() (bool, error) { + is, err := ExtractNetworkAssociations(r) + return len(is) == 0, err +} + +// ExtractNetworkAssociations accepts a Page struct, specifically a NetworkAssociationPage struct, +// and extracts the elements into a slice of NetworkAssociation structs. In other words, +// a generic collection is mapped into a relevant slice. +func ExtractNetworkAssociations(r pagination.Page) ([]NetworkAssociation, error) { + var s []NetworkAssociation + err := ExtractNetworkAssociationsInto(r, &s) + return s, err +} + +func ExtractNetworkAssociationsInto(r pagination.Page, v interface{}) error { + return r.(NetworkAssociationPage).Result.ExtractIntoSlicePtr(v, "network_associations") +} + +// CreateNetworkAssociationResult represents the result of a create operation. Call its Extract +// method to interpret it as a NetworkAssociation. +type CreateNetworkAssociationResult struct { + commonNetworkAssociationResult +} + +// GetNetworkAssociationResult represents the result of a get operation. Call its Extract +// method to interpret it as a NetworkAssociation. +type GetNetworkAssociationResult struct { + commonNetworkAssociationResult +} + +// DeleteNetworkAssociationResult represents the result of a delete operation. Call its +// ExtractErr method to determine if the request succeeded or failed. +type DeleteNetworkAssociationResult struct { + gophercloud.ErrResult +} + +type commonRouterAssociationResult struct { + gophercloud.Result +} + +// Extract is a function that accepts a result and extracts a BGP VPN resource. +func (r commonRouterAssociationResult) Extract() (*RouterAssociation, error) { + var s RouterAssociation + err := r.ExtractInto(&s) + return &s, err +} + +func (r commonRouterAssociationResult) ExtractInto(v interface{}) error { + return r.Result.ExtractIntoStructPtr(v, "router_association") +} + +// RouterAssociation represents a BGP VPN router association object. +type RouterAssociation struct { + ID string `json:"id"` + RouterID string `json:"router_id"` + TenantID string `json:"tenant_id"` + ProjectID string `json:"project_id"` + AdvertiseExtraRoutes bool `json:"advertise_extra_routes"` +} + +// RouterAssociationPage is the page returned by a pager when traversing over a +// collection of router associations. +type RouterAssociationPage struct { + pagination.MarkerPageBase +} + +// NextPageURL generates the URL for the page of results after this one. +func (r RouterAssociationPage) NextPageURL() (string, error) { + currentURL := r.URL + mark, err := r.Owner.LastMarker() + if err != nil { + return "", err + } + if mark == invalidMarker { + return "", nil + } + + q := currentURL.Query() + q.Set("marker", mark) + currentURL.RawQuery = q.Encode() + return currentURL.String(), nil +} + +// LastMarker returns the last offset in a ListResult. +func (r RouterAssociationPage) LastMarker() (string, error) { + results, err := ExtractRouterAssociations(r) + if err != nil { + return invalidMarker, err + } + if len(results) == 0 { + return invalidMarker, nil + } + + u, err := url.Parse(r.URL.String()) + if err != nil { + return invalidMarker, err + } + queryParams := u.Query() + limit := queryParams.Get("limit") + + // Limit is not present, only one page required + if limit == "" { + return invalidMarker, nil + } + + return results[len(results)-1].ID, nil +} + +// IsEmpty checks whether a RouterAssociationPage struct is empty. +func (r RouterAssociationPage) IsEmpty() (bool, error) { + is, err := ExtractRouterAssociations(r) + return len(is) == 0, err +} + +// ExtractRouterAssociations accepts a Page struct, specifically a RouterAssociationPage struct, +// and extracts the elements into a slice of RouterAssociation structs. In other words, +// a generic collection is mapped into a relevant slice. +func ExtractRouterAssociations(r pagination.Page) ([]RouterAssociation, error) { + var s []RouterAssociation + err := ExtractRouterAssociationsInto(r, &s) + return s, err +} + +func ExtractRouterAssociationsInto(r pagination.Page, v interface{}) error { + return r.(RouterAssociationPage).Result.ExtractIntoSlicePtr(v, "router_associations") +} + +// CreateRouterAssociationResult represents the result of a create operation. Call its Extract +// method to interpret it as a RouterAssociation. +type CreateRouterAssociationResult struct { + commonRouterAssociationResult +} + +// GetRouterAssociationResult represents the result of a get operation. Call its Extract +// method to interpret it as a RouterAssociation. +type GetRouterAssociationResult struct { + commonRouterAssociationResult +} + +// DeleteRouterAssociationResult represents the result of a delete operation. Call its +// ExtractErr method to determine if the request succeeded or failed. +type DeleteRouterAssociationResult struct { + gophercloud.ErrResult +} + +// UpdateRouterAssociationResult represents the result of an update operation. Call its Extract +// method to interpret it as a RouterAssociation. +type UpdateRouterAssociationResult struct { + commonRouterAssociationResult +} + +type commonPortAssociationResult struct { + gophercloud.Result +} + +// Extract is a function that accepts a result and extracts a BGP VPN resource. +func (r commonPortAssociationResult) Extract() (*PortAssociation, error) { + var s PortAssociation + err := r.ExtractInto(&s) + return &s, err +} + +func (r commonPortAssociationResult) ExtractInto(v interface{}) error { + return r.Result.ExtractIntoStructPtr(v, "port_association") +} + +// PortAssociation represents a BGP VPN port association object. +type PortAssociation struct { + ID string `json:"id"` + PortID string `json:"port_id"` + TenantID string `json:"tenant_id"` + ProjectID string `json:"project_id"` + Routes []PortRoutes `json:"routes"` + AdvertiseFixedIPs bool `json:"advertise_fixed_ips"` +} + +// PortAssociationPage is the page returned by a pager when traversing over a +// collection of port associations. +type PortAssociationPage struct { + pagination.MarkerPageBase +} + +// NextPageURL generates the URL for the page of results after this one. +func (r PortAssociationPage) NextPageURL() (string, error) { + currentURL := r.URL + mark, err := r.Owner.LastMarker() + if err != nil { + return "", err + } + if mark == invalidMarker { + return "", nil + } + + q := currentURL.Query() + q.Set("marker", mark) + currentURL.RawQuery = q.Encode() + return currentURL.String(), nil +} + +// LastMarker returns the last offset in a ListResult. +func (r PortAssociationPage) LastMarker() (string, error) { + results, err := ExtractPortAssociations(r) + if err != nil { + return invalidMarker, err + } + if len(results) == 0 { + return invalidMarker, nil + } + + u, err := url.Parse(r.URL.String()) + if err != nil { + return invalidMarker, err + } + queryParams := u.Query() + limit := queryParams.Get("limit") + + // Limit is not present, only one page required + if limit == "" { + return invalidMarker, nil + } + + return results[len(results)-1].ID, nil +} + +// IsEmpty checks whether a PortAssociationPage struct is empty. +func (r PortAssociationPage) IsEmpty() (bool, error) { + is, err := ExtractPortAssociations(r) + return len(is) == 0, err +} + +// ExtractPortAssociations accepts a Page struct, specifically a PortAssociationPage struct, +// and extracts the elements into a slice of PortAssociation structs. In other words, +// a generic collection is mapped into a relevant slice. +func ExtractPortAssociations(r pagination.Page) ([]PortAssociation, error) { + var s []PortAssociation + err := ExtractPortAssociationsInto(r, &s) + return s, err +} + +func ExtractPortAssociationsInto(r pagination.Page, v interface{}) error { + return r.(PortAssociationPage).Result.ExtractIntoSlicePtr(v, "port_associations") +} + +// CreatePortAssociationResult represents the result of a create operation. Call its Extract +// method to interpret it as a PortAssociation. +type CreatePortAssociationResult struct { + commonPortAssociationResult +} + +// GetPortAssociationResult represents the result of a get operation. Call its Extract +// method to interpret it as a PortAssociation. +type GetPortAssociationResult struct { + commonPortAssociationResult +} + +// DeletePortAssociationResult represents the result of a delete operation. Call its +// ExtractErr method to determine if the request succeeded or failed. +type DeletePortAssociationResult struct { + gophercloud.ErrResult +} + +// UpdatePortAssociationResult represents the result of an update operation. Call its Extract +// method to interpret it as a PortAssociation. +type UpdatePortAssociationResult struct { + commonPortAssociationResult +} diff --git a/openstack/networking/v2/extensions/bgpvpns/testing/doc.go b/openstack/networking/v2/extensions/bgpvpns/testing/doc.go new file mode 100644 index 0000000000..7a770b9160 --- /dev/null +++ b/openstack/networking/v2/extensions/bgpvpns/testing/doc.go @@ -0,0 +1,2 @@ +// Package testing for bgpvpns +package testing diff --git a/openstack/networking/v2/extensions/bgpvpns/testing/fixture.go b/openstack/networking/v2/extensions/bgpvpns/testing/fixture.go new file mode 100644 index 0000000000..e331f6b249 --- /dev/null +++ b/openstack/networking/v2/extensions/bgpvpns/testing/fixture.go @@ -0,0 +1,434 @@ +package testing + +import "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/bgpvpns" + +const ListBGPVPNsResult = ` +{ + "bgpvpns": [ + { + "export_targets": [ + "64512:1666" + ], + "name": "", + "routers": [], + "route_distinguishers": [ + "64512:1777", + "64512:1888", + "64512:1999" + ], + "tenant_id": "b7549121395844bea941bb92feb3fad9", + "project_id": "b7549121395844bea941bb92feb3fad9", + "import_targets": [ + "64512:1555" + ], + "route_targets": [ + "64512:1444" + ], + "type": "l3", + "id": "0f9d472a-908f-40f5-8574-b4e8a63ccbf0", + "networks": [], + "local_pref": null, + "vni": 1000 + } + ] +} +` + +var BGPVPN = bgpvpns.BGPVPN{ + ID: "0f9d472a-908f-40f5-8574-b4e8a63ccbf0", + Name: "", + RouteDistinguishers: []string{"64512:1777", "64512:1888", "64512:1999"}, + RouteTargets: []string{"64512:1444"}, + ImportTargets: []string{"64512:1555"}, + ExportTargets: []string{"64512:1666"}, + LocalPref: nil, + VNI: 1000, + TenantID: "b7549121395844bea941bb92feb3fad9", + ProjectID: "b7549121395844bea941bb92feb3fad9", + Type: "l3", + Routers: []string{}, + Networks: []string{}, +} + +const GetBGPVPNResult = ` +{ + "bgpvpn": { + "id": "460ac411-3dfb-45bb-8116-ed1a7233d143", + "name": "foo", + "route_targets": ["64512:1444"], + "export_targets": [], + "import_targets": [], + "type": "l3", + "tenant_id": "f94ea398564d49dfb0d542f086c68ce7", + "project_id": "f94ea398564d49dfb0d542f086c68ce7", + "routers": [], + "route_distinguishers": [], + "networks": [ + "a4f2b8df-cb42-4893-a333-d0b5c36ade17" + ], + "local_pref": null, + "vni": 1000 + } +} +` + +var GetBGPVPN = bgpvpns.BGPVPN{ + ID: "460ac411-3dfb-45bb-8116-ed1a7233d143", + Name: "foo", + RouteDistinguishers: []string{}, + RouteTargets: []string{"64512:1444"}, + ImportTargets: []string{}, + ExportTargets: []string{}, + LocalPref: nil, + VNI: 1000, + TenantID: "f94ea398564d49dfb0d542f086c68ce7", + ProjectID: "f94ea398564d49dfb0d542f086c68ce7", + Type: "l3", + Routers: []string{}, + Networks: []string{"a4f2b8df-cb42-4893-a333-d0b5c36ade17"}, +} + +const CreateRequest = ` +{ + "bgpvpn": { + "tenant_id": "b7549121395844bea941bb92feb3fad9", + "route_targets": ["64512:1444"], + "import_targets": ["64512:1555"], + "export_targets": ["64512:1666"], + "route_distinguishers": ["64512:1777", "64512:1888", "64512:1999"], + "type": "l3", + "vni": 1000 + } +} +` + +const CreateResponse = ` +{ + "bgpvpn": { + "export_targets": [ + "64512:1666" + ], + "name": "", + "routers": [], + "route_distinguishers": [ + "64512:1777", + "64512:1888", + "64512:1999" + ], + "tenant_id": "b7549121395844bea941bb92feb3fad9", + "project_id": "b7549121395844bea941bb92feb3fad9", + "import_targets": [ + "64512:1555" + ], + "route_targets": [ + "64512:1444" + ], + "type": "l3", + "id": "0f9d472a-908f-40f5-8574-b4e8a63ccbf0", + "networks": [], + "local_pref": null, + "vni": 1000 + } +} +` + +var CreateBGPVPN = bgpvpns.BGPVPN{ + ID: "0f9d472a-908f-40f5-8574-b4e8a63ccbf0", + RouteDistinguishers: []string{ + "64512:1777", + "64512:1888", + "64512:1999", + }, + RouteTargets: []string{"64512:1444"}, + ImportTargets: []string{"64512:1555"}, + ExportTargets: []string{"64512:1666"}, + LocalPref: nil, + VNI: 1000, + TenantID: "b7549121395844bea941bb92feb3fad9", + ProjectID: "b7549121395844bea941bb92feb3fad9", + Type: "l3", + Routers: []string{}, + Networks: []string{}, +} + +const UpdateBGPVPNRequest = ` +{ + "bgpvpn": { + "name": "foo", + "route_targets": ["64512:1444"], + "export_targets": [], + "import_targets": [] + } +} +` + +const UpdateBGPVPNResponse = ` +{ + "bgpvpn": { + "export_targets": [], + "name": "foo", + "routers": [], + "route_distinguishers": [ + "12345:1234" + ], + "tenant_id": "b7549121395844bea941bb92feb3fad9", + "import_targets": [], + "route_targets": ["64512:1444"], + "type": "l3", + "id": "4d627abf-06dd-45ab-920b-8e61422bb984", + "networks": [], + "local_pref": null, + "vni": 1000 + } +} +` + +const ListNetworkAssociationsResult = ` +{ + "network_associations": [ + { + "id": "73238ca1-e05d-4c7a-b4d4-70407b4b8730", + "network_id": "8c5d88dc-60ac-4b02-a65a-36b65888ddcd", + "tenant_id": "b7549121395844bea941bb92feb3fad9", + "project_id": "b7549121395844bea941bb92feb3fad9" + } + ] +} +` + +var NetworkAssociation = bgpvpns.NetworkAssociation{ + ID: "73238ca1-e05d-4c7a-b4d4-70407b4b8730", + NetworkID: "8c5d88dc-60ac-4b02-a65a-36b65888ddcd", + TenantID: "b7549121395844bea941bb92feb3fad9", + ProjectID: "b7549121395844bea941bb92feb3fad9", +} + +const GetNetworkAssociationResult = ` +{ + "network_association": { + "id": "73238ca1-e05d-4c7a-b4d4-70407b4b8730", + "network_id": "8c5d88dc-60ac-4b02-a65a-36b65888ddcd", + "tenant_id": "b7549121395844bea941bb92feb3fad9", + "project_id": "b7549121395844bea941bb92feb3fad9" + } +} +` + +var GetNetworkAssociation = bgpvpns.NetworkAssociation{ + ID: "73238ca1-e05d-4c7a-b4d4-70407b4b8730", + NetworkID: "8c5d88dc-60ac-4b02-a65a-36b65888ddcd", + TenantID: "b7549121395844bea941bb92feb3fad9", + ProjectID: "b7549121395844bea941bb92feb3fad9", +} + +const CreateNetworkAssociationRequest = ` +{ + "network_association": { + "network_id": "8c5d88dc-60ac-4b02-a65a-36b65888ddcd" + } +} +` +const CreateNetworkAssociationResponse = ` +{ + "network_association": { + "network_id": "8c5d88dc-60ac-4b02-a65a-36b65888ddcd", + "tenant_id": "b7549121395844bea941bb92feb3fad9", + "project_id": "b7549121395844bea941bb92feb3fad9", + "id": "73238ca1-e05d-4c7a-b4d4-70407b4b8730" + } +} +` + +var CreateNetworkAssociation = bgpvpns.NetworkAssociation{ + ID: "73238ca1-e05d-4c7a-b4d4-70407b4b8730", + NetworkID: "8c5d88dc-60ac-4b02-a65a-36b65888ddcd", + TenantID: "b7549121395844bea941bb92feb3fad9", + ProjectID: "b7549121395844bea941bb92feb3fad9", +} + +const ListRouterAssociationsResult = ` +{ + "router_associations": [ + { + "id": "73238ca1-e05d-4c7a-b4d4-70407b4b8730", + "router_id": "8c5d88dc-60ac-4b02-a65a-36b65888ddcd", + "tenant_id": "b7549121395844bea941bb92feb3fad9", + "project_id": "b7549121395844bea941bb92feb3fad9" + } + ] +} +` + +var RouterAssociation = bgpvpns.RouterAssociation{ + ID: "73238ca1-e05d-4c7a-b4d4-70407b4b8730", + RouterID: "8c5d88dc-60ac-4b02-a65a-36b65888ddcd", + TenantID: "b7549121395844bea941bb92feb3fad9", + ProjectID: "b7549121395844bea941bb92feb3fad9", +} + +const GetRouterAssociationResult = ` +{ + "router_association": { + "id": "73238ca1-e05d-4c7a-b4d4-70407b4b8730", + "router_id": "8c5d88dc-60ac-4b02-a65a-36b65888ddcd", + "tenant_id": "b7549121395844bea941bb92feb3fad9", + "project_id": "b7549121395844bea941bb92feb3fad9" + } +} +` + +var GetRouterAssociation = bgpvpns.RouterAssociation{ + ID: "73238ca1-e05d-4c7a-b4d4-70407b4b8730", + RouterID: "8c5d88dc-60ac-4b02-a65a-36b65888ddcd", + TenantID: "b7549121395844bea941bb92feb3fad9", + ProjectID: "b7549121395844bea941bb92feb3fad9", +} + +const CreateRouterAssociationRequest = ` +{ + "router_association": { + "router_id": "8c5d88dc-60ac-4b02-a65a-36b65888ddcd" + } +} +` +const CreateRouterAssociationResponse = ` +{ + "router_association": { + "router_id": "8c5d88dc-60ac-4b02-a65a-36b65888ddcd", + "tenant_id": "b7549121395844bea941bb92feb3fad9", + "project_id": "b7549121395844bea941bb92feb3fad9", + "id": "73238ca1-e05d-4c7a-b4d4-70407b4b8730", + "advertise_extra_routes": true + } +} +` + +var CreateRouterAssociation = bgpvpns.RouterAssociation{ + ID: "73238ca1-e05d-4c7a-b4d4-70407b4b8730", + RouterID: "8c5d88dc-60ac-4b02-a65a-36b65888ddcd", + TenantID: "b7549121395844bea941bb92feb3fad9", + ProjectID: "b7549121395844bea941bb92feb3fad9", + AdvertiseExtraRoutes: true, +} + +const UpdateRouterAssociationRequest = ` +{ + "router_association": { + "advertise_extra_routes": false + } +} +` +const UpdateRouterAssociationResponse = ` +{ + "router_association": { + "router_id": "8c5d88dc-60ac-4b02-a65a-36b65888ddcd", + "tenant_id": "b7549121395844bea941bb92feb3fad9", + "project_id": "b7549121395844bea941bb92feb3fad9", + "id": "73238ca1-e05d-4c7a-b4d4-70407b4b8730" + } +} +` + +var UpdateRouterAssociation = bgpvpns.RouterAssociation{ + ID: "73238ca1-e05d-4c7a-b4d4-70407b4b8730", + RouterID: "8c5d88dc-60ac-4b02-a65a-36b65888ddcd", + TenantID: "b7549121395844bea941bb92feb3fad9", + ProjectID: "b7549121395844bea941bb92feb3fad9", + AdvertiseExtraRoutes: false, +} + +const ListPortAssociationsResult = ` +{ + "port_associations": [ + { + "id": "73238ca1-e05d-4c7a-b4d4-70407b4b8730", + "port_id": "8c5d88dc-60ac-4b02-a65a-36b65888ddcd", + "tenant_id": "b7549121395844bea941bb92feb3fad9", + "project_id": "b7549121395844bea941bb92feb3fad9", + "advertise_fixed_ips": true + } + ] +} +` + +var PortAssociation = bgpvpns.PortAssociation{ + ID: "73238ca1-e05d-4c7a-b4d4-70407b4b8730", + PortID: "8c5d88dc-60ac-4b02-a65a-36b65888ddcd", + TenantID: "b7549121395844bea941bb92feb3fad9", + ProjectID: "b7549121395844bea941bb92feb3fad9", + AdvertiseFixedIPs: true, +} + +const GetPortAssociationResult = ` +{ + "port_association": { + "id": "73238ca1-e05d-4c7a-b4d4-70407b4b8730", + "port_id": "8c5d88dc-60ac-4b02-a65a-36b65888ddcd", + "tenant_id": "b7549121395844bea941bb92feb3fad9", + "project_id": "b7549121395844bea941bb92feb3fad9", + "advertise_fixed_ips": true + } +} +` + +var GetPortAssociation = bgpvpns.PortAssociation{ + ID: "73238ca1-e05d-4c7a-b4d4-70407b4b8730", + PortID: "8c5d88dc-60ac-4b02-a65a-36b65888ddcd", + TenantID: "b7549121395844bea941bb92feb3fad9", + ProjectID: "b7549121395844bea941bb92feb3fad9", + AdvertiseFixedIPs: true, +} + +const CreatePortAssociationRequest = ` +{ + "port_association": { + "port_id": "8c5d88dc-60ac-4b02-a65a-36b65888ddcd" + } +} +` +const CreatePortAssociationResponse = ` +{ + "port_association": { + "port_id": "8c5d88dc-60ac-4b02-a65a-36b65888ddcd", + "tenant_id": "b7549121395844bea941bb92feb3fad9", + "project_id": "b7549121395844bea941bb92feb3fad9", + "id": "73238ca1-e05d-4c7a-b4d4-70407b4b8730", + "advertise_fixed_ips": true + } +} +` + +var CreatePortAssociation = bgpvpns.PortAssociation{ + ID: "73238ca1-e05d-4c7a-b4d4-70407b4b8730", + PortID: "8c5d88dc-60ac-4b02-a65a-36b65888ddcd", + TenantID: "b7549121395844bea941bb92feb3fad9", + ProjectID: "b7549121395844bea941bb92feb3fad9", + AdvertiseFixedIPs: true, +} + +const UpdatePortAssociationRequest = ` +{ + "port_association": { + "advertise_fixed_ips": false + } +} +` +const UpdatePortAssociationResponse = ` +{ + "port_association": { + "port_id": "8c5d88dc-60ac-4b02-a65a-36b65888ddcd", + "tenant_id": "b7549121395844bea941bb92feb3fad9", + "project_id": "b7549121395844bea941bb92feb3fad9", + "id": "73238ca1-e05d-4c7a-b4d4-70407b4b8730", + "advertise_fixed_ips": false + } +} +` + +var UpdatePortAssociation = bgpvpns.PortAssociation{ + ID: "73238ca1-e05d-4c7a-b4d4-70407b4b8730", + PortID: "8c5d88dc-60ac-4b02-a65a-36b65888ddcd", + TenantID: "b7549121395844bea941bb92feb3fad9", + ProjectID: "b7549121395844bea941bb92feb3fad9", + AdvertiseFixedIPs: false, +} diff --git a/openstack/networking/v2/extensions/bgpvpns/testing/requests_test.go b/openstack/networking/v2/extensions/bgpvpns/testing/requests_test.go new file mode 100644 index 0000000000..a338a7cd15 --- /dev/null +++ b/openstack/networking/v2/extensions/bgpvpns/testing/requests_test.go @@ -0,0 +1,513 @@ +package testing + +import ( + "fmt" + "net/http" + "testing" + + fake "github.com/gophercloud/gophercloud/openstack/networking/v2/common" + "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/bgpvpns" + "github.com/gophercloud/gophercloud/pagination" + th "github.com/gophercloud/gophercloud/testhelper" +) + +func TestList(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + filterProjectID := []string{"b7549121395844bea941bb92feb3fad9"} + fields := []string{"id", "name"} + listOpts := bgpvpns.ListOpts{ + Fields: fields, + ProjectID: filterProjectID[0], + } + th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns", + func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "GET") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + + r.ParseForm() + th.AssertDeepEquals(t, r.Form["fields"], fields) + th.AssertDeepEquals(t, r.Form["project_id"], filterProjectID) + + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + fmt.Fprintf(w, ListBGPVPNsResult) + }) + count := 0 + + err := bgpvpns.List(fake.ServiceClient(), listOpts).EachPage( + func(page pagination.Page) (bool, error) { + count++ + actual, err := bgpvpns.ExtractBGPVPNs(page) + if err != nil { + t.Errorf("Failed to extract BGP VPNs: %v", err) + return false, nil + } + + expected := []bgpvpns.BGPVPN{BGPVPN} + th.CheckDeepEquals(t, expected, actual) + + return true, nil + }) + th.AssertNoErr(t, err) +} + +func TestGet(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + bgpVpnID := "460ac411-3dfb-45bb-8116-ed1a7233d143" + th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID, func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "GET") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + fmt.Fprintf(w, GetBGPVPNResult) + }) + + r, err := bgpvpns.Get(fake.ServiceClient(), bgpVpnID).Extract() + th.AssertNoErr(t, err) + th.CheckDeepEquals(t, GetBGPVPN, *r) +} + +func TestCreate(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "POST") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + th.TestHeader(t, r, "Content-Type", "application/json") + th.TestHeader(t, r, "Accept", "application/json") + th.TestJSONRequest(t, r, CreateRequest) + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(http.StatusCreated) + fmt.Fprintf(w, CreateResponse) + }) + + opts := bgpvpns.CreateOpts{ + TenantID: "b7549121395844bea941bb92feb3fad9", + RouteTargets: []string{ + "64512:1444", + }, + ImportTargets: []string{ + "64512:1555", + }, + ExportTargets: []string{ + "64512:1666", + }, + RouteDistinguishers: []string{ + "64512:1777", + "64512:1888", + "64512:1999", + }, + Type: "l3", + VNI: 1000, + } + + r, err := bgpvpns.Create(fake.ServiceClient(), opts).Extract() + th.AssertNoErr(t, err) + th.AssertDeepEquals(t, CreateBGPVPN, *r) +} + +func TestDelete(t *testing.T) { + bgpVpnID := "0f9d472a-908f-40f5-8574-b4e8a63ccbf0" + th.SetupHTTP() + defer th.TeardownHTTP() + + th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID, func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "DELETE") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + th.TestHeader(t, r, "Accept", "application/json") + + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(http.StatusNoContent) + }) + + err := bgpvpns.Delete(fake.ServiceClient(), bgpVpnID).ExtractErr() + th.AssertNoErr(t, err) +} + +func TestUpdate(t *testing.T) { + bgpVpnID := "4d627abf-06dd-45ab-920b-8e61422bb984" + th.SetupHTTP() + defer th.TeardownHTTP() + + th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID, func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "PUT") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + th.TestHeader(t, r, "Content-Type", "application/json") + th.TestHeader(t, r, "Accept", "application/json") + th.TestJSONRequest(t, r, UpdateBGPVPNRequest) + + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + + fmt.Fprintf(w, UpdateBGPVPNResponse) + }) + + name := "foo" + routeTargets := []string{"64512:1444"} + emptyTarget := []string{} + opts := bgpvpns.UpdateOpts{ + Name: &name, + RouteTargets: &routeTargets, + ImportTargets: &emptyTarget, + ExportTargets: &emptyTarget, + } + + r, err := bgpvpns.Update(fake.ServiceClient(), bgpVpnID, opts).Extract() + th.AssertNoErr(t, err) + th.AssertDeepEquals(t, *opts.Name, r.Name) +} + +func TestListNetworkAssociations(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + bgpVpnID := "460ac411-3dfb-45bb-8116-ed1a7233d143" + fields := []string{"id", "name"} + listOpts := bgpvpns.ListNetworkAssociationsOpts{ + Fields: fields, + } + th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID+"/network_associations", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "GET") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + + r.ParseForm() + th.AssertDeepEquals(t, fields, r.Form["fields"]) + + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + fmt.Fprintf(w, ListNetworkAssociationsResult) + }) + + count := 0 + err := bgpvpns.ListNetworkAssociations(fake.ServiceClient(), bgpVpnID, listOpts).EachPage( + func(page pagination.Page) (bool, error) { + count++ + actual, err := bgpvpns.ExtractNetworkAssociations(page) + if err != nil { + t.Errorf("Failed to extract network associations: %v", err) + return false, nil + } + + expected := []bgpvpns.NetworkAssociation{NetworkAssociation} + th.CheckDeepEquals(t, expected, actual) + + return true, nil + }) + + th.AssertNoErr(t, err) + th.AssertEquals(t, 1, count) +} + +func TestCreateNetworkAssociation(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + bgpVpnID := "460ac411-3dfb-45bb-8116-ed1a7233d143" + th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID+"/network_associations", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "POST") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + th.TestHeader(t, r, "Content-Type", "application/json") + th.TestHeader(t, r, "Accept", "application/json") + th.TestJSONRequest(t, r, CreateNetworkAssociationRequest) + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(http.StatusCreated) + fmt.Fprintf(w, CreateNetworkAssociationResponse) + }) + + opts := bgpvpns.CreateNetworkAssociationOpts{ + NetworkID: "8c5d88dc-60ac-4b02-a65a-36b65888ddcd", + } + r, err := bgpvpns.CreateNetworkAssociation(fake.ServiceClient(), bgpVpnID, opts).Extract() + th.AssertNoErr(t, err) + th.AssertDeepEquals(t, CreateNetworkAssociation, *r) +} + +func TestGetNetworkAssociation(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + bgpVpnID := "460ac411-3dfb-45bb-8116-ed1a7233d143" + networkAssociationID := "73238ca1-e05d-4c7a-b4d4-70407b4b8730" + th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID+"/network_associations/"+networkAssociationID, func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "GET") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + fmt.Fprintf(w, GetNetworkAssociationResult) + }) + + r, err := bgpvpns.GetNetworkAssociation(fake.ServiceClient(), bgpVpnID, networkAssociationID).Extract() + th.AssertNoErr(t, err) + th.CheckDeepEquals(t, GetNetworkAssociation, *r) +} + +func TestDeleteNetworkAssociation(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + bgpVpnID := "460ac411-3dfb-45bb-8116-ed1a7233d143" + networkAssociationID := "73238ca1-e05d-4c7a-b4d4-70407b4b8730" + th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID+"/network_associations/"+networkAssociationID, func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "DELETE") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + w.WriteHeader(http.StatusNoContent) + }) + + err := bgpvpns.DeleteNetworkAssociation(fake.ServiceClient(), bgpVpnID, networkAssociationID).ExtractErr() + th.AssertNoErr(t, err) +} + +func TestListRouterAssociations(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + bgpVpnID := "460ac411-3dfb-45bb-8116-ed1a7233d143" + fields := []string{"id", "name"} + listOpts := bgpvpns.ListRouterAssociationsOpts{ + Fields: fields, + } + th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID+"/router_associations", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "GET") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + + r.ParseForm() + th.AssertDeepEquals(t, fields, r.Form["fields"]) + + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + fmt.Fprintf(w, ListRouterAssociationsResult) + }) + + count := 0 + err := bgpvpns.ListRouterAssociations(fake.ServiceClient(), bgpVpnID, listOpts).EachPage( + func(page pagination.Page) (bool, error) { + count++ + actual, err := bgpvpns.ExtractRouterAssociations(page) + if err != nil { + t.Errorf("Failed to extract router associations: %v", err) + return false, nil + } + + expected := []bgpvpns.RouterAssociation{RouterAssociation} + th.CheckDeepEquals(t, expected, actual) + + return true, nil + }) + + th.AssertNoErr(t, err) + th.AssertEquals(t, 1, count) +} + +func TestCreateRouterAssociation(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + bgpVpnID := "460ac411-3dfb-45bb-8116-ed1a7233d143" + th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID+"/router_associations", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "POST") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + th.TestHeader(t, r, "Content-Type", "application/json") + th.TestHeader(t, r, "Accept", "application/json") + th.TestJSONRequest(t, r, CreateRouterAssociationRequest) + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(http.StatusCreated) + fmt.Fprintf(w, CreateRouterAssociationResponse) + }) + + opts := bgpvpns.CreateRouterAssociationOpts{ + RouterID: "8c5d88dc-60ac-4b02-a65a-36b65888ddcd", + } + r, err := bgpvpns.CreateRouterAssociation(fake.ServiceClient(), bgpVpnID, opts).Extract() + th.AssertNoErr(t, err) + th.AssertDeepEquals(t, CreateRouterAssociation, *r) +} + +func TestGetRouterAssociation(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + bgpVpnID := "460ac411-3dfb-45bb-8116-ed1a7233d143" + routerAssociationID := "73238ca1-e05d-4c7a-b4d4-70407b4b8730" + th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID+"/router_associations/"+routerAssociationID, func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "GET") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + fmt.Fprintf(w, GetRouterAssociationResult) + }) + + r, err := bgpvpns.GetRouterAssociation(fake.ServiceClient(), bgpVpnID, routerAssociationID).Extract() + th.AssertNoErr(t, err) + th.CheckDeepEquals(t, GetRouterAssociation, *r) +} + +func TestUpdateRouterAssociation(t *testing.T) { + bgpVpnID := "4d627abf-06dd-45ab-920b-8e61422bb984" + routerAssociationID := "73238ca1-e05d-4c7a-b4d4-70407b4b8730" + th.SetupHTTP() + defer th.TeardownHTTP() + + th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID+"/router_associations/"+routerAssociationID, func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "PUT") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + th.TestHeader(t, r, "Content-Type", "application/json") + th.TestHeader(t, r, "Accept", "application/json") + th.TestJSONRequest(t, r, UpdateRouterAssociationRequest) + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + fmt.Fprintf(w, UpdateRouterAssociationResponse) + }) + + opts := bgpvpns.UpdateRouterAssociationOpts{ + AdvertiseExtraRoutes: new(bool), + } + r, err := bgpvpns.UpdateRouterAssociation(fake.ServiceClient(), bgpVpnID, routerAssociationID, opts).Extract() + th.AssertNoErr(t, err) + th.AssertDeepEquals(t, UpdateRouterAssociation, *r) +} + +func TestDeleteRouterAssociation(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + bgpVpnID := "460ac411-3dfb-45bb-8116-ed1a7233d143" + routerAssociationID := "73238ca1-e05d-4c7a-b4d4-70407b4b8730" + th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID+"/router_associations/"+routerAssociationID, func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "DELETE") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + w.WriteHeader(http.StatusNoContent) + }) + + err := bgpvpns.DeleteRouterAssociation(fake.ServiceClient(), bgpVpnID, routerAssociationID).ExtractErr() + th.AssertNoErr(t, err) +} + +func TestListPortAssociations(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + bgpVpnID := "460ac411-3dfb-45bb-8116-ed1a7233d143" + fields := []string{"id", "name"} + listOpts := bgpvpns.ListPortAssociationsOpts{ + Fields: fields, + } + th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID+"/port_associations", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "GET") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + + r.ParseForm() + th.AssertDeepEquals(t, fields, r.Form["fields"]) + + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + fmt.Fprintf(w, ListPortAssociationsResult) + }) + + count := 0 + err := bgpvpns.ListPortAssociations(fake.ServiceClient(), bgpVpnID, listOpts).EachPage( + func(page pagination.Page) (bool, error) { + count++ + actual, err := bgpvpns.ExtractPortAssociations(page) + if err != nil { + t.Errorf("Failed to extract port associations: %v", err) + return false, nil + } + + expected := []bgpvpns.PortAssociation{PortAssociation} + th.CheckDeepEquals(t, expected, actual) + + return true, nil + }) + + th.AssertNoErr(t, err) + th.AssertEquals(t, 1, count) +} + +func TestCreatePortAssociation(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + bgpVpnID := "460ac411-3dfb-45bb-8116-ed1a7233d143" + th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID+"/port_associations", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "POST") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + th.TestHeader(t, r, "Content-Type", "application/json") + th.TestHeader(t, r, "Accept", "application/json") + th.TestJSONRequest(t, r, CreatePortAssociationRequest) + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(http.StatusCreated) + fmt.Fprintf(w, CreatePortAssociationResponse) + }) + + opts := bgpvpns.CreatePortAssociationOpts{ + PortID: "8c5d88dc-60ac-4b02-a65a-36b65888ddcd", + } + r, err := bgpvpns.CreatePortAssociation(fake.ServiceClient(), bgpVpnID, opts).Extract() + th.AssertNoErr(t, err) + th.AssertDeepEquals(t, CreatePortAssociation, *r) +} + +func TestGetPortAssociation(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + bgpVpnID := "460ac411-3dfb-45bb-8116-ed1a7233d143" + portAssociationID := "73238ca1-e05d-4c7a-b4d4-70407b4b8730" + th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID+"/port_associations/"+portAssociationID, func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "GET") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + fmt.Fprintf(w, GetPortAssociationResult) + }) + + r, err := bgpvpns.GetPortAssociation(fake.ServiceClient(), bgpVpnID, portAssociationID).Extract() + th.AssertNoErr(t, err) + th.CheckDeepEquals(t, GetPortAssociation, *r) +} + +func TestUpdatePortAssociation(t *testing.T) { + bgpVpnID := "4d627abf-06dd-45ab-920b-8e61422bb984" + portAssociationID := "73238ca1-e05d-4c7a-b4d4-70407b4b8730" + th.SetupHTTP() + defer th.TeardownHTTP() + + th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID+"/port_associations/"+portAssociationID, func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "PUT") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + th.TestHeader(t, r, "Content-Type", "application/json") + th.TestHeader(t, r, "Accept", "application/json") + th.TestJSONRequest(t, r, UpdatePortAssociationRequest) + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + fmt.Fprintf(w, UpdatePortAssociationResponse) + }) + + opts := bgpvpns.UpdatePortAssociationOpts{ + AdvertiseFixedIPs: new(bool), + } + r, err := bgpvpns.UpdatePortAssociation(fake.ServiceClient(), bgpVpnID, portAssociationID, opts).Extract() + th.AssertNoErr(t, err) + th.AssertDeepEquals(t, UpdatePortAssociation, *r) +} + +func TestDeletePortAssociation(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + bgpVpnID := "460ac411-3dfb-45bb-8116-ed1a7233d143" + portAssociationID := "73238ca1-e05d-4c7a-b4d4-70407b4b8730" + th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID+"/port_associations/"+portAssociationID, func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "DELETE") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + w.WriteHeader(http.StatusNoContent) + }) + + err := bgpvpns.DeletePortAssociation(fake.ServiceClient(), bgpVpnID, portAssociationID).ExtractErr() + th.AssertNoErr(t, err) +} diff --git a/openstack/networking/v2/extensions/bgpvpns/urls.go b/openstack/networking/v2/extensions/bgpvpns/urls.go new file mode 100644 index 0000000000..b2377581fa --- /dev/null +++ b/openstack/networking/v2/extensions/bgpvpns/urls.go @@ -0,0 +1,140 @@ +package bgpvpns + +import "github.com/gophercloud/gophercloud" + +const urlBase = "bgpvpn/bgpvpns" + +// return /v2.0/bgpvpn/bgpvpns/{bgpvpn-id} +func resourceURL(c *gophercloud.ServiceClient, id string) string { + return c.ServiceURL(urlBase, id) +} + +// return /v2.0/bgpvpn/bgpvpns +func rootURL(c *gophercloud.ServiceClient) string { + return c.ServiceURL(urlBase) +} + +// return /v2.0/bgpvpn/bgpvpns/{bgpvpn-id} +func getURL(c *gophercloud.ServiceClient, id string) string { + return resourceURL(c, id) +} + +// return /v2.0/bgpvpn/bgpvpns +func listURL(c *gophercloud.ServiceClient) string { + return rootURL(c) +} + +// return /v2.0/bgpvpn/bgpvpns +func createURL(c *gophercloud.ServiceClient) string { + return rootURL(c) +} + +// return /v2.0/bgpvpn/bgpvpns/{bgpvpn-id} +func deleteURL(c *gophercloud.ServiceClient, id string) string { + return resourceURL(c, id) +} + +// return /v2.0/bgpvpn/bgpvpns/{bgpvpn-id} +func updateURL(c *gophercloud.ServiceClient, id string) string { + return resourceURL(c, id) +} + +// return /v2.0/bgpvpn/bgpvpns/{bgpvpn-id}/network_associations +func networkAssociationsURL(c *gophercloud.ServiceClient, bgpVpnID string) string { + return c.ServiceURL(urlBase, bgpVpnID, "network_associations") +} + +// return /v2.0/bgpvpn/bgpvpns/{bgpvpn-id}/network_associations/{network-association-id} +func networkAssociationResourceURL(c *gophercloud.ServiceClient, bgpVpnID string, id string) string { + return c.ServiceURL(urlBase, bgpVpnID, "network_associations", id) +} + +// return /v2.0/bgpvpn/bgpvpns/{bgpvpn-id}/network_associations +func listNetworkAssociationsURL(c *gophercloud.ServiceClient, bgpVpnID string) string { + return networkAssociationsURL(c, bgpVpnID) +} + +// return /v2.0/bgpvpn/bgpvpns/{bgpvpn-id}/network_associations +func createNetworkAssociationURL(c *gophercloud.ServiceClient, bgpVpnID string) string { + return networkAssociationsURL(c, bgpVpnID) +} + +// return /v2.0/bgpvpn/bgpvpns/{bgpvpn-id}/network_associations/{network-association-id} +func getNetworkAssociationURL(c *gophercloud.ServiceClient, bgpVpnID string, id string) string { + return networkAssociationResourceURL(c, bgpVpnID, id) +} + +// return /v2.0/bgpvpn/bgpvpns/{bgpvpn-id}/network_associations/{network-association-id} +func deleteNetworkAssociationURL(c *gophercloud.ServiceClient, bgpVpnID string, id string) string { + return networkAssociationResourceURL(c, bgpVpnID, id) +} + +// return /v2.0/bgpvpn/bgpvpns/{bgpvpn-id}/router_associations +func routerAssociationsURL(c *gophercloud.ServiceClient, bgpVpnID string) string { + return c.ServiceURL(urlBase, bgpVpnID, "router_associations") +} + +// return /v2.0/bgpvpn/bgpvpns/{bgpvpn-id}/router_associations/{router-association-id} +func routerAssociationResourceURL(c *gophercloud.ServiceClient, bgpVpnID string, id string) string { + return c.ServiceURL(urlBase, bgpVpnID, "router_associations", id) +} + +// return /v2.0/bgpvpn/bgpvpns/{bgpvpn-id}/router_associations +func listRouterAssociationsURL(c *gophercloud.ServiceClient, bgpVpnID string) string { + return routerAssociationsURL(c, bgpVpnID) +} + +// return /v2.0/bgpvpn/bgpvpns/{bgpvpn-id}/router_associations +func createRouterAssociationURL(c *gophercloud.ServiceClient, bgpVpnID string) string { + return routerAssociationsURL(c, bgpVpnID) +} + +// return /v2.0/bgpvpn/bgpvpns/{bgpvpn-id}/router_associations/{router-association-id} +func getRouterAssociationURL(c *gophercloud.ServiceClient, bgpVpnID string, id string) string { + return routerAssociationResourceURL(c, bgpVpnID, id) +} + +// return /v2.0/bgpvpn/bgpvpns/{bgpvpn-id}/router_associations/{router-association-id} +func updateRouterAssociationURL(c *gophercloud.ServiceClient, bgpVpnID string, id string) string { + return routerAssociationResourceURL(c, bgpVpnID, id) +} + +// return /v2.0/bgpvpn/bgpvpns/{bgpvpn-id}/router_associations/{router-association-id} +func deleteRouterAssociationURL(c *gophercloud.ServiceClient, bgpVpnID string, id string) string { + return routerAssociationResourceURL(c, bgpVpnID, id) +} + +// return /v2.0/bgpvpn/bgpvpns/{bgpvpn-id}/port_associations +func portAssociationsURL(c *gophercloud.ServiceClient, bgpVpnID string) string { + return c.ServiceURL(urlBase, bgpVpnID, "port_associations") +} + +// return /v2.0/bgpvpn/bgpvpns/{bgpvpn-id}/port_associations/{port-association-id} +func portAssociationResourceURL(c *gophercloud.ServiceClient, bgpVpnID string, id string) string { + return c.ServiceURL(urlBase, bgpVpnID, "port_associations", id) +} + +// return /v2.0/bgpvpn/bgpvpns/{bgpvpn-id}/port_associations +func listPortAssociationsURL(c *gophercloud.ServiceClient, bgpVpnID string) string { + return portAssociationsURL(c, bgpVpnID) +} + +// return /v2.0/bgpvpn/bgpvpns/{bgpvpn-id}/port_associations +func createPortAssociationURL(c *gophercloud.ServiceClient, bgpVpnID string) string { + return portAssociationsURL(c, bgpVpnID) +} + +// return /v2.0/bgpvpn/bgpvpns/{bgpvpn-id}/port_associations/{port-association-id} +func getPortAssociationURL(c *gophercloud.ServiceClient, bgpVpnID string, id string) string { + return portAssociationResourceURL(c, bgpVpnID, id) +} + +// return /v2.0/bgpvpn/bgpvpns/{bgpvpn-id}/port_associations/{port-association-id} +func updatePortAssociationURL(c *gophercloud.ServiceClient, bgpVpnID string, id string) string { + return portAssociationResourceURL(c, bgpVpnID, id) +} + +// return /v2.0/bgpvpn/bgpvpns/{bgpvpn-id}/port_associations/{port-association-id} +func deletePortAssociationURL(c *gophercloud.ServiceClient, bgpVpnID string, id string) string { + return portAssociationResourceURL(c, bgpVpnID, id) +} diff --git a/openstack/networking/v2/extensions/dns/testing/fixtures.go b/openstack/networking/v2/extensions/dns/testing/fixtures_test.go similarity index 100% rename from openstack/networking/v2/extensions/dns/testing/fixtures.go rename to openstack/networking/v2/extensions/dns/testing/fixtures_test.go diff --git a/openstack/networking/v2/extensions/external/testing/fixtures.go b/openstack/networking/v2/extensions/external/testing/fixtures_test.go similarity index 100% rename from openstack/networking/v2/extensions/external/testing/fixtures.go rename to openstack/networking/v2/extensions/external/testing/fixtures_test.go diff --git a/openstack/networking/v2/extensions/fwaas_v2/policies/requests.go b/openstack/networking/v2/extensions/fwaas_v2/policies/requests.go index d5a701aa13..8f036ca93c 100644 --- a/openstack/networking/v2/extensions/fwaas_v2/policies/requests.go +++ b/openstack/networking/v2/extensions/fwaas_v2/policies/requests.go @@ -18,6 +18,7 @@ type ListOptsBuilder interface { // and is either `asc' or `desc'. Marker and Limit are used for pagination. type ListOpts struct { TenantID string `q:"tenant_id"` + ProjectID string `q:"project_id"` Name string `q:"name"` Description string `q:"description"` Shared *bool `q:"shared"` @@ -68,6 +69,7 @@ type CreateOpts struct { // Only required if the caller has an admin role and wants to create a firewall policy // for another tenant. TenantID string `json:"tenant_id,omitempty"` + ProjectID string `json:"project_id,omitempty"` Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Shared *bool `json:"shared,omitempty"` diff --git a/openstack/networking/v2/extensions/fwaas_v2/policies/results.go b/openstack/networking/v2/extensions/fwaas_v2/policies/results.go index c0139aea3f..8d7411c3de 100644 --- a/openstack/networking/v2/extensions/fwaas_v2/policies/results.go +++ b/openstack/networking/v2/extensions/fwaas_v2/policies/results.go @@ -11,6 +11,7 @@ type Policy struct { Name string `json:"name"` Description string `json:"description"` TenantID string `json:"tenant_id"` + ProjectID string `json:"project_id"` Audited bool `json:"audited"` Shared bool `json:"shared"` Rules []string `json:"firewall_rules,omitempty"` diff --git a/openstack/networking/v2/extensions/fwaas_v2/policies/testing/requests_test.go b/openstack/networking/v2/extensions/fwaas_v2/policies/testing/requests_test.go index ca0e09263c..e0251c770a 100644 --- a/openstack/networking/v2/extensions/fwaas_v2/policies/testing/requests_test.go +++ b/openstack/networking/v2/extensions/fwaas_v2/policies/testing/requests_test.go @@ -33,6 +33,7 @@ func TestList(t *testing.T) { "c9e77ca0-1bc8-497d-904d-948107873dc6" ], "tenant_id": "9145d91459d248b1b02fdaca97c6a75d", + "project_id": "9145d91459d248b1b02fdaca97c6a75d", "audited": true, "shared": false, "id": "f2b08c1e-aa81-4668-8ae1-1401bcb0576c", @@ -44,6 +45,7 @@ func TestList(t *testing.T) { "03d2a6ad-633f-431a-8463-4370d06a22c8" ], "tenant_id": "9145d91459d248b1b02fdaca97c6a75d", + "project_id": "9145d91459d248b1b02fdaca97c6a75d", "audited": false, "shared": true, "id": "c854fab5-bdaf-4a86-9359-78de93e5df01", @@ -72,6 +74,7 @@ func TestList(t *testing.T) { "c9e77ca0-1bc8-497d-904d-948107873dc6", }, TenantID: "9145d91459d248b1b02fdaca97c6a75d", + ProjectID: "9145d91459d248b1b02fdaca97c6a75d", Audited: true, Shared: false, ID: "f2b08c1e-aa81-4668-8ae1-1401bcb0576c", @@ -83,6 +86,7 @@ func TestList(t *testing.T) { "03d2a6ad-633f-431a-8463-4370d06a22c8", }, TenantID: "9145d91459d248b1b02fdaca97c6a75d", + ProjectID: "9145d91459d248b1b02fdaca97c6a75d", Audited: false, Shared: true, ID: "c854fab5-bdaf-4a86-9359-78de93e5df01", @@ -119,6 +123,7 @@ func TestCreate(t *testing.T) { ], "description": "Firewall policy", "tenant_id": "9145d91459d248b1b02fdaca97c6a75d", + "project_id": "9145d91459d248b1b02fdaca97c6a75d", "audited": true, "shared": false } @@ -137,6 +142,7 @@ func TestCreate(t *testing.T) { "11a58c87-76be-ae7c-a74e-b77fffb88a32" ], "tenant_id": "9145d91459d248b1b02fdaca97c6a75d", + "project_id": "9145d91459d248b1b02fdaca97c6a75d", "audited": false, "id": "f2b08c1e-aa81-4668-8ae1-1401bcb0576c", "description": "Firewall policy" @@ -147,6 +153,7 @@ func TestCreate(t *testing.T) { options := policies.CreateOpts{ TenantID: "9145d91459d248b1b02fdaca97c6a75d", + ProjectID: "9145d91459d248b1b02fdaca97c6a75d", Name: "policy", Description: "Firewall policy", Shared: gophercloud.Disabled, @@ -211,7 +218,7 @@ func TestInsertRule(t *testing.T) { th.AssertEquals(t, "e3c78ab6-e827-4297-8d68-739063865a8b", policy.ID) th.AssertEquals(t, "TESTACC-DESC-8P12aLfW", policy.Description) th.AssertEquals(t, "9f98fc0e5f944cd1b51798b668dc8778", policy.TenantID) - + th.AssertEquals(t, "9f98fc0e5f944cd1b51798b668dc8778", policy.ProjectID) } func TestInsertRuleWithInvalidParameters(t *testing.T) { @@ -253,6 +260,7 @@ func TestGet(t *testing.T) { "03d2a6ad-633f-431a-8463-4370d06a22c8" ], "tenant_id": "9145d91459d248b1b02fdaca97c6a75d", + "project_id": "9145d91459d248b1b02fdaca97c6a75d", "audited": false, "id": "f2b08c1e-aa81-4668-8ae1-1401bcb0576c", "description": "Firewall policy web" @@ -272,6 +280,7 @@ func TestGet(t *testing.T) { th.AssertEquals(t, "c9e77ca0-1bc8-497d-904d-948107873dc6", policy.Rules[1]) th.AssertEquals(t, "03d2a6ad-633f-431a-8463-4370d06a22c8", policy.Rules[2]) th.AssertEquals(t, "9145d91459d248b1b02fdaca97c6a75d", policy.TenantID) + th.AssertEquals(t, "9145d91459d248b1b02fdaca97c6a75d", policy.ProjectID) } func TestUpdate(t *testing.T) { @@ -309,6 +318,7 @@ func TestUpdate(t *testing.T) { "03d2a6ad-633f-431a-8463-4370d06a22c8" ], "tenant_id": "9145d91459d248b1b02fdaca97c6a75d", + "project_id": "9145d91459d248b1b02fdaca97c6a75d", "audited": false, "id": "f2b08c1e-aa81-4668-8ae1-1401bcb0576c", "description": "Firewall policy" diff --git a/openstack/networking/v2/extensions/fwaas_v2/rules/requests.go b/openstack/networking/v2/extensions/fwaas_v2/rules/requests.go index 7ffd681d96..d80e682796 100644 --- a/openstack/networking/v2/extensions/fwaas_v2/rules/requests.go +++ b/openstack/networking/v2/extensions/fwaas_v2/rules/requests.go @@ -117,6 +117,7 @@ type CreateOpts struct { Protocol Protocol `json:"protocol" required:"true"` Action Action `json:"action" required:"true"` TenantID string `json:"tenant_id,omitempty"` + ProjectID string `json:"project_id,omitempty"` Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` IPVersion gophercloud.IPVersion `json:"ip_version,omitempty"` diff --git a/openstack/networking/v2/extensions/fwaas_v2/rules/testing/requests_test.go b/openstack/networking/v2/extensions/fwaas_v2/rules/testing/requests_test.go index 7330833654..8ca0d70e28 100644 --- a/openstack/networking/v2/extensions/fwaas_v2/rules/testing/requests_test.go +++ b/openstack/networking/v2/extensions/fwaas_v2/rules/testing/requests_test.go @@ -37,6 +37,7 @@ func TestList(t *testing.T) { "id": "f03bd950-6c56-4f5e-a307-45967078f507", "name": "ssh_form_any", "tenant_id": "80cf934d6ffb4ef5b244f1c512ad1e61", + "project_id": "80cf934d6ffb4ef5b244f1c512ad1e61", "enabled": true, "action": "allow", "ip_version": 4, @@ -53,6 +54,7 @@ func TestList(t *testing.T) { "id": "ab7bd950-6c56-4f5e-a307-45967078f890", "name": "deny_all_udp", "tenant_id": "80cf934d6ffb4ef5b244f1c512ad1e61", + "project_id": "80cf934d6ffb4ef5b244f1c512ad1e61", "enabled": true, "action": "deny", "ip_version": 4, @@ -85,6 +87,7 @@ func TestList(t *testing.T) { ID: "f03bd950-6c56-4f5e-a307-45967078f507", Name: "ssh_form_any", TenantID: "80cf934d6ffb4ef5b244f1c512ad1e61", + ProjectID: "80cf934d6ffb4ef5b244f1c512ad1e61", Enabled: true, Action: string(rules.ActionAllow), IPVersion: 4, @@ -101,6 +104,7 @@ func TestList(t *testing.T) { ID: "ab7bd950-6c56-4f5e-a307-45967078f890", Name: "deny_all_udp", TenantID: "80cf934d6ffb4ef5b244f1c512ad1e61", + ProjectID: "80cf934d6ffb4ef5b244f1c512ad1e61", Enabled: true, Action: "deny", IPVersion: 4, @@ -135,7 +139,8 @@ func TestCreate(t *testing.T) { "destination_port": "22", "name": "ssh_form_any", "action": "allow", - "tenant_id": "80cf934d6ffb4ef5b244f1c512ad1e61" + "tenant_id": "80cf934d6ffb4ef5b244f1c512ad1e61", + "project_id": "80cf934d6ffb4ef5b244f1c512ad1e61" } } `) @@ -157,6 +162,7 @@ func TestCreate(t *testing.T) { "id": "f03bd950-6c56-4f5e-a307-45967078f507", "name": "ssh_form_any", "tenant_id": "80cf934d6ffb4ef5b244f1c512ad1e61", + "project_id": "80cf934d6ffb4ef5b244f1c512ad1e61", "enabled": true, "action": "allow", "ip_version": 4, @@ -168,6 +174,7 @@ func TestCreate(t *testing.T) { options := rules.CreateOpts{ TenantID: "80cf934d6ffb4ef5b244f1c512ad1e61", + ProjectID: "80cf934d6ffb4ef5b244f1c512ad1e61", Protocol: rules.ProtocolTCP, Description: "ssh rule", DestinationIPAddress: "192.168.1.0/24", @@ -197,7 +204,8 @@ func TestCreateAnyProtocol(t *testing.T) { "destination_ip_address": "192.168.1.0/24", "name": "any_to_192.168.1.0/24", "action": "allow", - "tenant_id": "80cf934d6ffb4ef5b244f1c512ad1e61" + "tenant_id": "80cf934d6ffb4ef5b244f1c512ad1e61", + "project_id": "80cf934d6ffb4ef5b244f1c512ad1e61" } } `) @@ -219,6 +227,7 @@ func TestCreateAnyProtocol(t *testing.T) { "id": "f03bd950-6c56-4f5e-a307-45967078f507", "name": "any_to_192.168.1.0/24", "tenant_id": "80cf934d6ffb4ef5b244f1c512ad1e61", + "project_id": "80cf934d6ffb4ef5b244f1c512ad1e61", "enabled": true, "action": "allow", "ip_version": 4, @@ -230,6 +239,7 @@ func TestCreateAnyProtocol(t *testing.T) { options := rules.CreateOpts{ TenantID: "80cf934d6ffb4ef5b244f1c512ad1e61", + ProjectID: "80cf934d6ffb4ef5b244f1c512ad1e61", Protocol: rules.ProtocolAny, Description: "any to 192.168.1.0/24", DestinationIPAddress: "192.168.1.0/24", @@ -266,6 +276,7 @@ func TestGet(t *testing.T) { "id": "f03bd950-6c56-4f5e-a307-45967078f507", "name": "ssh_form_any", "tenant_id": "80cf934d6ffb4ef5b244f1c512ad1e61", + "project_id": "80cf934d6ffb4ef5b244f1c512ad1e61", "enabled": true, "action": "allow", "ip_version": 4, @@ -287,6 +298,7 @@ func TestGet(t *testing.T) { th.AssertEquals(t, "f03bd950-6c56-4f5e-a307-45967078f507", rule.ID) th.AssertEquals(t, "ssh_form_any", rule.Name) th.AssertEquals(t, "80cf934d6ffb4ef5b244f1c512ad1e61", rule.TenantID) + th.AssertEquals(t, "80cf934d6ffb4ef5b244f1c512ad1e61", rule.ProjectID) th.AssertEquals(t, true, rule.Enabled) th.AssertEquals(t, "allow", rule.Action) th.AssertEquals(t, 4, rule.IPVersion) @@ -331,6 +343,7 @@ func TestUpdate(t *testing.T) { "id": "f03bd950-6c56-4f5e-a307-45967078f507", "name": "ssh_form_any", "tenant_id": "80cf934d6ffb4ef5b244f1c512ad1e61", + "project_id": "80cf934d6ffb4ef5b244f1c512ad1e61", "enabled": false, "action": "allow", "ip_version": 4, diff --git a/openstack/networking/v2/extensions/layer3/addressscopes/testing/fixtures.go b/openstack/networking/v2/extensions/layer3/addressscopes/testing/fixtures_test.go similarity index 100% rename from openstack/networking/v2/extensions/layer3/addressscopes/testing/fixtures.go rename to openstack/networking/v2/extensions/layer3/addressscopes/testing/fixtures_test.go diff --git a/openstack/networking/v2/extensions/layer3/portforwarding/requests.go b/openstack/networking/v2/extensions/layer3/portforwarding/requests.go index 9081bc3549..0ff314aa90 100644 --- a/openstack/networking/v2/extensions/layer3/portforwarding/requests.go +++ b/openstack/networking/v2/extensions/layer3/portforwarding/requests.go @@ -16,6 +16,7 @@ type ListOptsBuilder interface { // either `asc' or `desc'. Marker and Limit are used for pagination. type ListOpts struct { ID string `q:"id"` + Description string `q:"description"` InternalPortID string `q:"internal_port_id"` ExternalPort string `q:"external_port"` InternalIPAddress string `q:"internal_ip_address"` @@ -61,6 +62,7 @@ func Get(c *gophercloud.ServiceClient, floatingIpId string, pfId string) (r GetR // CreateOpts contains all the values needed to create a new port forwarding // resource. All attributes are required. type CreateOpts struct { + Description string `json:"description,omitempty"` InternalPortID string `json:"internal_port_id"` InternalIPAddress string `json:"internal_ip_address"` InternalPort int `json:"internal_port"` @@ -95,22 +97,18 @@ func Create(c *gophercloud.ServiceClient, floatingIpId string, opts CreateOptsBu // UpdateOpts contains the values used when updating a port forwarding resource. type UpdateOpts struct { - InternalPortID string `json:"internal_port_id,omitempty"` - InternalIPAddress string `json:"internal_ip_address,omitempty"` - InternalPort int `json:"internal_port,omitempty"` - ExternalPort int `json:"external_port,omitempty"` - Protocol string `json:"protocol,omitempty"` + Description *string `json:"description,omitempty"` + InternalPortID string `json:"internal_port_id,omitempty"` + InternalIPAddress string `json:"internal_ip_address,omitempty"` + InternalPort int `json:"internal_port,omitempty"` + ExternalPort int `json:"external_port,omitempty"` + Protocol string `json:"protocol,omitempty"` } // ToPortForwardingUpdateMap allows UpdateOpts to satisfy the UpdateOptsBuilder // interface func (opts UpdateOpts) ToPortForwardingUpdateMap() (map[string]interface{}, error) { - b, err := gophercloud.BuildRequestBody(opts, "port_forwarding") - if err != nil { - return nil, err - } - - return b, nil + return gophercloud.BuildRequestBody(opts, "port_forwarding") } // UpdateOptsBuilder allows extensions to add additional parameters to the diff --git a/openstack/networking/v2/extensions/layer3/portforwarding/results.go b/openstack/networking/v2/extensions/layer3/portforwarding/results.go index 70bd097336..db19e1b329 100644 --- a/openstack/networking/v2/extensions/layer3/portforwarding/results.go +++ b/openstack/networking/v2/extensions/layer3/portforwarding/results.go @@ -9,6 +9,10 @@ type PortForwarding struct { // The ID of the floating IP port forwarding ID string `json:"id"` + // A text describing the rule, which helps users to manage/find easily + // theirs rules. + Description string `json:"description"` + // The ID of the Neutron port associated to the floating IP port forwarding. InternalPortID string `json:"internal_port_id"` diff --git a/openstack/networking/v2/extensions/layer3/portforwarding/testing/fixtures.go b/openstack/networking/v2/extensions/layer3/portforwarding/testing/fixtures_test.go similarity index 100% rename from openstack/networking/v2/extensions/layer3/portforwarding/testing/fixtures.go rename to openstack/networking/v2/extensions/layer3/portforwarding/testing/fixtures_test.go diff --git a/openstack/networking/v2/extensions/layer3/routers/results.go b/openstack/networking/v2/extensions/layer3/routers/results.go index 0c93918991..1c93eab506 100644 --- a/openstack/networking/v2/extensions/layer3/routers/results.go +++ b/openstack/networking/v2/extensions/layer3/routers/results.go @@ -14,6 +14,7 @@ type GatewayInfo struct { NetworkID string `json:"network_id,omitempty"` EnableSNAT *bool `json:"enable_snat,omitempty"` ExternalFixedIPs []ExternalFixedIP `json:"external_fixed_ips,omitempty"` + QoSPolicyID string `json:"qos_policy_id,omitempty"` } // ExternalFixedIP is the IP address and subnet ID of the external gateway of a diff --git a/openstack/networking/v2/extensions/layer3/routers/testing/requests_test.go b/openstack/networking/v2/extensions/layer3/routers/testing/requests_test.go index 81818e59d7..4f2de23b53 100644 --- a/openstack/networking/v2/extensions/layer3/routers/testing/requests_test.go +++ b/openstack/networking/v2/extensions/layer3/routers/testing/requests_test.go @@ -53,7 +53,8 @@ func TestList(t *testing.T) { "external_fixed_ips": [ {"ip_address": "192.0.2.17", "subnet_id": "ab561bc4-1a8e-48f2-9fbd-376fcb1a1def"}, {"ip_address": "198.51.100.33", "subnet_id": "1d699529-bdfd-43f8-bcaa-bff00c547af2"} - ] + ], + "qos_policy_id": "6601bae5-f15a-4687-8be9-ddec9a2f8a8b" }, "name": "gateway", "admin_state_up": true, @@ -103,6 +104,7 @@ func TestList(t *testing.T) { {IPAddress: "192.0.2.17", SubnetID: "ab561bc4-1a8e-48f2-9fbd-376fcb1a1def"}, {IPAddress: "198.51.100.33", SubnetID: "1d699529-bdfd-43f8-bcaa-bff00c547af2"}, }, + QoSPolicyID: "6601bae5-f15a-4687-8be9-ddec9a2f8a8b", }, AdminStateUp: true, Distributed: false, @@ -141,7 +143,8 @@ func TestCreate(t *testing.T) { "network_id":"8ca37218-28ff-41cb-9b10-039601ea7e6b", "external_fixed_ips": [ {"subnet_id": "ab561bc4-1a8e-48f2-9fbd-376fcb1a1def"} - ] + ], + "qos_policy_id": "6601bae5-f15a-4687-8be9-ddec9a2f8a8b" }, "availability_zone_hints": ["zone1", "zone2"] } @@ -160,7 +163,8 @@ func TestCreate(t *testing.T) { "enable_snat": false, "external_fixed_ips": [ {"ip_address": "192.0.2.17", "subnet_id": "ab561bc4-1a8e-48f2-9fbd-376fcb1a1def"} - ] + ], + "qos_policy_id": "6601bae5-f15a-4687-8be9-ddec9a2f8a8b" }, "name": "foo_router", "admin_state_up": false, @@ -175,6 +179,7 @@ func TestCreate(t *testing.T) { asu := false enableSNAT := false + qosID := "6601bae5-f15a-4687-8be9-ddec9a2f8a8b" efi := []routers.ExternalFixedIP{ { SubnetID: "ab561bc4-1a8e-48f2-9fbd-376fcb1a1def", @@ -184,6 +189,7 @@ func TestCreate(t *testing.T) { NetworkID: "8ca37218-28ff-41cb-9b10-039601ea7e6b", EnableSNAT: &enableSNAT, ExternalFixedIPs: efi, + QoSPolicyID: qosID, } options := routers.CreateOpts{ Name: "foo_router", @@ -224,7 +230,8 @@ func TestGet(t *testing.T) { "network_id": "85d76829-6415-48ff-9c63-5c5ca8c61ac6", "external_fixed_ips": [ {"ip_address": "198.51.100.33", "subnet_id": "1d699529-bdfd-43f8-bcaa-bff00c547af2"} - ] + ], + "qos_policy_id": "6601bae5-f15a-4687-8be9-ddec9a2f8a8b" }, "routes": [ { @@ -252,6 +259,7 @@ func TestGet(t *testing.T) { ExternalFixedIPs: []routers.ExternalFixedIP{ {IPAddress: "198.51.100.33", SubnetID: "1d699529-bdfd-43f8-bcaa-bff00c547af2"}, }, + QoSPolicyID: "6601bae5-f15a-4687-8be9-ddec9a2f8a8b", }) th.AssertEquals(t, n.Name, "router1") th.AssertEquals(t, n.AdminStateUp, true) @@ -275,7 +283,8 @@ func TestUpdate(t *testing.T) { "router": { "name": "new_name", "external_gateway_info": { - "network_id": "8ca37218-28ff-41cb-9b10-039601ea7e6b" + "network_id": "8ca37218-28ff-41cb-9b10-039601ea7e6b", + "qos_policy_id": "01ba32e5-f15a-4687-8be9-ddec92a2f8a8" }, "routes": [ { @@ -298,7 +307,8 @@ func TestUpdate(t *testing.T) { "network_id": "8ca37218-28ff-41cb-9b10-039601ea7e6b", "external_fixed_ips": [ {"ip_address": "192.0.2.17", "subnet_id": "ab561bc4-1a8e-48f2-9fbd-376fcb1a1def"} - ] + ], + "qos_policy_id": "01ba32e5-f15a-4687-8be9-ddec92a2f8a8" }, "name": "new_name", "admin_state_up": true, @@ -316,7 +326,10 @@ func TestUpdate(t *testing.T) { `) }) - gwi := routers.GatewayInfo{NetworkID: "8ca37218-28ff-41cb-9b10-039601ea7e6b"} + gwi := routers.GatewayInfo{ + NetworkID: "8ca37218-28ff-41cb-9b10-039601ea7e6b", + QoSPolicyID: "01ba32e5-f15a-4687-8be9-ddec92a2f8a8", + } r := []routers.Route{{DestinationCIDR: "40.0.1.0/24", NextHop: "10.1.0.10"}} options := routers.UpdateOpts{Name: "new_name", GatewayInfo: &gwi, Routes: &r} diff --git a/openstack/networking/v2/extensions/lbaas_v2/l7policies/testing/fixtures.go b/openstack/networking/v2/extensions/lbaas_v2/l7policies/testing/fixtures_test.go similarity index 100% rename from openstack/networking/v2/extensions/lbaas_v2/l7policies/testing/fixtures.go rename to openstack/networking/v2/extensions/lbaas_v2/l7policies/testing/fixtures_test.go diff --git a/openstack/networking/v2/extensions/lbaas_v2/listeners/testing/fixtures.go b/openstack/networking/v2/extensions/lbaas_v2/listeners/testing/fixtures_test.go similarity index 100% rename from openstack/networking/v2/extensions/lbaas_v2/listeners/testing/fixtures.go rename to openstack/networking/v2/extensions/lbaas_v2/listeners/testing/fixtures_test.go diff --git a/openstack/networking/v2/extensions/lbaas_v2/loadbalancers/testing/fixtures.go b/openstack/networking/v2/extensions/lbaas_v2/loadbalancers/testing/fixtures_test.go similarity index 100% rename from openstack/networking/v2/extensions/lbaas_v2/loadbalancers/testing/fixtures.go rename to openstack/networking/v2/extensions/lbaas_v2/loadbalancers/testing/fixtures_test.go diff --git a/openstack/networking/v2/extensions/lbaas_v2/monitors/testing/fixtures.go b/openstack/networking/v2/extensions/lbaas_v2/monitors/testing/fixtures_test.go similarity index 100% rename from openstack/networking/v2/extensions/lbaas_v2/monitors/testing/fixtures.go rename to openstack/networking/v2/extensions/lbaas_v2/monitors/testing/fixtures_test.go diff --git a/openstack/networking/v2/extensions/lbaas_v2/pools/testing/fixtures.go b/openstack/networking/v2/extensions/lbaas_v2/pools/testing/fixtures_test.go similarity index 100% rename from openstack/networking/v2/extensions/lbaas_v2/pools/testing/fixtures.go rename to openstack/networking/v2/extensions/lbaas_v2/pools/testing/fixtures_test.go diff --git a/openstack/networking/v2/extensions/mtu/testing/fixtures.go b/openstack/networking/v2/extensions/mtu/testing/fixtures_test.go similarity index 100% rename from openstack/networking/v2/extensions/mtu/testing/fixtures.go rename to openstack/networking/v2/extensions/mtu/testing/fixtures_test.go diff --git a/openstack/networking/v2/extensions/networkipavailabilities/testing/fixtures.go b/openstack/networking/v2/extensions/networkipavailabilities/testing/fixtures_test.go similarity index 100% rename from openstack/networking/v2/extensions/networkipavailabilities/testing/fixtures.go rename to openstack/networking/v2/extensions/networkipavailabilities/testing/fixtures_test.go diff --git a/openstack/networking/v2/extensions/portsbinding/testing/fixtures.go b/openstack/networking/v2/extensions/portsbinding/testing/fixtures_test.go similarity index 100% rename from openstack/networking/v2/extensions/portsbinding/testing/fixtures.go rename to openstack/networking/v2/extensions/portsbinding/testing/fixtures_test.go diff --git a/openstack/networking/v2/extensions/qos/policies/testing/fixtures.go b/openstack/networking/v2/extensions/qos/policies/testing/fixtures_test.go similarity index 100% rename from openstack/networking/v2/extensions/qos/policies/testing/fixtures.go rename to openstack/networking/v2/extensions/qos/policies/testing/fixtures_test.go diff --git a/openstack/networking/v2/extensions/qos/rules/testing/fixtures.go b/openstack/networking/v2/extensions/qos/rules/testing/fixtures_test.go similarity index 100% rename from openstack/networking/v2/extensions/qos/rules/testing/fixtures.go rename to openstack/networking/v2/extensions/qos/rules/testing/fixtures_test.go diff --git a/openstack/networking/v2/extensions/qos/ruletypes/doc.go b/openstack/networking/v2/extensions/qos/ruletypes/doc.go index c36081b485..e87efd96bd 100644 --- a/openstack/networking/v2/extensions/qos/ruletypes/doc.go +++ b/openstack/networking/v2/extensions/qos/ruletypes/doc.go @@ -15,7 +15,7 @@ Example of Listing QoS rule types fmt.Printf("%v <- Rule Types\n", rules) -Example of Getting a single QoS rule type by it's name +Example of Getting a single QoS rule type by name ruleTypeName := "bandwidth_limit" diff --git a/openstack/networking/v2/extensions/qos/ruletypes/testing/fixtures.go b/openstack/networking/v2/extensions/qos/ruletypes/testing/fixtures_test.go similarity index 100% rename from openstack/networking/v2/extensions/qos/ruletypes/testing/fixtures.go rename to openstack/networking/v2/extensions/qos/ruletypes/testing/fixtures_test.go diff --git a/openstack/networking/v2/extensions/quotas/testing/fixtures.go b/openstack/networking/v2/extensions/quotas/testing/fixtures_test.go similarity index 100% rename from openstack/networking/v2/extensions/quotas/testing/fixtures.go rename to openstack/networking/v2/extensions/quotas/testing/fixtures_test.go diff --git a/openstack/networking/v2/extensions/rbacpolicies/testing/fixtures.go b/openstack/networking/v2/extensions/rbacpolicies/testing/fixtures_test.go similarity index 100% rename from openstack/networking/v2/extensions/rbacpolicies/testing/fixtures.go rename to openstack/networking/v2/extensions/rbacpolicies/testing/fixtures_test.go diff --git a/openstack/networking/v2/extensions/security/groups/requests.go b/openstack/networking/v2/extensions/security/groups/requests.go index 566a730eaf..645f87cfa9 100644 --- a/openstack/networking/v2/extensions/security/groups/requests.go +++ b/openstack/networking/v2/extensions/security/groups/requests.go @@ -14,6 +14,7 @@ type ListOpts struct { ID string `q:"id"` Name string `q:"name"` Description string `q:"description"` + Stateful *bool `q:"stateful"` TenantID string `q:"tenant_id"` ProjectID string `q:"project_id"` Limit int `q:"limit"` @@ -61,6 +62,9 @@ type CreateOpts struct { // Describes the security group. Description string `json:"description,omitempty"` + + // Stateful indicates if the security group is stateful or stateless. + Stateful *bool `json:"stateful,omitempty"` } // ToSecGroupCreateMap builds a request body from CreateOpts. @@ -95,6 +99,9 @@ type UpdateOpts struct { // Describes the security group. Description *string `json:"description,omitempty"` + + // Stateful indicates if the security group is stateful or stateless. + Stateful *bool `json:"stateful,omitempty"` } // ToSecGroupUpdateMap builds a request body from UpdateOpts. diff --git a/openstack/networking/v2/extensions/security/groups/results.go b/openstack/networking/v2/extensions/security/groups/results.go index 2027037de2..f892bcb5c2 100644 --- a/openstack/networking/v2/extensions/security/groups/results.go +++ b/openstack/networking/v2/extensions/security/groups/results.go @@ -25,6 +25,9 @@ type SecGroup struct { // traffic entering and leaving the group. Rules []rules.SecGroupRule `json:"security_group_rules"` + // Indicates if the security group is stateful or stateless. + Stateful bool `json:"stateful"` + // TenantID is the project owner of the security group. TenantID string `json:"tenant_id"` diff --git a/openstack/networking/v2/extensions/security/groups/testing/fixtures.go b/openstack/networking/v2/extensions/security/groups/testing/fixtures_test.go similarity index 100% rename from openstack/networking/v2/extensions/security/groups/testing/fixtures.go rename to openstack/networking/v2/extensions/security/groups/testing/fixtures_test.go diff --git a/openstack/networking/v2/extensions/security/rules/requests.go b/openstack/networking/v2/extensions/security/rules/requests.go index 364f7f5c98..480b1510ca 100644 --- a/openstack/networking/v2/extensions/security/rules/requests.go +++ b/openstack/networking/v2/extensions/security/rules/requests.go @@ -75,7 +75,7 @@ const ( ProtocolUDP RuleProtocol = "udp" ProtocolUDPLite RuleProtocol = "udplite" ProtocolVRRP RuleProtocol = "vrrp" - ProtocolAny RuleProtocol = "any" + ProtocolAny RuleProtocol = "" ) // CreateOptsBuilder allows extensions to add additional parameters to the diff --git a/openstack/networking/v2/extensions/subnetpools/testing/fixtures.go b/openstack/networking/v2/extensions/subnetpools/testing/fixtures_test.go similarity index 100% rename from openstack/networking/v2/extensions/subnetpools/testing/fixtures.go rename to openstack/networking/v2/extensions/subnetpools/testing/fixtures_test.go diff --git a/openstack/networking/v2/extensions/trunk_details/testing/fixtures.go b/openstack/networking/v2/extensions/trunk_details/testing/fixtures_test.go similarity index 100% rename from openstack/networking/v2/extensions/trunk_details/testing/fixtures.go rename to openstack/networking/v2/extensions/trunk_details/testing/fixtures_test.go diff --git a/openstack/networking/v2/extensions/trunks/testing/fixtures.go b/openstack/networking/v2/extensions/trunks/testing/fixtures_test.go similarity index 100% rename from openstack/networking/v2/extensions/trunks/testing/fixtures.go rename to openstack/networking/v2/extensions/trunks/testing/fixtures_test.go diff --git a/openstack/networking/v2/extensions/vlantransparent/testing/fixtures.go b/openstack/networking/v2/extensions/vlantransparent/testing/fixtures_test.go similarity index 100% rename from openstack/networking/v2/extensions/vlantransparent/testing/fixtures.go rename to openstack/networking/v2/extensions/vlantransparent/testing/fixtures_test.go diff --git a/openstack/networking/v2/ports/requests.go b/openstack/networking/v2/ports/requests.go index 48f9985643..805f0e5b99 100644 --- a/openstack/networking/v2/ports/requests.go +++ b/openstack/networking/v2/ports/requests.go @@ -21,26 +21,27 @@ type ListOptsBuilder interface { // by a particular port attribute. SortDir sets the direction, and is either // `asc' or `desc'. Marker and Limit are used for pagination. type ListOpts struct { - Status string `q:"status"` - Name string `q:"name"` - Description string `q:"description"` - AdminStateUp *bool `q:"admin_state_up"` - NetworkID string `q:"network_id"` - TenantID string `q:"tenant_id"` - ProjectID string `q:"project_id"` - DeviceOwner string `q:"device_owner"` - MACAddress string `q:"mac_address"` - ID string `q:"id"` - DeviceID string `q:"device_id"` - Limit int `q:"limit"` - Marker string `q:"marker"` - SortKey string `q:"sort_key"` - SortDir string `q:"sort_dir"` - Tags string `q:"tags"` - TagsAny string `q:"tags-any"` - NotTags string `q:"not-tags"` - NotTagsAny string `q:"not-tags-any"` - FixedIPs []FixedIPOpts + Status string `q:"status"` + Name string `q:"name"` + Description string `q:"description"` + AdminStateUp *bool `q:"admin_state_up"` + NetworkID string `q:"network_id"` + TenantID string `q:"tenant_id"` + ProjectID string `q:"project_id"` + DeviceOwner string `q:"device_owner"` + MACAddress string `q:"mac_address"` + ID string `q:"id"` + DeviceID string `q:"device_id"` + Limit int `q:"limit"` + Marker string `q:"marker"` + SortKey string `q:"sort_key"` + SortDir string `q:"sort_dir"` + Tags string `q:"tags"` + TagsAny string `q:"tags-any"` + NotTags string `q:"not-tags"` + NotTagsAny string `q:"not-tags-any"` + SecurityGroups []string `q:"security_groups"` + FixedIPs []FixedIPOpts } type FixedIPOpts struct { diff --git a/openstack/networking/v2/subnets/requests.go b/openstack/networking/v2/subnets/requests.go index 2e87907587..a9e28faf04 100644 --- a/openstack/networking/v2/subnets/requests.go +++ b/openstack/networking/v2/subnets/requests.go @@ -19,27 +19,28 @@ type ListOptsBuilder interface { // by a particular subnet attribute. SortDir sets the direction, and is either // `asc' or `desc'. Marker and Limit are used for pagination. type ListOpts struct { - Name string `q:"name"` - Description string `q:"description"` - EnableDHCP *bool `q:"enable_dhcp"` - NetworkID string `q:"network_id"` - TenantID string `q:"tenant_id"` - ProjectID string `q:"project_id"` - IPVersion int `q:"ip_version"` - GatewayIP string `q:"gateway_ip"` - CIDR string `q:"cidr"` - IPv6AddressMode string `q:"ipv6_address_mode"` - IPv6RAMode string `q:"ipv6_ra_mode"` - ID string `q:"id"` - SubnetPoolID string `q:"subnetpool_id"` - Limit int `q:"limit"` - Marker string `q:"marker"` - SortKey string `q:"sort_key"` - SortDir string `q:"sort_dir"` - Tags string `q:"tags"` - TagsAny string `q:"tags-any"` - NotTags string `q:"not-tags"` - NotTagsAny string `q:"not-tags-any"` + Name string `q:"name"` + Description string `q:"description"` + DNSPublishFixedIP *bool `q:"dns_publish_fixed_ip"` + EnableDHCP *bool `q:"enable_dhcp"` + NetworkID string `q:"network_id"` + TenantID string `q:"tenant_id"` + ProjectID string `q:"project_id"` + IPVersion int `q:"ip_version"` + GatewayIP string `q:"gateway_ip"` + CIDR string `q:"cidr"` + IPv6AddressMode string `q:"ipv6_address_mode"` + IPv6RAMode string `q:"ipv6_ra_mode"` + ID string `q:"id"` + SubnetPoolID string `q:"subnetpool_id"` + Limit int `q:"limit"` + Marker string `q:"marker"` + SortKey string `q:"sort_key"` + SortDir string `q:"sort_dir"` + Tags string `q:"tags"` + TagsAny string `q:"tags-any"` + NotTags string `q:"not-tags"` + NotTagsAny string `q:"not-tags-any"` } // ToSubnetListQuery formats a ListOpts into a query string. @@ -122,6 +123,9 @@ type CreateOpts struct { // DNSNameservers are the nameservers to be set via DHCP. DNSNameservers []string `json:"dns_nameservers,omitempty"` + // DNSPublishFixedIP will either enable or disable the publication of fixed IPs to the DNS + DNSPublishFixedIP *bool `json:"dns_publish_fixed_ip,omitempty"` + // ServiceTypes are the service types associated with the subnet. ServiceTypes []string `json:"service_types,omitempty"` @@ -188,15 +192,17 @@ type UpdateOpts struct { // AllocationPools are IP Address pools that will be available for DHCP. AllocationPools []AllocationPool `json:"allocation_pools,omitempty"` - // GatewayIP sets gateway information for the subnet. Setting to nil will - // cause a default gateway to automatically be created. Setting to an empty - // string will cause the subnet to be created with no gateway. Setting to + // GatewayIP sets gateway information for the subnet. Setting to an empty + // string will cause the subnet to not have a gateway. Setting to // an explicit address will set that address as the gateway. GatewayIP *string `json:"gateway_ip,omitempty"` // DNSNameservers are the nameservers to be set via DHCP. DNSNameservers *[]string `json:"dns_nameservers,omitempty"` + // DNSPublishFixedIP will either enable or disable the publication of fixed IPs to the DNS + DNSPublishFixedIP *bool `json:"dns_publish_fixed_ip,omitempty"` + // ServiceTypes are the service types associated with the subnet. ServiceTypes *[]string `json:"service_types,omitempty"` diff --git a/openstack/networking/v2/subnets/results.go b/openstack/networking/v2/subnets/results.go index cd09b6f6e6..422eb428bf 100644 --- a/openstack/networking/v2/subnets/results.go +++ b/openstack/networking/v2/subnets/results.go @@ -83,6 +83,9 @@ type Subnet struct { // DNS name servers used by hosts in this subnet. DNSNameservers []string `json:"dns_nameservers"` + // Specifies whether the fixed IP addresses are published to the DNS. + DNSPublishFixedIP bool `json:"dns_publish_fixed_ip"` + // Service types associated with the subnet. ServiceTypes []string `json:"service_types"` diff --git a/openstack/networking/v2/subnets/testing/fixtures.go b/openstack/networking/v2/subnets/testing/fixtures.go deleted file mode 100644 index af8512e549..0000000000 --- a/openstack/networking/v2/subnets/testing/fixtures.go +++ /dev/null @@ -1,571 +0,0 @@ -package testing - -import ( - "github.com/gophercloud/gophercloud/openstack/networking/v2/subnets" -) - -const SubnetListResult = ` -{ - "subnets": [ - { - "name": "private-subnet", - "enable_dhcp": true, - "network_id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324", - "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e", - "dns_nameservers": [], - "allocation_pools": [ - { - "start": "10.0.0.2", - "end": "10.0.0.254" - } - ], - "host_routes": [], - "ip_version": 4, - "gateway_ip": "10.0.0.1", - "cidr": "10.0.0.0/24", - "id": "08eae331-0402-425a-923c-34f7cfe39c1b" - }, - { - "name": "my_subnet", - "enable_dhcp": true, - "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", - "tenant_id": "4fd44f30292945e481c7b8a0c8908869", - "dns_nameservers": [], - "allocation_pools": [ - { - "start": "192.0.0.2", - "end": "192.255.255.254" - } - ], - "host_routes": [], - "ip_version": 4, - "gateway_ip": "192.0.0.1", - "cidr": "192.0.0.0/8", - "id": "54d6f61d-db07-451c-9ab3-b9609b6b6f0b" - }, - { - "name": "my_gatewayless_subnet", - "enable_dhcp": true, - "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a23", - "tenant_id": "4fd44f30292945e481c7b8a0c8908869", - "dns_nameservers": [], - "allocation_pools": [ - { - "start": "192.168.1.2", - "end": "192.168.1.254" - } - ], - "host_routes": [], - "ip_version": 4, - "gateway_ip": null, - "cidr": "192.168.1.0/24", - "id": "54d6f61d-db07-451c-9ab3-b9609b6b6f0c" - }, - { - "name": "my_subnet_with_subnetpool", - "enable_dhcp": false, - "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a23", - "tenant_id": "4fd44f30292945e481c7b8a0c8908869", - "dns_nameservers": [], - "allocation_pools": [ - { - "start": "10.11.12.2", - "end": "10.11.12.254" - } - ], - "host_routes": [], - "ip_version": 4, - "gateway_ip": null, - "cidr": "10.11.12.0/24", - "id": "38186a51-f373-4bbc-838b-6eaa1aa13eac", - "subnetpool_id": "b80340c7-9960-4f67-a99c-02501656284b" - } - ] -} -` - -var Subnet1 = subnets.Subnet{ - Name: "private-subnet", - EnableDHCP: true, - NetworkID: "db193ab3-96e3-4cb3-8fc5-05f4296d0324", - TenantID: "26a7980765d0414dbc1fc1f88cdb7e6e", - DNSNameservers: []string{}, - AllocationPools: []subnets.AllocationPool{ - { - Start: "10.0.0.2", - End: "10.0.0.254", - }, - }, - HostRoutes: []subnets.HostRoute{}, - IPVersion: 4, - GatewayIP: "10.0.0.1", - CIDR: "10.0.0.0/24", - ID: "08eae331-0402-425a-923c-34f7cfe39c1b", -} - -var Subnet2 = subnets.Subnet{ - Name: "my_subnet", - EnableDHCP: true, - NetworkID: "d32019d3-bc6e-4319-9c1d-6722fc136a22", - TenantID: "4fd44f30292945e481c7b8a0c8908869", - DNSNameservers: []string{}, - AllocationPools: []subnets.AllocationPool{ - { - Start: "192.0.0.2", - End: "192.255.255.254", - }, - }, - HostRoutes: []subnets.HostRoute{}, - IPVersion: 4, - GatewayIP: "192.0.0.1", - CIDR: "192.0.0.0/8", - ID: "54d6f61d-db07-451c-9ab3-b9609b6b6f0b", -} - -var Subnet3 = subnets.Subnet{ - Name: "my_gatewayless_subnet", - EnableDHCP: true, - NetworkID: "d32019d3-bc6e-4319-9c1d-6722fc136a23", - TenantID: "4fd44f30292945e481c7b8a0c8908869", - DNSNameservers: []string{}, - AllocationPools: []subnets.AllocationPool{ - { - Start: "192.168.1.2", - End: "192.168.1.254", - }, - }, - HostRoutes: []subnets.HostRoute{}, - IPVersion: 4, - GatewayIP: "", - CIDR: "192.168.1.0/24", - ID: "54d6f61d-db07-451c-9ab3-b9609b6b6f0c", -} - -var Subnet4 = subnets.Subnet{ - Name: "my_subnet_with_subnetpool", - EnableDHCP: false, - NetworkID: "d32019d3-bc6e-4319-9c1d-6722fc136a23", - TenantID: "4fd44f30292945e481c7b8a0c8908869", - DNSNameservers: []string{}, - AllocationPools: []subnets.AllocationPool{ - { - Start: "10.11.12.2", - End: "10.11.12.254", - }, - }, - HostRoutes: []subnets.HostRoute{}, - IPVersion: 4, - GatewayIP: "", - CIDR: "10.11.12.0/24", - ID: "38186a51-f373-4bbc-838b-6eaa1aa13eac", - SubnetPoolID: "b80340c7-9960-4f67-a99c-02501656284b", -} - -const SubnetGetResult = ` -{ - "subnet": { - "name": "my_subnet", - "enable_dhcp": true, - "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", - "tenant_id": "4fd44f30292945e481c7b8a0c8908869", - "dns_nameservers": [], - "allocation_pools": [ - { - "start": "192.0.0.2", - "end": "192.255.255.254" - } - ], - "host_routes": [], - "ip_version": 4, - "gateway_ip": "192.0.0.1", - "cidr": "192.0.0.0/8", - "id": "54d6f61d-db07-451c-9ab3-b9609b6b6f0b", - "subnetpool_id": "b80340c7-9960-4f67-a99c-02501656284b" - } -} -` - -const SubnetCreateRequest = ` -{ - "subnet": { - "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", - "ip_version": 4, - "gateway_ip": "192.168.199.1", - "cidr": "192.168.199.0/24", - "dns_nameservers": ["foo"], - "service_types": ["network:routed"], - "allocation_pools": [ - { - "start": "192.168.199.2", - "end": "192.168.199.254" - } - ], - "host_routes": [{"destination":"","nexthop": "bar"}], - "subnetpool_id": "b80340c7-9960-4f67-a99c-02501656284b" - } -} -` - -const SubnetCreateResult = ` -{ - "subnet": { - "name": "", - "enable_dhcp": true, - "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", - "tenant_id": "4fd44f30292945e481c7b8a0c8908869", - "dns_nameservers": ["foo"], - "service_types": ["network:routed"], - "allocation_pools": [ - { - "start": "192.168.199.2", - "end": "192.168.199.254" - } - ], - "host_routes": [], - "ip_version": 4, - "gateway_ip": "192.168.199.1", - "cidr": "192.168.199.0/24", - "id": "3b80198d-4f7b-4f77-9ef5-774d54e17126", - "subnetpool_id": "b80340c7-9960-4f67-a99c-02501656284b" - } -} -` - -const SubnetCreateWithNoGatewayRequest = ` -{ - "subnet": { - "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a23", - "ip_version": 4, - "cidr": "192.168.1.0/24", - "gateway_ip": null, - "allocation_pools": [ - { - "start": "192.168.1.2", - "end": "192.168.1.254" - } - ] - } -} -` - -const SubnetCreateWithNoGatewayResponse = ` -{ - "subnet": { - "name": "", - "enable_dhcp": true, - "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a23", - "tenant_id": "4fd44f30292945e481c7b8a0c8908869", - "allocation_pools": [ - { - "start": "192.168.1.2", - "end": "192.168.1.254" - } - ], - "host_routes": [], - "ip_version": 4, - "gateway_ip": null, - "cidr": "192.168.1.0/24", - "id": "54d6f61d-db07-451c-9ab3-b9609b6b6f0c" - } -} -` - -const SubnetCreateWithDefaultGatewayRequest = ` -{ - "subnet": { - "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a23", - "ip_version": 4, - "cidr": "192.168.1.0/24", - "allocation_pools": [ - { - "start": "192.168.1.2", - "end": "192.168.1.254" - } - ] - } -} -` - -const SubnetCreateWithDefaultGatewayResponse = ` -{ - "subnet": { - "name": "", - "enable_dhcp": true, - "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a23", - "tenant_id": "4fd44f30292945e481c7b8a0c8908869", - "allocation_pools": [ - { - "start": "192.168.1.2", - "end": "192.168.1.254" - } - ], - "host_routes": [], - "ip_version": 4, - "gateway_ip": "192.168.1.1", - "cidr": "192.168.1.0/24", - "id": "54d6f61d-db07-451c-9ab3-b9609b6b6f0c" - } -} -` -const SubnetCreateWithIPv6RaAddressModeRequest = ` -{ - "subnet": { - "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", - "ip_version": 6, - "gateway_ip": "2001:db8:0:a::1", - "cidr": "2001:db8:0:a:0:0:0:0/64", - "ipv6_address_mode": "slaac", - "ipv6_ra_mode": "slaac" - } -} -` -const SubnetCreateWithIPv6RaAddressModeResponse = ` -{ - "subnet": { - "name": "", - "enable_dhcp": true, - "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", - "tenant_id": "4fd44f30292945e481c7b8a0c8908869", - "dns_nameservers": [], - "host_routes": [], - "ip_version": 6, - "gateway_ip": "2001:db8:0:a::1", - "cidr": "2001:db8:0:a:0:0:0:0/64", - "id": "3b80198d-4f7b-4f77-9ef5-774d54e17126", - "ipv6_address_mode": "slaac", - "ipv6_ra_mode": "slaac" - } -} -` - -const SubnetCreateRequestWithNoCIDR = ` -{ - "subnet": { - "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", - "ip_version": 4, - "dns_nameservers": ["foo"], - "host_routes": [{"destination":"","nexthop": "bar"}], - "subnetpool_id": "b80340c7-9960-4f67-a99c-02501656284b" - } -} -` - -const SubnetCreateRequestWithPrefixlen = ` -{ - "subnet": { - "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", - "ip_version": 4, - "dns_nameservers": ["foo"], - "host_routes": [{"destination":"","nexthop": "bar"}], - "subnetpool_id": "b80340c7-9960-4f67-a99c-02501656284b", - "prefixlen": 12 - } -} -` - -const SubnetUpdateRequest = ` -{ - "subnet": { - "name": "my_new_subnet", - "dns_nameservers": ["foo"], - "host_routes": [{"destination":"","nexthop": "bar"}] - } -} -` - -const SubnetUpdateResponse = ` -{ - "subnet": { - "name": "my_new_subnet", - "enable_dhcp": true, - "network_id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324", - "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e", - "dns_nameservers": [], - "allocation_pools": [ - { - "start": "10.0.0.2", - "end": "10.0.0.254" - } - ], - "host_routes": [], - "ip_version": 4, - "gateway_ip": "10.0.0.1", - "cidr": "10.0.0.0/24", - "id": "08eae331-0402-425a-923c-34f7cfe39c1b" - } -} -` - -const SubnetUpdateGatewayRequest = ` -{ - "subnet": { - "name": "my_new_subnet", - "gateway_ip": "10.0.0.1" - } -} -` - -const SubnetUpdateGatewayResponse = ` -{ - "subnet": { - "name": "my_new_subnet", - "enable_dhcp": true, - "network_id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324", - "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e", - "dns_nameservers": [], - "allocation_pools": [ - { - "start": "10.0.0.2", - "end": "10.0.0.254" - } - ], - "host_routes": [], - "ip_version": 4, - "gateway_ip": "10.0.0.1", - "cidr": "10.0.0.0/24", - "id": "08eae331-0402-425a-923c-34f7cfe39c1b" - } -} -` - -const SubnetUpdateRemoveGatewayRequest = ` -{ - "subnet": { - "name": "my_new_subnet", - "gateway_ip": null - } -} -` - -const SubnetUpdateRemoveGatewayResponse = ` -{ - "subnet": { - "name": "my_new_subnet", - "enable_dhcp": true, - "network_id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324", - "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e", - "dns_nameservers": [], - "allocation_pools": [ - { - "start": "10.0.0.2", - "end": "10.0.0.254" - } - ], - "host_routes": [], - "ip_version": 4, - "gateway_ip": null, - "cidr": "10.0.0.0/24", - "id": "08eae331-0402-425a-923c-34f7cfe39c1b" - } -} -` - -const SubnetUpdateHostRoutesRequest = ` -{ - "subnet": { - "name": "my_new_subnet", - "host_routes": [ - { - "destination": "192.168.1.1/24", - "nexthop": "bar" - } - ] - } -} -` - -const SubnetUpdateHostRoutesResponse = ` -{ - "subnet": { - "name": "my_new_subnet", - "enable_dhcp": true, - "network_id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324", - "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e", - "dns_nameservers": [], - "allocation_pools": [ - { - "start": "10.0.0.2", - "end": "10.0.0.254" - } - ], - "ip_version": 4, - "gateway_ip": "10.0.0.1", - "host_routes": [ - { - "destination": "192.168.1.1/24", - "nexthop": "bar" - } - ], - "cidr": "10.0.0.0/24", - "id": "08eae331-0402-425a-923c-34f7cfe39c1b" - } -} -` - -const SubnetUpdateRemoveHostRoutesRequest = ` -{ - "subnet": { - "host_routes": [] - } -} -` - -const SubnetUpdateRemoveHostRoutesResponse = ` -{ - "subnet": { - "name": "my_new_subnet", - "enable_dhcp": true, - "network_id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324", - "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e", - "dns_nameservers": [], - "allocation_pools": [ - { - "start": "10.0.0.2", - "end": "10.0.0.254" - } - ], - "host_routes": [], - "ip_version": 4, - "gateway_ip": null, - "cidr": "10.0.0.0/24", - "id": "08eae331-0402-425a-923c-34f7cfe39c1b" - } -} -` - -const SubnetUpdateAllocationPoolRequest = ` -{ - "subnet": { - "name": "my_new_subnet", - "allocation_pools": [ - { - "start": "10.1.0.2", - "end": "10.1.0.254" - } - ] - } -} -` - -const SubnetUpdateAllocationPoolResponse = ` -{ - "subnet": { - "name": "my_new_subnet", - "enable_dhcp": true, - "network_id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324", - "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e", - "dns_nameservers": [], - "allocation_pools": [ - { - "start": "10.1.0.2", - "end": "10.1.0.254" - } - ], - "host_routes": [], - "ip_version": 4, - "gateway_ip": "10.0.0.1", - "cidr": "10.0.0.0/24", - "id": "08eae331-0402-425a-923c-34f7cfe39c1b" - } -} -` diff --git a/openstack/networking/v2/subnets/testing/fixtures_test.go b/openstack/networking/v2/subnets/testing/fixtures_test.go new file mode 100644 index 0000000000..f9811fd549 --- /dev/null +++ b/openstack/networking/v2/subnets/testing/fixtures_test.go @@ -0,0 +1,584 @@ +package testing + +import ( + "github.com/gophercloud/gophercloud/openstack/networking/v2/subnets" +) + +const SubnetListResult = ` +{ + "subnets": [ + { + "name": "private-subnet", + "enable_dhcp": true, + "dns_publish_fixed_ip": true, + "network_id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324", + "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e", + "dns_nameservers": [], + "allocation_pools": [ + { + "start": "10.0.0.2", + "end": "10.0.0.254" + } + ], + "host_routes": [], + "ip_version": 4, + "gateway_ip": "10.0.0.1", + "cidr": "10.0.0.0/24", + "id": "08eae331-0402-425a-923c-34f7cfe39c1b" + }, + { + "name": "my_subnet", + "enable_dhcp": true, + "dns_publish_fixed_ip": true, + "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", + "tenant_id": "4fd44f30292945e481c7b8a0c8908869", + "dns_nameservers": [], + "allocation_pools": [ + { + "start": "192.0.0.2", + "end": "192.255.255.254" + } + ], + "host_routes": [], + "ip_version": 4, + "gateway_ip": "192.0.0.1", + "cidr": "192.0.0.0/8", + "id": "54d6f61d-db07-451c-9ab3-b9609b6b6f0b" + }, + { + "name": "my_gatewayless_subnet", + "enable_dhcp": true, + "dns_publish_fixed_ip": true, + "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a23", + "tenant_id": "4fd44f30292945e481c7b8a0c8908869", + "dns_nameservers": [], + "allocation_pools": [ + { + "start": "192.168.1.2", + "end": "192.168.1.254" + } + ], + "host_routes": [], + "ip_version": 4, + "gateway_ip": null, + "cidr": "192.168.1.0/24", + "id": "54d6f61d-db07-451c-9ab3-b9609b6b6f0c" + }, + { + "name": "my_subnet_with_subnetpool", + "enable_dhcp": false, + "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a23", + "tenant_id": "4fd44f30292945e481c7b8a0c8908869", + "dns_nameservers": [], + "allocation_pools": [ + { + "start": "10.11.12.2", + "end": "10.11.12.254" + } + ], + "host_routes": [], + "ip_version": 4, + "gateway_ip": null, + "cidr": "10.11.12.0/24", + "id": "38186a51-f373-4bbc-838b-6eaa1aa13eac", + "subnetpool_id": "b80340c7-9960-4f67-a99c-02501656284b" + } + ] +} +` + +var Subnet1 = subnets.Subnet{ + Name: "private-subnet", + EnableDHCP: true, + NetworkID: "db193ab3-96e3-4cb3-8fc5-05f4296d0324", + TenantID: "26a7980765d0414dbc1fc1f88cdb7e6e", + DNSNameservers: []string{}, + DNSPublishFixedIP: true, + AllocationPools: []subnets.AllocationPool{ + { + Start: "10.0.0.2", + End: "10.0.0.254", + }, + }, + HostRoutes: []subnets.HostRoute{}, + IPVersion: 4, + GatewayIP: "10.0.0.1", + CIDR: "10.0.0.0/24", + ID: "08eae331-0402-425a-923c-34f7cfe39c1b", +} + +var Subnet2 = subnets.Subnet{ + Name: "my_subnet", + EnableDHCP: true, + + NetworkID: "d32019d3-bc6e-4319-9c1d-6722fc136a22", + TenantID: "4fd44f30292945e481c7b8a0c8908869", + DNSNameservers: []string{}, + DNSPublishFixedIP: true, + AllocationPools: []subnets.AllocationPool{ + { + Start: "192.0.0.2", + End: "192.255.255.254", + }, + }, + HostRoutes: []subnets.HostRoute{}, + IPVersion: 4, + GatewayIP: "192.0.0.1", + CIDR: "192.0.0.0/8", + ID: "54d6f61d-db07-451c-9ab3-b9609b6b6f0b", +} + +var Subnet3 = subnets.Subnet{ + Name: "my_gatewayless_subnet", + EnableDHCP: true, + NetworkID: "d32019d3-bc6e-4319-9c1d-6722fc136a23", + TenantID: "4fd44f30292945e481c7b8a0c8908869", + DNSNameservers: []string{}, + DNSPublishFixedIP: true, + AllocationPools: []subnets.AllocationPool{ + { + Start: "192.168.1.2", + End: "192.168.1.254", + }, + }, + HostRoutes: []subnets.HostRoute{}, + IPVersion: 4, + GatewayIP: "", + CIDR: "192.168.1.0/24", + ID: "54d6f61d-db07-451c-9ab3-b9609b6b6f0c", +} + +var Subnet4 = subnets.Subnet{ + Name: "my_subnet_with_subnetpool", + EnableDHCP: false, + NetworkID: "d32019d3-bc6e-4319-9c1d-6722fc136a23", + TenantID: "4fd44f30292945e481c7b8a0c8908869", + DNSNameservers: []string{}, + DNSPublishFixedIP: false, + AllocationPools: []subnets.AllocationPool{ + { + Start: "10.11.12.2", + End: "10.11.12.254", + }, + }, + HostRoutes: []subnets.HostRoute{}, + IPVersion: 4, + GatewayIP: "", + CIDR: "10.11.12.0/24", + ID: "38186a51-f373-4bbc-838b-6eaa1aa13eac", + SubnetPoolID: "b80340c7-9960-4f67-a99c-02501656284b", +} + +const SubnetGetResult = ` +{ + "subnet": { + "name": "my_subnet", + "enable_dhcp": true, + "dns_publish_fixed_ip": true, + "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", + "tenant_id": "4fd44f30292945e481c7b8a0c8908869", + "dns_nameservers": [], + "allocation_pools": [ + { + "start": "192.0.0.2", + "end": "192.255.255.254" + } + ], + "host_routes": [], + "ip_version": 4, + "gateway_ip": "192.0.0.1", + "cidr": "192.0.0.0/8", + "id": "54d6f61d-db07-451c-9ab3-b9609b6b6f0b", + "subnetpool_id": "b80340c7-9960-4f67-a99c-02501656284b" + } +} +` + +const SubnetCreateRequest = ` +{ + "subnet": { + "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", + "ip_version": 4, + "dns_publish_fixed_ip": true, + "gateway_ip": "192.168.199.1", + "cidr": "192.168.199.0/24", + "dns_nameservers": ["foo"], + "service_types": ["network:routed"], + "allocation_pools": [ + { + "start": "192.168.199.2", + "end": "192.168.199.254" + } + ], + "host_routes": [{"destination":"","nexthop": "bar"}], + "subnetpool_id": "b80340c7-9960-4f67-a99c-02501656284b" + } +} +` + +const SubnetCreateResult = ` +{ + "subnet": { + "name": "", + "enable_dhcp": true, + "dns_publish_fixed_ip": true, + "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", + "tenant_id": "4fd44f30292945e481c7b8a0c8908869", + "dns_nameservers": ["foo"], + "service_types": ["network:routed"], + "allocation_pools": [ + { + "start": "192.168.199.2", + "end": "192.168.199.254" + } + ], + "host_routes": [], + "ip_version": 4, + "gateway_ip": "192.168.199.1", + "cidr": "192.168.199.0/24", + "id": "3b80198d-4f7b-4f77-9ef5-774d54e17126", + "subnetpool_id": "b80340c7-9960-4f67-a99c-02501656284b" + } +} +` + +const SubnetCreateWithNoGatewayRequest = ` +{ + "subnet": { + "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a23", + "ip_version": 4, + "cidr": "192.168.1.0/24", + "gateway_ip": null, + "allocation_pools": [ + { + "start": "192.168.1.2", + "end": "192.168.1.254" + } + ] + } +} +` + +const SubnetCreateWithNoGatewayResponse = ` +{ + "subnet": { + "name": "", + "enable_dhcp": true, + "dns_publish_fixed_ip": true, + "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a23", + "tenant_id": "4fd44f30292945e481c7b8a0c8908869", + "allocation_pools": [ + { + "start": "192.168.1.2", + "end": "192.168.1.254" + } + ], + "host_routes": [], + "ip_version": 4, + "gateway_ip": null, + "cidr": "192.168.1.0/24", + "id": "54d6f61d-db07-451c-9ab3-b9609b6b6f0c" + } +} +` + +const SubnetCreateWithDefaultGatewayRequest = ` +{ + "subnet": { + "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a23", + "ip_version": 4, + "cidr": "192.168.1.0/24", + "allocation_pools": [ + { + "start": "192.168.1.2", + "end": "192.168.1.254" + } + ] + } +} +` + +const SubnetCreateWithDefaultGatewayResponse = ` +{ + "subnet": { + "name": "", + "enable_dhcp": true, + "dns_publish_fixed_ip": true, + "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a23", + "tenant_id": "4fd44f30292945e481c7b8a0c8908869", + "allocation_pools": [ + { + "start": "192.168.1.2", + "end": "192.168.1.254" + } + ], + "host_routes": [], + "ip_version": 4, + "gateway_ip": "192.168.1.1", + "cidr": "192.168.1.0/24", + "id": "54d6f61d-db07-451c-9ab3-b9609b6b6f0c" + } +} +` +const SubnetCreateWithIPv6RaAddressModeRequest = ` +{ + "subnet": { + "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", + "ip_version": 6, + "gateway_ip": "2001:db8:0:a::1", + "cidr": "2001:db8:0:a:0:0:0:0/64", + "ipv6_address_mode": "slaac", + "ipv6_ra_mode": "slaac" + } +} +` +const SubnetCreateWithIPv6RaAddressModeResponse = ` +{ + "subnet": { + "name": "", + "enable_dhcp": true, + "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", + "tenant_id": "4fd44f30292945e481c7b8a0c8908869", + "dns_nameservers": [], + "host_routes": [], + "ip_version": 6, + "gateway_ip": "2001:db8:0:a::1", + "cidr": "2001:db8:0:a:0:0:0:0/64", + "id": "3b80198d-4f7b-4f77-9ef5-774d54e17126", + "ipv6_address_mode": "slaac", + "ipv6_ra_mode": "slaac" + } +} +` + +const SubnetCreateRequestWithNoCIDR = ` +{ + "subnet": { + "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", + "ip_version": 4, + "dns_nameservers": ["foo"], + "host_routes": [{"destination":"","nexthop": "bar"}], + "subnetpool_id": "b80340c7-9960-4f67-a99c-02501656284b" + } +} +` + +const SubnetCreateRequestWithPrefixlen = ` +{ + "subnet": { + "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", + "ip_version": 4, + "dns_nameservers": ["foo"], + "host_routes": [{"destination":"","nexthop": "bar"}], + "subnetpool_id": "b80340c7-9960-4f67-a99c-02501656284b", + "prefixlen": 12 + } +} +` + +const SubnetUpdateRequest = ` +{ + "subnet": { + "name": "my_new_subnet", + "dns_nameservers": ["foo"], + "host_routes": [{"destination":"","nexthop": "bar"}] + } +} +` + +const SubnetUpdateResponse = ` +{ + "subnet": { + "name": "my_new_subnet", + "enable_dhcp": true, + "network_id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324", + "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e", + "dns_nameservers": [], + "allocation_pools": [ + { + "start": "10.0.0.2", + "end": "10.0.0.254" + } + ], + "host_routes": [], + "ip_version": 4, + "gateway_ip": "10.0.0.1", + "cidr": "10.0.0.0/24", + "id": "08eae331-0402-425a-923c-34f7cfe39c1b" + } +} +` + +const SubnetUpdateGatewayRequest = ` +{ + "subnet": { + "name": "my_new_subnet", + "gateway_ip": "10.0.0.1" + } +} +` + +const SubnetUpdateGatewayResponse = ` +{ + "subnet": { + "name": "my_new_subnet", + "enable_dhcp": true, + "network_id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324", + "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e", + "dns_nameservers": [], + "allocation_pools": [ + { + "start": "10.0.0.2", + "end": "10.0.0.254" + } + ], + "host_routes": [], + "ip_version": 4, + "gateway_ip": "10.0.0.1", + "cidr": "10.0.0.0/24", + "id": "08eae331-0402-425a-923c-34f7cfe39c1b" + } +} +` + +const SubnetUpdateRemoveGatewayRequest = ` +{ + "subnet": { + "name": "my_new_subnet", + "gateway_ip": null + } +} +` + +const SubnetUpdateRemoveGatewayResponse = ` +{ + "subnet": { + "name": "my_new_subnet", + "enable_dhcp": true, + "network_id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324", + "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e", + "dns_nameservers": [], + "allocation_pools": [ + { + "start": "10.0.0.2", + "end": "10.0.0.254" + } + ], + "host_routes": [], + "ip_version": 4, + "gateway_ip": null, + "cidr": "10.0.0.0/24", + "id": "08eae331-0402-425a-923c-34f7cfe39c1b" + } +} +` + +const SubnetUpdateHostRoutesRequest = ` +{ + "subnet": { + "name": "my_new_subnet", + "host_routes": [ + { + "destination": "192.168.1.1/24", + "nexthop": "bar" + } + ] + } +} +` + +const SubnetUpdateHostRoutesResponse = ` +{ + "subnet": { + "name": "my_new_subnet", + "enable_dhcp": true, + "network_id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324", + "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e", + "dns_nameservers": [], + "allocation_pools": [ + { + "start": "10.0.0.2", + "end": "10.0.0.254" + } + ], + "ip_version": 4, + "gateway_ip": "10.0.0.1", + "host_routes": [ + { + "destination": "192.168.1.1/24", + "nexthop": "bar" + } + ], + "cidr": "10.0.0.0/24", + "id": "08eae331-0402-425a-923c-34f7cfe39c1b" + } +} +` + +const SubnetUpdateRemoveHostRoutesRequest = ` +{ + "subnet": { + "host_routes": [] + } +} +` + +const SubnetUpdateRemoveHostRoutesResponse = ` +{ + "subnet": { + "name": "my_new_subnet", + "enable_dhcp": true, + "network_id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324", + "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e", + "dns_nameservers": [], + "allocation_pools": [ + { + "start": "10.0.0.2", + "end": "10.0.0.254" + } + ], + "host_routes": [], + "ip_version": 4, + "gateway_ip": null, + "cidr": "10.0.0.0/24", + "id": "08eae331-0402-425a-923c-34f7cfe39c1b" + } +} +` + +const SubnetUpdateAllocationPoolRequest = ` +{ + "subnet": { + "name": "my_new_subnet", + "allocation_pools": [ + { + "start": "10.1.0.2", + "end": "10.1.0.254" + } + ] + } +} +` + +const SubnetUpdateAllocationPoolResponse = ` +{ + "subnet": { + "name": "my_new_subnet", + "enable_dhcp": true, + "network_id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324", + "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e", + "dns_nameservers": [], + "allocation_pools": [ + { + "start": "10.1.0.2", + "end": "10.1.0.254" + } + ], + "host_routes": [], + "ip_version": 4, + "gateway_ip": "10.0.0.1", + "cidr": "10.0.0.0/24", + "id": "08eae331-0402-425a-923c-34f7cfe39c1b" + } +} +` diff --git a/openstack/networking/v2/subnets/testing/requests_test.go b/openstack/networking/v2/subnets/testing/requests_test.go index 7e82d5855d..a87da46236 100644 --- a/openstack/networking/v2/subnets/testing/requests_test.go +++ b/openstack/networking/v2/subnets/testing/requests_test.go @@ -106,6 +106,7 @@ func TestCreate(t *testing.T) { }) var gatewayIP = "192.168.199.1" + var dnsPublishFixedIP = true opts := subnets.CreateOpts{ NetworkID: "d32019d3-bc6e-4319-9c1d-6722fc136a22", IPVersion: 4, @@ -117,8 +118,9 @@ func TestCreate(t *testing.T) { End: "192.168.199.254", }, }, - DNSNameservers: []string{"foo"}, - ServiceTypes: []string{"network:routed"}, + DNSNameservers: []string{"foo"}, + DNSPublishFixedIP: &dnsPublishFixedIP, + ServiceTypes: []string{"network:routed"}, HostRoutes: []subnets.HostRoute{ {NextHop: "bar"}, }, @@ -128,6 +130,7 @@ func TestCreate(t *testing.T) { th.AssertNoErr(t, err) th.AssertEquals(t, s.Name, "") + th.AssertEquals(t, s.DNSPublishFixedIP, true) th.AssertEquals(t, s.EnableDHCP, true) th.AssertEquals(t, s.NetworkID, "d32019d3-bc6e-4319-9c1d-6722fc136a22") th.AssertEquals(t, s.TenantID, "4fd44f30292945e481c7b8a0c8908869") @@ -318,6 +321,7 @@ func TestCreateWithNoCIDR(t *testing.T) { th.AssertNoErr(t, err) th.AssertEquals(t, s.Name, "") + th.AssertEquals(t, s.DNSPublishFixedIP, true) th.AssertEquals(t, s.EnableDHCP, true) th.AssertEquals(t, s.NetworkID, "d32019d3-bc6e-4319-9c1d-6722fc136a22") th.AssertEquals(t, s.TenantID, "4fd44f30292945e481c7b8a0c8908869") @@ -367,6 +371,7 @@ func TestCreateWithPrefixlen(t *testing.T) { th.AssertNoErr(t, err) th.AssertEquals(t, s.Name, "") + th.AssertEquals(t, s.DNSPublishFixedIP, true) th.AssertEquals(t, s.EnableDHCP, true) th.AssertEquals(t, s.NetworkID, "d32019d3-bc6e-4319-9c1d-6722fc136a22") th.AssertEquals(t, s.TenantID, "4fd44f30292945e481c7b8a0c8908869") diff --git a/openstack/objectstorage/v1/objects/requests.go b/openstack/objectstorage/v1/objects/requests.go index c03a27fce5..ed9bd180f9 100644 --- a/openstack/objectstorage/v1/objects/requests.go +++ b/openstack/objectstorage/v1/objects/requests.go @@ -612,7 +612,7 @@ func CreateTempURL(c *gophercloud.ServiceClient, containerName, objectName strin } secretKey := []byte(tempURLKey) - splitPath := strings.Split(url, opts.Split) + splitPath := strings.SplitN(url, opts.Split, 2) baseURL, objectPath := splitPath[0], splitPath[1] objectPath = opts.Split + objectPath body := fmt.Sprintf("%s\n%d\n%s", opts.Method, expiry, objectPath) diff --git a/openstack/objectstorage/v1/objects/testing/fixtures.go b/openstack/objectstorage/v1/objects/testing/fixtures_test.go similarity index 100% rename from openstack/objectstorage/v1/objects/testing/fixtures.go rename to openstack/objectstorage/v1/objects/testing/fixtures_test.go diff --git a/openstack/objectstorage/v1/swauth/testing/fixtures.go b/openstack/objectstorage/v1/swauth/testing/fixtures_test.go similarity index 100% rename from openstack/objectstorage/v1/swauth/testing/fixtures.go rename to openstack/objectstorage/v1/swauth/testing/fixtures_test.go diff --git a/openstack/orchestration/v1/buildinfo/testing/fixtures.go b/openstack/orchestration/v1/buildinfo/testing/fixtures_test.go similarity index 100% rename from openstack/orchestration/v1/buildinfo/testing/fixtures.go rename to openstack/orchestration/v1/buildinfo/testing/fixtures_test.go diff --git a/openstack/orchestration/v1/resourcetypes/testing/fixtures.go b/openstack/orchestration/v1/resourcetypes/testing/fixtures_test.go similarity index 100% rename from openstack/orchestration/v1/resourcetypes/testing/fixtures.go rename to openstack/orchestration/v1/resourcetypes/testing/fixtures_test.go diff --git a/openstack/orchestration/v1/stackevents/testing/fixtures.go b/openstack/orchestration/v1/stackevents/testing/fixtures_test.go similarity index 100% rename from openstack/orchestration/v1/stackevents/testing/fixtures.go rename to openstack/orchestration/v1/stackevents/testing/fixtures_test.go diff --git a/openstack/orchestration/v1/stackresources/testing/fixtures.go b/openstack/orchestration/v1/stackresources/testing/fixtures_test.go similarity index 100% rename from openstack/orchestration/v1/stackresources/testing/fixtures.go rename to openstack/orchestration/v1/stackresources/testing/fixtures_test.go diff --git a/openstack/orchestration/v1/stacks/requests.go b/openstack/orchestration/v1/stacks/requests.go index 620e7576dc..0bd16543b9 100644 --- a/openstack/orchestration/v1/stacks/requests.go +++ b/openstack/orchestration/v1/stacks/requests.go @@ -1,6 +1,7 @@ package stacks import ( + "fmt" "strings" "github.com/gophercloud/gophercloud" @@ -89,7 +90,7 @@ func (opts CreateOpts) ToStackCreateMap() (map[string]interface{}, error) { func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { b, err := opts.ToStackCreateMap() if err != nil { - r.Err = err + r.Err = fmt.Errorf("error creating the options map: %w", err) return } resp, err := c.Post(createURL(c), b, &r.Body, nil) diff --git a/openstack/orchestration/v1/stacks/testing/fixtures.go b/openstack/orchestration/v1/stacks/testing/fixtures_test.go similarity index 100% rename from openstack/orchestration/v1/stacks/testing/fixtures.go rename to openstack/orchestration/v1/stacks/testing/fixtures_test.go diff --git a/openstack/orchestration/v1/stacks/testing/requests_test.go b/openstack/orchestration/v1/stacks/testing/requests_test.go index 6f0eb3a8e9..9f0932a4d2 100644 --- a/openstack/orchestration/v1/stacks/testing/requests_test.go +++ b/openstack/orchestration/v1/stacks/testing/requests_test.go @@ -59,7 +59,7 @@ func TestCreateStackMissingRequiredInOpts(t *testing.T) { DisableRollback: gophercloud.Disabled, } r := stacks.Create(fake.ServiceClient(), createOpts) - th.AssertEquals(t, "Missing input for argument [Name]", r.Err.Error()) + th.AssertEquals(t, "error creating the options map: Missing input for argument [Name]", r.Err.Error()) } func TestAdoptStack(t *testing.T) { diff --git a/openstack/orchestration/v1/stacktemplates/testing/fixtures.go b/openstack/orchestration/v1/stacktemplates/testing/fixtures_test.go similarity index 100% rename from openstack/orchestration/v1/stacktemplates/testing/fixtures.go rename to openstack/orchestration/v1/stacktemplates/testing/fixtures_test.go diff --git a/openstack/placement/v1/resourceproviders/testing/fixtures.go b/openstack/placement/v1/resourceproviders/testing/fixtures_test.go similarity index 100% rename from openstack/placement/v1/resourceproviders/testing/fixtures.go rename to openstack/placement/v1/resourceproviders/testing/fixtures_test.go diff --git a/openstack/sharedfilesystems/apiversions/testing/fixtures.go b/openstack/sharedfilesystems/apiversions/testing/fixtures_test.go similarity index 100% rename from openstack/sharedfilesystems/apiversions/testing/fixtures.go rename to openstack/sharedfilesystems/apiversions/testing/fixtures_test.go diff --git a/openstack/sharedfilesystems/v2/availabilityzones/testing/fixtures.go b/openstack/sharedfilesystems/v2/availabilityzones/testing/fixtures_test.go similarity index 100% rename from openstack/sharedfilesystems/v2/availabilityzones/testing/fixtures.go rename to openstack/sharedfilesystems/v2/availabilityzones/testing/fixtures_test.go diff --git a/openstack/sharedfilesystems/v2/errors/testing/fixtures.go b/openstack/sharedfilesystems/v2/errors/testing/fixtures_test.go similarity index 100% rename from openstack/sharedfilesystems/v2/errors/testing/fixtures.go rename to openstack/sharedfilesystems/v2/errors/testing/fixtures_test.go diff --git a/openstack/sharedfilesystems/v2/messages/testing/fixtures.go b/openstack/sharedfilesystems/v2/messages/testing/fixtures_test.go similarity index 100% rename from openstack/sharedfilesystems/v2/messages/testing/fixtures.go rename to openstack/sharedfilesystems/v2/messages/testing/fixtures_test.go diff --git a/openstack/sharedfilesystems/v2/replicas/testing/fixtures.go b/openstack/sharedfilesystems/v2/replicas/testing/fixtures_test.go similarity index 100% rename from openstack/sharedfilesystems/v2/replicas/testing/fixtures.go rename to openstack/sharedfilesystems/v2/replicas/testing/fixtures_test.go diff --git a/openstack/sharedfilesystems/v2/schedulerstats/testing/fixtures.go b/openstack/sharedfilesystems/v2/schedulerstats/testing/fixtures_test.go similarity index 100% rename from openstack/sharedfilesystems/v2/schedulerstats/testing/fixtures.go rename to openstack/sharedfilesystems/v2/schedulerstats/testing/fixtures_test.go diff --git a/openstack/sharedfilesystems/v2/securityservices/testing/fixtures.go b/openstack/sharedfilesystems/v2/securityservices/testing/fixtures_test.go similarity index 100% rename from openstack/sharedfilesystems/v2/securityservices/testing/fixtures.go rename to openstack/sharedfilesystems/v2/securityservices/testing/fixtures_test.go diff --git a/openstack/sharedfilesystems/v2/services/testing/fixtures.go b/openstack/sharedfilesystems/v2/services/testing/fixtures_test.go similarity index 100% rename from openstack/sharedfilesystems/v2/services/testing/fixtures.go rename to openstack/sharedfilesystems/v2/services/testing/fixtures_test.go diff --git a/openstack/sharedfilesystems/v2/shareaccessrules/testing/fixtures.go b/openstack/sharedfilesystems/v2/shareaccessrules/testing/fixtures_test.go similarity index 100% rename from openstack/sharedfilesystems/v2/shareaccessrules/testing/fixtures.go rename to openstack/sharedfilesystems/v2/shareaccessrules/testing/fixtures_test.go diff --git a/openstack/sharedfilesystems/v2/sharenetworks/testing/fixtures.go b/openstack/sharedfilesystems/v2/sharenetworks/testing/fixtures_test.go similarity index 100% rename from openstack/sharedfilesystems/v2/sharenetworks/testing/fixtures.go rename to openstack/sharedfilesystems/v2/sharenetworks/testing/fixtures_test.go diff --git a/openstack/sharedfilesystems/v2/shares/testing/fixtures.go b/openstack/sharedfilesystems/v2/shares/testing/fixtures_test.go similarity index 100% rename from openstack/sharedfilesystems/v2/shares/testing/fixtures.go rename to openstack/sharedfilesystems/v2/shares/testing/fixtures_test.go diff --git a/openstack/sharedfilesystems/v2/sharetransfers/testing/fixtures.go b/openstack/sharedfilesystems/v2/sharetransfers/testing/fixtures_test.go similarity index 100% rename from openstack/sharedfilesystems/v2/sharetransfers/testing/fixtures.go rename to openstack/sharedfilesystems/v2/sharetransfers/testing/fixtures_test.go diff --git a/openstack/sharedfilesystems/v2/sharetypes/testing/fixtures.go b/openstack/sharedfilesystems/v2/sharetypes/testing/fixtures_test.go similarity index 100% rename from openstack/sharedfilesystems/v2/sharetypes/testing/fixtures.go rename to openstack/sharedfilesystems/v2/sharetypes/testing/fixtures_test.go diff --git a/openstack/sharedfilesystems/v2/snapshots/requests.go b/openstack/sharedfilesystems/v2/snapshots/requests.go index 1ed6e8aef2..bbdde5eac1 100644 --- a/openstack/sharedfilesystems/v2/snapshots/requests.go +++ b/openstack/sharedfilesystems/v2/snapshots/requests.go @@ -163,3 +163,54 @@ func Update(client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } + +// ResetStatusOptsBuilder allows extensions to add additional parameters to the +// ResetStatus request. +type ResetStatusOptsBuilder interface { + ToSnapshotResetStatusMap() (map[string]interface{}, error) +} + +// ResetStatusOpts contains options for resetting a Snapshot status. +// For more information about these parameters, please, refer to the shared file systems API v2, +// Snapshot Actions, ResetStatus share documentation. +type ResetStatusOpts struct { + // Status is a snapshot status to reset to. Can be "available", "error", + // "creating", "deleting", "manage_starting", "manage_error", + // "unmanage_starting", "unmanage_error" or "error_deleting". + Status string `json:"status"` +} + +// ToSnapshotResetStatusMap assembles a request body based on the contents of a +// ResetStatusOpts. +func (opts ResetStatusOpts) ToSnapshotResetStatusMap() (map[string]interface{}, error) { + return gophercloud.BuildRequestBody(opts, "reset_status") +} + +// ResetStatus will reset the existing snapshot status. ResetStatusResult contains only the error. +// To extract it, call the ExtractErr method on the ResetStatusResult. +func ResetStatus(client *gophercloud.ServiceClient, id string, opts ResetStatusOptsBuilder) (r ResetStatusResult) { + b, err := opts.ToSnapshotResetStatusMap() + if err != nil { + r.Err = err + return + } + + resp, err := client.Post(resetStatusURL(client, id), b, nil, &gophercloud.RequestOpts{ + OkCodes: []int{202}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// ForceDelete will delete the existing snapshot in any state. ForceDeleteResult contains only the error. +// To extract it, call the ExtractErr method on the ForceDeleteResult. +func ForceDelete(client *gophercloud.ServiceClient, id string) (r ForceDeleteResult) { + b := map[string]interface{}{ + "force_delete": nil, + } + resp, err := client.Post(forceDeleteURL(client, id), b, nil, &gophercloud.RequestOpts{ + OkCodes: []int{202}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} diff --git a/openstack/sharedfilesystems/v2/snapshots/results.go b/openstack/sharedfilesystems/v2/snapshots/results.go index a3d45aaa94..44337b17a7 100644 --- a/openstack/sharedfilesystems/v2/snapshots/results.go +++ b/openstack/sharedfilesystems/v2/snapshots/results.go @@ -173,3 +173,13 @@ type GetResult struct { type UpdateResult struct { commonResult } + +// ResetStatusResult contains the response error from an ResetStatus request. +type ResetStatusResult struct { + gophercloud.ErrResult +} + +// ForceDeleteResult contains the response error from an ForceDelete request. +type ForceDeleteResult struct { + gophercloud.ErrResult +} diff --git a/openstack/sharedfilesystems/v2/snapshots/testing/fixtures.go b/openstack/sharedfilesystems/v2/snapshots/testing/fixtures_test.go similarity index 81% rename from openstack/sharedfilesystems/v2/snapshots/testing/fixtures.go rename to openstack/sharedfilesystems/v2/snapshots/testing/fixtures_test.go index c02ef10c71..fb677918dd 100644 --- a/openstack/sharedfilesystems/v2/snapshots/testing/fixtures.go +++ b/openstack/sharedfilesystems/v2/snapshots/testing/fixtures_test.go @@ -204,3 +204,39 @@ func MockListDetailResponse(t *testing.T) { } }) } + +var resetStatusRequest = `{ + "reset_status": { + "status": "error" + } + }` + +// MockResetStatusResponse creates a mock reset status snapshot response +func MockResetStatusResponse(t *testing.T) { + th.Mux.HandleFunc(snapshotEndpoint+"/"+snapshotID+"/action", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "POST") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + th.TestHeader(t, r, "Content-Type", "application/json") + th.TestHeader(t, r, "Accept", "application/json") + th.TestJSONRequest(t, r, resetStatusRequest) + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(http.StatusAccepted) + }) +} + +var forceDeleteRequest = `{ + "force_delete": null + }` + +// MockForceDeleteResponse creates a mock force delete snapshot response +func MockForceDeleteResponse(t *testing.T) { + th.Mux.HandleFunc(snapshotEndpoint+"/"+snapshotID+"/action", func(w http.ResponseWriter, r *http.Request) { + th.TestMethod(t, r, "POST") + th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) + th.TestHeader(t, r, "Content-Type", "application/json") + th.TestHeader(t, r, "Accept", "application/json") + th.TestJSONRequest(t, r, forceDeleteRequest) + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(http.StatusAccepted) + }) +} diff --git a/openstack/sharedfilesystems/v2/snapshots/testing/request_test.go b/openstack/sharedfilesystems/v2/snapshots/testing/request_test.go index e210b4adc9..52f9c33a23 100644 --- a/openstack/sharedfilesystems/v2/snapshots/testing/request_test.go +++ b/openstack/sharedfilesystems/v2/snapshots/testing/request_test.go @@ -125,3 +125,27 @@ func TestListDetail(t *testing.T) { }, }) } + +func TestResetStatusSuccess(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + MockResetStatusResponse(t) + + c := client.ServiceClient() + + err := snapshots.ResetStatus(c, snapshotID, &snapshots.ResetStatusOpts{Status: "error"}).ExtractErr() + th.AssertNoErr(t, err) +} + +func TestForceDeleteSuccess(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + MockForceDeleteResponse(t) + + c := client.ServiceClient() + + err := snapshots.ForceDelete(c, snapshotID).ExtractErr() + th.AssertNoErr(t, err) +} diff --git a/openstack/sharedfilesystems/v2/snapshots/urls.go b/openstack/sharedfilesystems/v2/snapshots/urls.go index a07e3ec873..138d97f350 100644 --- a/openstack/sharedfilesystems/v2/snapshots/urls.go +++ b/openstack/sharedfilesystems/v2/snapshots/urls.go @@ -21,3 +21,11 @@ func getURL(c *gophercloud.ServiceClient, id string) string { func updateURL(c *gophercloud.ServiceClient, id string) string { return c.ServiceURL("snapshots", id) } + +func resetStatusURL(c *gophercloud.ServiceClient, id string) string { + return c.ServiceURL("snapshots", id, "action") +} + +func forceDeleteURL(c *gophercloud.ServiceClient, id string) string { + return c.ServiceURL("snapshots", id, "action") +} diff --git a/params.go b/params.go index 17b200cd23..5abc2c5589 100644 --- a/params.go +++ b/params.go @@ -318,8 +318,15 @@ converted into query parameters based on a "q" tag. For example: will be converted into "?x_bar=AAA&lorem_ipsum=BBB". -The struct's fields may be strings, integers, or boolean values. Fields left at -their type's zero value will be omitted from the query. +The struct's fields may be strings, integers, slices, or boolean values. Fields +left at their type's zero value will be omitted from the query. + +Slice are handled in one of two ways: + + type struct Something { + Bar []string `q:"bar"` // E.g. ?bar=1&bar=2 + Baz []int `q:"baz" format="comma-separated"` // E.g. ?baz=1,2 + } */ func BuildQueryString(opts interface{}) (*url.URL, error) { optsValue := reflect.ValueOf(opts) @@ -358,16 +365,22 @@ func BuildQueryString(opts interface{}) (*url.URL, error) { case reflect.Bool: params.Add(tags[0], strconv.FormatBool(v.Bool())) case reflect.Slice: + var values []string switch v.Type().Elem() { case reflect.TypeOf(0): for i := 0; i < v.Len(); i++ { - params.Add(tags[0], strconv.FormatInt(v.Index(i).Int(), 10)) + values = append(values, strconv.FormatInt(v.Index(i).Int(), 10)) } default: for i := 0; i < v.Len(); i++ { - params.Add(tags[0], v.Index(i).String()) + values = append(values, v.Index(i).String()) } } + if sliceFormat := f.Tag.Get("format"); sliceFormat == "comma-separated" { + params.Add(tags[0], strings.Join(values, ",")) + } else { + params[tags[0]] = append(params[tags[0]], values...) + } case reflect.Map: if v.Type().Key().Kind() == reflect.String && v.Type().Elem().Kind() == reflect.String { var s []string diff --git a/provider_client.go b/provider_client.go index 6cfb14fd7e..7e25882c87 100644 --- a/provider_client.go +++ b/provider_client.go @@ -14,7 +14,7 @@ import ( // DefaultUserAgent is the default User-Agent string set in the request header. const ( - DefaultUserAgent = "gophercloud/v1.5.0" + DefaultUserAgent = "gophercloud/v1.14.1" DefaultMaxBackoffRetries = 60 ) diff --git a/script/acceptancetest b/script/acceptancetest index 09db3f38fa..9e540b2d84 100755 --- a/script/acceptancetest +++ b/script/acceptancetest @@ -15,11 +15,11 @@ fi mkdir -p ${LOG_DIR} if [[ -z "${ACCEPTANCE_TESTS_FILTER}" ]]; then - ACCEPTANCE_TESTS=($(python <<< "print(' '.join($ACCEPTANCE_TESTS))")) + ACCEPTANCE_TESTS=$(find internal/acceptance/openstack -name '*_test.go' -exec dirname {} \; | sort -n | uniq) else - ACCEPTANCE_TESTS=$(find acceptance/openstack -name '*_test.go' -exec dirname {} \; | sort -n | uniq | grep -P "$ACCEPTANCE_TESTS_FILTER") - ACCEPTANCE_TESTS=($ACCEPTANCE_TESTS) + ACCEPTANCE_TESTS=$(find internal/acceptance/openstack -name '*_test.go' -exec dirname {} \; | sort -n | uniq | grep -P "$ACCEPTANCE_TESTS_FILTER") fi +ACCEPTANCE_TESTS=($ACCEPTANCE_TESTS) if [[ -z $ACCEPTANCE_TESTS ]]; then echo "No acceptance tests to run" diff --git a/script/coverage b/script/coverage index 3efa81ba5a..6b76a1be7b 100755 --- a/script/coverage +++ b/script/coverage @@ -5,8 +5,17 @@ set -e n=1 for testpkg in $(go list ./testing ./.../testing); do covpkg="${testpkg/"/testing"/}" - go test -covermode count -coverprofile "testing_"$n.coverprofile -coverpkg $covpkg $testpkg 2>/dev/null + go test -covermode count -coverprofile "testing_"$n.coverprofile -coverpkg "$covpkg" "$testpkg" 2>/dev/null n=$((n+1)) done + +base_pkg=$(go list) +# Look for additional test files +for path in $(find . -path '*/testing' -prune -o -path '*/internal' -prune -o -name '*_test.go' -exec dirname {} \; | uniq); do + pkg="${base_pkg}${path:1}" + go test -covermode count -coverprofile "testing_"$n.coverprofile -coverpkg "$pkg" "$pkg" 2>/dev/null + n=$((n+1)) +done + gocovmerge `ls *.coverprofile` > cover.out -rm *.coverprofile +rm ./*.coverprofile diff --git a/script/stackenv b/script/stackenv index d51d311e74..ef6311c039 100644 --- a/script/stackenv +++ b/script/stackenv @@ -30,4 +30,8 @@ echo export OS_DOMAIN_ID=default >> openrc echo export OS_MAGNUM_IMAGE_ID="$_MAGNUM_IMAGE_ID" >> openrc echo export OS_MAGNUM_KEYPAIR=magnum >> openrc source openrc admin admin +if [[ "${OS_SYSTEM_SCOPE:-}" == "all" ]]; then + unset PROJECT_NAME + unset TENANT_NAME +fi popd diff --git a/service_client.go b/service_client.go index dd54abe30e..94a161e340 100644 --- a/service_client.go +++ b/service_client.go @@ -47,7 +47,7 @@ func (client *ServiceClient) ServiceURL(parts ...string) string { return client.ResourceBaseURL() + strings.Join(parts, "/") } -func (client *ServiceClient) initReqOpts(url string, JSONBody interface{}, JSONResponse interface{}, opts *RequestOpts) { +func (client *ServiceClient) initReqOpts(JSONBody interface{}, JSONResponse interface{}, opts *RequestOpts) { if v, ok := (JSONBody).(io.Reader); ok { opts.RawBody = v } else if JSONBody != nil { @@ -57,14 +57,6 @@ func (client *ServiceClient) initReqOpts(url string, JSONBody interface{}, JSONR if JSONResponse != nil { opts.JSONResponse = JSONResponse } - - if opts.MoreHeaders == nil { - opts.MoreHeaders = make(map[string]string) - } - - if client.Microversion != "" { - client.setMicroversionHeader(opts) - } } // Get calls `Request` with the "GET" HTTP verb. @@ -72,7 +64,7 @@ func (client *ServiceClient) Get(url string, JSONResponse interface{}, opts *Req if opts == nil { opts = new(RequestOpts) } - client.initReqOpts(url, nil, JSONResponse, opts) + client.initReqOpts(nil, JSONResponse, opts) return client.Request("GET", url, opts) } @@ -81,7 +73,7 @@ func (client *ServiceClient) Post(url string, JSONBody interface{}, JSONResponse if opts == nil { opts = new(RequestOpts) } - client.initReqOpts(url, JSONBody, JSONResponse, opts) + client.initReqOpts(JSONBody, JSONResponse, opts) return client.Request("POST", url, opts) } @@ -90,7 +82,7 @@ func (client *ServiceClient) Put(url string, JSONBody interface{}, JSONResponse if opts == nil { opts = new(RequestOpts) } - client.initReqOpts(url, JSONBody, JSONResponse, opts) + client.initReqOpts(JSONBody, JSONResponse, opts) return client.Request("PUT", url, opts) } @@ -99,7 +91,7 @@ func (client *ServiceClient) Patch(url string, JSONBody interface{}, JSONRespons if opts == nil { opts = new(RequestOpts) } - client.initReqOpts(url, JSONBody, JSONResponse, opts) + client.initReqOpts(JSONBody, JSONResponse, opts) return client.Request("PATCH", url, opts) } @@ -108,7 +100,7 @@ func (client *ServiceClient) Delete(url string, opts *RequestOpts) (*http.Respon if opts == nil { opts = new(RequestOpts) } - client.initReqOpts(url, nil, nil, opts) + client.initReqOpts(nil, nil, opts) return client.Request("DELETE", url, opts) } @@ -117,7 +109,7 @@ func (client *ServiceClient) Head(url string, opts *RequestOpts) (*http.Response if opts == nil { opts = new(RequestOpts) } - client.initReqOpts(url, nil, nil, opts) + client.initReqOpts(nil, nil, opts) return client.Request("HEAD", url, opts) } @@ -142,10 +134,19 @@ func (client *ServiceClient) setMicroversionHeader(opts *RequestOpts) { // Request carries out the HTTP operation for the service client func (client *ServiceClient) Request(method, url string, options *RequestOpts) (*http.Response, error) { + if options.MoreHeaders == nil { + options.MoreHeaders = make(map[string]string) + } + + if client.Microversion != "" { + client.setMicroversionHeader(options) + } + if len(client.MoreHeaders) > 0 { if options == nil { options = new(RequestOpts) } + for k, v := range client.MoreHeaders { options.MoreHeaders[k] = v } diff --git a/testhelper/convenience.go b/testhelper/convenience.go index 2ae247052b..1602431fe1 100644 --- a/testhelper/convenience.go +++ b/testhelper/convenience.go @@ -33,10 +33,12 @@ func yellow(str interface{}) string { } func logFatal(t *testing.T, str string) { + t.Helper() t.Fatalf(logBodyFmt, prefix(3), str) } func logError(t *testing.T, str string) { + t.Helper() t.Errorf(logBodyFmt, prefix(3), str) } @@ -214,6 +216,8 @@ func deepDiff(expected, actual interface{}, logDifference diffLogger) { // AssertEquals compares two arbitrary values and performs a comparison. If the // comparison fails, a fatal error is raised that will fail the test func AssertEquals(t *testing.T, expected, actual interface{}) { + t.Helper() + if expected != actual { logFatal(t, fmt.Sprintf("expected %s but got %s", green(expected), yellow(actual))) } @@ -221,6 +225,8 @@ func AssertEquals(t *testing.T, expected, actual interface{}) { // CheckEquals is similar to AssertEquals, except with a non-fatal error func CheckEquals(t *testing.T, expected, actual interface{}) { + t.Helper() + if expected != actual { logError(t, fmt.Sprintf("expected %s but got %s", green(expected), yellow(actual))) } @@ -229,6 +235,8 @@ func CheckEquals(t *testing.T, expected, actual interface{}) { // AssertDeepEquals - like Equals - performs a comparison - but on more complex // structures that requires deeper inspection func AssertDeepEquals(t *testing.T, expected, actual interface{}) { + t.Helper() + pre := prefix(2) differed := false @@ -247,6 +255,8 @@ func AssertDeepEquals(t *testing.T, expected, actual interface{}) { // CheckDeepEquals is similar to AssertDeepEquals, except with a non-fatal error func CheckDeepEquals(t *testing.T, expected, actual interface{}) { + t.Helper() + pre := prefix(2) deepDiff(expected, actual, func(path []string, expected, actual interface{}) { @@ -264,6 +274,8 @@ func isByteArrayEquals(t *testing.T, expectedBytes []byte, actualBytes []byte) b // AssertByteArrayEquals a convenience function for checking whether two byte arrays are equal func AssertByteArrayEquals(t *testing.T, expectedBytes []byte, actualBytes []byte) { + t.Helper() + if !isByteArrayEquals(t, expectedBytes, actualBytes) { logFatal(t, "The bytes differed.") } @@ -271,6 +283,8 @@ func AssertByteArrayEquals(t *testing.T, expectedBytes []byte, actualBytes []byt // CheckByteArrayEquals a convenience function for silent checking whether two byte arrays are equal func CheckByteArrayEquals(t *testing.T, expectedBytes []byte, actualBytes []byte) { + t.Helper() + if !isByteArrayEquals(t, expectedBytes, actualBytes) { logError(t, "The bytes differed.") } @@ -321,6 +335,8 @@ func isJSONEquals(t *testing.T, expectedJSON string, actual interface{}) bool { // This is useful for comparing structures that are built as nested map[string]interface{} values, // which are a pain to construct as literals. func AssertJSONEquals(t *testing.T, expectedJSON string, actual interface{}) { + t.Helper() + if !isJSONEquals(t, expectedJSON, actual) { logFatal(t, "The generated JSON structure differed.") } @@ -328,6 +344,8 @@ func AssertJSONEquals(t *testing.T, expectedJSON string, actual interface{}) { // CheckJSONEquals is similar to AssertJSONEquals, but nonfatal. func CheckJSONEquals(t *testing.T, expectedJSON string, actual interface{}) { + t.Helper() + if !isJSONEquals(t, expectedJSON, actual) { logError(t, "The generated JSON structure differed.") } @@ -336,6 +354,8 @@ func CheckJSONEquals(t *testing.T, expectedJSON string, actual interface{}) { // AssertNoErr is a convenience function for checking whether an error value is // an actual error func AssertNoErr(t *testing.T, e error) { + t.Helper() + if e != nil { logFatal(t, fmt.Sprintf("unexpected error %s", yellow(e.Error()))) } @@ -344,6 +364,8 @@ func AssertNoErr(t *testing.T, e error) { // AssertErr is a convenience function for checking whether an error value is // nil func AssertErr(t *testing.T, e error) { + t.Helper() + if e == nil { logFatal(t, fmt.Sprintf("expected error, got nil")) } @@ -351,6 +373,8 @@ func AssertErr(t *testing.T, e error) { // CheckNoErr is similar to AssertNoErr, except with a non-fatal error func CheckNoErr(t *testing.T, e error) { + t.Helper() + if e != nil { logError(t, fmt.Sprintf("unexpected error %s", yellow(e.Error()))) } @@ -364,6 +388,8 @@ func CheckNoErr(t *testing.T, e error) { // CheckErr panics if expected contains anything other than non-nil pointers to // either a type that implements error, or to any interface type. func CheckErr(t *testing.T, e error, expected ...interface{}) { + t.Helper() + if e == nil { logError(t, "expected error, got nil") return @@ -381,6 +407,8 @@ func CheckErr(t *testing.T, e error, expected ...interface{}) { // AssertIntLesserOrEqual verifies that first value is lesser or equal than second values func AssertIntLesserOrEqual(t *testing.T, v1 int, v2 int) { + t.Helper() + if !(v1 <= v2) { logFatal(t, fmt.Sprintf("The first value \"%v\" is greater than the second value \"%v\"", v1, v2)) } @@ -388,6 +416,8 @@ func AssertIntLesserOrEqual(t *testing.T, v1 int, v2 int) { // AssertIntGreaterOrEqual verifies that first value is greater or equal than second values func AssertIntGreaterOrEqual(t *testing.T, v1 int, v2 int) { + t.Helper() + if !(v1 >= v2) { logFatal(t, fmt.Sprintf("The first value \"%v\" is lesser than the second value \"%v\"", v1, v2)) }