Пример #1
0
def get_pandora_info():
    """
    获取当前pandora信息
    :return:
    """
    return {'hostname': get_cur_ip(),
            'datetime': datetime_to_string(datetime.datetime.now()),
            'version': VERSION}
Пример #2
0
 def add_cmd_opts(self, arg_parser):
     """
     在获取sm参数之前,提供添加arg_parser参数接口
     :param arg_parser: 参数变量
     :return:
     """
     arg_parser.add_argument('--xxtea_key', default='A~3c0(@8$B65Wb<9', type=str, help="The key of XXTEA cryptor")
     arg_parser.add_argument('--pandora_host', default=get_cur_ip(), type=str, help='The host pandora proxy (default %(default)r)')
     arg_parser.add_argument('--pandora_port', default=20000, type=int, help='The port pandora is listening on (default %(default)r)')
Пример #3
0
def get_pandora_info():
    """
    获取当前pandora信息
    :return:
    """
    return {
        'hostname': get_cur_ip(),
        'datetime': datetime_to_string(datetime.datetime.now()),
        'version': VERSION
    }
Пример #4
0
    def get_msg(self):
        if self.load_getter:
            self.update_load(self.load_getter() or self.default_load)

        running = self.running
        return ujson.dumps([
            self.service_group,
            get_cur_ip(), self.port, self.jid, self.service_version,
            self.current_load, running
        ])
Пример #5
0
        def sm_sign_param_checker(self, *args, **kwargs):
            if "sign" not in kwargs:
                logger.error("%s:%s ERROR_SIGN_ERROR, not sign param!!!" % (self.__class__.__name__, fun.__name__))
                return {"result": error_code.ERROR_SIGN_ERROR}

            sign = kwargs.pop('sign')
            if not Signer().check_sign(sign, get_cur_ip(), SM_TCP_PORT):
                logger.error("%s:%s ERROR_SIGN_ERROR, check_sign false!!!" % (self.__class__.__name__, fun.__name__))
                return {"result": error_code.ERROR_SIGN_ERROR}
            return fun(self, *args, **kwargs)
Пример #6
0
        def sm_sign_param_checker(self, *args, **kwargs):
            if "sign" not in kwargs:
                logger.error("%s:%s ERROR_SIGN_ERROR, not sign param!!!" %
                             (self.__class__.__name__, fun.__name__))
                return {"result": error_code.ERROR_SIGN_ERROR}

            sign = kwargs.pop('sign')
            if not Signer().check_sign(sign, get_cur_ip(), SM_TCP_PORT):
                logger.error("%s:%s ERROR_SIGN_ERROR, check_sign false!!!" %
                             (self.__class__.__name__, fun.__name__))
                return {"result": error_code.ERROR_SIGN_ERROR}
            return fun(self, *args, **kwargs)
Пример #7
0
    def get_msg(self):
        if self.load_getter:
            self.update_load(self.load_getter() or self.default_load)

        running = self.running
        return ujson.dumps([self.service_group,
                            get_cur_ip(),
                            self.port,
                            self.jid,
                            self.service_version,
                            self.current_load,
                            running])
Пример #8
0
    def _gen_jid(self):
        args = ArgumentParser().args
        user_name = passwd = "_".join([get_cur_ip(), str(args.tcp_port), str(args.http_port)])

        http_rpc = ServiceMgrCacher().get_connection(US_REGISTER, protocol=PT_HTTPS)
        assert http_rpc

        login_result = login(http_rpc, user_name, passwd, enum.ADMIN_USER)
        if login_result.get("result", None) != error_code.ERROR_SUCCESS:
            regiger_result = register(http_rpc, "", user_name, passwd, enum.ADMIN_USER, des="bridge_auto_created")
            assert regiger_result.get("result", None) == error_code.ERROR_SUCCESS
            login_result = login(http_rpc, user_name, passwd, enum.ADMIN_USER)
            assert login_result.get("result", None) == error_code.ERROR_SUCCESS

        self.__jid = login_result["user_info"]["jid"]
        self.__jid_pwd = login_result["user_info"]["jid_pwd"]
"""
from lib.common import *
from lib.service import *
from utils.network.mqtt import MQTTClient
from interfaces.mxadap import mqtt
from utils.wapper.stackless import gevent_adaptor
import gevent
import time
from utils.meta.singleton import Singleton
from lib.xmpp import make_xmpp_relation
from utils.service_control.finder import get_cur_ip
from utest_mxadap.utest_smoke import MXADAP_WAIT_BASE_TIME

# xmpp username
# 这里更多考虑使用现有账号测试功能,不引入创建账号的不确定因数
user_name1 = "xmpp_bcast_test1" + "_%s" % get_cur_ip()
user_name2 = "xmpp_bcast_test2" + "_%s" % get_cur_ip()
user_name3 = "xmpp_bcast_test3" + "_%s" % get_cur_ip()
[(user_jid1, user_jid_pass1),
 (user_jid2, user_jid_pass2),
 (user_jid3, user_jid_pass3)] \
    = make_xmpp_relation([user_name1, user_name2, user_name3], add_roster=True)


# mqtt client
mqtt_client1 = MQTTClient()
mqtt_client1.init(MQTT_IP, MQTT_PORT)
mqtt_client1.start()

mqtt_client2 = MQTTClient()
mqtt_client2.init(MQTT_IP, MQTT_PORT)
"""
from lib.common import *
from lib.service import *
from utils.network.mqtt import MQTTClient
from interfaces.mxadap import mqtt
from utils.wapper.stackless import gevent_adaptor
import gevent
from pyxmpp2.jid import JID
import time
from utils.meta.singleton import Singleton
from lib.xmpp import make_xmpp_relation
from utils.service_control.finder import get_cur_ip
from utest_mxadap.utest_smoke import MXADAP_WAIT_BASE_TIME

# xmpp username
user_name1 = "xmpp_message_test1" + "_%s" % get_cur_ip()
user_name2 = "xmpp_message_test2" + "_%s" % get_cur_ip()
user_name3 = "xmpp_message_test3" + "_%s" % get_cur_ip()
[(user_jid1, user_jid_pass1),
 (user_jid2, user_jid_pass2),
 (user_jid3, user_jid_pass3)] \
    = make_xmpp_relation([user_name1, user_name2, user_name3], add_roster=True)


# xmpp client
xmpp_client = XMPPClient()
xmpp_client.init(JID(user_jid1), user_jid_pass1)
xmpp_client.start()

# mqtt client
mqtt_client2 = MQTTClient()
Пример #11
0
#!/usr/bin/python2.7
# coding=utf-8
"""
Created on 2015-7-17

@author: Jay
"""
from utils.crypto.sign import Signer
from utils.service_control.finder import get_cur_ip
from utils.service_control.parser import ArgumentParser

HTTP_SIGN = Signer().gen_sign(get_cur_ip(), ArgumentParser().args.http_port)
Пример #12
0
#!/usr/bin/python2.7
# coding=utf-8
"""
Created on 2015-7-27

@author: Jay
"""
from utils.service_control.parser import ArgumentParser
from utils.service_control.finder import get_cur_ip
from utils.comm_func import get_mxadap_host_flag

SERVICE_HOST = get_mxadap_host_flag(get_cur_ip(), ArgumentParser().args.http_port, ArgumentParser().args.tcp_port)

"""
Created on 2015-10-28

@author: Jay
"""
from lib.common import *
from lib.service import *
from utils.network.mqtt import MQTTClient
import time
from interfaces.mxadap import mqtt
from utils.wapper.stackless import gevent_adaptor
from lib.xmpp import make_xmpp_relation
from utils.service_control.finder import get_cur_ip
from utest_mxadap.utest_smoke import MXADAP_WAIT_BASE_TIME

login_test_user_name1 = "xmpp_roster_heartbeat_test1" + "_%s" % get_cur_ip()
[(login_test_jid1, login_test_password1)] \
    = make_xmpp_relation([login_test_user_name1])

xmpp_heartbeat_result = None
mqtt_adapter_expire_time = 40

class XmppHeartBeatAdapter(object):
    """
    heartbeat
    """

    def __init__(self):
        self.is_stop = False

        # mqtt client
Пример #14
0
#!/usr/bin/python2.7
# coding=utf-8
"""
Created on 2015-4-27

@author: Jay
"""
from utils.crypto.sign import Signer
from utils.service_control.finder import get_cur_ip
from utils.service_control.setting import SM_TCP_PORT

TCP_SIGN = Signer().gen_sign(get_cur_ip(), SM_TCP_PORT)
Пример #15
0
# coding=utf-8
"""
Created on 2015-4-22

@author: Jay
"""
from utils.service_control.finder import get_cur_ip

SERVICE_TYPE = "service_mgr"
VERSION = "0.0.1"

