Class: Seiso::Connector

Inherits:
Object
  • Object
show all
Defined in:
lib/seiso/connector.rb,
lib/seiso/connector/connector_v1.rb,
lib/seiso/connector/rest_connector.rb,
lib/seiso/connector/uri_factory_v1.rb,
lib/seiso/connector/uri_factory_v2.rb,
lib/seiso/connector/request_failed_error.rb

Overview

Seiso connector.

Author

Willie Wheeler

Copyright

Copyright (c) 2014-2015 Expedia, Inc.

License

Apache 2.0

Defined Under Namespace

Classes: ConnectorV1, RequestFailedError, RestConnector, UriFactoryV1, UriFactoryV2

Instance Method Summary collapse

Constructor Details

#initialize(settings) ⇒ Connector

  • settings: a hash containing the following entries:
    • host
    • port
    • use_ssl (default false)
    • ignore_cert (default false)
    • username
    • password


26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/seiso/connector.rb', line 26

def initialize(settings)
  host = settings['host']
  port = settings['port']
  use_ssl = settings['use_ssl'] || false
  ignore_cert = settings['ignore_cert'] || false
  username = settings['username']
  password = settings['password']
  
  http = create_http(host, port, use_ssl, ignore_cert)
  
  @connector_v1 = Seiso::Connector::ConnectorV1.new(http, username, password)
end

Instance Method Details

#connector_v1Object

Tests can override this



40
41
42
# File 'lib/seiso/connector.rb', line 40

def connector_v1
  @connector_v1
end

#get_items(type) ⇒ Object

GET item list



45
46
47
# File 'lib/seiso/connector.rb', line 45

def get_items(type)
  connector_v1.do_get("/v1/#{type}")
end

#post_items(type, items) ⇒ Object

POST items to Seiso



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/seiso/connector.rb', line 58

def post_items(type, items)
  if type == 'ip-address-roles'
    do_put_ip_address_roles items
  elsif type == 'node-ip-addresses'
    do_put_node_ip_addresses items
  elsif type == 'service-instance-ports'
    do_put_service_instance_ports items
  else
    connector_v1.do_post("/v1/#{type}?mode=batch", items)
  end
end

#put_item(type, item, key) ⇒ Object

PUT a single item to Seiso.

  • type: Item type
  • item: Item
  • key: Item key


74
75
76
# File 'lib/seiso/connector.rb', line 74

def put_item(type, item, key)
  connector_v1.do_put("/v1/#{type}/#{key}", item)
end