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

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

Overview

class Pool model of VMs

Instance Method Summary collapse

Methods inherited from Proxmox::Model

#initialize, #inspect

Constructor Details

This class inherits a constructor from Fog::Proxmox::Model

Instance Method Details

#add_server(server) ⇒ Object


54
55
56
# File 'lib/fog/identity/proxmox/models/pool.rb', line 54

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

#add_storage(storage) ⇒ Object


58
59
60
# File 'lib/fog/identity/proxmox/models/pool.rb', line 58

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

#create(new_attributes = {}) ⇒ Object


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

def create(new_attributes = {})
  service.create_pool(attributes.merge(new_attributes))
end

#destroyObject


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

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

#remove_server(server) ⇒ Object


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

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

#remove_storage(storage) ⇒ Object


62
63
64
# File 'lib/fog/identity/proxmox/models/pool.rb', line 62

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

#to_sObject


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

def to_s
  poolid
end

#updateObject


78
79
80
# File 'lib/fog/identity/proxmox/models/pool.rb', line 78

def update
  update_with_member(nil, nil, false)
end

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


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

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