mirapoint 0.0.1 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +26 -0
- data/lib/mirapoint/version.rb +1 -1
- data/lib/mirapoint.rb +14 -10
- metadata +2 -2
data/README
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
Documentation coming. For now here is an example:
|
2
|
+
|
3
|
+
require 'mirapoint'
|
4
|
+
|
5
|
+
# Connect to the host with the params
|
6
|
+
# hostname - mirahost.example.com
|
7
|
+
# port - 10243 (default 10143)
|
8
|
+
# ssl - true (default false)
|
9
|
+
# debug - true (default false)
|
10
|
+
|
11
|
+
m = Mirapoint::Connection.new('mirahost.example.com', 10243, true, true)
|
12
|
+
m.connect
|
13
|
+
|
14
|
+
if m.login("administrator", "adminpass")
|
15
|
+
puts "Login Successful"
|
16
|
+
puts "Session ID: " + m.sessionid
|
17
|
+
end
|
18
|
+
|
19
|
+
m.command("domain", "setcurrent", "example.com")
|
20
|
+
puts m.okno
|
21
|
+
|
22
|
+
m.command("user", "list", "", "", "").each do |res|
|
23
|
+
puts res
|
24
|
+
end
|
25
|
+
|
26
|
+
puts m.okno
|
data/lib/mirapoint/version.rb
CHANGED
data/lib/mirapoint.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
#
|
2
|
+
# A simple library for connecting to Mirapoint's admind service
|
3
|
+
#
|
1
4
|
require 'socket'
|
2
5
|
require 'openssl'
|
3
6
|
|
@@ -11,11 +14,12 @@ module Mirapoint
|
|
11
14
|
attr_reader :sessionid
|
12
15
|
attr_reader :okno
|
13
16
|
|
14
|
-
def initialize(hostname, port=10143, ssl=false)
|
17
|
+
def initialize(hostname, port=10143, ssl=false, debug=false)
|
15
18
|
@hostname = hostname
|
16
19
|
@port = port
|
17
20
|
@ssl = ssl
|
18
21
|
@connected = false
|
22
|
+
@debug = debug
|
19
23
|
end
|
20
24
|
|
21
25
|
def connect
|
@@ -63,9 +67,6 @@ module Mirapoint
|
|
63
67
|
|
64
68
|
def command(*cmds)
|
65
69
|
|
66
|
-
puts cmds.size
|
67
|
-
puts cmds.class
|
68
|
-
|
69
70
|
tag = send_command(cmds)
|
70
71
|
|
71
72
|
response = []
|
@@ -89,18 +90,12 @@ module Mirapoint
|
|
89
90
|
tag = @lasttag
|
90
91
|
cmd = tag.to_s
|
91
92
|
|
92
|
-
puts cmds.size
|
93
|
-
puts cmd
|
94
|
-
puts cmds.join(" ")
|
95
|
-
|
96
93
|
if cmds.size < 2
|
97
94
|
cmd = cmd + " " + cmds[0]
|
98
95
|
else
|
99
96
|
cmd = cmd + escape_args(cmds)
|
100
97
|
end
|
101
98
|
|
102
|
-
puts cmd
|
103
|
-
|
104
99
|
if xmit(cmd)
|
105
100
|
return tag
|
106
101
|
end
|
@@ -135,6 +130,11 @@ module Mirapoint
|
|
135
130
|
loop do
|
136
131
|
line = @socket.gets
|
137
132
|
|
133
|
+
if @debug
|
134
|
+
puts "S: " + line;
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
138
|
if /^\* #{tag} /.match line
|
139
139
|
line.sub!(/^\* #{tag} /, "")
|
140
140
|
elsif (/^#{tag} OK/.match line) || (/^#{tag} NO/.match line)
|
@@ -155,6 +155,10 @@ module Mirapoint
|
|
155
155
|
|
156
156
|
def xmit(cmd)
|
157
157
|
|
158
|
+
if @debug
|
159
|
+
puts "C: " + cmd;
|
160
|
+
end
|
161
|
+
|
158
162
|
if @connected
|
159
163
|
@socket.puts(cmd + "\r\n")
|
160
164
|
return true
|