Class: Auger::Project
- Inherits:
-
Object
- Object
- Auger::Project
- 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
-
#connections ⇒ Object
Returns the value of attribute connections.
-
#fqdns(*ranges) ⇒ Object
(also: #fqdn)
add fqdn or return list of fqdns.
-
#hosts ⇒ Object
Sets the attribute hosts.
-
#name ⇒ Object
Returns the value of attribute name.
-
#roles ⇒ Object
Returns the value of attribute roles.
Class Method Summary collapse
Instance Method Summary collapse
- #cassandra(port = 9160, &block) ⇒ Object
- #cql(port = 9160, &block) ⇒ Object
- #dns(port = 53, &block) ⇒ Object
- #http(port = 80, &block) ⇒ Object
- #https(port = 443, &block) ⇒ Object
-
#initialize(name) ⇒ Project
constructor
A new instance of Project.
- #redis(port = 6379, &block) ⇒ Object
- #role(name, *args) ⇒ Object
- #server(*args) ⇒ Object (also: #hosts)
-
#servers(roles = []) ⇒ Object
return array of servers for given array of roles (default to all).
- #socket(port, &block) ⇒ Object
- #telnet(port = 23, &block) ⇒ Object
- #tests ⇒ Object
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
#connections ⇒ Object
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
6 7 8 |
# File 'lib/auger/project.rb', line 6 def hosts=(value) @hosts = value end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/auger/project.rb', line 6 def name @name end |
#roles ⇒ Object
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) = 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, ) } 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) = 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, ) } 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 |
#tests ⇒ Object
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 |