Exemplo n.º 1
0
def client(session=None):
    return GogameChen1DBClient(
        httpclient=ManagerClient(url=CONF.gcenter,
                                 port=CONF.gcenter_port,
                                 retries=CONF.retries,
                                 timeout=CONF.apitimeout,
                                 token=CONF.trusted,
                                 session=session))
Exemplo n.º 2
0
def init_http_client():
    global HTTPClient
    if HTTPClient is None:
        with lock.get('http'):
            if HTTPClient is None:
                LOG.debug("Try init http client for manager")
                conf = CONF[manager_group.name]
                HTTPClient = ManagerClient(url=conf.gcenter,
                                           port=conf.gcenter_port,
                                           token=conf.trusted)
    else:
        LOG.warning("Do not call init_http_client more then once")
Exemplo n.º 3
0
import time
import simpleservice

from simpleutil.config import cfg
from goperation import config

from goperation.api.client import ManagerClient

from simpleservice.plugin.exceptions import ServerExecuteRequestError


a = 'C:\\Users\\loliz_000\\Desktop\\etc\\goperation\\goperation.conf'
b = 'C:\\Users\\loliz_000\\Desktop\\etc\\goperation\\gcenter.conf'
config.configure('test', [a, b])


wsgi_url = '172.31.0.110'
wsgi_port = 7999


client = ManagerClient(wsgi_url, wsgi_port)


try:
    print client.file_show(file_id='517247dcab85b61087485498a409a707')
except ServerExecuteRequestError as e:
    print 'error'
    print e.resone


Exemplo n.º 4
0
from goperation.api.client import ManagerClient

from gopdb.api.client import GopDBClient
from gopdb import common

from goperation.manager import common as manager_common

a = 'C:\\Users\\loliz_000\\Desktop\\etc\\goperation\\goperation.conf'
b = 'C:\\Users\\loliz_000\\Desktop\\etc\\goperation\\gcenter.conf'
config.configure('test', [a, b])

# wsgi_url = '127.0.0.1'
wsgi_url = '172.31.0.110'
wsgi_port = 7999

httpclient = ManagerClient(wsgi_url, wsgi_port, timeout=30)

client = GopDBClient(httpclient)


def active_agent(agent_id):
    print client.agent_active(agent_id, manager_common.ACTIVE)


def create_test():
    print client.databases_create(
        body={
            'impl': 'record',
            'user': '******',
            'dbtype': 'mysql',
            'passwd': None,
Exemplo n.º 5
0
basepath = 'C:\\Users\\loliz_000\\Desktop\\etc\\goperation'

configs = [
    os.path.join(basepath, 'goperation.conf'),
    os.path.join(basepath, 'gcenter.conf')
]

configure(configs)

# wsgi_url = '127.0.0.1'
wsgi_url = '172.31.0.110'
wsgi_port = 7999

httpclient = ManagerClient(wsgi_url,
                           wsgi_port,
                           timeout=30,
                           token='938lhsaposg433tsdlfasjlgk938')

client = GogameChen1DBClient(httpclient)


def group_index_test():
    for r in client.groups_index()['data']:
        print r


def group_create_test():
    print client.groups_create(name='test', desc='test group')


def group_show_test(group_id):
Exemplo n.º 6
0
from simpleutil.utils import digestutils
from goperation.manager import common as manager_common

from gopcdn.utils import build_fileinfo

a = 'C:\\Users\\loliz_000\\Desktop\\etc\\goperation\\goperation.conf'
b = 'C:\\Users\\loliz_000\\Desktop\\etc\\goperation\\gcenter.conf'
config.configure('test', [a, b])

# wsgi_url = '127.0.0.1'
wsgi_url = '172.31.0.110'
wsgi_port = 7999

from requests import session

httpclient = ManagerClient(wsgi_url, wsgi_port, timeout=30, session=session())

client = GogameChen1DBClient(httpclient)


def file_create(objtype, version, path):
    md5 = digestutils.filemd5(path)
    size = os.path.getsize(path)
    ext = os.path.splitext(path)[1][1:]
    filename = os.path.split(path)[1]
    fileinfo = {
        'size': size,
        'md5': md5,
        'ext': ext,
        'filename': filename,
    }
Exemplo n.º 7
0
import time
import simpleservice

from simpleutil.config import cfg
from goperation import config

from goperation.api.client import ManagerClient

a = 'C:\\Users\\loliz_000\\Desktop\\etc\\goperation\\goperation.conf'
b = 'C:\\Users\\loliz_000\\Desktop\\etc\\goperation\\gcenter.conf'
config.configure('test', [a, b])

wsgi_url = '172.31.0.110'
wsgi_port = 7999

client = ManagerClient(wsgi_url, wsgi_port, token='goperation-trusted-token')

# for r in client.asyncs_index()['data']:
#     print r

print client.async_show(request_id='fa768282-d91f-40fc-9ad0-3c59254d799c',
                        body={'details': True})

# asyncs_index(self, body
# async_show(self, request_id, body)
# async_details(self, request_id, body)

# async_responses(self, request_id, body)
# async_overtime(self, request_id, body)
Exemplo n.º 8
0
from goperation.api.client import ManagerClient

from simpleservice.plugin.exceptions import AfterRequestError

from goperation.manager import exceptions

from goperation.manager import common

host = 'surface'
local_ip = '127.0.0.1'
wsgi_url = '172.31.0.110'
wsgi_port = 7999

client = ManagerClient(wsgi_url,
                       wsgi_port,
                       host=host,
                       local_ip=local_ip,
                       agent_type=common.APPLICATION)


def test_cache():
    print client.cache_flush()
    print client.cache_online(client.host, client.local_ip, client.agent_type)


def test_file():
    print client.files_index()
    print client.file_show(uuidutils.generate_uuid())
    print client.file_delete(uuidutils.generate_uuid(), body={'force': False})
    print client.file_add(body={'wtf': 1})
Exemplo n.º 9
0
import requests

from simpleservice.plugin.exceptions import ClientRequestError

from goperation.api.client import ManagerClient

a = 'C:\\Users\\loliz_000\\Desktop\\etc\\goperation\\goperation.conf'
b = 'C:\\Users\\loliz_000\\Desktop\\etc\\goperation\\gcenter.conf'
config.configure('test', [a, b])

wsgi_url = '172.31.0.110'
# wsgi_url = '127.0.0.1'
wsgi_port = 7999

session = requests.Session()
client = ManagerClient(wsgi_url, wsgi_port, session=session)

try:
    print client.agents_index()
except ClientRequestError as e:
    print e.message
    print e.code
    print e.resone
# print client.agent_show(agent_id=1)['data']
# print client.agents_status(agent_id=1, body={'request_time': int(time.time())})
# print client.agent_active(agent_id=1, status=1)['data']
# print client.agent_logs(agent_id=1)
# print client.agents_upgrade(agent_id='all', body={'request_time': int(time.time())})

import time