From a3a6cf05333a1e856bef01052e639b709961e802 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 7 Apr 2022 14:04:15 +0000 Subject: [PATCH 1/6] Bump puma from 5.5.2 to 5.6.4 Bumps [puma](https://github.com/puma/puma) from 5.5.2 to 5.6.4. - [Release notes](https://github.com/puma/puma/releases) - [Changelog](https://github.com/puma/puma/blob/master/History.md) - [Commits](https://github.com/puma/puma/compare/v5.5.2...v5.6.4) --- updated-dependencies: - dependency-name: puma dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 219973d..335c0ba 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -70,9 +70,12 @@ GEM mustermann (1.1.1) ruby2_keywords (~> 0.0.1) net-ldap (0.17.0) + nio4r (2.5.8) nio4r (2.5.8-java) nokogiri (1.12.5-java) racc (~> 1.4) + nokogiri (1.12.5-x86_64-linux) + racc (~> 1.4) opentelemetry-api (1.0.1) opentelemetry-common (0.19.3) opentelemetry-api (~> 1.0) @@ -113,12 +116,18 @@ GEM ast (~> 2.4.1) pickup (0.0.11) prometheus-client (2.1.0) + pry (0.14.1) + coderay (~> 1.1) + method_source (~> 1.0) pry (0.14.1-java) coderay (~> 1.1) method_source (~> 1.0) spoon (~> 0.0) - puma (5.6.2-java) + puma (5.6.4) nio4r (~> 2.0) + puma (5.6.4-java) + nio4r (~> 2.0) + racc (1.6.0) racc (1.6.0-java) rack (2.2.3) rack-protection (2.2.0) @@ -182,6 +191,7 @@ GEM PLATFORMS universal-java-1.8 + x86_64-linux DEPENDENCIES climate_control (>= 0.2.0) From 6aa10151ca0debe68442cdf8adc74462d3c353ec Mon Sep 17 00:00:00 2001 From: Samuel Beaulieu Date: Wed, 29 Jun 2022 13:57:48 -0500 Subject: [PATCH 2/6] (DIO-3138) vmpooler v2 api missing vm/hostname there was one API that was falling back on v1 and was returning a domain key. in order to make it consistent with the changes in v2, the domain is not returned anymore, and the fqdn is returned if it is available --- lib/vmpooler/api/helpers.rb | 9 +---- lib/vmpooler/api/v1.rb | 2 +- lib/vmpooler/api/v2.rb | 76 +++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 8 deletions(-) diff --git a/lib/vmpooler/api/helpers.rb b/lib/vmpooler/api/helpers.rb index 6d1a347..cb983cb 100644 --- a/lib/vmpooler/api/helpers.rb +++ b/lib/vmpooler/api/helpers.rb @@ -181,14 +181,9 @@ module Vmpooler /^\d{4}-\d{2}-\d{2}$/ === date_str end + # note: domain is not needed here, so we should update the callers of this method def hostname_shorten(hostname, domain=nil) - if domain && hostname =~ /^[\w-]+\.#{domain}$/ - hostname = hostname[/[^.]+/] - elsif hostname =~ /^[\w-]+\..+$/ - hostname = hostname[/[^.]+/] - end - - hostname + hostname[/[^.]+/] end def get_task_times(backend, task, date_str) diff --git a/lib/vmpooler/api/v1.rb b/lib/vmpooler/api/v1.rb index e333afd..c6e7d9b 100644 --- a/lib/vmpooler/api/v1.rb +++ b/lib/vmpooler/api/v1.rb @@ -1519,7 +1519,7 @@ module Vmpooler post "#{api_prefix}/vm/:hostname/snapshot/:snapshot/?" do content_type :json - metrics.increment('http_requests_vm_total.post.vm.disksize') + metrics.increment('http_requests_vm_total.post.vm.snapshot') need_token! if Vmpooler::API.settings.config[:auth] diff --git a/lib/vmpooler/api/v2.rb b/lib/vmpooler/api/v2.rb index b39722d..44dad6e 100644 --- a/lib/vmpooler/api/v2.rb +++ b/lib/vmpooler/api/v2.rb @@ -258,6 +258,82 @@ module Vmpooler JSON.pretty_generate(result) end + get "#{api_prefix}/vm/:hostname/?" do + content_type :json + metrics.increment('http_requests_vm_total.get.vm.hostname') + + result = {} + + status 404 + result['ok'] = false + + params[:hostname] = hostname_shorten(params[:hostname], nil) + + rdata = backend.hgetall("vmpooler__vm__#{params[:hostname]}") + unless rdata.empty? + status 200 + result['ok'] = true + + result[params[:hostname]] = {} + + result[params[:hostname]]['template'] = rdata['template'] + result[params[:hostname]]['lifetime'] = (rdata['lifetime'] || config['vm_lifetime']).to_i + + if rdata['destroy'] + result[params[:hostname]]['running'] = ((Time.parse(rdata['destroy']) - Time.parse(rdata['checkout'])) / 60 / 60).round(2) if rdata['checkout'] + result[params[:hostname]]['state'] = 'destroyed' + elsif rdata['checkout'] + result[params[:hostname]]['running'] = ((Time.now - Time.parse(rdata['checkout'])) / 60 / 60).round(2) + result[params[:hostname]]['remaining'] = ((Time.parse(rdata['checkout']) + rdata['lifetime'].to_i*60*60 - Time.now) / 60 / 60).round(2) + result[params[:hostname]]['start_time'] = Time.parse(rdata['checkout']).to_datetime.rfc3339 + result[params[:hostname]]['end_time'] = (Time.parse(rdata['checkout']) + rdata['lifetime'].to_i*60*60).to_datetime.rfc3339 + result[params[:hostname]]['state'] = 'running' + elsif rdata['check'] + result[params[:hostname]]['state'] = 'ready' + else + result[params[:hostname]]['state'] = 'pending' + end + + rdata.keys.each do |key| + if key.match('^tag\:(.+?)$') + result[params[:hostname]]['tags'] ||= {} + result[params[:hostname]]['tags'][$1] = rdata[key] + end + + if key.match('^snapshot\:(.+?)$') + result[params[:hostname]]['snapshots'] ||= [] + result[params[:hostname]]['snapshots'].push($1) + end + end + + if rdata['disk'] + result[params[:hostname]]['disk'] = rdata['disk'].split(':') + end + + # Look up IP address of the hostname + begin + ipAddress = TCPSocket.gethostbyname(params[:hostname])[3] + rescue StandardError + ipAddress = "" + end + + result[params[:hostname]]['ip'] = ipAddress + + if rdata['pool'] + vmdomain = Parsing.get_domain_for_pool(full_config, rdata['pool']) + if vmdomain + result[params[:hostname]]['fqdn'] = "#{params[:hostname]}.#{vmdomain}" + end + end + + result[params[:hostname]]['host'] = rdata['host'] if rdata['host'] + result[params[:hostname]]['migrated'] = rdata['migrated'] if rdata['migrated'] + + end + + JSON.pretty_generate(result) + end + post "#{api_prefix}/ondemandvm/?" do content_type :json metrics.increment('http_requests_vm_total.post.ondemand.requestid') From f5866d51b647c097d54bb22e55690341f24c3824 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Apr 2022 13:02:32 +0000 Subject: [PATCH 3/6] Update rubocop requirement from ~> 1.1.0 to ~> 1.28.2 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.1.0...v1.28.2) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 20 ++++++++++---------- vmpooler.gemspec | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 335c0ba..f138766 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -112,7 +112,7 @@ GEM opentelemetry-semantic_conventions (1.8.0) opentelemetry-api (~> 1.0) parallel (1.22.1) - parser (3.1.1.0) + parser (3.1.2.0) ast (~> 2.4.1) pickup (0.0.11) prometheus-client (2.1.0) @@ -137,7 +137,7 @@ GEM rainbow (3.1.1) rake (13.0.6) redis (4.6.0) - regexp_parser (2.2.1) + regexp_parser (2.3.1) rexml (3.2.5) rspec (3.11.0) rspec-core (~> 3.11.0) @@ -152,16 +152,16 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-support (3.11.0) - rubocop (1.1.0) + rubocop (1.28.2) parallel (~> 1.10) - parser (>= 2.7.1.5) + parser (>= 3.1.0.0) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8) + regexp_parser (>= 1.8, < 3.0) rexml - rubocop-ast (>= 1.0.1) + rubocop-ast (>= 1.17.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 2.0) - rubocop-ast (1.16.0) + unicode-display_width (>= 1.4.0, < 3.0) + rubocop-ast (1.17.0) parser (>= 3.1.1.0) ruby-progressbar (1.11.0) ruby2_keywords (0.0.5) @@ -184,7 +184,7 @@ GEM thor (1.2.1) thrift (0.16.0) tilt (2.0.10) - unicode-display_width (1.8.0) + unicode-display_width (2.1.0) yarjuf (2.0.0) builder rspec (~> 3) @@ -199,7 +199,7 @@ DEPENDENCIES pry rack-test (>= 0.6) rspec (>= 3.2) - rubocop (~> 1.1.0) + rubocop (~> 1.28.2) simplecov (>= 0.11.2) thor (~> 1.0, >= 1.0.1) vmpooler! diff --git a/vmpooler.gemspec b/vmpooler.gemspec index 49e2375..cee2a74 100644 --- a/vmpooler.gemspec +++ b/vmpooler.gemspec @@ -45,7 +45,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'pry' s.add_development_dependency 'rack-test', '>= 0.6' s.add_development_dependency 'rspec', '>= 3.2' - s.add_development_dependency 'rubocop', '~> 1.1.0' + s.add_development_dependency 'rubocop', '~> 1.28.2' s.add_development_dependency 'simplecov', '>= 0.11.2' s.add_development_dependency 'thor', '~> 1.0', '>= 1.0.1' s.add_development_dependency 'yarjuf', '>= 2.0' From c846e41780974c1f3f414386f33810814b2fec32 Mon Sep 17 00:00:00 2001 From: Samuel Beaulieu Date: Mon, 25 Jul 2022 08:59:12 -0500 Subject: [PATCH 4/6] fix rubocoop offences --- .rubocop.yml | 1 + lib/vmpooler/pool_manager.rb | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 2d50ca0..0fe1eff 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -66,6 +66,7 @@ Style/Next: Enabled: false Metrics/ParameterLists: Max: 10 + MaxOptionalParameters: 10 Style/GuardClause: Enabled: false diff --git a/lib/vmpooler/pool_manager.rb b/lib/vmpooler/pool_manager.rb index 9ed2982..95922d5 100644 --- a/lib/vmpooler/pool_manager.rb +++ b/lib/vmpooler/pool_manager.rb @@ -1596,19 +1596,19 @@ module Vmpooler $config[:pools].each do |pool| provider_name = pool['provider'] # The provider_class parameter can be defined in the provider's data eg - #:providers: - # :vsphere: - # provider_class: 'vsphere' - # :another-vsphere: - # provider_class: 'vsphere' + # :providers: + # :vsphere: + # provider_class: 'vsphere' + # :another-vsphere: + # provider_class: 'vsphere' # the above would create two providers/vsphere.rb class objects named 'vsphere' and 'another-vsphere' # each pools would then define which provider definition to use: vsphere or another-vsphere # # if provider_class is not defined it will try to use the provider_name as the class, this is to be # backwards compatible for example when there is only one provider listed # :providers: - # :dummy: - # filename: 'db.txs' + # :dummy: + # filename: 'db.txs' # the above example would create an object based on the class providers/dummy.rb if $config[:providers].nil? || $config[:providers][provider_name.to_sym].nil? || $config[:providers][provider_name.to_sym]['provider_class'].nil? provider_class = provider_name From 7f1f8def8e05b1561ccbffa8e2206790e588f337 Mon Sep 17 00:00:00 2001 From: Samuel Beaulieu Date: Mon, 25 Jul 2022 09:12:12 -0500 Subject: [PATCH 5/6] fix comment offence --- lib/vmpooler/api/helpers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vmpooler/api/helpers.rb b/lib/vmpooler/api/helpers.rb index cb983cb..136b5f1 100644 --- a/lib/vmpooler/api/helpers.rb +++ b/lib/vmpooler/api/helpers.rb @@ -181,7 +181,7 @@ module Vmpooler /^\d{4}-\d{2}-\d{2}$/ === date_str end - # note: domain is not needed here, so we should update the callers of this method + # NOTE: domain is not needed here, so we should update the callers of this method def hostname_shorten(hostname, domain=nil) hostname[/[^.]+/] end From febca3a9b79c3e5b96ffce80cd4e001b2715d4cf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Apr 2022 13:08:05 +0000 Subject: [PATCH 6/6] Bump mock_redis from 0.30.0 to 0.31.0 Bumps [mock_redis](https://github.com/sds/mock_redis) from 0.30.0 to 0.31.0. - [Release notes](https://github.com/sds/mock_redis/releases) - [Changelog](https://github.com/sds/mock_redis/blob/main/CHANGELOG.md) - [Commits](https://github.com/sds/mock_redis/compare/v0.30.0...v0.31.0) --- updated-dependencies: - dependency-name: mock_redis dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index f138766..fae20e0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -64,7 +64,7 @@ GEM google-cloud-env (1.6.0) faraday (>= 0.17.3, < 3.0) method_source (1.0.0) - mock_redis (0.30.0) + mock_redis (0.31.0) ruby2_keywords multipart-post (2.1.1) mustermann (1.1.1)