Class: Auger::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/plugins/cql.rb,
lib/plugins/dns.rb,
lib/plugins/http.rb,
lib/auger/project.rb,
lib/plugins/redis.rb,
lib/plugins/socket.rb,
lib/plugins/telnet.rb,
lib/plugins/cassandra.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Project

Returns a new instance of Project.



14
15
16
17
18
19
20
21
# File 'lib/auger/project.rb', line 14

def initialize(name)
  @name = name
  @hosts = []
  @fqdns = []
  @connections = []
  @roles = Hash.new { |h,k| h[k] = [] }
  self
end

Instance Attribute Details

#connectionsObject

Returns the value of attribute connections.



6
7
8
# File 'lib/auger/project.rb', line 6

def connections
  @connections
end

#fqdns(*ranges) ⇒ Object Also known as: fqdn

add fqdn or return list of fqdns



56
57
58
# File 'lib/auger/project.rb', line 56

def fqdns
  @fqdns
end

#hosts=(value) ⇒ Object

Sets the attribute hosts

Parameters:

  • value

    the value to set the attribute hosts to.



6
7
8
# File 'lib/auger/project.rb', line 6

def hosts=(value)
  @hosts = value
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/auger/project.rb', line 6

def name
  @name
end

#rolesObject

Returns the value of attribute roles.



6
7
8
# File 'lib/auger/project.rb', line 6

def roles
  @roles
end

Class Method Details

.load(name, &block) ⇒ Object



8
9
10
11
12
# File 'lib/auger/project.rb', line 8

def self.load(name, &block)
  project = new(name)
  project.instance_eval(&block)
  project
end

Instance Method Details

#cassandra(port = 9160, &block) ⇒ Object



6
7
8
# File 'lib/plugins/cassandra.rb', line 6

def cassandra(port = 9160, &block)
  @connections << Cassandra.load(port, &block)
end

#cql(port = 9160, &block) ⇒ Object



6
7
8
# File 'lib/plugins/cql.rb', line 6

def cql(port = 9160, &block)
  @connections << Cql.load(port, &block)
end

#dns(port = 53, &block) ⇒ Object



6
7
8
# File 'lib/plugins/dns.rb', line 6

def dns(port = 53, &block)
  @connections << Dns.load(port, &block)
end

#http(port = 80, &block) ⇒ Object



6
7
8
# File 'lib/plugins/http.rb', line 6

def http(port = 80, &block)
  @connections << Http.load(port, &block)
end

#https(port = 443, &block) ⇒ Object



10
11
12
13
14
# File 'lib/plugins/http.rb', line 10

def https(port = 443, &block)
  http = Http.load(port, &block)
  http.ssl(true)
  @connections << http
end

#redis(port = 6379, &block) ⇒ Object



7
8
9
# File 'lib/plugins/redis.rb', line 7

def redis(port = 6379, &block)
  @connections << Auger::Redis.load(port, &block)
end

#role(name, *args) ⇒ Object



23
24
25
26
27
28
# File 'lib/auger/project.rb', line 23

def role(name, *args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  servers = args.map { |arg| HostRange.parse(arg) }.flatten
  #servers.each { |server| roles[name] << server }
  servers.each { |server| roles[name] << Auger::Server.new(server, options) }
end

#server(*args) ⇒ Object Also known as: hosts



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/auger/project.rb', line 30

def server(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  roles = []
  servers = []
  args.each do |arg|
    case arg
    when Symbol then roles << arg
    when String then servers << arg
    else raise ArgumentError, "illegal argument to server: #{arg}"
    end
  end
  roles = [nil] if roles.empty? # default role
  roles.each { |name| role(name, *servers, options) }
end

#servers(roles = []) ⇒ Object

return array of servers for given array of roles (default to all)



48
49
50
51
# File 'lib/auger/project.rb', line 48

def servers(roles = [])
  (roles.empty? ? @roles.values : @roles.values_at(*roles))
    .flatten
end

#socket(port, &block) ⇒ Object



5
6
7
# File 'lib/plugins/socket.rb', line 5

def socket(port, &block)
  @connections << Socket.load(port, &block)
end

#telnet(port = 23, &block) ⇒ Object



5
6
7
# File 'lib/plugins/telnet.rb', line 5

def telnet(port = 23, &block)
  @connections << Telnet.load(port, &block)
end

#testsObject



62
63
64
65
66
67
68
# File 'lib/auger/project.rb', line 62

def tests
  @connections.map do |connection|
    connection.requests.map do |request|
      request.tests.map { |test| test }
    end
  end.flatten
end