rake-proxmox 0.2.1 → 0.3.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
2
  SHA1:
3
- metadata.gz: ddc54a7d1025c0d1d4ef3485b11d91460127e0d5
4
- data.tar.gz: b9e745a90f770bc202950f1cd5a88d1b44ace6c9
3
+ metadata.gz: 80a3a7211e9b18aef9d3400e0fdb054dbda38ea0
4
+ data.tar.gz: 11d14ecd46d0b780b773720cd424436738420bf3
5
5
  SHA512:
6
- metadata.gz: 8924c943442197af05ab08d4fd5b634e8c4af9a0af9265dbc683332ebed796d120dbf90cee706216e6667c330d181b0790d325c57dd78c772c2e52d15b9d2a76
7
- data.tar.gz: a017e780493c48b3fd852b4bf1cade426446e175333bde786f9cf6c2bec270ae0a5dc2dddb1062c7ca9ee417364a3eb4e03b8bfa0fe4e94606542ce64fffe1ee
6
+ metadata.gz: a4de0c41c9c6fc8a24100d48e077d7ba810080a755034f6eefe8bb1bfd09609f77372ca772357025cbcf26f8a0f032651a20a6f4c40fd9f3aae418bdd6c73afd
7
+ data.tar.gz: 84a61870ba2c749957b44a7b2907ecc64660b165720fc72921ee702e0163a703d89e87b67786a7091aec1b32dc2a8dda93b6c20d985f0872545d46e98388c560
@@ -427,6 +427,11 @@ module Rake
427
427
  http_action_get("cluster/resources?type=#{type}")
428
428
  end
429
429
 
430
+ # get cluster status
431
+ def cluster_status
432
+ http_action_get('cluster/status')
433
+ end
434
+
430
435
  # Backup VM
431
436
  def vzdump_single(vmid, node = @node, storage = 'local',
432
437
  mode = 'snapshot', compress = 1, remove = 1, pigz = 1,
@@ -1,5 +1,5 @@
1
1
  module Rake
2
2
  module Proxmox
3
- VERSION = "0.2.1"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
data/lib/rake/proxmox.rb CHANGED
@@ -6,10 +6,8 @@ module Rake
6
6
  module Proxmox
7
7
  # This class provides rake tasks to control proxmox cluster through api.
8
8
  #
9
- # rubocop:disable Metrics/ClassLength
10
9
  class RakeTasks < ::Rake::TaskLib
11
10
  # @yield [self] gives itself to the block
12
- # rubocop:disable Metrics/AbcSize
13
11
  def initialize(ssl_options = {})
14
12
  unless ENV.include?('PROXMOX_PVE_CLUSTER')
15
13
  puts ''
@@ -186,6 +184,30 @@ module Rake
186
184
  desc 'Proxmox'
187
185
  update_lxc_status
188
186
  namespace 'proxmox' do
187
+ desc 'get proxmox cluster status'
188
+ task 'cluster:status' do
189
+ status = { nodes: 0, cluster_name: nil }
190
+ proxmox.cluster_status.each do |entry|
191
+ case entry['type']
192
+ when 'cluster'
193
+ unless entry['quorate'] == 1
194
+ raise "Proxmox Cluster #{entry} is not quorate"
195
+ end
196
+ status[:cluster_name] = entry['name']
197
+ when 'node'
198
+ if entry['level'].nil?
199
+ node_name = entry.sort.map { |k, v| "#{k}=#{v}" }.join(',')
200
+ raise "Proxmox Node #{node_name} has errors"
201
+ end
202
+ status[:nodes] += 1
203
+ else
204
+ raise "unknown entry: #{entry}"
205
+ end
206
+ end
207
+ puts "Proxmox Cluster #{status[:cluster_name]} online with"\
208
+ " #{status[:nodes]} nodes"
209
+ end
210
+
189
211
  desc 'upload template to proxmox storage'
190
212
  task 'storage:upload:template', %i[filename
191
213
  node
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake-proxmox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Lehn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-08 00:00:00.000000000 Z
11
+ date: 2018-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler