예제 #1
0
def get_trnsfr_copm_list():
    return [(2, ServiceInfo("HN0101_8888_container-server", "10.0.0.44",
                            2222)),
            (3, ServiceInfo("HN0102_8888_container-server", "10.0.0.45",
                            2222)),
            (4, ServiceInfo("HN0103_8888_container-server", "10.0.0.46",
                            2222))]
예제 #2
0
 def service_comp_map(self):
     #my_dict = {"ABC" : ['1', '2', '3'], "XYZ" : ['1', '2', '3'], "PQR" : ['1', '2', '3']}
     my_dict = {}
     my_dict[ServiceInfo(10, '1.1.1.1', 7890)] = [1, 2, 3]
     my_dict[ServiceInfo(101, '2.2.2.2', 6570)] = [7, 8, 9]
     my_dict[ServiceInfo(111, '6.6.6.6', 4321)] = [4, 5, 6]
     return my_dict
예제 #3
0
def test_node_deletion(node_id, ip, port):
    request = Req()
    node = ServiceInfo(node_id, ip, port)
    dest = ServiceInfo("Rajnikant", "192.168.123.13", 87654)
    con = request.connector(IoType.SOCKETIO, node)
    resp = request.node_deletion(dest, con)
    if resp.status.get_status_code() == Resp.SUCCESS:
        print "Success"
    else:
        print "Failed"
    con.close()
예제 #4
0
def get_gl_map_message():
    for service_name, port in service_data.iteritems():
        lst = []
        for i in range(512):
            if i < 256:
                lst.append(
                    ServiceInfo(ll_node_id_list[0] + service_name + "-server",
                                "10.0.0.44", port))
            else:
                lst.append(
                    ServiceInfo(ll_node_id_list[1] + service_name + "-server",
                                "10.0.0.45", port))
        test_gl_map[service_name + "-server"] = (lst, 3.0)
    gl_map_obj = GlobalMapMessage(test_gl_map, 5.0)
    return gl_map_obj
예제 #5
0
def test_node_addition(my_id, gl_id, gl_ip, gl_port):
    request = Req()
    node = ServiceInfo(gl_id, gl_ip, gl_port)
    con = request.connector(IoType.EVENTIO, node)
    nodes = [
        ServiceInfo("", "10.0.0.45", 2222),
        ServiceInfo("", "10.0.0.45", 2222),
        ServiceInfo("", "10.0.0.45", 2222)
    ]
    resp = request.node_addition(nodes, con)
    if resp.status.get_status_code() == Resp.SUCCESS:
        print "Success"
        #print resp.message.node_ack_list()
    else:
        print "Failed"
    con.close()
예제 #6
0
def test_get_comp_list(my_id, gl_id, gl_ip, gl_port):
    request = Req()
    node = ServiceInfo(gl_id, gl_ip, gl_port)
    con = request.connector(IoType.EVENTIO, node)
    resp = request.get_comp_list(my_id, con)
    if resp.status.get_status_code() == Resp.SUCCESS:
        print "Success"
    else:
        print "Failed"
    con.close()
예제 #7
0
def test_node_stop(node_id, ip, port):
    request = Req()
    node = ServiceInfo(node_id, ip, port)
    con = request.connector(IoType.EVENTIO, node)
    resp = request.node_stop(node_id, con)
    if resp.status.get_status_code() == Resp.SUCCESS:
        print "Success"
    else:
        print "Failed"
    con.close()
예제 #8
0
 def de_serialize(self, msg_str):
     """
     @desc Populate message object by de-serializing binary string.
     @param msg_str: A serialize binary string.
     """
     assert type(msg_str) is str, "Input is not a string"
     if msg_str:
         msg_obj = NodeDeletionCli()
         msg_obj.ParseFromString(msg_str)
         self.__node = ServiceInfo(msg_obj.node.service_id, msg_obj.node.ip,
                                   msg_obj.node.port)
