Compare commits

..

No commits in common. "main" and "1.5.0" have entirely different histories.
main ... 1.5.0

21 changed files with 5165 additions and 646 deletions

View file

@ -3,11 +3,6 @@ updates:
- package-ecosystem: bundler - package-ecosystem: bundler
directory: "/" directory: "/"
schedule: schedule:
interval: weekly interval: daily
open-pull-requests-limit: 10 time: "13:00"
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10 open-pull-requests-limit: 10

View file

@ -1,12 +0,0 @@
name: Automated release prep
on:
workflow_dispatch:
jobs:
auto_release_prep:
uses: puppetlabs/release-engineering-repo-standards/.github/workflows/auto_release_prep.yml@v1
secrets: inherit
with:
project-type: ruby
version-file-path: lib/vmpooler-provider-vsphere/version.rb

View file

@ -1,8 +0,0 @@
name: Dependabot auto-merge
on: pull_request
jobs:
dependabot_merge:
uses: puppetlabs/release-engineering-repo-standards/.github/workflows/dependabot_merge.yml@v1
secrets: inherit

View file

@ -1,8 +0,0 @@
name: Ensure label
on: pull_request
jobs:
ensure_label:
uses: puppetlabs/release-engineering-repo-standards/.github/workflows/ensure_label.yml@v1
secrets: inherit

View file

@ -1,4 +1,4 @@
name: Release Gem name: Release
on: workflow_dispatch on: workflow_dispatch
@ -7,77 +7,25 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.repository == 'puppetlabs/vmpooler-provider-vsphere' if: github.repository == 'puppetlabs/vmpooler-provider-vsphere'
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v2
- name: Get Version
- name: Get Current Version id: gv
uses: actions/github-script@v7
id: cv
with:
script: |
const { data: response } = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo,
})
console.log(`The latest release is ${response.tag_name}`)
return response.tag_name
result-encoding: string
- name: Get Next Version
id: nv
run: | run: |
version=$(grep VERSION lib/vmpooler-provider-vsphere/version.rb |rev |cut -d "'" -f2 |rev) echo "::set-output name=ver::$(grep VERSION lib/vmpooler-provider-vsphere/version.rb |rev |cut -d "'" -f2 |rev)"
echo "version=$version" >> $GITHUB_OUTPUT
echo "Found version $version from lib/vmpooler-provider-vsphere/version.rb"
- name: Generate Changelog
uses: docker://githubchangeloggenerator/github-changelog-generator:1.16.2
with:
args: >-
--future-release ${{ steps.nv.outputs.version }}
env:
CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Validate Changelog
run : |
set -e
if [[ -n $(git status --porcelain) ]]; then
echo "Here is the current git status:"
git status
echo
echo "The following changes were detected:"
git --no-pager diff
echo "Uncommitted PRs found in the changelog. Please submit a release prep PR of changes after running `./update-changelog`"
exit 1
fi
- name: Generate Release Notes
uses: docker://githubchangeloggenerator/github-changelog-generator:1.16.2
with:
args: >-
--since-tag ${{ steps.cv.outputs.result }}
--future-release ${{ steps.nv.outputs.version }}
--output release-notes.md
env:
CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Tag Release - name: Tag Release
uses: ncipollo/release-action@v1 uses: ncipollo/release-action@v1
with: with:
tag: ${{ steps.nv.outputs.version }} tag: ${{ steps.gv.outputs.ver }}
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
bodyfile: release-notes.md
draft: false draft: false
prerelease: false prerelease: false
generateReleaseNotes: true
# This step should closely match what is used in `docker/Dockerfile` in vmpooler-deployment - name: Install Ruby 2.5.8
- name: Install Ruby jruby-9.3.6.0
uses: ruby/setup-ruby@v1 uses: ruby/setup-ruby@v1
with: with:
ruby-version: 'jruby-9.4.3.0' ruby-version: '2.5.8'
- name: Build gem - name: Build gem
run: gem build *.gemspec run: gem build *.gemspec
- name: Publish gem - name: Publish gem
run: | run: |
mkdir -p $HOME/.gem mkdir -p $HOME/.gem

View file

@ -1,39 +0,0 @@
name: Security
on:
workflow_dispatch:
push:
branches:
- main
jobs:
scan:
name: Mend Scanning
runs-on: ubuntu-latest
steps:
- name: checkout repo content
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
# setup a package lock if one doesn't exist, otherwise do nothing
- name: check lock
run: '[ -f "Gemfile.lock" ] && echo "package lock file exists, skipping" || bundle lock'
# install java
- uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
# download mend
- name: download_mend
run: curl -o wss-unified-agent.jar https://unified-agent.s3.amazonaws.com/wss-unified-agent.jar
- name: run mend
run: java -jar wss-unified-agent.jar
env:
WS_APIKEY: ${{ secrets.MEND_API_KEY }}
WS_WSS_URL: https://saas-eu.whitesourcesoftware.com/agent
WS_USERKEY: ${{ secrets.MEND_TOKEN }}
WS_PRODUCTNAME: RE
WS_PROJECTNAME: ${{ github.event.repository.name }}

View file

@ -18,9 +18,9 @@ jobs:
strategy: strategy:
matrix: matrix:
ruby-version: ruby-version:
- 'jruby-9.4.3.0' - '2.5.8'
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v2
- name: Set up Ruby - name: Set up Ruby
uses: ruby/setup-ruby@v1 uses: ruby/setup-ruby@v1
with: with:
@ -34,9 +34,10 @@ jobs:
strategy: strategy:
matrix: matrix:
ruby-version: ruby-version:
- 'jruby-9.4.3.0' - '2.5.8'
- 'jruby-9.2.12.0'
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v2
- name: Set up Ruby - name: Set up Ruby
uses: ruby/setup-ruby@v1 uses: ruby/setup-ruby@v1
with: with:

View file

@ -1,3 +0,0 @@
project=vmpooler-provider-vsphere
user=puppetlabs
exclude_labels=maintenance

View file

