Class: OvirtSDK4::OpenstackNetworkProviderService

Inherits:
ExternalProviderService show all
Defined in:
lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb

Instance Method Summary (collapse)

Instance Method Details

- (ExternalProviderCertificatesService) certificates_service

Locates the certificates service.

Returns:



13936
13937
13938
# File 'lib/ovirtsdk4/services.rb', line 13936

def certificates_service
  return ExternalProviderCertificatesService.new(@connection, "#{@path}/certificates")
end

- (OpenStackNetworkProvider) get(opts = {})

Returns the representation of the object managed by this service.

Parameters:

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

    Additional options.

Returns:



13818
13819
13820
13821
13822
13823
13824
13825
13826
13827
13828
13829
13830
13831
13832
13833
# File 'lib/ovirtsdk4/services.rb', line 13818

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 OpenStackNetworkProviderReader.read_one(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

- (Object) import_certificates(opts = {})

Executes the import_certificates method.



13838
13839
13840
13841
13842
13843
13844
13845
13846
13847
13848
13849
13850
13851
13852
13853
13854
13855
13856
# File 'lib/ovirtsdk4/services.rb', line 13838

def import_certificates(opts = {})
  action = Action.new(opts)
  writer = XmlWriter.new(nil, true)
  ActionWriter.write_one(action, writer)
  body = writer.string
  writer.close
  request = Request.new({
  :method => :POST,
  :path => "#{@path}/importcertificates",
  :body => body,
  })
  response = @connection.send(request)
  case response.code
  when 200
    action = check_action(response)
  else
    check_fault(response)
  end
end

- (OpenstackNetworksService) networks_service

Locates the networks service.

Returns:



13944
13945
13946
# File 'lib/ovirtsdk4/services.rb', line 13944

def networks_service
  return OpenstackNetworksService.new(@connection, "#{@path}/networks")
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.



13865
13866
13867
13868
13869
13870
13871
13872
13873
13874
13875
13876
13877
# File 'lib/ovirtsdk4/services.rb', line 13865

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)


13955
13956
13957
13958
13959
13960
13961
13962
13963
13964
13965
13966
13967
13968
13969
13970
13971
13972
# File 'lib/ovirtsdk4/services.rb', line 13955

def service(path)
  if path.nil? || path == ''
    return self
  end
  if path == 'certificates'
    return certificates_service
  end
  if path.start_with?('certificates/')
    return certificates_service.service(path[13..-1])
  end
  if path == 'networks'
    return networks_service
  end
  if path.start_with?('networks/')
    return networks_service.service(path[9..-1])
  end
  raise Error.new("The path \"#{path}\" doesn't correspond to any service")
end

- (Object) test_connectivity(opts = {})

Executes the test_connectivity method.



13882
13883
13884
13885
13886
13887
13888
13889
13890
13891
13892
13893
13894
13895
13896
13897
13898
13899
13900
# File 'lib/ovirtsdk4/services.rb', line 13882

def test_connectivity(opts = {})
  action = Action.new(opts)
  writer = XmlWriter.new(nil, true)
  ActionWriter.write_one(action, writer)
  body = writer.string
  writer.close
  request = Request.new({
  :method => :POST,
  :path => "#{@path}/testconnectivity",
  :body => body,
  })
  response = @connection.send(request)
  case response.code
  when 200
    action = check_action(response)
  else
    check_fault(response)
  end
end

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


13979
13980
13981
# File 'lib/ovirtsdk4/services.rb', line 13979

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

- (Object) update(provider)

Updates the object managed by this service.



13905
13906
13907
13908
13909
13910
13911
13912
13913
13914
13915
13916
13917
13918
13919
13920
13921
13922
13923
13924
13925
13926
13927
13928
13929
13930
# File 'lib/ovirtsdk4/services.rb', line 13905

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