예제 #9
0
def test_local_node_status(dest_id, dest_ip, dest_port):
    request = Req()
    node = ServiceInfo(dest_id, dest_ip, dest_port)
    con = request.connector(IoType.EVENTIO, node)
    resp = request.local_node_status(dest_id, con)
    if resp.status.get_status_code() == Resp.SUCCESS:
        print "Success"
        #print "status_code: %s, Msg: %s, enum: %s" % (resp.status.get_status_code(), resp.status.get_status_message(), resp.message.get_node_status())
    else:
        print "Failed: status_code: %s, msg: %s" % (
            resp.status.get_status_code(), resp.status.get_status_message())
    con.close()
예제 #10
0
def test_get_gl_map(my_id, gl_id, gl_ip, gl_port):
    request = Req()
    node = ServiceInfo(gl_id, gl_ip, gl_port)
    con = request.connector(IoType.EVENTIO, node)
    resp = request.get_global_map(my_id, con)
    if resp.status.get_status_code() == Resp.SUCCESS:
        print "Success"
        #print resp.message.map()
        #print resp.message.version()
    else:
        print "Failed"
    con.close()
예제 #11
0
def comp_transfer_info(my_id, gl_id, gl_ip, gl_port):
    request = Req()
    node = ServiceInfo(gl_id, gl_ip, gl_port)
    con = request.connector(IoType.EVENTIO, node)
    resp = request.comp_transfer_info(my_id, get_trnsfr_copm_list(), con)
    if resp.status.get_status_code() == Resp.SUCCESS:
        print "Success"
        #print resp.message.map()
        #print resp.message.version()
    else:
        print "Failed"
    con.close()
예제 #12
0
 def de_serialize(self, msg_str):
     """
     @desc Populate message object by de-serializing binary string.
     @param msg_str: A serialize binary string.
     """
     assert type(msg_str) is str, "Input is not a string"
     if msg_str:
         self.__dest_comp_map = {}
         msg_obj = RecvProcStartMonitoringAck()
         msg_obj.ParseFromString(msg_str)
         if msg_obj.status == True:
             for entry in msg_obj.service_name:
                 cmp_lst = list()
                 for comp in entry.component_list:
                     cmp_lst.append(comp)
                 self.__dest_comp_map[ServiceInfo(\
                 entry.service.service_id, entry.service.ip, \
                 entry.service.port)] = cmp_lst
             if msg_obj.source_service:
                 self.__source_service = ServiceInfo(\
                 msg_obj.source_service.service_id, \
                 msg_obj.source_service.ip, msg_obj.source_service.port)
예제 #13
0
 def de_serialize(self, msg_str):
     """
     @desc Populate message object by de-serializing binary string.
     @param msg_str: A serialize binary string.
     """
     assert type(msg_str) is str, "Input is not a string"
     if msg_str:
         self.__node_ack_list = []
         msg_obj = NodeAdditionCliAck()
         msg_obj.ParseFromString(msg_str)
         for node_ack in msg_obj.node_ack_list:
             self.__node_ack_list.append(
                 (Status(node_ack.status.code, node_ack.status.msg),
                  ServiceInfo(node_ack.node.service_id, node_ack.node.ip,
                              node_ack.node.port)))
예제 #14
0
 def de_serialize(self, msg_str):
     """
     @desc Populate message object by de-serializing binary string.
     @param msg_str: A serialize binary string.
     """
     assert type(msg_str) is str, "Input is not a string"
     if msg_str:
         msg_obj = GlobalMapInfo()
         msg_obj.ParseFromString(msg_str)
         self.__global_map = {}
         self.__global_map["account-server"] = ([ServiceInfo(
                                           service.service_id,
                                           service.ip,
                                           service.port) \
                             for service in msg_obj.account.service_list],
                         msg_obj.account.version)
         self.__global_map["container-server"] = ([ServiceInfo(
                                           service.service_id,
                                           service.ip,
                                           service.port) \
                             for service in msg_obj.container.service_list],
                         msg_obj.container.version)
         self.__global_map["accountUpdater-server"] = ([ServiceInfo(
                                           service.service_id,
                                           service.ip,
                                           service.port) \
                             for service in msg_obj.updater.service_list],
                         msg_obj.updater.version)
         self.__global_map["object-server"] = ([ServiceInfo(
                                           service.service_id,
                                           service.ip,
                                           service.port) \
                             for service in msg_obj.object.service_list],
                         msg_obj.object.version)
         self.__version = msg_obj.version
         self.__status = msg_obj.status
