class OpenNebula::Zone
Constants
- SHORT_ZONE_STATES
- ZONE_METHODS
-
Constants and Class Methods
- ZONE_STATES
Public Class Methods
Source
# File lib/opennebula/zone.rb, line 52 def Zone.build_xml(pe_id=nil) if pe_id zone_xml = "<ZONE><ID>#{pe_id}</ID></ZONE>" else zone_xml = "<ZONE></ZONE>" end XMLElement.build_xml(zone_xml,'ZONE') end
Creates a Zone
description with just its identifier this method should be used to create plain Zone
objects. @param id [Integer] the id of the Zone
Example:
zone = Zone.new(Zone.build_xml(3),rpc_client)
Source
# File lib/opennebula/zone.rb, line 63 def initialize(xml, client) super(xml,client) end
Class constructor
OpenNebula::PoolElement::new
Public Instance Methods
Source
# File lib/opennebula/zone.rb, line 166 def add_servers(servers) return call(ZONE_METHODS[:addserver], @pe_id, servers) end
Adds servers to this Zone
@param name [String] Template
with zone servers
SERVER = [ NAME = "<server_name>", ENDPOINT = "<rpc_ep>" ]
@return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
Source
# File lib/opennebula/zone.rb, line 126 def allocate(description) super(ZONE_METHODS[:allocate], description) end
Allocates a new Zone
in OpenNebula
@param description [String] The template of the Zone
. @return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
OpenNebula::PoolElement#allocate
Source
# File lib/opennebula/zone.rb, line 145 def delete() super(ZONE_METHODS[:delete]) end
Deletes the Zone
@return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
OpenNebula::PoolElement#delete
Source
# File lib/opennebula/zone.rb, line 176 def delete_servers(server_id) return call(ZONE_METHODS[:delserver], @pe_id, server_id) end
Delete servers from this Zone
@param id [Int] Server ID
@return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
Source
# File lib/opennebula/zone.rb, line 203 def disable() return call(ZONE_METHODS[:enable], @pe_id, false) end
Disable zone, only readonly commands can be executed in disabled state
@return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
Source
# File lib/opennebula/zone.rb, line 194 def enable() return call(ZONE_METHODS[:enable], @pe_id, true) end
Enable zone
@return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
Source
# File lib/opennebula/zone.rb, line 74 def info() super(ZONE_METHODS[:info], 'ZONE') end
Retrieves the information of the given Zone
. @return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
OpenNebula::PoolElement#info
Source
# File lib/opennebula/zone.rb, line 81 def info_extended() rc = info() return rc if OpenNebula.is_error?(rc) @xml.xpath("SERVER_POOL/SERVER").each do |server| endpoint = server.xpath("ENDPOINT") endpoint = endpoint.text if endpoint next if endpoint.nil? client = OpenNebula::Client.new(nil, endpoint, {:timeout => 5}) xml = client.call("zone.raftstatus") if OpenNebula.is_error?(xml) add_element(server, "STATE", "-") add_element(server, "TERM", "-") add_element(server, "VOTEDFOR", "-") add_element(server, "COMMIT", "-") add_element(server, "LOG_INDEX", "-") add_element(server, "FEDLOG_INDEX", "-") next end xml = Nokogiri::XML(xml) add_element_xml(server, xml, "STATE", "RAFT/STATE") add_element_xml(server, xml, "TERM", "RAFT/TERM") add_element_xml(server, xml, "VOTEDFOR", "RAFT/VOTEDFOR") add_element_xml(server, xml, "COMMIT", "RAFT/COMMIT") add_element_xml(server, xml, "LOG_INDEX", "RAFT/LOG_INDEX") add_element_xml(server, xml, "FEDLOG_INDEX","RAFT/FEDLOG_INDEX") end end
Retrieves the information extended of the given Zone
. @return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
Source
# File lib/opennebula/zone.rb, line 155 def rename(name) return call(ZONE_METHODS[:rename], @pe_id, name) end
Renames this Zone
@param name [String] New name for the Zone
.
@return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
Source
# File lib/opennebula/zone.rb, line 186 def reset_server(server_id) return call(ZONE_METHODS[:resetserver], @pe_id, server_id) end
Reset index for a follower
@param id [Int] Server ID
@return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
Source
# File lib/opennebula/zone.rb, line 212 def state self['STATE'].to_i end
Returns the state of the Zone
(numeric value)
Source
# File lib/opennebula/zone.rb, line 217 def state_str ZONE_STATES[state] end
Returns the state of the Zone
(string value)
Source
# File lib/opennebula/zone.rb, line 138 def update(new_template=nil, append=false) super(ZONE_METHODS[:update], new_template, append ? 1 : 0) end
Replaces the template contents
@param new_template [String] New template contents @param append [true, false] True to append new attributes instead of
replace the whole template
@return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
OpenNebula::PoolElement#update
Private Instance Methods
Source
# File lib/opennebula/zone.rb, line 224 def add_element(parent, key, value) elem = Nokogiri::XML::Node.new(key, @xml.document) elem.content = value parent.add_child(elem) end
These methods adds elements to the given node of the zone
Source
# File lib/opennebula/zone.rb, line 231 def add_element_xml(parent, doc, key, xpath) value = doc.at_xpath(xpath) if value value = value.text else value = "-" end elem = Nokogiri::XML::Node.new(key, @xml.document) elem.content = value parent.add_child(elem) end