-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchkclient_test.py
79 lines (66 loc) · 2.15 KB
/
chkclient_test.py
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
import Client
import rpc, logging
import messages_pb2 as msg
import mds, ChunkServer
import gevent.socket
import guid as Guid
import block.dm as dm
from mds import Object
import libiscsi
import scandev
import config,util
def configuration():
global PARAM
helpmsg = '''group directories before files.
augment with a --sort option, but any
use of --sort=none (-U) disables grouping
'''
default_cfgfile = './test.conf'
cfgdict = (('MDS_IP', 'M', '192.168.0.149', 'ip address of metadata server'), \
('MDS_PORT','m','6789','port of metadata server'), \
('CHK_IP','C', '192.168.0.149', helpmsg), \
('CHK_PORT','c', '3456', 'the port of chunk server'),\
('enablexxx','x',False,'enable x'),\
('cfgfile','f', default_cfgfile, 'name of the configuration file'))
configure,_ = config.config(cfgdict)
PARAM = util.Object(configure)
default_cfgfile = './test.conf'
print '----------------',PARAM.MDS_IP
print '----------------',PARAM.MDS_PORT
def test_with_chkserv():
global PARAM
# logging.basicConfig(level=logging.DEBUG)
# s1=gevent.socket.socket()
# s1.connect((PARAM.MDS_IP, int(PARAM.MDS_PORT)))
# guid=msg.Guid()
# guid.a=10
# guid.b=22
# guid.c=30
# guid.d=40
# stub=rpc.RpcStub(guid, s1, mds.MDS)
# arg=msg.GetChunkServers_Request()
# ret=stub.callMethod('GetChunkServers', arg)
# s2=gevent.socket.socket()
# s2.connect((ret.random[0].ServiceAddress, ret.random[0].ServicePort))
# stub2=rpc.RpcStub(guid, s2, ChunkServer.ChunkServer)
mdsip='192.168.0.149'
mdsport='6789'
client = Client.Client(PARAM.MDS_IP, int(PARAM.MDS_PORT))
serlist = client.mds.GetChunkServers()
print len(serlist)
print serlist[0].ServiceAddress, serlist[0].ServicePort
# chkaddr = serlist[0].ServiceAddress
# chkport = serlist[0].ServicePort
# chkclient = ChunkServerClient(client.guid, chkaddr, chkport)
# chklist = chkclient.NewChunk(32, 1)
# print chklist
# volume = Object()
# volume.size = 50
# volume.guid = Guid.toStr(chklist.guids[0])
# target = chkclient.AssembleChunk(volume)
# print target
# chkclient.DisassembleChunk(target.access_point)
# chkclient.DeleteChunk(volume)
if __name__=='__main__':
configuration()
test_with_chkserv()