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
af53a9d7
Commit
af53a9d7
authored
5 months ago
by
Lluis Gifre Renom
Browse files
Options
Downloads
Patches
Plain Diff
Pre-merge code fixes and cleanup
parent
79ba36d6
No related branches found
No related tags found
2 merge requests
!294
Release TeraFlowSDN 4.0
,
!285
Resolve: "(CNIT) New SBI Driver based on OpenROADM for ROADMs"
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
deploy/crdb.sh
+2
-3
2 additions, 3 deletions
deploy/crdb.sh
src/common/tests/MockServicerImpl_Context.py
+79
-3
79 additions, 3 deletions
src/common/tests/MockServicerImpl_Context.py
with
81 additions
and
6 deletions
deploy/crdb.sh
+
2
−
3
View file @
af53a9d7
...
...
@@ -158,9 +158,8 @@ function crdb_drop_databases_single() {
echo
"Drop TFS databases, if exist"
if
[[
-z
"
${
GITLAB_CI
}
"
]]
;
then
kubectl
--namespace
${
CRDB_NAMESPACE
}
get service cockroachdb-public
-o
yaml
CRDB_HOST
=
"cockroachdb-0"
#CRDB_HOST=$(kubectl --namespace ${CRDB_NAMESPACE} get service cockroachdb-public -o 'jsonpath={.spec.clusterIP}')
#kubectl --namespace ${CRDB_NAMESPACE} get service cockroachdb-public -o yaml
CRDB_HOST
=
$(
kubectl
--namespace
${
CRDB_NAMESPACE
}
get service cockroachdb-public
-o
'jsonpath={.spec.clusterIP}'
)
CRDB_PORT
=
$(
kubectl
--namespace
${
CRDB_NAMESPACE
}
get service cockroachdb-public
-o
'jsonpath={.spec.ports[?(@.name=="sql")].port}'
)
else
CRDB_HOST
=
"127.0.0.1"
...
...
This diff is collapsed.
Click to expand it.
src/common/tests/MockServicerImpl_Context.py
+
79
−
3
View file @
af53a9d7
...
...
@@ -21,9 +21,11 @@ from common.proto.context_pb2 import (
Device
,
DeviceEvent
,
DeviceFilter
,
DeviceId
,
DeviceIdList
,
DeviceList
,
Empty
,
EventTypeEnum
,
Link
,
LinkEvent
,
LinkId
,
LinkIdList
,
LinkList
,
OpticalLink
,
OpticalLinkList
,
Service
,
ServiceEvent
,
ServiceFilter
,
ServiceId
,
ServiceIdList
,
ServiceList
,
Slice
,
SliceEvent
,
SliceFilter
,
SliceId
,
SliceIdList
,
SliceList
,
Topology
,
TopologyDetails
,
TopologyEvent
,
TopologyId
,
TopologyIdList
,
TopologyList
)
Topology
,
TopologyDetails
,
TopologyEvent
,
TopologyId
,
TopologyIdList
,
TopologyList
)
from
common.proto.context_pb2_grpc
import
ContextServiceServicer
from
common.proto.policy_pb2
import
PolicyRule
,
PolicyRuleId
,
PolicyRuleIdList
,
PolicyRuleList
from
common.tools.grpc.Tools
import
grpc_message_to_json
,
grpc_message_to_json_string
...
...
@@ -31,8 +33,10 @@ from common.tools.object_factory.Device import json_device_id
from
common.tools.object_factory.Link
import
json_link_id
from
.InMemoryObjectDatabase
import
InMemoryObjectDatabase
from
.MockMessageBroker
import
(
TOPIC_CONNECTION
,
TOPIC_CONTEXT
,
TOPIC_DEVICE
,
TOPIC_LINK
,
TOPIC_SERVICE
,
TOPIC_SLICE
,
TOPIC_TOPOLOGY
,
TOPIC_POLICY
,
MockMessageBroker
,
notify_event
)
TOPIC_CONNECTION
,
TOPIC_CONTEXT
,
TOPIC_DEVICE
,
TOPIC_LINK
,
TOPIC_SERVICE
,
TOPIC_SLICE
,
TOPIC_TOPOLOGY
,
TOPIC_POLICY
,
MockMessageBroker
,
notify_event
)
LOGGER
=
logging
.
getLogger
(
__name__
)
...
...
@@ -579,6 +583,7 @@ class MockServicerImpl_Context(ContextServiceServicer):
LOGGER
.
debug
(
'
[SelectService] reply={:s}
'
.
format
(
grpc_message_to_json_string
(
reply
)))
return
reply
# ----- Connection -------------------------------------------------------------------------------------------------
def
ListConnectionIds
(
self
,
request
:
ServiceId
,
context
:
grpc
.
ServicerContext
)
->
ConnectionIdList
:
...
...
@@ -628,6 +633,9 @@ class MockServicerImpl_Context(ContextServiceServicer):
LOGGER
.
debug
(
'
[GetConnectionEvents] request={:s}
'
.
format
(
grpc_message_to_json_string
(
request
)))
for
message
in
self
.
msg_broker
.
consume
({
TOPIC_CONNECTION
}):
yield
ConnectionEvent
(
**
json
.
loads
(
message
.
content
))
# ----- Policy Rule ------------------------------------------------------------------------------------------------
def
ListPolicyRuleIds
(
self
,
request
:
Empty
,
context
:
grpc
.
ServicerContext
):
# pylint: disable=unused-argument
LOGGER
.
debug
(
'
[ListPolicyRuleIds] request={:s}
'
.
format
(
grpc_message_to_json_string
(
request
)))
reply
=
PolicyRuleIdList
(
policyRuleIdList
=
[
...
...
@@ -666,3 +674,71 @@ class MockServicerImpl_Context(ContextServiceServicer):
reply
=
self
.
_del
(
request
,
'
policy
'
,
policy_uuid
,
rule_id_field
,
TOPIC_CONTEXT
,
context
)
LOGGER
.
debug
(
'
[RemovePolicyRule] reply={:s}
'
.
format
(
grpc_message_to_json_string
(
reply
)))
return
reply
# ----- Optical Link -----------------------------------------------------------------------------------------------
def
GetOpticalLinkList
(
self
,
request
:
Empty
,
context
:
grpc
.
ServicerContext
)
->
OpticalLinkList
:
LOGGER
.
debug
(
'
[GetOpticalLinkList] request={:s}
'
.
format
(
grpc_message_to_json_string
(
request
)))
reply
=
OpticalLinkList
(
optical_links
=
self
.
obj_db
.
get_entries
(
'
optical_link
'
))
LOGGER
.
debug
(
'
[GetOpticalLinkList] reply={:s}
'
.
format
(
grpc_message_to_json_string
(
reply
)))
return
reply
def
GetOpticalLink
(
self
,
request
:
LinkId
,
context
:
grpc
.
ServicerContext
)
->
OpticalLink
:
LOGGER
.
debug
(
'
[GetOpticalLink] request={:s}
'
.
format
(
grpc_message_to_json_string
(
request
)))
reply
=
self
.
obj_db
.
get_entry
(
'
optical_link
'
,
request
.
link_uuid
.
uuid
,
context
)
LOGGER
.
debug
(
'
[GetOpticalLink] reply={:s}
'
.
format
(
grpc_message_to_json_string
(
reply
)))
return
reply
def
SetOpticalLink
(
self
,
request
:
OpticalLink
,
context
:
grpc
.
ServicerContext
)
->
Empty
:
LOGGER
.
debug
(
'
[SetOpticalLink] request={:s}
'
.
format
(
grpc_message_to_json_string
(
request
)))
link_uuid
=
request
.
link_id
.
link_uuid
.
uuid
reply
,
link
=
self
.
_set
(
request
,
'
optical_link
'
,
link_uuid
,
'
link_id
'
,
TOPIC_LINK
)
context_topology_uuids
:
Set
[
Tuple
[
str
,
str
]]
=
set
()
context_topology_uuids
.
add
((
DEFAULT_CONTEXT_NAME
,
DEFAULT_TOPOLOGY_NAME
))
for
endpoint_id
in
link
.
link_endpoint_ids
:
endpoint_context_uuid
=
endpoint_id
.
topology_id
.
context_id
.
context_uuid
.
uuid
if
len
(
endpoint_context_uuid
)
==
0
:
endpoint_context_uuid
=
DEFAULT_CONTEXT_NAME
endpoint_topology_uuid
=
endpoint_id
.
topology_id
.
topology_uuid
.
uuid
if
len
(
endpoint_topology_uuid
)
==
0
:
endpoint_topology_uuid
=
DEFAULT_TOPOLOGY_NAME
context_topology_uuids
.
add
((
endpoint_context_uuid
,
endpoint_topology_uuid
))
for
context_uuid
,
topology_uuid
in
context_topology_uuids
:
container_name
=
'
topology[{:s}]
'
.
format
(
str
(
context_uuid
))
topology
=
self
.
obj_db
.
get_entry
(
container_name
,
topology_uuid
,
context
)
for
_optical_link_id
in
topology
.
optical_link_ids
:
if
_optical_link_id
.
link_uuid
.
uuid
==
link_uuid
:
break
else
:
# link not found, add it
topology
.
optical_link_ids
.
add
().
link_uuid
.
uuid
=
link_uuid
reply
=
Empty
()
LOGGER
.
debug
(
'
[SetOpticalLink] reply={:s}
'
.
format
(
grpc_message_to_json_string
(
reply
)))
return
reply
def
DeleteOpticalLink
(
self
,
request
:
LinkId
,
context
:
grpc
.
ServicerContext
)
->
Empty
:
LOGGER
.
debug
(
'
[DeleteOpticalLink] request={:s}
'
.
format
(
grpc_message_to_json_string
(
request
)))
link_uuid
=
request
.
link_uuid
.
uuid
optical_link
=
self
.
obj_db
.
get_entry
(
'
optical_link
'
,
link_uuid
,
context
)
reply
=
self
.
_del
(
request
,
'
optical_link
'
,
link_uuid
,
'
link_id
'
,
TOPIC_LINK
,
context
)
context_topology_uuids
:
Set
[
Tuple
[
str
,
str
]]
=
set
()
context_topology_uuids
.
add
((
DEFAULT_CONTEXT_NAME
,
DEFAULT_TOPOLOGY_NAME
))
for
endpoint_id
in
optical_link
.
link_endpoint_ids
:
endpoint_context_uuid
=
endpoint_id
.
topology_id
.
context_id
.
context_uuid
.
uuid
if
len
(
endpoint_context_uuid
)
==
0
:
endpoint_context_uuid
=
DEFAULT_CONTEXT_NAME
endpoint_topology_uuid
=
endpoint_id
.
topology_id
.
topology_uuid
.
uuid
if
len
(
endpoint_topology_uuid
)
==
0
:
endpoint_topology_uuid
=
DEFAULT_TOPOLOGY_NAME
context_topology_uuids
.
add
((
endpoint_context_uuid
,
endpoint_topology_uuid
))
for
context_uuid
,
topology_uuid
in
context_topology_uuids
:
container_name
=
'
topology[{:s}]
'
.
format
(
str
(
context_uuid
))
topology
=
self
.
obj_db
.
get_entry
(
container_name
,
topology_uuid
,
context
)
for
optical_link_id
in
topology
.
optical_link_ids
:
if
optical_link_id
.
link_uuid
.
uuid
==
link_uuid
:
topology
.
optical_link_ids
.
remove
(
optical_link_id
)
break
LOGGER
.
debug
(
'
[DeleteOpticalLink] reply={:s}
'
.
format
(
grpc_message_to_json_string
(
reply
)))
return
reply
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