summaryrefslogtreecommitdiff
path: root/cpp/config/IcePackAdmin.py
blob: 3bf2c475c4c95381fdb93ecfbb9a480362f2f5e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/usr/bin/env python
# **********************************************************************
#
# Copyright (c) 2001
# Mutable Realms, Inc.
# Huntsville, AL, USA
#
# All Rights Reserved
#
# **********************************************************************

import sys, os, TestUtil

icePackPort = "0";

def startIcePack(toplevel, port, testdir):

    global icePackPort

    options = TestUtil.serverOptions.replace("TOPLEVELDIR", toplevel)

    icePackPort = port
    
    icePack = os.path.join(toplevel, "bin", "icepack")

    print "starting icepack...",
    command = icePack + options + ' --nowarn ' + \
          r' --IcePack.Locator.Endpoints="default -p ' + icePackPort + '  -t 5000" ' + \
          r' --IcePack.LocatorRegistry.Endpoints=default' + \
          r' --IcePack.Admin.Endpoints=default' + \
          r' --IcePack.Data=' + os.path.join(testdir, "db")

    icePackPipe = os.popen(command)
    TestUtil.getServerPid(icePackPipe)
    TestUtil.getAdapterReady(icePackPipe)
    TestUtil.getAdapterReady(icePackPipe)
    print "ok"
    return icePackPipe

def shutdownIcePack(toplevel, icePackPipe):

    global icePackPort
    icePackAdmin = os.path.join(toplevel, "bin", "icepackadmin")

    options = TestUtil.clientOptions.replace("TOPLEVELDIR", toplevel)

    print "shutting down icepack...",
    command = icePackAdmin + options + \
              r' "--Ice.Default.Locator=IcePack/locator:default -p ' + icePackPort + '" ' + \
              r' -e "shutdown" '
    
    icePackAdminPipe = os.popen(command)
    icePackAdminStatus = icePackAdminPipe.close()
    icePackPipe.close()
    print "ok"

    if icePackAdminStatus:
        TestUtil.killServers()
        sys.exit(1)
        

def addServer(toplevel, name, server, libpath, serverDescriptor):

    global icePackPort
    icePackAdmin = os.path.join(toplevel, "bin", "icepackadmin")

    options = TestUtil.clientOptions.replace("TOPLEVELDIR", toplevel)
    
    command = icePackAdmin + options + \
              r' "--Ice.Default.Locator=IcePack/locator:default -p ' + icePackPort + '" ' + \
              r' -e "server add \"' + name + '\\" \\"' + server + '\\" ' + \
              r' \"' + libpath + '\\" ' + serverDescriptor + '\"'

    icePackAdminPipe = os.popen(command)
    icePackAdminStatus = icePackAdminPipe.close()
    if icePackAdminStatus:
        TestUtil.killServers()
        sys.exit(1)

def removeServer(toplevel, name):

    global icePackPort
    icePackAdmin = os.path.join(toplevel, "bin", "icepackadmin")

    options = TestUtil.clientOptions.replace("TOPLEVELDIR", toplevel)
    
    command = icePackAdmin + options + \
              r' "--Ice.Default.Locator=IcePack/locator:default -p ' + icePackPort + '" ' + \
              r' -e "server remove \"' + name + '\\" \"'

    icePackAdminPipe = os.popen(command)
    icePackAdminStatus = icePackAdminPipe.close()
    if icePackAdminStatus:
        TestUtil.killServers()
        sys.exit(1)

def startServer(toplevel, name):
    global icePackPort
    icePackAdmin = os.path.join(toplevel, "bin", "icepackadmin")

    options = TestUtil.clientOptions.replace("TOPLEVELDIR", toplevel)

    command = icePackAdmin + options + \
              r' "--Ice.Default.Locator=IcePack/locator:default -p ' + icePackPort + '" ' + \
              r' -e "server start \"' + name + '\\""'

    icePackAdminPipe = os.popen(command)
    icePackAdminStatus = icePackAdminPipe.close()
    if icePackAdminStatus:
        TestUtil.killServers()
        sys.exit(1)

def listAdapters(toplevel):
    global icePackPort
    icePackAdmin = os.path.join(toplevel, "bin", "icepackadmin")

    options = TestUtil.clientOptions.replace("TOPLEVELDIR", toplevel)

    command = icePackAdmin + options + \
              r' "--Ice.Default.Locator=IcePack/locator:default -p ' + icePackPort + '" ' + \
              r' -e "adapter list"'

    icePackAdminPipe = os.popen(command)
    return icePackAdminPipe

def removeAdapter(toplevel, name):

    global icePackPort
    icePackAdmin = os.path.join(toplevel, "bin", "icepackadmin")

    options = TestUtil.clientOptions.replace("TOPLEVELDIR", toplevel)

    command = icePackAdmin + options + \
              r' "--Ice.Default.Locator=IcePack/locator:default -p ' + icePackPort + '" ' + \
              r' -e "adapter remove \"' + name + '\\""'

    icePackAdminPipe = os.popen(command)
    icePackAdminStatus = icePackAdminPipe.close()
    if icePackAdminStatus:
        TestUtil.killServers()
        sys.exit(1)