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
681e6276
Commit
681e6276
authored
2 months ago
by
Shayan Hajipour
Browse files
Options
Downloads
Patches
Plain Diff
debug & refactor: ConnectionEntry added as a dependency of the ConnectionEntry
parent
9f1b13b1
No related branches found
No related tags found
3 merge requests
!346
Draft: support for restconf protocol
,
!345
Draft: support ipinfusion devices via netconf
,
!331
Resolve "Redundant Subservice Creation After Multi-Domain Service Update"
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/pathcomp/frontend/service/algorithms/tools/ComputeSubServices.py
+11
-13
11 additions, 13 deletions
...p/frontend/service/algorithms/tools/ComputeSubServices.py
with
11 additions
and
13 deletions
src/pathcomp/frontend/service/algorithms/tools/ComputeSubServices.py
+
11
−
13
View file @
681e6276
...
@@ -61,9 +61,11 @@ class ConnectionEntry:
...
@@ -61,9 +61,11 @@ class ConnectionEntry:
uuid
:
str
=
''
uuid
:
str
=
''
service_type
:
ServiceTypeEnum
=
ServiceTypeEnum
.
SERVICETYPE_UNKNOWN
service_type
:
ServiceTypeEnum
=
ServiceTypeEnum
.
SERVICETYPE_UNKNOWN
path_hops
:
List
[
Dict
]
=
field
(
default_factory
=
list
)
path_hops
:
List
[
Dict
]
=
field
(
default_factory
=
list
)
dependencies
:
List
[
str
]
=
field
(
default_factory
=
list
)
dependencies
:
List
[
'
ConnectionEntry
'
]
=
field
(
default_factory
=
list
)
def
calculate_subservice_uuid
(
self
,
main_service_uuid
:
str
)
->
None
:
def
calculate_subservice_uuid
(
self
,
main_service_uuid
:
str
)
->
None
:
if
self
.
uuid
:
return
composed_string
=
main_service_uuid
+
'
-
'
.
join
(
composed_string
=
main_service_uuid
+
'
-
'
.
join
(
f
'
{
path_hop
[
"
device
"
]
}
/
{
path_hop
[
"
ingress_ep
"
]
}
/
{
path_hop
[
"
egress_ep
"
]
}
'
for
path_hop
in
self
.
path_hops
f
'
{
path_hop
[
"
device
"
]
}
/
{
path_hop
[
"
ingress_ep
"
]
}
/
{
path_hop
[
"
egress_ep
"
]
}
'
for
path_hop
in
self
.
path_hops
)
)
...
@@ -103,28 +105,25 @@ def convert_explicit_path_hops_to_connections(
...
@@ -103,28 +105,25 @@ def convert_explicit_path_hops_to_connections(
prv_service_type
=
connection_stack
.
queue
[
-
1
].
service_type
prv_service_type
=
connection_stack
.
queue
[
-
1
].
service_type
service_type
=
get_service_type
(
res_class
[
1
],
prv_service_type
)
service_type
=
get_service_type
(
res_class
[
1
],
prv_service_type
)
connection_entry
=
ConnectionEntry
(
service_type
=
service_type
,
path_hops
=
[
path_hop
])
connection_entry
=
ConnectionEntry
(
service_type
=
service_type
,
path_hops
=
[
path_hop
])
connection_entry
.
calculate_subservice_uuid
(
main_service_uuid
)
connection_stack
.
put
(
connection_entry
)
connection_stack
.
put
(
connection_entry
)
# underlying connection ended
# underlying connection ended
connection
:
ConnectionEntry
=
connection_stack
.
get
()
connection
:
ConnectionEntry
=
connection_stack
.
get
()
connections
.
append
(
connection
)
connections
.
append
(
connection
)
connection_stack
.
queue
[
-
1
].
dependencies
.
append
(
connection
.
uuid
)
connection_stack
.
queue
[
-
1
].
dependencies
.
append
(
connection
)
#connection_stack.queue[-1][2].append(path_hop)
elif
prv_res_class
[
2
]
is
None
and
res_class
[
2
]
is
not
None
:
elif
prv_res_class
[
2
]
is
None
and
res_class
[
2
]
is
not
None
:
# entering domain of a device controller, create underlying connection
# entering domain of a device controller, create underlying connection
LOGGER
.
debug
(
'
entering domain of a device controller, create underlying connection
'
)
LOGGER
.
debug
(
'
entering domain of a device controller, create underlying connection
'
)
prv_service_type
=
connection_stack
.
queue
[
-
1
].
service_type
prv_service_type
=
connection_stack
.
queue
[
-
1
].
service_type
service_type
=
get_service_type
(
res_class
[
1
],
prv_service_type
)
service_type
=
get_service_type
(
res_class
[
1
],
prv_service_type
)
connection_entry
=
ConnectionEntry
(
service_type
=
service_type
,
path_hops
=
[
path_hop
])
connection_entry
=
ConnectionEntry
(
service_type
=
service_type
,
path_hops
=
[
path_hop
])
connection_entry
.
calculate_subservice_uuid
(
main_service_uuid
)
connection_stack
.
put
(
connection_entry
)
connection_stack
.
put
(
connection_entry
)
elif
prv_res_class
[
2
]
is
not
None
and
res_class
[
2
]
is
None
:
elif
prv_res_class
[
2
]
is
not
None
and
res_class
[
2
]
is
None
:
# leaving domain of a device controller, terminate underlying connection
# leaving domain of a device controller, terminate underlying connection
LOGGER
.
debug
(
'
leaving domain of a device controller, terminate underlying connection
'
)
LOGGER
.
debug
(
'
leaving domain of a device controller, terminate underlying connection
'
)
connection
=
connection_stack
.
get
()
connection
=
connection_stack
.
get
()
connections
.
append
(
connection
)
connections
.
append
(
connection
)
connection_stack
.
queue
[
-
1
].
dependencies
.
append
(
connection
.
uuid
)
connection_stack
.
queue
[
-
1
].
dependencies
.
append
(
connection
)
connection_stack
.
queue
[
-
1
].
path_hops
.
append
(
path_hop
)
connection_stack
.
queue
[
-
1
].
path_hops
.
append
(
path_hop
)
elif
prv_res_class
[
2
]
is
not
None
and
res_class
[
2
]
is
not
None
:
elif
prv_res_class
[
2
]
is
not
None
and
res_class
[
2
]
is
not
None
:
if
prv_res_class
[
2
]
==
res_class
[
2
]:
if
prv_res_class
[
2
]
==
res_class
[
2
]:
...
@@ -136,12 +135,11 @@ def convert_explicit_path_hops_to_connections(
...
@@ -136,12 +135,11 @@ def convert_explicit_path_hops_to_connections(
LOGGER
.
debug
(
'
switching to different device controller, chain connections
'
)
LOGGER
.
debug
(
'
switching to different device controller, chain connections
'
)
connection
=
connection_stack
.
get
()
connection
=
connection_stack
.
get
()
connections
.
append
(
connection
)
connections
.
append
(
connection
)
connection_stack
.
queue
[
-
1
].
dependencies
.
append
(
connection
.
uuid
)
connection_stack
.
queue
[
-
1
].
dependencies
.
append
(
connection
)
prv_service_type
=
connection_stack
.
queue
[
-
1
].
service_type
prv_service_type
=
connection_stack
.
queue
[
-
1
].
service_type
service_type
=
get_service_type
(
res_class
[
1
],
prv_service_type
)
service_type
=
get_service_type
(
res_class
[
1
],
prv_service_type
)
connection_entry
=
ConnectionEntry
(
service_type
=
service_type
,
path_hops
=
[
path_hop
])
connection_entry
=
ConnectionEntry
(
service_type
=
service_type
,
path_hops
=
[
path_hop
])
connection_entry
.
calculate_subservice_uuid
(
main_service_uuid
)
connection_stack
.
put
(
connection_entry
)
connection_stack
.
put
(
connection_entry
)
elif
prv_res_class
[
0
]
is
None
:
elif
prv_res_class
[
0
]
is
None
:
# path ingress
# path ingress
...
@@ -154,7 +152,6 @@ def convert_explicit_path_hops_to_connections(
...
@@ -154,7 +152,6 @@ def convert_explicit_path_hops_to_connections(
prv_service_type
=
connection_stack
.
queue
[
-
1
].
service_type
prv_service_type
=
connection_stack
.
queue
[
-
1
].
service_type
service_type
=
get_service_type
(
res_class
[
1
],
prv_service_type
)
service_type
=
get_service_type
(
res_class
[
1
],
prv_service_type
)
connection_entry
=
ConnectionEntry
(
service_type
=
service_type
,
path_hops
=
[
path_hop
])
connection_entry
=
ConnectionEntry
(
service_type
=
service_type
,
path_hops
=
[
path_hop
])
connection_entry
.
calculate_subservice_uuid
(
main_service_uuid
)
connection_stack
.
put
(
connection_entry
)
connection_stack
.
put
(
connection_entry
)
elif
prv_res_class
[
0
]
==
res_class
[
0
]:
elif
prv_res_class
[
0
]
==
res_class
[
0
]:
# same resource group kind
# same resource group kind
...
@@ -168,19 +165,18 @@ def convert_explicit_path_hops_to_connections(
...
@@ -168,19 +165,18 @@ def convert_explicit_path_hops_to_connections(
LOGGER
.
debug
(
'
chain connections
'
)
LOGGER
.
debug
(
'
chain connections
'
)
connection
=
connection_stack
.
get
()
connection
=
connection_stack
.
get
()
connections
.
append
(
connection
)
connections
.
append
(
connection
)
connection_stack
.
queue
[
-
1
].
dependencies
.
append
(
connection
.
uuid
)
connection_stack
.
queue
[
-
1
].
dependencies
.
append
(
connection
)
prv_service_type
=
connection_stack
.
queue
[
-
1
].
service_type
prv_service_type
=
connection_stack
.
queue
[
-
1
].
service_type
service_type
=
get_service_type
(
res_class
[
1
],
prv_service_type
)
service_type
=
get_service_type
(
res_class
[
1
],
prv_service_type
)
connection_entry
=
ConnectionEntry
(
service_type
=
service_type
,
path_hops
=
[
path_hop
])
connection_entry
=
ConnectionEntry
(
service_type
=
service_type
,
path_hops
=
[
path_hop
])
connection_entry
.
calculate_subservice_uuid
(
main_service_uuid
)
connection_stack
.
put
(
connection_entry
)
connection_stack
.
put
(
connection_entry
)
elif
prv_res_class
[
0
]
<
res_class
[
0
]:
elif
prv_res_class
[
0
]
<
res_class
[
0
]:
# underlying connection ended
# underlying connection ended
LOGGER
.
debug
(
'
underlying connection ended
'
)
LOGGER
.
debug
(
'
underlying connection ended
'
)
connection
=
connection_stack
.
get
()
connection
=
connection_stack
.
get
()
connections
.
append
(
connection
)
connections
.
append
(
connection
)
connection_stack
.
queue
[
-
1
].
dependencies
.
append
(
connection
.
uuid
)
connection_stack
.
queue
[
-
1
].
dependencies
.
append
(
connection
)
connection_stack
.
queue
[
-
1
].
path_hops
.
append
(
path_hop
)
connection_stack
.
queue
[
-
1
].
path_hops
.
append
(
path_hop
)
else
:
else
:
raise
Exception
(
'
Uncontrolled condition
'
)
raise
Exception
(
'
Uncontrolled condition
'
)
...
@@ -193,7 +189,9 @@ def convert_explicit_path_hops_to_connections(
...
@@ -193,7 +189,9 @@ def convert_explicit_path_hops_to_connections(
connections
.
append
(
connection_stack
.
get
())
connections
.
append
(
connection_stack
.
get
())
LOGGER
.
debug
(
'
connections={:s}
'
.
format
(
str
(
connections
)))
LOGGER
.
debug
(
'
connections={:s}
'
.
format
(
str
(
connections
)))
assert
connection_stack
.
empty
()
assert
connection_stack
.
empty
()
return
[(
c
.
uuid
,
c
.
service_type
,
c
.
path_hops
,
c
.
dependencies
)
for
c
in
connections
]
for
c
in
connections
:
c
.
calculate_subservice_uuid
(
main_service_uuid
)
return
[(
c
.
uuid
,
c
.
service_type
,
c
.
path_hops
,
[
cd
.
uuid
for
cd
in
c
.
dependencies
])
for
c
in
connections
]
def
convert_explicit_path_hops_to_plain_connection
(
def
convert_explicit_path_hops_to_plain_connection
(
path_hops
:
List
[
Dict
],
main_service_uuid
:
str
,
main_service_type
:
ServiceTypeEnum
path_hops
:
List
[
Dict
],
main_service_uuid
:
str
,
main_service_type
:
ServiceTypeEnum
...
...
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