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.
593
594
595
|
# File 'lib/pve/proxmox.rb', line 593
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
603
604
605
|
# File 'lib/pve/proxmox.rb', line 603
def create host, **options
find( host).create **options
end
|
.find(host) ⇒ Object
598
599
600
601
|
# File 'lib/pve/proxmox.rb', line 598
def find host
ha = HA.send :__new__, digest: nil, state: nil, virt: host
ha.refresh!
end
|
Instance Method Details
#active? ⇒ Boolean
657
|
# File 'lib/pve/proxmox.rb', line 657
def active?() ! ! digest end
|
#create(group: nil, comment: nil, max_relocate: nil, max_restart: nil, state: nil) ⇒ Object
616
617
618
619
620
621
622
623
624
625
626
627
628
|
# File 'lib/pve/proxmox.rb', line 616
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
630
631
632
|
# File 'lib/pve/proxmox.rb', line 630
def delete
rest_del "#{@rest_prefix}"
end
|
#disabled! ⇒ Object
649
650
651
652
|
# File 'lib/pve/proxmox.rb', line 649
def disabled!
self.state = :disabled
self
end
|
#error? ⇒ Boolean
656
|
# File 'lib/pve/proxmox.rb', line 656
def error?() 'error' == self.state end
|
#refresh! ⇒ Object
608
609
610
611
612
613
614
|
# File 'lib/pve/proxmox.rb', line 608
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
589
590
591
|
# File 'lib/pve/proxmox.rb', line 589
def rest_prefix
@rest_prefix ||= "/cluster/ha/resources/#{virt.sid}"
end
|
#started! ⇒ Object
639
640
641
642
|
# File 'lib/pve/proxmox.rb', line 639
def started!
self.state = :started
self
end
|
#started? ⇒ Boolean
654
|
# File 'lib/pve/proxmox.rb', line 654
def started?() 'started' == self.state end
|
#state=(state) ⇒ Object
634
635
636
637
|
# File 'lib/pve/proxmox.rb', line 634
def state= state
rest_put "#{@rest_prefix}", state: state.to_s
refresh!
end
|
#stopped! ⇒ Object
644
645
646
647
|
# File 'lib/pve/proxmox.rb', line 644
def stopped!
self.state = :stopped
self
end
|
#stopped? ⇒ Boolean
655
|
# File 'lib/pve/proxmox.rb', line 655
def stopped?() 'stopped' == self.state end
|