Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
controller
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TFS
controller
Merge requests
!192
Resolve "Implement Optical component"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Implement Optical component"
feat/106-implement-optical-component
into
develop
Overview
0
Commits
4
Pipelines
9
Changes
17
Merged
Lluis Gifre Renom
requested to merge
feat/106-implement-optical-component
into
develop
1 year ago
Overview
0
Commits
4
Pipelines
9
Changes
17
Expand
Closes
#106 (closed)
0
0
Merge request reports
Viewing commit
2673daca
Show latest version
17 files
+
1347
−
8
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
17
Search (e.g. *.vue) (Ctrl+P)
2673daca
opticalcontroller device
· 2673daca
Andrea Sgambelluri
authored
1 year ago
src/device/client/DeviceClient.py
+
9
−
2
Options
@@ -15,12 +15,12 @@
import
grpc
,
logging
from
common.Constants
import
ServiceNameEnum
from
common.Settings
import
get_service_host
,
get_service_port_grpc
from
common.proto.context_pb2
import
Device
,
DeviceConfig
,
DeviceId
,
Empty
from
common.proto.context_pb2
import
Device
,
DeviceConfig
,
DeviceId
,
Empty
,
MyConfig
,
MyConfigId
from
common.proto.device_pb2
import
MonitoringSettings
from
common.proto.device_pb2_grpc
import
DeviceServiceStub
from
common.tools.client.RetryDecorator
import
retry
,
delay_exponential
from
common.tools.grpc.Tools
import
grpc_message_to_json_string
from
common.proto.openconfig_device_pb2_grpc
import
OpenConfigServiceStub
LOGGER
=
logging
.
getLogger
(
__name__
)
MAX_RETRIES
=
15
DELAY_FUNCTION
=
delay_exponential
(
initial
=
0.01
,
increment
=
2.0
,
maximum
=
5.0
)
@@ -34,12 +34,14 @@ class DeviceClient:
LOGGER
.
debug
(
'
Creating channel to {:s}...
'
.
format
(
str
(
self
.
endpoint
)))
self
.
channel
=
None
self
.
stub
=
None
self
.
openconfig_stub
=
None
self
.
connect
()
LOGGER
.
debug
(
'
Channel created
'
)
def
connect
(
self
):
self
.
channel
=
grpc
.
insecure_channel
(
self
.
endpoint
)
self
.
stub
=
DeviceServiceStub
(
self
.
channel
)
self
.
openconfig_stub
=
OpenConfigServiceStub
(
self
.
channel
)
def
close
(
self
):
if
self
.
channel
is
not
None
:
self
.
channel
.
close
()
@@ -80,3 +82,8 @@ class DeviceClient:
response
=
self
.
stub
.
MonitorDeviceKpi
(
request
)
LOGGER
.
debug
(
'
MonitorDeviceKpi result: {:s}
'
.
format
(
grpc_message_to_json_string
(
response
)))
return
response
def
ConfigureOpticalDevice
(
self
,
request
:
MyConfig
)
->
MyConfigId
:
response
=
self
.
openconfig_stub
.
ConfigureOpticalDevice
(
request
)
return
response
Loading