Class: OvirtSDK4::AffinityLabelsService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::AffinityLabelsService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (AffinityLabel) add(label, opts = {})
Creates a new label.
-
- (AffinityLabelService) label_service(id)
Link to a single label details.
-
- (Array<AffinityLabel>) list(opts = {})
Lists all labels present in the system.
-
- (Service) service(path)
Locates the service corresponding to the given path.
-
- (String) to_s
Returns an string representation of this service.
Instance Method Details
- (AffinityLabel) add(label, opts = {})
Creates a new label. The label is automatically attached to all entities mentioned in the vms or hosts lists.
1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 |
# File 'lib/ovirtsdk4/services.rb', line 1712 def add(label, opts = {}) if label.is_a?(Hash) label = OvirtSDK4::AffinityLabel.new(label) end request = Request.new(:method => :POST, :path => @path) begin writer = XmlWriter.new(nil, true) AffinityLabelWriter.write_one(label, writer, 'label') request.body = writer.string ensure writer.close end response = @connection.send(request) case response.code when 201, 202 begin reader = XmlReader.new(response.body) return AffinityLabelReader.read_one(reader) ensure reader.close end else check_fault(response) end end |
- (AffinityLabelService) label_service(id)
Link to a single label details.
1776 1777 1778 |
# File 'lib/ovirtsdk4/services.rb', line 1776 def label_service(id) return AffinityLabelService.new(@connection, "#{@path}/#{id}") end |
- (Array<AffinityLabel>) list(opts = {})
Lists all labels present in the system.
1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 |
# File 'lib/ovirtsdk4/services.rb', line 1747 def list(opts = {}) query = {} value = opts[:max] unless value.nil? value = Writer.render_integer(value) query['max'] = value end request = Request.new(:method => :GET, :path => @path, :query => query) response = @connection.send(request) case response.code when 200 begin reader = XmlReader.new(response.body) return AffinityLabelReader.read_many(reader) ensure reader.close end else check_fault(response) end end |
- (Service) service(path)
Locates the service corresponding to the given path.
1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 |
# File 'lib/ovirtsdk4/services.rb', line 1787 def service(path) if path.nil? || path == '' return self end index = path.index('/') if index.nil? return label_service(path) end return label_service(path[0..(index - 1)]).service(path[(index +1)..-1]) end |
- (String) to_s
Returns an string representation of this service.
1803 1804 1805 |
# File 'lib/ovirtsdk4/services.rb', line 1803 def to_s return "#<#{AffinityLabelsService}:#{@path}>" end |