Module: IIB::Node

Included in:
CLI, REST
Defined in:
lib/iib/node.rb,
lib/iib/node/CLI.rb,
lib/iib/node/REST.rb

Defined Under Namespace

Classes: CLI, REST

Class Method Summary collapse

Class Method Details

.create_local_node(name) ⇒ Object



43
44
45
46
47
48
49
50
# File 'lib/iib/node.rb', line 43

def self.create_local_node(name)
  IIB.check_local_iib_environment

  iib_create_broker = Mixlib::ShellOut.new("iib createbroker #{name}")
  iib_create_broker.run_command

  return IIB::Node.new(type: :CLI, name: name)
end

.delete_local_node(name) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/iib/node.rb', line 52

def self.delete_local_node(name)
  IIB.check_local_iib_environment

  iib_delete_broker = Mixlib::ShellOut.new("iib deletebroker #{name}")

  iib_delete_broker.run_command
end

.get_all_local_nodesObject



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/iib/node.rb', line 29

def self.get_all_local_nodes
  IIB.check_local_iib_environment

  iib_list = Mixlib::ShellOut.new("iib list -d 0")
  iib_list.run_command

  output = iib_list.stdout
  matches = output.scan(/BIP8099I:\ Broker:\ ([^\ ]*)\ \ -\ \ ([^\n]*)/m)

  matches.map do |match|
    IIB::Node.new(type: :CLI,name: match[0])
  end
end

.new(options) ⇒ Object



24
25
26
27
# File 'lib/iib/node.rb', line 24

def self.new(options)
  return IIB::Node::REST.new(options) if options.has_key?(:hostname)
  return IIB::Node::CLI.new(options)  if options.has_key?(:name)
end