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
Commits
e8b426c1
Commit
e8b426c1
authored
2 years ago
by
Lluis Gifre Renom
Browse files
Options
Downloads
Patches
Plain Diff
Service component:
- Minor code cleanup before merging
parent
131d8008
No related branches found
No related tags found
2 merge requests
!142
Release TeraFlowSDN 2.1
,
!89
First implementation of location-aware services
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/service/requirements.in
+2
-2
2 additions, 2 deletions
src/service/requirements.in
src/service/service/ServiceServiceServicerImpl.py
+4
-7
4 additions, 7 deletions
src/service/service/ServiceServiceServicerImpl.py
with
6 additions
and
9 deletions
src/service/requirements.in
+
2
−
2
View file @
e8b426c1
...
...
@@ -14,7 +14,7 @@
anytree==2.8.0
geopy==2.3.0
networkx==2.6.3
pydot==1.4.2
redis==4.1.2
geopy==2.3.0
\ No newline at end of file
redis==4.1.2
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/service/service/ServiceServiceServicerImpl.py
+
4
−
7
View file @
e8b426c1
...
...
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
grpc
,
json
,
logging
import
copy
,
grpc
,
json
,
logging
from
typing
import
Optional
from
common.method_wrappers.Decorator
import
MetricsPool
,
safe_and_metered_rpc_method
from
common.method_wrappers.ServiceExceptions
import
AlreadyExistsException
,
InvalidArgumentException
...
...
@@ -26,7 +26,6 @@ from pathcomp.frontend.client.PathCompClient import PathCompClient
from
.service_handler_api.ServiceHandlerFactory
import
ServiceHandlerFactory
from
.task_scheduler.TaskScheduler
import
TasksScheduler
from
.tools.GeodesicDistance
import
gps_distance
import
copy
LOGGER
=
logging
.
getLogger
(
__name__
)
...
...
@@ -121,18 +120,16 @@ class ServiceServiceServicerImpl(ServiceServiceServicer):
for
config_rule
in
request
.
service_config
.
config_rules
:
service
.
service_config
.
config_rules
.
add
().
CopyFrom
(
config_rule
)
# pylint: disable=no-member
for
constraint
in
request
.
service_constraints
:
if
constraint
.
WhichOneof
(
'
constraint
'
)
==
'
endpoint_location
'
:
context_client
=
ContextClient
()
device_list
=
context_client
.
ListDevices
(
Empty
())
service_location
=
constraint
.
endpoint_location
.
location
distances
=
{}
for
device
in
device_list
.
devices
:
for
endpoint
in
device
.
device_endpoints
:
if
endpoint
.
endpoint_location
.
HasField
(
'
gps_position
'
):
distance
=
gps_distance
(
service_location
.
gps_position
,
endpoint
.
endpoint_location
.
gps_position
)
distances
[
distance
]
=
endpoint
.
endpoint_id
if
not
endpoint
.
endpoint_location
.
HasField
(
'
gps_position
'
):
continue
distance
=
gps_distance
(
service_location
.
gps_position
,
endpoint
.
endpoint_location
.
gps_position
)
distances
[
distance
]
=
endpoint
.
endpoint_id
closer_endpoint_uuid
=
distances
[
min
(
distances
)]
service
.
service_endpoint_ids
.
append
(
closer_endpoint_uuid
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment