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
e57862b5
Commit
e57862b5
authored
1 year ago
by
Lluis Gifre Renom
Browse files
Options
Downloads
Patches
Plain Diff
Update ComposeConfigRules.py
parent
f0de9596
No related branches found
No related tags found
2 merge requests
!142
Release TeraFlowSDN 2.1
,
!139
Fixes on OpenConfig and ACLs
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/pathcomp/frontend/service/algorithms/tools/ComposeConfigRules.py
+21
-14
21 additions, 14 deletions
...p/frontend/service/algorithms/tools/ComposeConfigRules.py
with
21 additions
and
14 deletions
src/pathcomp/frontend/service/algorithms/tools/ComposeConfigRules.py
+
21
−
14
View file @
e57862b5
...
@@ -81,6 +81,9 @@ def compose_device_config_rules(
...
@@ -81,6 +81,9 @@ def compose_device_config_rules(
)
->
None
:
)
->
None
:
LOGGER
.
warning
(
'
[compose_device_config_rules] begin
'
)
LOGGER
.
warning
(
'
[compose_device_config_rules] begin
'
)
LOGGER
.
warning
(
'
[compose_device_config_rules] device_name_mapping={:s}
'
.
format
(
str
(
device_name_mapping
)))
LOGGER
.
warning
(
'
[compose_device_config_rules] endpoint_name_mapping={:s}
'
.
format
(
str
(
endpoint_name_mapping
)))
devices_traversed
=
set
()
devices_traversed
=
set
()
endpoints_traversed
=
set
()
endpoints_traversed
=
set
()
for
path_hop
in
path_hops
:
for
path_hop
in
path_hops
:
...
@@ -98,21 +101,25 @@ def compose_device_config_rules(
...
@@ -98,21 +101,25 @@ def compose_device_config_rules(
if
config_rule
.
WhichOneof
(
'
config_rule
'
)
==
'
acl
'
:
if
config_rule
.
WhichOneof
(
'
config_rule
'
)
==
'
acl
'
:
LOGGER
.
warning
(
'
[compose_device_config_rules] is acl
'
)
LOGGER
.
warning
(
'
[compose_device_config_rules] is acl
'
)
acl_endpoint_id
=
config_rule
.
acl
.
endpoint_id
endpoint_id
=
config_rule
.
acl
.
endpoint_id
acl_device_uuid
=
acl_endpoint_id
.
device_id
.
device_uuid
.
uuid
device_uuid_or_name
=
endpoint_id
.
device_id
.
device_uuid
.
uuid
LOGGER
.
warning
(
'
[compose_device_config_rules] acl_device_uuid={:s}
'
.
format
(
str
(
acl_device_uuid
)))
LOGGER
.
warning
(
'
[compose_device_config_rules] device_uuid_or_name={:s}
'
.
format
(
str
(
device_uuid_or_name
)))
if
acl_device_uuid
not
in
devices_traversed
:
continue
device_name_or_uuid
=
device_name_mapping
.
get
(
device_uuid_or_name
,
device_uuid_or_name
)
LOGGER
.
warning
(
'
[compose_device_config_rules] device_name_or_uuid={:s}
'
.
format
(
str
(
device_name_or_uuid
)))
acl_endpoint_uuid
=
acl_endpoint_id
.
endpoint_uuid
.
uuid
device_keys
=
{
device_uuid_or_name
,
device_name_or_uuid
}
LOGGER
.
warning
(
'
[compose_device_config_rules] initial acl_endpoint_uuid={:s}
'
.
format
(
str
(
acl_endpoint_uuid
)))
if
len
(
device_keys
.
intersection
(
devices_traversed
))
==
0
:
continue
endpoint_uuid
=
endpoint_id
.
endpoint_uuid
.
uuid
LOGGER
.
warning
(
'
[compose_device_config_rules] endpoint_uuid={:s}
'
.
format
(
str
(
endpoint_uuid
)))
# given endpoint uuids link 'eth-1/0/20.533', remove last part after the '.'
# given endpoint uuids link 'eth-1/0/20.533', remove last part after the '.'
acl_endpoint_uuid_reversed
=
acl_endpoint_uuid
[::
-
1
]
endpoint_uuid_or_name
=
(
endpoint_uuid
[::
-
1
].
split
(
'
.
'
,
maxsplit
=
1
)[
-
1
])[::
-
1
]
acl_endpoint_uuid_reversed_parts
=
acl_endpoint_uuid_reversed
.
split
(
'
.
'
,
maxsplit
=
1
)
LOGGER
.
warning
(
'
[compose_device_config_rules] endpoint_uuid_or_name={:s}
'
.
format
(
str
(
endpoint_uuid_or_name
)))
acl_endpoint_uuid_reversed_last_part
=
acl_endpoint_uuid_reversed_parts
[
-
1
]
endpoint_name_or_uuid_1
=
endpoint_name_mapping
[(
device_uuid_or_name
,
endpoint_uuid_or_name
)]
acl_endpoint_uuid
=
acl_endpoint_uuid_reversed_last_part
[::
-
1
]
endpoint_name_or_uuid_2
=
endpoint_name_mapping
[(
device_name_or_uuid
,
endpoint_uuid_or_name
)]
LOGGER
.
warning
(
'
[compose_device_config_rules] corrected acl_endpoint_uuid={:s}
'
.
format
(
str
(
acl_endpoint_uuid
)))
endpoint_keys
=
{
endpoint_uuid_or_name
,
endpoint_name_or_uuid_1
,
endpoint_name_or_uuid_2
}
if
acl_endpoint_uuid
not
in
endpoints_traversed
:
continue
device_endpoint_keys
=
set
(
itertools
.
product
(
device_keys
,
endpoint_keys
))
if
len
(
device_endpoint_keys
.
intersection
(
endpoints_traversed
))
==
0
:
continue
LOGGER
.
warning
(
'
[compose_device_config_rules] adding acl config rule
'
)
LOGGER
.
warning
(
'
[compose_device_config_rules] adding acl config rule
'
)
subservice_config_rules
.
append
(
config_rule
)
subservice_config_rules
.
append
(
config_rule
)
...
...
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