# 内网默认配置
DB_HOST = "10.24.6.7"
DB_PORT = 3306
DB_NAME = "service_mgr" + get_cur_ip().replace(".", "_")
DB_USER = "******"
DB_PWD = "!System"

USED_SERVICES = [
    US_DEVICE_END,
    US_MAIL,
    US_SMS,
] = [
    "s_device_end",
    "s_mail",
    "s_sms"
]
Пример #16
0
 def is_sm_local(self):
     return self.sm_ip == get_cur_ip()
Пример #17
0
# coding=utf-8
"""
Created on 2015-4-22

@author: Jay
"""
from utils.service_control.finder import get_cur_ip

SERVICE_TYPE = "service_mgr"
VERSION = "0.0.1"

# MYSQL配置
DB_HOST = "192.168.2.192"
DB_PORT = 3306
DB_NAME = "service_mgr" + get_cur_ip().replace(".", "_")
DB_USER = "******"
DB_PWD = "System"

USED_SERVICES = [
    US_DEVICE_END,
    US_MAIL,
    US_SMS,
] = ["s_device_end", "s_mail", "s_sms"]
from utils.service_control.finder import get_cur_ip
from utest_mxadap.utest_smoke import MXADAP_WAIT_BASE_TIME

# mqtt client
mqtt_client1 = MQTTClient()
mqtt_client1.init(MQTT_IP, MQTT_PORT)
mqtt_client1.start()

mqtt_client2 = MQTTClient()
mqtt_client2.init(MQTT_IP, MQTT_PORT)
mqtt_client2.start()


# add jid and roster
# xmpp client
mqtt_name1 = "xmpp_presence_test1" + "_%s" % get_cur_ip()
mqtt_name2 = "xmpp_presence_test2" + "_%s" % get_cur_ip()
[(mqtt_jid1, mqtt_jid_pass1), (mqtt_jid2, mqtt_jid_pass2)] = make_xmpp_relation(
    [mqtt_name1, mqtt_name2], add_roster=True
)

# should result
xmpp_login_result = None
xmpp_roster_result = None
xmpp_roster_ls = None

mxid1 = None
mxid2 = None

xmpp_roster_present_notify1 = None
xmpp_roster_present_notify2 = None
Пример #19
0
 def is_sm_local(self):
     return self.sm_ip == get_cur_ip()
"""
Created on 2015-10-23

@author: Jay
"""
from lib.common import *
from lib.service import *
from utils.network.mqtt import MQTTClient
import time
from interfaces.mxadap import mqtt
from utils.wapper.stackless import gevent_adaptor
from lib.xmpp import make_xmpp_relation
from utils.service_control.finder import get_cur_ip
from utest_mxadap.utest_smoke import MXADAP_WAIT_BASE_TIME

login_test_user_name1 = "xmpp_roster_expire_test1" + "_%s" % get_cur_ip()
[(login_test_jid1, login_test_password1)] \
    = make_xmpp_relation([login_test_user_name1])

xmpp_logout_result = None

class XmppExpireAdapter(object):
    """
    LOGIN <==> LOGOUT
    """

    def __init__(self):
        self.is_stop = False

        # mqtt client
        self.mqtt_client = MQTTClient()
"""
Created on 2015-7-29

@author: Jay
"""
from lib.common import *
from lib.service import *
from utils.network.mqtt import MQTTClient
from interfaces.mxadap import mqtt
from utils.wapper.stackless import gevent_adaptor
from utils.meta.singleton import Singleton
from utils.service_control.finder import get_cur_ip
from lib.xmpp import make_xmpp_relation
from utest_mxadap.utest_smoke import MXADAP_WAIT_BASE_TIME

roster_test_user_name1 = "xmpp_roster_add_test1" + "_%s" % get_cur_ip()
roster_test_password1 = "xmpp_roster_add_test1" + "_%s" % get_cur_ip()
roster_test_user_name2 = "xmpp_roster_add_test2" + "_%s" % get_cur_ip()
roster_test_password2 = "xmpp_roster_add_test2" + "_%s" % get_cur_ip()
[(roster_test_jid1, roster_test_password1),
 (roster_test_jid2, roster_test_password2)] \
    = make_xmpp_relation([roster_test_user_name1, roster_test_user_name2], del_roster=True)

xmpp_login_result = None
xmpp_roster_add_result = None
xmpp_roster_del_result = None
xmpp_roster_present_notify_dic = {}
presence_type = [u"subscribe", u"subscribed", u"unsubscribe", u"unsubscribed", u"available", u"unavailable"]


class MqttRosterAdapter(object):