Class: Fog::Proxmox::Identity::Pool

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/proxmox/identity/models/pool.rb

Overview

class Pool model of VMs

Instance Method Summary collapse

Instance Method Details

#add_server(server) ⇒ Object



40
41
42
# File 'lib/fog/proxmox/identity/models/pool.rb', line 40

def add_server(server)
  update_with_member('vms', server, false)
end

#add_storage(storage) ⇒ Object



44
45
46
# File 'lib/fog/proxmox/identity/models/pool.rb', line 44

def add_storage(storage)
  update_with_member('storage', storage, false)
end

#destroyObject



34
35
36
37
38
# File 'lib/fog/proxmox/identity/models/pool.rb', line 34

def destroy
  requires :poolid
  service.delete_pool(poolid)
  true
end

#has_server?(vmid) ⇒ Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/fog/proxmox/identity/models/pool.rb', line 69

def has_server?(vmid)
  has?('vmid', vmid)
end

#has_storage?(storage) ⇒ Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/fog/proxmox/identity/models/pool.rb', line 73

def has_storage?(storage)
  has?('storage', storage)
end

#remove_server(server) ⇒ Object



52
53
54
# File 'lib/fog/proxmox/identity/models/pool.rb', line 52

def remove_server(server)
  update_with_member('vms', server, true)
end

#remove_storage(storage) ⇒ Object



48
49
50
# File 'lib/fog/proxmox/identity/models/pool.rb', line 48

def remove_storage(storage)
  update_with_member('storage', storage, true)
end

#save(options = {}) ⇒ Object



29
30
31
32
# File 'lib/fog/proxmox/identity/models/pool.rb', line 29

def save(options = {})
  service.create_pool(attributes.merge(options))
  reload
end

#updateObject



65
66
67
# File 'lib/fog/proxmox/identity/models/pool.rb', line 65

def update
  update_with_member(nil, nil, false)
end

#update_with_member(member_name, member_id, delete = false) ⇒ Object



56
57
58
59
60
61
62
63
# File 'lib/fog/proxmox/identity/models/pool.rb', line 56

def update_with_member(member_name, member_id, delete = false)
  requires :poolid
  otpions = attributes.reject { |attribute| %i[poolid members].include? attribute }
  otpions.store(member_name, member_id) if member_name
  otpions.store('delete', 1) if delete
  service.update_pool(poolid, otpions)
  reload
end