예제 #15
0
 def de_serialize(self, msg_str):
     """
     @desc Populate message object by de-serializing binary string.
     @param msg_str: A serialize binary string.
     """
     assert type(msg_str) is str, "Input is not a string"
     if msg_str:
         msg_obj = CompTransferInfo()
         msg_obj.ParseFromString(msg_str)
         self.__service_id = msg_obj.service_id
         self.__comp_service_list = []
         for comp_service in msg_obj.component_service_pair:
             self.__comp_service_list.append((comp_service.component, \
             ServiceInfo(comp_service.dest_service.service_id,
                                      comp_service.dest_service.ip,
                                      comp_service.dest_service.port)))
예제 #16
0
def test_get_osd_status(node_id, ip, port):
    request = Req()
    node = ServiceInfo(node_id, ip, port)
    service_id = "cli"
    con = request.connector(IoType.SOCKETIO, node)
    resp = request.get_osd_status(service_id, con)
    if resp.status.get_status_code() == Resp.SUCCESS:
        print "Success"
        #mp =  resp.message
        #print mp
        #for i in mp:
        #    print i, mp[i]
    else:
        print "Failed"
        print resp.status.get_status_code()
        print resp.status.get_status_message()
    con.close()
예제 #17
0
 def de_serialize(self, msg_str):
     """
     @desc Populate message object by de-serializing binary string.
     @param msg_str: A serialize binary string.
     """
     assert type(msg_str) is str, "Input is not a string"
     if msg_str:
         msg_obj = TransferComp()
         msg_obj.ParseFromString(msg_str)
         self.__service_comp_map = {}
         for service_comp_pair in msg_obj.service_comp_list:
             cmp_lst = list()
             for comp in service_comp_pair.component:
                 cmp_lst.append(comp)
             self.__service_comp_map[ServiceInfo(\
                     service_comp_pair.dest_service.service_id,
                     service_comp_pair.dest_service.ip,
                     service_comp_pair.dest_service.port)] = cmp_lst
예제 #18
0
 def get_gl_info(self):
     """
     @desc get global leader info object
     @return An object of ServiceInfo class, which contains service id, ip and port.
     @see ServiceInfo
     """
     self.__logger.debug("Search gl info file: %s" % GL_FILE_BASE)
     try:
         file_list = [f for f in os.listdir(GL_FS_PATH) \
             if fnmatch.fnmatch(f, GL_FILE_BASE+'*')]
     except OSError as ex:
         self.__logger.warn("While listing %s: %s" %(GL_FS_PATH, ex))
         raise FileNotFoundException( \
         "global leader fs path not found", 2)
     if not file_list:
         self.__logger.error("gl info file not found named with: %s" \
         % GL_FILE_BASE)
         raise FileNotFoundException( \
         "osd_global_leader_information file not found", 2)
     self.__logger.debug("gl info file list: %s" %file_list)
     gl_file = file_list[0]
     gl_file_path = os.path.join(GL_FS_PATH, gl_file)
     with open(gl_file_path, 'r') as f:
         gl_data = f.read(MAX_FILE_READ_SIZE)
     try:
         self.__logger.debug("read bytes from gl info file: %s" % gl_data)
         host_id, ip, port = gl_data.split()
     except ValueError as ex:
         self.__logger.error("While geting gl info from data: %s : %s" \
                             % (gl_data, ex))
         raise FileCorruptedException( \
         "Could not get gl info from osd_global_leader_information file")
     gl_info_obj = ServiceInfo(host_id.strip(),
                               ip.strip(),
                               int(port.strip()))
     return gl_info_obj
예제 #19
0
def get_added_node_message():
    node_ack_list = [(Status(0, "Done By Dk"),
                      ServiceInfo("HN0101_8888", "10.0.0.44", 2222)),
                     (Status(0, "Done By Dk"),
                      ServiceInfo("HN0101_8888", "10.0.0.44", 2222))]
    return NodeAdditionCliAckMessage(node_ack_list)