Class: Proxmox::HA
Instance Attribute Summary
Attributes inherited from Base
#sid
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
__new__, fetch, #method_missing, #respond_to?
#bench, #rest_del, #rest_get, #rest_post, #rest_put
Constructor Details
#initialize ⇒ HA
Returns a new instance of HA.
589
590
591
|
# File 'lib/pve/proxmox.rb', line 589
def initialize
rest_prefix
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Proxmox::Base
Class Method Details
.create(host, **options) ⇒ Object
599
600
601
|
# File 'lib/pve/proxmox.rb', line 599
def create host, **options
find( host).create **options
end
|
.find(host) ⇒ Object
594
595
596
597
|
# File 'lib/pve/proxmox.rb', line 594
def find host
ha = HA.send :__new__, digest: nil, state: nil, virt: host
ha.refresh!
end
|
Instance Method Details
#active? ⇒ Boolean
653
|
# File 'lib/pve/proxmox.rb', line 653
def active?() ! ! digest end
|
#create(group: nil, comment: nil, max_relocate: nil, max_restart: nil, state: nil) ⇒ Object
612
613
614
615
616
617
618
619
620
621
622
623
624
|
# File 'lib/pve/proxmox.rb', line 612
def create group: nil, comment: nil, max_relocate: nil, max_restart: nil, state: nil
options = {
sid: virt.sid,
group: group,
comment: ,
max_relocate: max_relocate,
max_restart: max_restart,
state: state
}
options.delete_if {|k,v| v.nil? }
rest_post "/cluster/ha/resources", **options
refresh!
end
|
#delete ⇒ Object
626
627
628
|
# File 'lib/pve/proxmox.rb', line 626
def delete
rest_del "#{@rest_prefix}"
end
|
#disabled! ⇒ Object
645
646
647
648
|
# File 'lib/pve/proxmox.rb', line 645
def disabled!
self.state = :disabled
self
end
|
#error? ⇒ Boolean
652
|
# File 'lib/pve/proxmox.rb', line 652
def error?() 'error' == self.state end
|
#refresh! ⇒ Object
604
605
606
607
608
609
610
|
# File 'lib/pve/proxmox.rb', line 604
def refresh!
virt = @virt
__update__( {state: nil}.merge( rest_get( "/cluster/ha/resources/#{virt.sid}")).merge( virt: virt))
self
rescue RestClient::InternalServerError
__update__ digest: nil, state: nil, virt: virt
end
|
#rest_prefix ⇒ Object
585
586
587
|
# File 'lib/pve/proxmox.rb', line 585
def rest_prefix
@rest_prefix ||= "/cluster/ha/resources/#{virt.sid}"
end
|
#started! ⇒ Object
635
636
637
638
|
# File 'lib/pve/proxmox.rb', line 635
def started!
self.state = :started
self
end
|
#started? ⇒ Boolean
650
|
# File 'lib/pve/proxmox.rb', line 650
def started?() 'started' == self.state end
|
#state=(state) ⇒ Object
630
631
632
633
|
# File 'lib/pve/proxmox.rb', line 630
def state= state
rest_put "#{@rest_prefix}", state: state.to_s
refresh!
end
|
#stopped! ⇒ Object
640
641
642
643
|
# File 'lib/pve/proxmox.rb', line 640
def stopped!
self.state = :stopped
self
end
|
#stopped? ⇒ Boolean
651
|
# File 'lib/pve/proxmox.rb', line 651
def stopped?() 'stopped' == self.state end
|