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
606fb96c
Commit
606fb96c
authored
1 month ago
by
Lluis Gifre Renom
Browse files
Options
Downloads
Patches
Plain Diff
Service component - L3NM OpenConfig:
- Corrected management of settings
parent
aee95791
No related branches found
Branches containing commit
No related tags found
2 merge requests
!328
Resolve "(CTTC) Update recommendations to use SocketIO on NBI and E2E Orch components"
,
!286
Resolve "(CTTC) Implement integration test between E2E-IP-Optical SDN Controllers"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py
+51
-29
51 additions, 29 deletions
...e/service/service_handlers/l3nm_openconfig/ConfigRules.py
with
51 additions
and
29 deletions
src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py
+
51
−
29
View file @
606fb96c
...
...
@@ -12,52 +12,74 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
functools
from
typing
import
Any
,
Dict
,
List
,
Optional
,
Tuple
from
common.tools.object_factory.ConfigRule
import
json_config_rule_delete
,
json_config_rule_set
from
service.service.service_handler_api.AnyTreeTools
import
TreeNode
def
get_value
(
field_name
:
str
,
*
containers
,
default
=
None
)
->
Optional
[
Any
]:
def
get_settings_containers
(
service_settings
:
TreeNode
,
device_settings
:
TreeNode
,
endpoint_settings
:
TreeNode
)
->
List
[
Dict
]:
settings_containers
:
List
[
Dict
]
=
list
()
# highest priority settings container
if
endpoint_settings
is
not
None
:
json_endpoint_settings
:
Dict
=
endpoint_settings
.
value
settings_containers
.
append
(
json_endpoint_settings
)
if
device_settings
is
not
None
:
json_device_settings
:
Dict
=
device_settings
.
value
settings_containers
.
append
(
json_device_settings
)
# lowest priority settings container
if
service_settings
is
not
None
:
json_service_settings
:
Dict
=
service_settings
.
value
settings_containers
.
append
(
json_service_settings
)
return
settings_containers
def
get_value
(
containers
:
List
[
Dict
],
field_name
:
str
,
**
kwargs
)
->
Optional
[
Any
]:
if
len
(
containers
)
==
0
:
raise
Exception
(
'
No containers specified
'
)
for
container
in
containers
:
if
field_name
not
in
container
:
continue
return
container
[
field_name
]
return
default
if
'
default
'
in
kwargs
:
return
kwargs
[
'
default
'
]
MSG
=
'
Field({:s}) not found in containers specified({:s}) and no default value specified
'
# pylint: disable=broad-exception-raised
raise
Exception
(
MSG
.
format
(
str
(
field_name
),
str
(
containers
)))
def
setup_config_rules
(
service_uuid
:
str
,
connection_uuid
:
str
,
device_uuid
:
str
,
endpoint_uuid
:
str
,
endpoint_name
:
str
,
service_settings
:
TreeNode
,
device_settings
:
TreeNode
,
endpoint_settings
:
TreeNode
,
endpoint_acls
:
List
[
Tuple
]
)
->
List
[
Dict
]:
if
service_settings
is
None
:
return
[]
if
device_settings
is
None
:
return
[]
if
endpoint_settings
is
None
:
return
[]
json_settings
:
Dict
=
service_settings
.
value
json_device_settings
:
Dict
=
device_settings
.
value
json_endpoint_settings
:
Dict
=
endpoint_settings
.
value
settings
=
(
json_settings
,
json_endpoint_settings
,
json_device_settings
)
mtu
=
get_value
(
'
mtu
'
,
*
settings
,
default
=
1450
)
# 1512
#address_families = json_settings.get('address_families', [] ) # ['IPV4']
bgp_as
=
get_value
(
'
bgp_as
'
,
*
settings
,
default
=
65000
)
# 65000
router_id
=
json_endpoint_settings
.
get
(
'
router_id
'
,
'
0.0.0.0
'
)
# '10.95.0.10'
route_distinguisher
=
json_settings
.
get
(
'
route_distinguisher
'
,
'
65000:101
'
)
# '60001:801'
sub_interface_index
=
json_endpoint_settings
.
get
(
'
sub_interface_index
'
,
0
)
# 1
vlan_id
=
json_endpoint_settings
.
get
(
'
vlan_id
'
,
1
)
# 400
address_ip
=
json_endpoint_settings
.
get
(
'
address_ip
'
,
'
0.0.0.0
'
)
# '2.2.2.1'
address_prefix
=
json_endpoint_settings
.
get
(
'
address_prefix
'
,
24
)
# 30
policy_import
=
json_endpoint_settings
.
get
(
'
policy_AZ
'
,
'
2
'
)
# 2
policy_export
=
json_endpoint_settings
.
get
(
'
policy_ZA
'
,
'
7
'
)
# 30
settings_containers
:
Tuple
[
Dict
]
=
get_settings_containers
(
service_settings
,
device_settings
,
endpoint_settings
)
get_settings_value
=
functools
.
partial
(
get_value
,
settings_containers
)
mtu
=
get_settings_value
(
'
mtu
'
,
default
=
1450
)
# 1512
#address_families = get_settings_value('address_families', default=[] ) # ['IPV4']
bgp_as
=
get_settings_value
(
'
bgp_as
'
,
default
=
65000
)
# 65000
router_id
=
get_settings_value
(
'
router_id
'
,
default
=
'
0.0.0.0
'
)
# '10.95.0.10'
route_distinguisher
=
get_settings_value
(
'
route_distinguisher
'
,
default
=
'
65000:101
'
)
# '60001:801'
sub_interface_index
=
get_settings_value
(
'
sub_interface_index
'
,
default
=
0
)
# 1
vlan_id
=
get_settings_value
(
'
vlan_id
'
,
default
=
1
)
# 400
address_ip
=
get_settings_value
(
'
address_ip
'
,
default
=
'
0.0.0.0
'
)
# '2.2.2.1'
address_prefix
=
get_settings_value
(
'
address_prefix
'
,
default
=
24
)
# 30
policy_import
=
get_settings_value
(
'
policy_AZ
'
,
default
=
'
2
'
)
# 2
policy_export
=
get_settings_value
(
'
policy_ZA
'
,
default
=
'
7
'
)
# 30
#network_interface_desc = '{:s}-NetIf'.format(service_uuid)
network_interface_desc
=
json_endpoin
t_settings
.
get
(
'
ni_description
'
,
''
)
network_interface_desc
=
ge
t_settings
_value
(
'
ni_description
'
,
default
=
''
)
#network_subinterface_desc = '{:s}-NetSubIf'.format(service_uuid)
network_subinterface_desc
=
json_endpoin
t_settings
.
get
(
'
subif_description
'
,
''
)
#
service_short_uuid = service_uuid.split('-')[-1]
network_subinterface_desc
=
ge
t_settings
_value
(
'
subif_description
'
,
default
=
''
)
service_short_uuid
=
service_uuid
.
split
(
'
-
'
)[
-
1
]
#network_instance_name = '{:s}-NetInst'.format(service_short_uuid)
network_instance_name
=
json_endpoin
t_settings
.
get
(
'
ni_name
'
,
service_uuid
.
split
(
'
-
'
)[
-
1
])
#ELAN-AC:1
network_instance_name
=
ge
t_settings
_value
(
'
ni_name
'
,
default
=
service_short_uuid
)
#ELAN-AC:1
if_subif_name
=
'
{:s}.{:d}
'
.
format
(
endpoint_name
,
vlan_id
)
...
...
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