Skip to content

Commit

Permalink
remove the grpc client defined in synse server, use the new one defin…
Browse files Browse the repository at this point in the history
…ed in synse_grpc (#285)
  • Loading branch information
edaniszewski authored Apr 4, 2019
1 parent e48abc1 commit 75e1623
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 893 deletions.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#
FROM vaporio/python:3.6 as builder
COPY requirements.txt .
COPY synse_grpc-3.0.0.tar.gz .

RUN pip install --prefix=/build --no-warn-script-location synse_grpc-3.0.0.tar.gz \
&& rm -rf /root/.cache

RUN pip install --prefix=/build -r /requirements.txt --no-warn-script-location \
&& rm -rf /root/.cache
Expand Down
31 changes: 12 additions & 19 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,33 @@
#
# pip-compile --output-file requirements.txt setup.py
#
adal==1.2.1 # via kubernetes
aiocache==0.10.1
aiofiles==0.4.0 # via sanic
asn1crypto==0.24.0 # via cryptography
bison==0.1.0
cachetools==3.1.0 # via google-auth
certifi==2018.11.29 # via kubernetes, requests
cffi==1.11.5 # via cryptography
certifi==2019.3.9 # via kubernetes, requests
chardet==3.0.4 # via requests
cryptography==2.5 # via adal
google-auth==1.6.2 # via kubernetes
grpcio==1.18.0
httptools==0.0.11 # via sanic
google-auth==1.6.3 # via kubernetes
grpcio==1.19.0
httptools==0.0.13 # via sanic
idna==2.8 # via requests
kubernetes==8.0.1
kubernetes==9.0.0
multidict==4.5.2 # via sanic
oauthlib==3.0.1 # via requests-oauthlib
protobuf==3.6.1
pyasn1-modules==0.2.4 # via google-auth
pyasn1==0.4.5 # via pyasn1-modules, rsa
pycparser==2.19 # via cffi
pyjwt==1.7.1 # via adal
python-dateutil==2.8.0 # via adal, kubernetes
python-json-logger==0.1.10
pyyaml==4.2b4
python-dateutil==2.8.0 # via kubernetes
python-json-logger==0.1.11
pyyaml==5.1
requests-oauthlib==1.2.0 # via kubernetes
requests==2.21.0
rsa==4.0 # via google-auth
sanic==18.12.0
six==1.12.0 # via cryptography, google-auth, grpcio, kubernetes, protobuf, python-dateutil, structlog, websocket-client
sanic==19.3.1
six==1.12.0 # via google-auth, grpcio, kubernetes, python-dateutil, structlog, websocket-client
structlog==19.1.0
synse-grpc==1.1.0
ujson==1.35 # via sanic
urllib3==1.24.1 # via kubernetes, requests
uvloop==0.12.0 # via sanic
websocket-client==0.54.0 # via kubernetes
uvloop==0.12.2 # via sanic
websocket-client==0.56.0 # via kubernetes
websockets==6.0 # via sanic
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@
'requests>=2.20.0', # used by 'kubernetes'
'sanic>=0.8.0',
'structlog',
'synse-grpc>=1.1.0',
# FIXME: protobuf should be removed here, it should be a dep of synse_grpc
'protobuf',
'synse-grpc>=1.1.0', # fixme: this will need to be >= 3.0.0 once that is released
],
tests_require=[
'aiohttp',
Expand Down
Binary file added synse_grpc-3.0.0.tar.gz
Binary file not shown.
5 changes: 3 additions & 2 deletions synse_server/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
import aiocache
import grpc

import synse_grpc.utils

from synse_server import config, errors, utils
from synse_server.i18n import _
from synse_server.log import logger
from synse_server.plugin import Plugin, get_plugins, register_plugins
from synse_server.proto import util as putil

# The aiocache configuration
AIOCACHE = {
Expand Down Expand Up @@ -633,7 +634,7 @@ def _build_resource_info_cache(metainfo):

for source in metainfo.values():

src = putil.device_info_to_dict(source)
src = synse_grpc.utils.to_dict(source)

rack = source.location.rack
board = source.location.board
Expand Down
7 changes: 4 additions & 3 deletions synse_server/commands/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import grpc

import synse_grpc.utils

from synse_server import plugin, utils
from synse_server.i18n import _
from synse_server.log import logger
from synse_server.proto import util
from synse_server.scheme.plugins import PluginsResponse


Expand Down Expand Up @@ -65,12 +66,12 @@ async def get_plugins():
else:
plugin_data['health'] = {
'timestamp': health.timestamp,
'status': util.plugin_health_status_name(health.status),
'status': synse_grpc.utils.health_status_name(health.status),
'message': '',
'checks': [
{
'name': check.name,
'status': util.plugin_health_status_name(check.status),
'status': synse_grpc.utils.health_status_name(check.status),
'message': check.message,
'timestamp': check.timestamp,
'type': check.type,
Expand Down
3 changes: 1 addition & 2 deletions synse_server/commands/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from synse_server import cache, errors, plugin
from synse_server.i18n import _
from synse_server.log import logger
from synse_server.proto.client import WriteData
from synse_server.scheme.write import WriteResponse


Expand Down Expand Up @@ -59,7 +58,7 @@ async def write(rack, board, device, data):
)
write_data = str.encode(write_data)

wd = WriteData(action=write_action, data=write_data)
wd = {'action': write_action, 'data': write_data}
logger.info(_('Writing to {}: {}').format('/'.join((rack, board, device)), wd))

# Perform a gRPC write on the device's managing plugin
Expand Down
12 changes: 4 additions & 8 deletions synse_server/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
import os
import stat

from synse_grpc import client

from synse_server import config, const, errors
from synse_server.discovery import kubernetes
from synse_server.i18n import _
from synse_server.log import logger
from synse_server.proto import client


class PluginManager:
Expand Down Expand Up @@ -243,12 +244,7 @@ def register_plugin(address, protocol):
# The client does not exist, so we must register it. This means we need to
# connect with it to (a) make sure its reachable, and (b) get its metadata
# in order to properly create a new Plugin model for it.
if protocol == 'tcp':
plugin_client = client.PluginTCPClient(address)
elif protocol == 'unix':
plugin_client = client.PluginUnixClient(address)
else:
raise ValueError(_('Invalid protocol specified for registration: {}').format(protocol))
plugin_client = client.PluginClientV3(address, protocol)

try:
status = plugin_client.test()
Expand All @@ -263,7 +259,7 @@ def register_plugin(address, protocol):
# with the plugin. Now, we should get its metainfo and create a Plugin
# instance with it.
try:
meta = plugin_client.metainfo()
meta = plugin_client.metadata()
except Exception as e:
logger.warning(_('Failed to get plugin metadata at address {}: {}').format(address, e))
return None
Expand Down
5 changes: 0 additions & 5 deletions synse_server/proto/__init__.py

This file was deleted.

Loading

0 comments on commit 75e1623

Please sign in to comment.