Class: OvirtSDK4::AffinityGroupService

Inherits:
Service
  • Object
show all
Defined in:
lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb

Instance Method Summary (collapse)

Instance Method Details

- (AffinityGroup) get(opts = {})

Returns the representation of the object managed by this service.

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Returns:



751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
# File 'lib/ovirtsdk4/services.rb', line 751

def get(opts = {})
  query = {}
  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 AffinityGroupReader.read_one(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

- (Object) remove(opts = {})

Deletes the object managed by this service.

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the remove should be performed asynchronously.



775
776
777
778
779
780
781
782
783
784
785
786
787
# File 'lib/ovirtsdk4/services.rb', line 775

def remove(opts = {})
  query = {}
  value = opts[:async]
  unless value.nil?
    value = Writer.render_boolean(value)
    query['async'] = value
  end
  request = Request.new(:method => :DELETE, :path => @path, :query => query)
  response = @connection.send(request)
  unless response.code == 200
    check_fault(response)
  end
end

- (Service) service(path)

Locates the service corresponding to the given path.

Parameters:

  • path (String)

    The path of the service.

Returns:

  • (Service)

    A reference to the service.

Raises:

  • (Error)


834
835
836
837
838
839
840
841
842
843
844
845
# File 'lib/ovirtsdk4/services.rb', line 834

def service(path)
  if path.nil? || path == ''
    return self
  end
  if path == 'vms'
    return vms_service
  end
  if path.start_with?('vms/')
    return vms_service.service(path[4..-1])
  end
  raise Error.new("The path \"#{path}\" doesn't correspond to any service")
end

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


852
853
854
# File 'lib/ovirtsdk4/services.rb', line 852

def to_s
  return "#<#{AffinityGroupService}:#{@path}>"
end

- (Object) update(group)

Updates the object managed by this service.



792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
# File 'lib/ovirtsdk4/services.rb', line 792

def update(group)
  if group.is_a?(Hash)
    group = OvirtSDK4::AffinityGroup.new(group)
  end
  request = Request.new(:method => :PUT, :path => @path)
  begin
    writer = XmlWriter.new(nil, true)
    AffinityGroupWriter.write_one(group, writer, 'group')
    request.body = writer.string
  ensure
    writer.close
  end
  response = @connection.send(request)
  case response.code
  when 200
    begin
      reader = XmlReader.new(response.body)
      return AffinityGroupReader.read_one(reader)
    ensure
      reader.close
    end
    return result
  else
    check_fault(response)
  end
end

- (AffinityGroupVmsService) vms_service

Locates the vms service.

Returns:



823
824
825
# File 'lib/ovirtsdk4/services.rb', line 823

def vms_service
  return AffinityGroupVmsService.new(@connection, "#{@path}/vms")
end