@ -1,136 +0,0 @@
# Changelog
## [3.3.4](https://github.com/puppetlabs/vmpooler-provider-vsphere/tree/3.3.4) (2023-08-30)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-vsphere/compare/3.3.3...3.3.4)
**Fixed bugs:**
- \(maint\) Convert booleans and Time objects to strings when being added to redis [\#51](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/51) ([isaac-hammes](https://github.com/isaac-hammes))
## [3.3.3](https://github.com/puppetlabs/vmpooler-provider-vsphere/tree/3.3.3) (2023-08-28)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-vsphere/compare/3.3.2...3.3.3)
**Fixed bugs:**
- \(maint\) Update Gemfile.lock and use block for transaction. [\#49](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/49) ([isaac-hammes](https://github.com/isaac-hammes))
## [3.3.2](https://github.com/puppetlabs/vmpooler-provider-vsphere/tree/3.3.2) (2023-08-23)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-vsphere/compare/3.3.1...3.3.2)
**Fixed bugs:**
- \(maint\) Increase timeout for cloned vms to obtain IPs. [\#47](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/47) ([isaac-hammes](https://github.com/isaac-hammes))
## [3.3.1](https://github.com/puppetlabs/vmpooler-provider-vsphere/tree/3.3.1) (2023-08-22)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-vsphere/compare/3.3.0...3.3.1)
**Fixed bugs:**
- \(RE-15710\) Fix IP address that is returned and increase timeout [\#44](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/44) ([yachub](https://github.com/yachub))
## [3.3.0](https://github.com/puppetlabs/vmpooler-provider-vsphere/tree/3.3.0) (2023-08-18)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-vsphere/compare/3.2.0...3.3.0)
**Implemented enhancements:**
- \(POD-10\) Log reason for failed VM checks. [\#42](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/42) ([isaac-hammes](https://github.com/isaac-hammes))
## [3.2.0](https://github.com/puppetlabs/vmpooler-provider-vsphere/tree/3.2.0) (2023-08-10)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-vsphere/compare/3.1.0...3.2.0)
**Implemented enhancements:**
- Bump jruby to 9.4.3.0 and update lockfile [\#40](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/40) ([yachub](https://github.com/yachub))
**Merged pull requests:**
- Bump thor from 1.2.1 to 1.2.2 [\#38](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/38) ([dependabot[bot]](https://github.com/apps/dependabot))
- Bump vmpooler from 3.0.0 to 3.1.0 [\#37](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/37) ([dependabot[bot]](https://github.com/apps/dependabot))
- Bump rack-test from 2.0.2 to 2.1.0 [\#36](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/36) ([dependabot[bot]](https://github.com/apps/dependabot))
## [3.1.0](https://github.com/puppetlabs/vmpooler-provider-vsphere/tree/3.1.0) (2023-05-01)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-vsphere/compare/3.0.0...3.1.0)
**Merged pull requests:**
- Migrate issue management to Jira [\#34](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/34) ([yachub](https://github.com/yachub))
- Bump jruby to 9.4.2.0 [\#33](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/33) ([yachub](https://github.com/yachub))
## [3.0.0](https://github.com/puppetlabs/vmpooler-provider-vsphere/tree/3.0.0) (2023-04-19)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-vsphere/compare/2.1.0...3.0.0)
**Breaking changes:**
- \(RE-15124\) Collect VMs IP for use with DNS Plugins [\#29](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/29) ([yachub](https://github.com/yachub))
## [2.1.0](https://github.com/puppetlabs/vmpooler-provider-vsphere/tree/2.1.0) (2023-03-06)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-vsphere/compare/2.0.0...2.1.0)
**Implemented enhancements:**
- \(RE-15161\) Use timeout builtin to TCPSocket when opening sockets. [\#30](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/30) ([isaac-hammes](https://github.com/isaac-hammes))
## [2.0.0](https://github.com/puppetlabs/vmpooler-provider-vsphere/tree/2.0.0) (2023-01-30)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-vsphere/compare/1.6.0...2.0.0)
**Implemented enhancements:**
- Migrate to rbvmomi2 [\#25](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/25) ([yachub](https://github.com/yachub))
**Closed issues:**
- Document Custom VM Attribute [\#23](https://github.com/puppetlabs/vmpooler-provider-vsphere/issues/23)
**Merged pull requests:**
- Fix workflow deprecations, changelog, and add docs [\#24](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/24) ([yachub](https://github.com/yachub))
- \(RE-15111\) Migrate Snyk to Mend Scanning [\#22](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/22) ([yachub](https://github.com/yachub))
- \(RE-14811\) Remove DIO as codeowners [\#21](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/21) ([yachub](https://github.com/yachub))
- Add Snyk action [\#20](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/20) ([yachub](https://github.com/yachub))
- Add release-engineering to codeowners [\#19](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/19) ([yachub](https://github.com/yachub))
- Update rubocop requirement from ~\> 1.1.0 to ~\> 1.28.2 [\#17](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/17) ([dependabot[bot]](https://github.com/apps/dependabot))
## [1.6.0](https://github.com/puppetlabs/vmpooler-provider-vsphere/tree/1.6.0) (2022-07-25)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-vsphere/compare/1.5.0...1.6.0)
**Merged pull requests:**
- pin to vmpooler 2.4 [\#18](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/18) ([sbeaulie](https://github.com/sbeaulie))
## [1.5.0](https://github.com/puppetlabs/vmpooler-provider-vsphere/tree/1.5.0) (2021-12-13)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-vsphere/compare/1.4.0...1.5.0)
**Merged pull requests:**
- Bump version to 1.5.0, require vmpooler \>= 2.1 [\#5](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/5) ([genebean](https://github.com/genebean))
- Move vsphere specific methods out of vmpooler [\#4](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/4) ([sbeaulie](https://github.com/sbeaulie))
## [1.4.0](https://github.com/puppetlabs/vmpooler-provider-vsphere/tree/1.4.0) (2021-12-08)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-vsphere/compare/1.3.0...1.4.0)
**Merged pull requests:**
- Prep for initial standalone release: v1.4.0 [\#3](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/3) ([genebean](https://github.com/genebean))
- Add GH Action for releasing gems [\#2](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/2) ([genebean](https://github.com/genebean))
- Fix naming, add docs, add missing test file [\#1](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/1) ([genebean](https://github.com/genebean))
## [1.3.0](https://github.com/puppetlabs/vmpooler-provider-vsphere/tree/1.3.0) (2021-11-29)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-vsphere/compare/a08cba099f867b1db01a50940ec3ae9239245db5...1.3.0)
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*

View file

@ -1,10 +1,10 @@
# This will cause RE to be assigned review of any opened PRs against # This will cause DIO to be assigned review of any opened PRs against
# the branches containing this file. # the branches containing this file.
# See https://help.github.com/en/articles/about-code-owners for info on how to # See https://help.github.com/en/articles/about-code-owners for info on how to
# take ownership of parts of the code base that should be reviewed by another # take ownership of parts of the code base that should be reviewed by another
# team. # team.
# RE will be the default owners for everything in the repo. # DIO will be the default owners for everything in the repo.
* @puppetlabs/release-engineering * @puppetlabs/dio

View file

@ -1,190 +1,183 @@
PATH PATH
remote: . remote: .
specs: specs:
vmpooler-provider-vsphere (3.3.4) vmpooler-provider-vsphere (1.5.0)
rbvmomi2 (>= 3.1, < 4.0) rbvmomi (>= 2.1, < 4.0)
vmpooler (~> 3.0)
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
ast (2.4.2) ast (2.4.2)
bindata (2.4.15) bindata (2.4.10)
builder (3.2.4) builder (3.2.4)
climate_control (1.2.0) climate_control (1.0.1)
coderay (1.1.3) coderay (1.1.3)
concurrent-ruby (1.2.2) concurrent-ruby (1.1.9)
connection_pool (2.4.1) connection_pool (2.2.5)
deep_merge (1.2.2) diff-lcs (1.4.4)
diff-lcs (1.5.0)
docile (1.4.0) docile (1.4.0)
faraday (2.7.10) faraday (1.8.0)
faraday-net_http (>= 2.0, < 3.1) faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0.1)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.1)
faraday-patron (~> 1.0)
faraday-rack (~> 1.0)
multipart-post (>= 1.2, < 3)
ruby2_keywords (>= 0.0.4) ruby2_keywords (>= 0.0.4)
faraday-net_http (3.0.2) faraday-em_http (1.0.0)
ffi (1.15.5-java) faraday-em_synchrony (1.0.0)
google-cloud-env (1.6.0) faraday-excon (1.1.0)
faraday (>= 0.17.3, < 3.0) faraday-httpclient (1.0.1)
json (2.6.3) faraday-net_http (1.0.1)
json (2.6.3-java) faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
ffi (1.15.4-java)
google-cloud-env (1.5.0)
faraday (>= 0.17.3, < 2.0)
json (2.6.1)
json (2.6.1-java)
method_source (1.0.0) method_source (1.0.0)
mock_redis (0.37.0) mock_redis (0.29.0)
mustermann (3.0.0) ruby2_keywords
multipart-post (2.1.1)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1) ruby2_keywords (~> 0.0.1)
net-ldap (0.18.0) net-ldap (0.17.0)
nio4r (2.5.9) nio4r (2.5.8)
nio4r (2.5.9-java) nio4r (2.5.8-java)
nokogiri (1.15.4-java) nokogiri (1.12.5-java)
racc (~> 1.4) racc (~> 1.4)
nokogiri (1.15.4-x86_64-linux) nokogiri (1.12.5-x86_64-linux)
racc (~> 1.4) racc (~> 1.4)
opentelemetry-api (1.2.2) opentelemetry-api (0.17.0)
opentelemetry-common (0.20.0) opentelemetry-common (0.17.0)
opentelemetry-api (~> 1.0) opentelemetry-api (~> 0.17.0)
opentelemetry-exporter-jaeger (0.23.0) opentelemetry-exporter-jaeger (0.17.0)
opentelemetry-api (~> 1.1) opentelemetry-api (~> 0.17.0)
opentelemetry-common (~> 0.20) opentelemetry-common (~> 0.17.0)
opentelemetry-sdk (~> 1.2) opentelemetry-sdk (~> 0.17.0)
opentelemetry-semantic_conventions
thrift thrift
opentelemetry-instrumentation-base (0.22.2) opentelemetry-instrumentation-base (0.17.0)
opentelemetry-api (~> 1.0) opentelemetry-api (~> 0.17.0)
opentelemetry-registry (~> 0.1) opentelemetry-instrumentation-concurrent_ruby (0.17.0)
opentelemetry-instrumentation-concurrent_ruby (0.21.1) opentelemetry-api (~> 0.17.0)
opentelemetry-api (~> 1.0) opentelemetry-instrumentation-base (~> 0.17.0)
opentelemetry-instrumentation-base (~> 0.22.1) opentelemetry-instrumentation-redis (0.17.0)
opentelemetry-instrumentation-http_client (0.22.2) opentelemetry-api (~> 0.17.0)
opentelemetry-api (~> 1.0) opentelemetry-common (~> 0.17.0)
opentelemetry-common (~> 0.20.0) opentelemetry-instrumentation-base (~> 0.17.0)
opentelemetry-instrumentation-base (~> 0.22.1) opentelemetry-instrumentation-sinatra (0.17.0)
opentelemetry-instrumentation-rack (0.23.4) opentelemetry-api (~> 0.17.0)
opentelemetry-api (~> 1.0) opentelemetry-instrumentation-base (~> 0.17.0)
opentelemetry-common (~> 0.20.0) opentelemetry-resource_detectors (0.17.0)
opentelemetry-instrumentation-base (~> 0.22.1)
opentelemetry-instrumentation-redis (0.25.3)
opentelemetry-api (~> 1.0)
opentelemetry-common (~> 0.20.0)
opentelemetry-instrumentation-base (~> 0.22.1)
opentelemetry-instrumentation-sinatra (0.23.2)
opentelemetry-api (~> 1.0)
opentelemetry-common (~> 0.20.0)
opentelemetry-instrumentation-base (~> 0.22.1)
opentelemetry-instrumentation-rack (~> 0.21)
opentelemetry-registry (0.3.0)
opentelemetry-api (~> 1.1)
opentelemetry-resource_detectors (0.24.1)
google-cloud-env google-cloud-env
opentelemetry-sdk (~> 1.0) opentelemetry-sdk
opentelemetry-sdk (1.3.0) opentelemetry-sdk (0.17.0)
opentelemetry-api (~> 1.1) opentelemetry-api (~> 0.17.0)
opentelemetry-common (~> 0.20) opentelemetry-common (~> 0.17.0)
opentelemetry-registry (~> 0.2) opentelemetry-instrumentation-base (~> 0.17.0)
opentelemetry-semantic_conventions optimist (3.0.1)
opentelemetry-semantic_conventions (1.10.0) parallel (1.21.0)
opentelemetry-api (~> 1.0) parser (3.0.3.2)
optimist (3.1.0)
parallel (1.23.0)
parser (3.2.2.3)
ast (~> 2.4.1) ast (~> 2.4.1)
racc
pickup (0.0.11) pickup (0.0.11)
prometheus-client (4.2.1) prometheus-client (2.1.0)
pry (0.14.2) pry (0.14.1)
coderay (~> 1.1) coderay (~> 1.1)
method_source (~> 1.0) method_source (~> 1.0)
pry (0.14.2-java) pry (0.14.1-java)
coderay (~> 1.1) coderay (~> 1.1)
method_source (~> 1.0) method_source (~> 1.0)
spoon (~> 0.0) spoon (~> 0.0)
puma (6.3.1) puma (5.5.2)
nio4r (~> 2.0) nio4r (~> 2.0)
puma (6.3.1-java) puma (5.5.2-java)
nio4r (~> 2.0) nio4r (~> 2.0)
racc (1.7.1) racc (1.6.0)
racc (1.7.1-java) racc (1.6.0-java)
rack (2.2.8) rack (2.2.3)
rack-protection (3.1.0) rack-protection (2.1.0)
rack (~> 2.2, >= 2.2.4) rack
rack-test (2.1.0) rack-test (1.1.0)
rack (>= 1.3) rack (>= 1.0, < 3)
rainbow (3.1.1) rainbow (3.0.0)
rake (13.0.6) rake (13.0.6)
rbvmomi2 (3.6.1) rbvmomi (3.0.0)
builder (~> 3.2) builder (~> 3.2)
json (~> 2.3) json (~> 2.3)
nokogiri (~> 1.12, >= 1.12.5) nokogiri (~> 1.10)
optimist (~> 3.0) optimist (~> 3.0)
redis (5.0.7) redis (4.5.1)
redis-client (>= 0.9.0) regexp_parser (2.2.0)
redis-client (0.16.0) rexml (3.2.5)
connection_pool rspec (3.10.0)
regexp_parser (2.8.1) rspec-core (~> 3.10.0)
rexml (3.2.6) rspec-expectations (~> 3.10.0)
rspec (3.12.0) rspec-mocks (~> 3.10.0)
rspec-core (~> 3.12.0) rspec-core (3.10.1)
rspec-expectations (~> 3.12.0) rspec-support (~> 3.10.0)
rspec-mocks (~> 3.12.0) rspec-expectations (3.10.1)
rspec-core (3.12.2)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.3)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0) rspec-support (~> 3.10.0)
rspec-mocks (3.12.6) rspec-mocks (3.10.2)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0) rspec-support (~> 3.10.0)
rspec-support (3.12.1) rspec-support (3.10.3)
rubocop (1.28.2) rubocop (1.1.0)
parallel (~> 1.10) parallel (~> 1.10)
parser (>= 3.1.0.0) parser (>= 2.7.1.5)
rainbow (>= 2.2.2, < 4.0) rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0) regexp_parser (>= 1.8)
rexml rexml
rubocop-ast (>= 1.17.0, < 2.0) rubocop-ast (>= 1.0.1)
ruby-progressbar (~> 1.7) ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0) unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (1.29.0) rubocop-ast (1.15.0)
parser (>= 3.2.1.0) parser (>= 3.0.1.1)
ruby-progressbar (1.13.0) ruby-progressbar (1.11.0)
ruby2_keywords (0.0.5) ruby2_keywords (0.0.5)
simplecov (0.22.0) simplecov (0.21.2)
docile (~> 1.1) docile (~> 1.1)
simplecov-html (~> 0.11) simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1) simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3) simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4) simplecov_json_formatter (0.1.3)
sinatra (3.1.0) sinatra (2.1.0)
mustermann (~> 3.0) mustermann (~> 1.0)
rack (~> 2.2, >= 2.2.4) rack (~> 2.2)
rack-protection (= 3.1.0) rack-protection (= 2.1.0)
tilt (~> 2.0) tilt (~> 2.0)
spicy-proton (2.1.15) spicy-proton (2.1.13)
bindata (~> 2.3) bindata (~> 2.3)
spoon (0.0.6) spoon (0.0.6)
ffi ffi
statsd-ruby (1.5.0) statsd-ruby (1.5.0)
thor (1.2.2) thor (1.1.0)
thrift (0.18.1) thrift (0.15.0)
tilt (2.2.0) tilt (2.0.10)
unicode-display_width (2.4.2) unicode-display_width (1.8.0)
vmpooler (3.5.1) vmpooler (2.1.0)
concurrent-ruby (~> 1.1) concurrent-ruby (~> 1.1)
connection_pool (~> 2.4) connection_pool (~> 2.2)
deep_merge (~> 1.2)
net-ldap (~> 0.16) net-ldap (~> 0.16)
opentelemetry-exporter-jaeger (= 0.23.0) nokogiri (~> 1.10)
opentelemetry-instrumentation-concurrent_ruby (= 0.21.1) opentelemetry-exporter-jaeger (= 0.17.0)
opentelemetry-instrumentation-http_client (= 0.22.2) opentelemetry-instrumentation-concurrent_ruby (= 0.17.0)
opentelemetry-instrumentation-redis (= 0.25.3) opentelemetry-instrumentation-redis (= 0.17.0)
opentelemetry-instrumentation-sinatra (= 0.23.2) opentelemetry-instrumentation-sinatra (= 0.17.0)
opentelemetry-resource_detectors (= 0.24.1) opentelemetry-resource_detectors (= 0.17.0)
opentelemetry-sdk (~> 1.3, >= 1.3.0) opentelemetry-sdk (= 0.17.0)
pickup (~> 0.0.11) pickup (~> 0.0.11)
prometheus-client (>= 2, < 5) prometheus-client (~> 2.0)
puma (>= 5.0.4, < 7) puma (~> 5.0, >= 5.0.4)
rack (>= 2.2, < 4.0) rack (~> 2.2)
rake (~> 13.0) rake (~> 13.0)
redis (~> 5.0) redis (~> 4.1)
sinatra (>= 2, < 4) sinatra (~> 2.0)
spicy-proton (~> 2.1) spicy-proton (~> 2.1)
statsd-ruby (~> 1.4) statsd-ruby (~> 1.4)
yarjuf (2.0.0) yarjuf (2.0.0)
@ -201,11 +194,12 @@ DEPENDENCIES
pry pry
rack-test (>= 0.6) rack-test (>= 0.6)
rspec (>= 3.2) rspec (>= 3.2)
rubocop (~> 1.28.2) rubocop (~> 1.1.0)
simplecov (>= 0.11.2) simplecov (>= 0.11.2)
thor (~> 1.0, >= 1.0.1) thor (~> 1.0, >= 1.0.1)
vmpooler (~> 2.1)
vmpooler-provider-vsphere! vmpooler-provider-vsphere!
yarjuf (>= 2.0) yarjuf (>= 2.0)
BUNDLED WITH BUNDLED WITH
2.4.10 2.2.22

View file

@ -1,12 +1,5 @@
# vmpooler-provider-vsphere # vmpooler-provider-vsphere
- [vmpooler-provider-vsphere](#vmpooler-provider-vsphere)
- [Usage](#usage)
- [Custom VM Config Attribute](#custom-vm-config-attribute)
- [Update the Gemfile Lock](#update-the-gemfile-lock)
- [Releasing](#releasing)
- [License](#license)
This is a provider for [VMPooler](https://github.com/puppetlabs/vmpooler) allows using vSphere as a source of machines. This provider was originally part of the main VMPooler code base but was extracted to be a standalone gem so that development could be done independently of VMPooler itself. This is a provider for [VMPooler](https://github.com/puppetlabs/vmpooler) allows using vSphere as a source of machines. This provider was originally part of the main VMPooler code base but was extracted to be a standalone gem so that development could be done independently of VMPooler itself.
## Usage ## Usage
@ -15,30 +8,6 @@ Include this gem in the same Gemfile that you use to install VMPooler itself and
Examples of deploying VMPooler with this provider can be found in the [puppetlabs/vmpooler-deployment](https://github.com/puppetlabs/vmpooler-deployment) repository. Examples of deploying VMPooler with this provider can be found in the [puppetlabs/vmpooler-deployment](https://github.com/puppetlabs/vmpooler-deployment) repository.
### Custom VM Config Attribute
This provider sets a custom attribute on the VM called `guestinfo.hostname` to the name of the generated VM, which can be queried from inside the guest OS if VMware Tools is isntalled. For example:
macOS: `"/Library/Application Support/VMware Tools/vmware-tools-daemon" --cmd "info-get guestinfo.hostname"`
Linux or Windows Guest: `vmtoolsd --cmd "info-get guestinfo.hostname"`
See the [VMware Tools Administration docs](https://docs.vmware.com/en/VMware-Tools/12.1.0/com.vmware.vsphere.vmwaretools.doc/GUID-D026777B-606D-4442-957A-B953C2049659.html) for more information about querying information from the GuestInfo variable.
## Update the Gemfile Lock
To update the `Gemfile.lock` run `./update-gemfile-lock`.
Verify, and update if needed, that the docker tag in the script and GitHub action workflows matches what is used in the [vmpooler-deployment Dockerfile](https://github.com/puppetlabs/vmpooler-deployment/blob/main/docker/Dockerfile).
## Releasing
Follow these steps to publish a new GitHub release, and build and push the gem to <https://rubygems.org>.
1. Bump the "VERSION" in `lib/vmpooler-provider-vsphere/version.rb` appropriately based on changes in `CHANGELOG.md` since the last release.
2. Run `./release-prep` to update `Gemfile.lock` and `CHANGELOG.md`.
3. Commit and push changes to a new branch, then open a pull request against `main` and be sure to add the "maintenance" label.
4. After the pull request is approved and merged, then navigate to Actions --> Release Gem --> run workflow --> Branch: main --> Run workflow.
## License ## License
vmpooler-provider-vsphere is distributed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html). See the [LICENSE](LICENSE) file for more details. vmpooler-provider-vsphere is distributed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html). See the [LICENSE](LICENSE) file for more details.

View file

@ -1,7 +0,0 @@
#!/usr/bin/env bash
# The container tag should closely match what is used in `docker/Dockerfile` in vmpooler-deployment
docker run -it --rm \
-v $(pwd):/app \
jruby:9.4.3.0-jdk11 \
/bin/bash -c 'apt-get update -qq && apt-get install -y --no-install-recommends make git netbase && cd /app && gem install bundler && bundle install --jobs 3; echo "LOCK_FILE_UPDATE_EXIT_CODE=$?"'

View file

@ -1,5 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
module VmpoolerProviderVsphere module VmpoolerProviderVsphere
VERSION = '3.3.4' VERSION = '1.5.0'
end end

View file

@ -51,11 +51,6 @@ module Vmpooler
'vsphere' 'vsphere'
end end
def domain(pool_name)
dns_plugin_name = pool_config(pool_name)['dns_plugin']
dns_config(dns_plugin_name)
end
def folder_configured?(folder_title, base_folder, configured_folders, allowlist) def folder_configured?(folder_title, base_folder, configured_folders, allowlist)
return true if allowlist&.include?(folder_title) return true if allowlist&.include?(folder_title)
return false unless configured_folders.keys.include?(folder_title) return false unless configured_folders.keys.include?(folder_title)
@ -68,14 +63,14 @@ module Vmpooler
try = 0 if try.nil? try = 0 if try.nil?
max_tries = 3 max_tries = 3
@redis.with_metrics do |redis| @redis.with_metrics do |redis|
redis.multi do |transaction| redis.multi
transaction.srem("vmpooler__completed__#{pool}", vm_name) redis.srem("vmpooler__completed__#{pool}", vm_name)
transaction.hdel("vmpooler__active__#{pool}", vm_name) redis.hdel("vmpooler__active__#{pool}", vm_name)
transaction.hset("vmpooler__vm__#{vm_name}", 'destroy', Time.now.to_s) redis.hset("vmpooler__vm__#{vm_name}", 'destroy', Time.now)
# Auto-expire metadata key # Auto-expire metadata key
transaction.expire("vmpooler__vm__#{vm_name}", (data_ttl * 60 * 60)) redis.expire("vmpooler__vm__#{vm_name}", (data_ttl * 60 * 60))
end redis.exec
end end
start = Time.now start = Time.now
@ -392,16 +387,6 @@ module Vmpooler
vm_hash vm_hash
end end
# The inner method requires vmware tools running in the guest os
def get_vm_ip_address(vm_name, pool_name)
@connection_pool.with_metrics do |pool_object|
connection = ensured_vsphere_connection(pool_object)
vm_object = find_vm(pool_name, vm_name, connection)
vm_hash = generate_vm_hash(vm_object, pool_name)
return vm_hash['ip']
end
end
def create_config_spec(vm_name, template_name, extra_config) def create_config_spec(vm_name, template_name, extra_config)
RbVmomi::VIM.VirtualMachineConfigSpec( RbVmomi::VIM.VirtualMachineConfigSpec(
annotation: JSON.pretty_generate( annotation: JSON.pretty_generate(
@ -555,15 +540,13 @@ module Vmpooler
true true
end end
def vm_ready?(pool_name, vm_name, redis) def vm_ready?(_pool_name, vm_name)
begin begin
domain = domain(pool_name) open_socket(vm_name, global_config[:config]['domain'])
open_socket(vm_name, domain) rescue StandardError => _e
rescue StandardError => e
redis.hset("vmpooler__vm__#{vm_name}", 'open_socket_error', e.to_s)
return false return false
end end
redis.hdel("vmpooler__vm__#{vm_name}", 'open_socket_error')
true true
end end
@ -599,30 +582,13 @@ module Vmpooler
boottime = vm_object.runtime.bootTime if vm_object.runtime&.bootTime boottime = vm_object.runtime.bootTime if vm_object.runtime&.bootTime
powerstate = vm_object.runtime.powerState if vm_object.runtime&.powerState powerstate = vm_object.runtime.powerState if vm_object.runtime&.powerState
ip_maxloop = 240
ip_loop_delay = 1
ip_loop_count = 1
ip = nil
invalid_addresses = /(0|169)\.(0|254)\.\d+\.\d+/
while ip.nil?
sleep(ip_loop_delay)
ip = vm_object.guest_ip
ip = nil if !ip.nil? && ip.match?(invalid_addresses)
unless ip_maxloop == 0
break if ip_loop_count >= ip_maxloop
ip_loop_count += 1
end
end
{ {
'name' => vm_object.name, 'name' => vm_object.name,
'hostname' => hostname, 'hostname' => hostname,
'template' => pool_configuration['template'], 'template' => pool_configuration['template'],
'poolname' => pool_name, 'poolname' => pool_name,
'boottime' => boottime, 'boottime' => boottime,
'powerstate' => powerstate, 'powerstate' => powerstate
'ip' => ip
} }
end end
@ -666,13 +632,15 @@ module Vmpooler
# This should supercede the open_socket method in the Pool Manager # This should supercede the open_socket method in the Pool Manager
def open_socket(host, domain = nil, timeout = 5, port = 22, &_block) def open_socket(host, domain = nil, timeout = 5, port = 22, &_block)
target_host = host Timeout.timeout(timeout) do
target_host = "#{host}.#{domain}" if domain target_host = host
sock = TCPSocket.new(target_host, port, connect_timeout: timeout) target_host = "#{host}.#{domain}" if domain
begin sock = TCPSocket.new target_host, port
yield sock if block_given? begin
ensure yield sock if block_given?
sock.close ensure
sock.close
end
end end
end end
@ -1103,9 +1071,6 @@ module Vmpooler
begin begin
connection = ensured_vsphere_connection(pool_object) connection = ensured_vsphere_connection(pool_object)
vm_hash = get_vm_details(pool_name, vm_name, connection) vm_hash = get_vm_details(pool_name, vm_name, connection)
raise StandardError, 'failed to get vm details. vm is unreachable or no longer exists' if vm_hash.nil?
@redis.with_metrics do |redis| @redis.with_metrics do |redis|
redis.hset("vmpooler__vm__#{vm_name}", 'host', vm_hash['host_name']) redis.hset("vmpooler__vm__#{vm_name}", 'host', vm_hash['host_name'])
migration_count = redis.scard('vmpooler__migration') migration_count = redis.scard('vmpooler__migration')
@ -1140,10 +1105,10 @@ module Vmpooler
target_host_object = find_host_by_dnsname(connection, target_host_name) target_host_object = find_host_by_dnsname(connection, target_host_name)
finish = migrate_vm_and_record_timing(pool_name, vm_name, vm_hash, target_host_object, target_host_name) finish = migrate_vm_and_record_timing(pool_name, vm_name, vm_hash, target_host_object, target_host_name)
@redis.with_metrics do |redis| @redis.with_metrics do |redis|
redis.multi do |transaction| redis.multi
transaction.hset("vmpooler__vm__#{vm_name}", 'host', target_host_name) redis.hset("vmpooler__vm__#{vm_name}", 'host', target_host_name)
transaction.hset("vmpooler__vm__#{vm_name}", 'migrated', 'true') redis.hset("vmpooler__vm__#{vm_name}", 'migrated', true)
end redis.exec
end end
logger.log('s', "[>] [#{pool_name}] '#{vm_name}' migrated from #{vm_hash['host_name']} to #{target_host_name} in #{finish} seconds") logger.log('s', "[>] [#{pool_name}] '#{vm_name}' migrated from #{vm_hash['host_name']} to #{target_host_name} in #{finish} seconds")
ensure ensure
@ -1161,10 +1126,10 @@ module Vmpooler
metrics.increment("migrate_to.#{dest_host_name}") metrics.increment("migrate_to.#{dest_host_name}")
@redis.with_metrics do |redis| @redis.with_metrics do |redis|
checkout_to_migration = format('%<time>.2f', time: Time.now - Time.parse(redis.hget("vmpooler__vm__#{vm_name}", 'checkout'))) checkout_to_migration = format('%<time>.2f', time: Time.now - Time.parse(redis.hget("vmpooler__vm__#{vm_name}", 'checkout')))
redis.multi do |transaction| redis.multi
transaction.hset("vmpooler__vm__#{vm_name}", 'migration_time', finish) redis.hset("vmpooler__vm__#{vm_name}", 'migration_time', finish)
transaction.hset("vmpooler__vm__#{vm_name}", 'checkout_to_migration', checkout_to_migration) redis.hset("vmpooler__vm__#{vm_name}", 'checkout_to_migration', checkout_to_migration)
end redis.exec
end end
finish finish
end end

View file

@ -1,15 +0,0 @@
#!/usr/bin/env bash
# The container tag should closely match what is used in `docker/Dockerfile` in vmpooler-deployment
#
# Update Gemfile.lock
docker run -t --rm \
-v $(pwd):/app \
jruby:9.4.3.0-jdk11 \
/bin/bash -c 'apt-get update -qq && apt-get install -y --no-install-recommends git make netbase && cd /app && gem install bundler && bundle install --jobs 3; echo "LOCK_FILE_UPDATE_EXIT_CODE=$?"'
# Update Changelog
docker run -t --rm -e CHANGELOG_GITHUB_TOKEN -v $(pwd):/usr/local/src/your-app \
githubchangeloggenerator/github-changelog-generator:1.16.2 \
github_changelog_generator --future-release $(grep VERSION lib/vmpooler-provider-vsphere/version.rb |rev |cut -d "'" -f2 |rev)

View file

@ -198,24 +198,13 @@ MockVirtualDiskManager = Object
MockVirtualMachine = Struct.new( MockVirtualMachine = Struct.new(
# https://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.VirtualMachine.html # https://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.VirtualMachine.html
# From VirtualMachine # From VirtualMachine
:config, :runtime, :snapshot, :summary, :guest, :config, :runtime, :snapshot, :summary,
# From ManagedEntity # From ManagedEntity
:name, :name,
# From RbVmomi::VIM::ManagedEntity # From RbVmomi::VIM::ManagedEntity
# https://github.com/vmware/rbvmomi/blob/master/lib/rbvmomi/vim/ManagedEntity.rb # https://github.com/vmware/rbvmomi/blob/master/lib/rbvmomi/vim/ManagedEntity.rb
:path :path
) do )
# From RbVmomi::VIM::VirtualMachine
# https://github.com/ManageIQ/rbvmomi2/blob/59a5904031a0d7558f306e8d2a05001f9b6822de/lib/rbvmomi/vim/VirtualMachine.rb#L20
def guest_ip
g = self.guest
if g.ipAddress
g.ipAddress
else
nil
end
end
end
MockVirtualMachineSnapshot = Struct.new( MockVirtualMachineSnapshot = Struct.new(
# https://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.vm.Snapshot.html # https://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.vm.Snapshot.html
@ -358,12 +347,6 @@ MockVirtualMachineGuestSummary = Struct.new(
:hostName :hostName
) )
MockVirtualMachineGuestInfo = Struct.new(
# https://developer.vmware.com/apis/1311/vsphere
# From Data Object - GuestInfo(vim.vm.GuestInfo)
:ipAddress
)
MockVirtualMachineRuntimeInfo = Struct.new( MockVirtualMachineRuntimeInfo = Struct.new(
# https://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.vm.RuntimeInfo.html # https://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.vm.RuntimeInfo.html
# From VirtualMachineRuntimeInfo # From VirtualMachineRuntimeInfo
@ -818,7 +801,6 @@ end
def mock_RbVmomi_VIM_VirtualMachine(options = {}) def mock_RbVmomi_VIM_VirtualMachine(options = {})
options[:snapshot_tree] = nil if options[:snapshot_tree].nil? options[:snapshot_tree] = nil if options[:snapshot_tree].nil?
options[:name] = 'VM' + rand(65536).to_s if options[:name].nil? options[:name] = 'VM' + rand(65536).to_s if options[:name].nil?
options[:ip] = '192.168.0.2' if options[:ip].nil?
options[:path] = [] if options[:path].nil? options[:path] = [] if options[:path].nil?
mock = MockVirtualMachine.new() mock = MockVirtualMachine.new()
@ -828,13 +810,11 @@ def mock_RbVmomi_VIM_VirtualMachine(options = {})
mock.summary.runtime = MockVirtualMachineRuntimeInfo.new() mock.summary.runtime = MockVirtualMachineRuntimeInfo.new()
mock.summary.guest = MockVirtualMachineGuestSummary.new() mock.summary.guest = MockVirtualMachineGuestSummary.new()
mock.runtime = mock.summary.runtime mock.runtime = mock.summary.runtime
mock.guest = MockVirtualMachineGuestInfo.new()
mock.name = options[:name] mock.name = options[:name]
mock.summary.guest.hostName = options[:hostname] mock.summary.guest.hostName = options[:hostname]
mock.runtime.bootTime = options[:boottime] mock.runtime.bootTime = options[:boottime]
mock.runtime.powerState = options[:powerstate] mock.runtime.powerState = options[:powerstate]
mock.guest.ipAddress = options[:ip]
unless options[:snapshot_tree].nil? unless options[:snapshot_tree].nil?
mock.snapshot = MockVirtualMachineSnapshotInfo.new() mock.snapshot = MockVirtualMachineSnapshotInfo.new()

File diff suppressed because it is too large Load diff

View file

@ -50,11 +50,6 @@ describe 'Vmpooler::PoolManager::Provider::VSphere' do
:config: :config:
max_tries: 3 max_tries: 3
retry_factor: 10 retry_factor: 10
:dns_configs:
:gcp-clouddns:
project: vmpooler-test
domain: vmpooler.example.com
dns_zone_resource_name: vmpooler-example-com
:providers: :providers:
:vsphere: :vsphere:
server: "vcenter.domain.local" server: "vcenter.domain.local"
@ -76,7 +71,6 @@ describe 'Vmpooler::PoolManager::Provider::VSphere' do
ready_ttl: 1440 ready_ttl: 1440
clone_target: 'cluster1' clone_target: 'cluster1'
provider: 'vsphere' provider: 'vsphere'
dns_config: 'gcp-clouddns'
EOT EOT
) )
} }
@ -541,7 +535,7 @@ EOT
end end
end end
context 'when VM exists but is missing hostname, boottime, powerstate' do context 'when VM exists but is missing information' do
let(:vm_object) { mock_RbVmomi_VIM_VirtualMachine({ let(:vm_object) { mock_RbVmomi_VIM_VirtualMachine({
:name => vmname, :name => vmname,
}) })
@ -566,55 +560,10 @@ EOT
end end
end end
context 'when VM exists but is missing ip' do
let(:vm_object) { mock_RbVmomi_VIM_VirtualMachine({
:name => vmname,
:ip => '',
})
}
it 'should return empty for ip' do
result = subject.get_vm(poolname,vmname)
expect(result['ip']).to eq('')
end
end
context 'when VM exists but contains a self assigned ip' do
let(:vm_object) { mock_RbVmomi_VIM_VirtualMachine({
:name => vmname,
:ip => '169.254.255.255',
})
}
it 'should return nil ip' do
allow(subject).to receive(:sleep)
result = subject.get_vm(poolname,vmname)
expect(result['ip']).to eq(nil)
end
end
context 'when VM exists but contains an invalid ip' do
let(:vm_object) { mock_RbVmomi_VIM_VirtualMachine({
:name => vmname,
:ip => '0.0.0.0',
})
}
it 'should return nil for ip' do
allow(subject).to receive(:sleep)
result = subject.get_vm(poolname,vmname)
expect(result['ip']).to eq(nil)
end
end
context 'when VM exists and contains all information' do context 'when VM exists and contains all information' do
let(:vm_hostname) { "#{vmname}.demo.local" } let(:vm_hostname) { "#{vmname}.demo.local" }
let(:boot_time) { Time.now } let(:boot_time) { Time.now }
let(:power_state) { 'MockPowerState' } let(:power_state) { 'MockPowerState' }
let(:ip) { '192.168.0.2' }
let(:vm_object) { mock_RbVmomi_VIM_VirtualMachine({ let(:vm_object) { mock_RbVmomi_VIM_VirtualMachine({
:name => vmname, :name => vmname,
@ -673,11 +622,6 @@ EOT
expect(result['powerstate']).to eq(power_state) expect(result['powerstate']).to eq(power_state)
end end
it 'should return the ip' do
result = subject.get_vm(poolname,vmname)
expect(result['ip']).to eq(ip)
end
end end
end end
@ -1112,17 +1056,14 @@ EOT
end end
describe '#vm_ready?' do describe '#vm_ready?' do
let(:domain) { 'vmpooler.example.com' } let(:domain) { nil }
context 'When a VM is ready' do context 'When a VM is ready' do
before(:each) do before(:each) do
allow(subject).to receive(:domain).and_return('vmpooler.example.com')
expect(subject).to receive(:open_socket).with(vmname, domain) expect(subject).to receive(:open_socket).with(vmname, domain)
end end
it 'should return true' do it 'should return true' do
redis_connection_pool.with do |redis| expect(subject.vm_ready?(poolname,vmname)).to be true
expect(subject.vm_ready?(poolname, vmname, redis)).to be true
end
end end
end end
@ -1134,10 +1075,7 @@ EOT
end end
it 'should return true' do it 'should return true' do
allow(subject).to receive(:domain).and_return('vmpooler.example.com') expect(subject.vm_ready?('missing_pool',vmname)).to be true
redis_connection_pool.with do |redis|
expect(subject.vm_ready?('missing_pool', vmname, redis)).to be true
end
end end
end end
@ -1149,9 +1087,7 @@ EOT
end end
it 'should return false' do it 'should return false' do
redis_connection_pool.with do |redis| expect(subject.vm_ready?(poolname,vmname)).to be false
expect(subject.vm_ready?(poolname, vmname, redis)).to be false
end
end end
end end
end end
@ -1454,7 +1390,7 @@ EOT
let(:TCPSocket) { double('tcpsocket') } let(:TCPSocket) { double('tcpsocket') }
let(:socket) { double('tcpsocket') } let(:socket) { double('tcpsocket') }
let(:hostname) { 'host' } let(:hostname) { 'host' }
let(:domain) { 'vmpooler.example.com' } let(:domain) { 'domain.local'}
let(:default_socket) { 22 } let(:default_socket) { 22 }
before do before do
@ -1463,44 +1399,44 @@ EOT
end end
it 'opens socket with defaults' do it 'opens socket with defaults' do
expect(TCPSocket).to receive(:new).with(hostname,default_socket,{connect_timeout: 5}).and_return(socket) expect(TCPSocket).to receive(:new).with(hostname,default_socket).and_return(socket)
expect(subject.open_socket(hostname)).to eq(nil) expect(subject.open_socket(hostname)).to eq(nil)
end end
it 'yields the socket if a block is given' do it 'yields the socket if a block is given' do
expect(TCPSocket).to receive(:new).with(hostname,default_socket,{connect_timeout: nil}).and_return(socket) expect(TCPSocket).to receive(:new).with(hostname,default_socket).and_return(socket)
expect{ |socket| subject.open_socket(hostname,nil,nil,default_socket,&socket) }.to yield_control.exactly(1).times expect{ |socket| subject.open_socket(hostname,nil,nil,default_socket,&socket) }.to yield_control.exactly(1).times
end end
it 'closes the opened socket' do it 'closes the opened socket' do
expect(TCPSocket).to receive(:new).with(hostname,default_socket,{connect_timeout: 5}).and_return(socket) expect(TCPSocket).to receive(:new).with(hostname,default_socket).and_return(socket)
expect(socket).to receive(:close) expect(socket).to receive(:close)
expect(subject.open_socket(hostname)).to eq(nil) expect(subject.open_socket(hostname)).to eq(nil)
end end
it 'opens a specific socket' do it 'opens a specific socket' do
expect(TCPSocket).to receive(:new).with(hostname,80,{connect_timeout: nil}).and_return(socket) expect(TCPSocket).to receive(:new).with(hostname,80).and_return(socket)
expect(subject.open_socket(hostname,nil,nil,80)).to eq(nil) expect(subject.open_socket(hostname,nil,nil,80)).to eq(nil)
end end
it 'uses a specific domain with the hostname' do it 'uses a specific domain with the hostname' do
expect(TCPSocket).to receive(:new).with("#{hostname}.#{domain}",default_socket,{connect_timeout: 5}).and_return(socket) expect(TCPSocket).to receive(:new).with("#{hostname}.#{domain}",default_socket).and_return(socket)
expect(subject.open_socket(hostname,domain)).to eq(nil) expect(subject.open_socket(hostname,domain)).to eq(nil)
end end
it 'raises error if host is not resolvable' do it 'raises error if host is not resolvable' do
expect(TCPSocket).to receive(:new).with(hostname,default_socket,{connect_timeout: 1}).and_raise(SocketError,'getaddrinfo: No such host is known') expect(TCPSocket).to receive(:new).with(hostname,default_socket).and_raise(SocketError,'getaddrinfo: No such host is known')
expect { subject.open_socket(hostname,nil,1) }.to raise_error(SocketError) expect { subject.open_socket(hostname,nil,1) }.to raise_error(SocketError)
end end
it 'raises error if socket is not listening' do it 'raises error if socket is not listening' do
expect(TCPSocket).to receive(:new).with(hostname,default_socket,{connect_timeout: 1}).and_raise(SocketError,'No connection could be made because the target machine actively refused it') expect(TCPSocket).to receive(:new).with(hostname,default_socket).and_raise(SocketError,'No connection could be made because the target machine actively refused it')
expect { subject.open_socket(hostname,nil,1) }.to raise_error(SocketError) expect { subject.open_socket(hostname,nil,1) }.to raise_error(SocketError)
end end

View file

@ -1,7 +0,0 @@
#!/usr/bin/env bash
# The container tag should closely match what is used in `docker/Dockerfile` in vmpooler-deployment
docker run -it --rm \
-v $(pwd):/app \
jruby:9.4.3.0-jdk11 \
/bin/bash -c 'apt-get update -qq && apt-get install -y --no-install-recommends git make netbase && cd /app && gem install bundler && bundle install --jobs 3 && bundle update; echo "LOCK_FILE_UPDATE_EXIT_CODE=$?"'

View file

@ -15,8 +15,9 @@ Gem::Specification.new do |s|
s.files = Dir[ "lib/**/*" ] s.files = Dir[ "lib/**/*" ]
s.require_paths = ["lib"] s.require_paths = ["lib"]
s.add_dependency 'rbvmomi2', '>= 3.1', '< 4.0' s.add_dependency 'rbvmomi', '>= 2.1', '< 4.0'
s.add_dependency 'vmpooler', '~> 3.0'
s.add_development_dependency 'vmpooler', '~> 2.1' # renaming done in version 2.1
# Testing dependencies # Testing dependencies
s.add_development_dependency 'climate_control', '>= 0.2.0' s.add_development_dependency 'climate_control', '>= 0.2.0'
@ -24,7 +25,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'pry' s.add_development_dependency 'pry'
s.add_development_dependency 'rack-test', '>= 0.6' s.add_development_dependency 'rack-test', '>= 0.6'
s.add_development_dependency 'rspec', '>= 3.2' s.add_development_dependency 'rspec', '>= 3.2'
s.add_development_dependency 'rubocop', '~> 1.28.2' s.add_development_dependency 'rubocop', '~> 1.1.0'
s.add_development_dependency 'simplecov', '>= 0.11.2' s.add_development_dependency 'simplecov', '>= 0.11.2'
s.add_development_dependency 'thor', '~> 1.0', '>= 1.0.1' s.add_development_dependency 'thor', '~> 1.0', '>= 1.0.1'
s.add_development_dependency 'yarjuf', '>= 2.0' s.add_development_dependency 'yarjuf', '>= 2.0'