Module: Trema
- Includes:
- Defaults
- Defined in:
- lib/trema/drb.rb,
lib/trema/dirs.rb,
lib/trema/logger.rb,
lib/trema/switch.rb,
lib/trema/command.rb,
lib/trema/version.rb,
lib/trema/controller.rb,
lib/trema/monkey_patch/integer/durations.rb,
lib/trema/monkey_patch/integer/base_conversions.rb
Overview
Defined Under Namespace
Modules: Defaults, MonkeyPatch
Classes: Command, Controller, Logger, NoControllerDefined, Switch
Constant Summary
collapse
- VERSION =
'0.10.1'
Constants included
from Defaults
Defaults::DEFAULT_LOG_DIR, Defaults::DEFAULT_PID_DIR, Defaults::DEFAULT_SOCKET_DIR
Class Method Summary
collapse
Class Method Details
.fetch(name, socket_dir) ⇒ Object
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/trema/drb.rb', line 47
def self.fetch(name, socket_dir)
trema_processes(socket_dir).each do |trema|
begin
return trema.fetch(name)
rescue
next
end
end
raise %("#{name}" does not exist.)
end
|
.trema_process(controller_name, socket_dir) ⇒ Object
7
8
9
10
11
12
13
14
|
# File 'lib/trema/drb.rb', line 7
def self.trema_process(controller_name, socket_dir)
Phut.socket_dir = socket_dir
socket_path = File.join(Phut.socket_dir, "#{controller_name}.ctl")
unless FileTest.socket?(socket_path)
raise %(Controller process "#{controller_name}" does not exist.)
end
DRbObject.new_with_uri('drbunix:' + socket_path)
end
|
.trema_processes(socket_dir = Phut.socket_dir) ⇒ Object
16
17
18
19
20
21
|
# File 'lib/trema/drb.rb', line 16
def self.trema_processes(socket_dir = Phut.socket_dir)
Phut.socket_dir = socket_dir
all = Dir.glob(File.join(Phut.socket_dir, '*.ctl'))
vhosts = Dir.glob(File.join(Phut.socket_dir, 'vhost.*.ctl'))
(all - vhosts).map { |each| DRbObject.new_with_uri("drbunix:#{each}") }
end
|
.vhost(socket_dir) ⇒ Object
35
36
37
38
39
|
# File 'lib/trema/drb.rb', line 35
def self.vhost(socket_dir)
trema_processes(socket_dir).map do |trema|
trema.try(:vhost)
end.compact
end
|
.vhosts(socket_dir = Phut.socket_dir) ⇒ Object
23
24
25
26
27
|
# File 'lib/trema/drb.rb', line 23
def self.vhosts(socket_dir = Phut.socket_dir)
Phut.socket_dir = socket_dir
vhosts = Dir.glob(File.join(Phut.socket_dir, 'vhost.*.ctl'))
vhosts.map { |each| DRbObject.new_with_uri("drbunix:#{each}") }
end
|
.vlink(socket_dir) ⇒ Object
41
42
43
44
45
|
# File 'lib/trema/drb.rb', line 41
def self.vlink(socket_dir)
trema_processes(socket_dir).map do |trema|
trema.try(:vlink)
end.compact
end
|
.vswitch(socket_dir) ⇒ Object
29
30
31
32
33
|
# File 'lib/trema/drb.rb', line 29
def self.vswitch(socket_dir)
trema_processes(socket_dir).map do |trema|
trema.try(:vswitch)
end.compact
end
|