Class: CMDB::Source::Network

Inherits:
CMDB::Source show all
Defined in:
lib/cmdb/source/network.rb

Overview

Abstract base class for sources that are backed by an HTTP k/v store. Contains reusable HTTP request logic.

Direct Known Subclasses

Consul

Instance Attribute Summary collapse

Attributes inherited from CMDB::Source

#prefix, #uri

Instance Method Summary collapse

Methods inherited from CMDB::Source

create, detect

Constructor Details

#initialize(uri, port, prefix) ⇒ Network

Construct a new HTTP source. The logical URI is transformed into an HTTP base URL by preserving the hostname, overriding the port (unless the URI already has a specific port), replacing the scheme with http and eliminating the path.

Parameters:

  • uri (String, URI)

    logical description of this source

  • port (Integer)

    default HTTP port if not specified in URI

  • dot-notation (String)

    prefix of all keys



16
17
18
19
# File 'lib/cmdb/source/network.rb', line 16

def initialize(uri, port, prefix)
  super(uri, prefix)
  @http_url = URI.parse("http://%s:%s" % [@uri.host, @uri.port || port])
end

Instance Attribute Details

#http_urlURI (readonly)

Returns HTTP base location of this source (minus path).

Returns:

  • (URI)

    HTTP base location of this source (minus path)



6
7
8
# File 'lib/cmdb/source/network.rb', line 6

def http_url
  @http_url
end