vmpooler 0.8.2 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9ca5e041d051fc1f66b4de635492388443b35ec4
4
- data.tar.gz: 0389293f134e875f3a7f74da8cfcb6f72bd94601
2
+ SHA256:
3
+ metadata.gz: 5ed26a71aa47a1ec841f9ed0cc2e7ad6b0ddbc3c29474829133a3f344acacb1d
4
+ data.tar.gz: b8858d6c730532458d9b6dd9bff125e6aaeca7fa33eb30f2cfbf1d9ffe7b9875
5
5
  SHA512:
6
- metadata.gz: 3cadcac1a60a44662720f498ce83af5506e8c13ab39c9029fa53c030936d22d942529a41873d7ae7489d64487388f195d99f944f831e51cbb172e96c111a0052
7
- data.tar.gz: f1ff4a6f52c8a8981f4ce126add76eee6d1ae863ba078053d48fa537e78ebc249989192abbe728482385de65208e7180a6e77c9c7c6849de35eafaec39fb194d
6
+ metadata.gz: 1f0daff36d86b1bfcc4b6afcf4e1a6303d10bcb92316a0880d57a9ba6697fbaa234d35dae0a1afc2e960f1def86b4f6ec4a66180487f13ffcefc80ba0aec51c3
7
+ data.tar.gz: 518fedee319ca02be46f81f25fc477c2eb488a81d8841997c41ccedceccc57f3043564bc706c7f84b3a5b4028780a5f0dd9140d0d6e8190c3dd1a99f2226f523
@@ -875,7 +875,7 @@ module Vmpooler
875
875
  status 404
876
876
  result = { 'ok' => false }
877
877
 
878
- failure = false
878
+ failure = []
879
879
 
880
880
  params[:hostname] = hostname_shorten(params[:hostname], config['domain'])
881
881
 
@@ -892,24 +892,42 @@ module Vmpooler
892
892
  when 'lifetime'
893
893
  need_token! if Vmpooler::API.settings.config[:auth]
894
894
 
895
+ # in hours, defaults to one week
896
+ max_lifetime_upper_limit = config['max_lifetime_upper_limit']
897
+ if max_lifetime_upper_limit
898
+ max_lifetime_upper_limit = max_lifetime_upper_limit.to_i
899
+ if arg.to_i >= max_lifetime_upper_limit
900
+ failure.push("You provided a lifetime (#{arg}) that exceeds the configured maximum of #{max_lifetime_upper_limit}.")
901
+ else
902
+ # also make sure we do not extend past max_lifetime_upper_limit
903
+ rdata = backend.hgetall('vmpooler__vm__' + params[:hostname])
904
+ running = ((Time.now - Time.parse(rdata['checkout'])) / 60 / 60).round(2)
905
+ unless running + arg.to_i < max_lifetime_upper_limit
906
+ failure.push("You provided a lifetime (#{arg}) that will extend the current lifetime past the configured maximum of #{max_lifetime_upper_limit}.")
907
+ end
908
+ end
909
+ end
910
+
911
+ # validate lifetime is within boundaries
895
912
  unless arg.to_i > 0
896
- failure = true
913
+ failure.push("You provided a lifetime (#{arg}) but you must provide a positive number.")
897
914
  end
898
915
  when 'tags'
899
916
  unless arg.is_a?(Hash)
900
- failure = true
917
+ failure.push("You provided tags (#{arg}) as something other than a hash.")
901
918
  end
902
919
 
903
920
  if config['allowed_tags']
904
- failure = true if not (arg.keys - config['allowed_tags']).empty?
921
+ failure.push("You provided unsuppored tags (#{arg}).") if not (arg.keys - config['allowed_tags']).empty?
905
922
  end
906
923
  else
907
- failure = true
924
+ failure.push("Unknown argument #{arg}.")
908
925
  end
909
926
  end
910
927
 
911
- if failure
928
+ if failure.size > 0
912
929
  status 400
930
+ result['failure'] = failure
913
931
  else
914
932
  jdata.each do |param, arg|
915
933
  case param
@@ -104,6 +104,7 @@ module Vmpooler
104
104
  if time_since_clone > timeout
105
105
  if exists
106
106
  $redis.smove('vmpooler__pending__' + pool, 'vmpooler__completed__' + pool, vm)
107
+ $metrics.increment("errors.markedasfailed.#{pool}")
107
108
  $logger.log('d', "[!] [#{pool}] '#{vm}' marked as 'failed' after #{timeout} minutes")
108
109
  else
109
110
  remove_nonexistent_vm(vm, pool)
@@ -839,7 +839,20 @@ module Vmpooler
839
839
  def find_cluster(cluster, connection, datacentername)
840
840
  datacenter = connection.serviceInstance.find_datacenter(datacentername)
841
841
  raise("Datacenter #{datacentername} does not exist") if datacenter.nil?
842
- datacenter.hostFolder.children.find { |cluster_object| cluster_object.name == cluster }
842
+
843
+ # In the event the cluster is not a direct descendent of the
844
+ # datacenter, we use a ContainerView to leverage its recursive
845
+ # search. This will find clusters which are, for example, in
846
+ # folders under the datacenter. This will also find standalone
847
+ # hosts which are not part of a cluster.
848
+ cv = connection.serviceContent.viewManager.CreateContainerView(
849
+ container: datacenter.hostFolder,
850
+ type: ['ComputeResource', 'ClusterComputeResource'],
851
+ recursive: true,
852
+ )
853
+ cluster = cv.view.find { |cluster_object| cluster_object.name == cluster }
854
+ cv.DestroyView
855
+ cluster
843
856
  end
844
857
 
845
858
  def get_cluster_host_utilization(cluster, model = nil)
@@ -1,3 +1,3 @@
1
1
  module Vmpooler
2
- VERSION = '0.8.2'.freeze
2
+ VERSION = '0.9.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vmpooler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-06 00:00:00.000000000 Z
11
+ date: 2019-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pickup
@@ -237,8 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
237
237
  - !ruby/object:Gem::Version
238
238
  version: '0'
239
239
  requirements: []
240
- rubyforge_project:
241
- rubygems_version: 2.5.1
240
+ rubygems_version: 3.0.6
242
241
  signing_key:
243
242
  specification_version: 4
244
243
  summary: vmpooler provides configurable pools of instantly-available (running) virtual