Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GÉANT Service Orchestrator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
GÉANT Orchestration and Automation Team
GAP
GÉANT Service Orchestrator
Commits
52058e9d
Commit
52058e9d
authored
11 months ago
by
Karel van Klink
Committed by
Neda Moeini
8 months ago
Browse files
Options
Downloads
Patches
Plain Diff
replace calls to += with append
parent
66ac933a
No related branches found
No related tags found
1 merge request
!139
Feature/add validation workflows
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gso/services/librenms_client.py
+2
-2
2 additions, 2 deletions
gso/services/librenms_client.py
gso/workflows/iptrunk/validate_iptrunk.py
+33
-47
33 additions, 47 deletions
gso/workflows/iptrunk/validate_iptrunk.py
with
35 additions
and
49 deletions
gso/services/librenms_client.py
+
2
−
2
View file @
52058e9d
...
...
@@ -102,10 +102,10 @@ class LibreNMSClient:
device
=
self
.
get_device
(
fqdn
)
if
device
[
"
devices
"
][
0
][
"
hostname
"
]
!=
fqdn
:
errors
+=
[
"
Device hostname in LibreNMS does not match FQDN.
"
]
errors
.
append
(
"
Device hostname in LibreNMS does not match FQDN.
"
)
except
HTTPError
as
e
:
if
e
.
response
.
status_code
==
HTTPStatus
.
NOT_FOUND
:
errors
+=
[
"
Device does not exist in LibreNMS.
"
]
errors
.
append
(
"
Device does not exist in LibreNMS.
"
)
else
:
raise
...
...
This diff is collapsed.
Click to expand it.
gso/workflows/iptrunk/validate_iptrunk.py
+
33
−
47
View file @
52058e9d
...
...
@@ -42,13 +42,11 @@ def verify_ipam_records(subscription: Iptrunk) -> None:
ipam_v6_network
=
infoblox
.
find_network_by_cidr
(
subscription
.
iptrunk
.
iptrunk_ipv6_network
)
if
not
ipam_v4_network
or
not
ipam_v6_network
:
ipam_errors
+=
[
(
"
Missing IP trunk IPAM records, found the following instead.
\n
"
f
"
IPv4 expected
'
{
subscription
.
iptrunk
.
iptrunk_ipv4_network
}
'
, actual:
'
{
ipam_v4_network
}
'
\n
"
f
"
IPv6 expected
'
{
subscription
.
iptrunk
.
iptrunk_ipv6_network
}
'
, actual:
'
{
ipam_v6_network
}
'"
)
]
ipam_errors
.
append
(
"
Missing IP trunk IPAM records, found the following instead.
\n
"
f
"
IPv4 expected
'
{
subscription
.
iptrunk
.
iptrunk_ipv4_network
}
'
, actual:
'
{
ipam_v4_network
}
'
\n
"
f
"
IPv6 expected
'
{
subscription
.
iptrunk
.
iptrunk_ipv6_network
}
'
, actual:
'
{
ipam_v6_network
}
'"
)
for
index
,
side
in
enumerate
(
subscription
.
iptrunk
.
iptrunk_sides
):
lag_fqdn
=
f
"
{
side
.
iptrunk_side_ae_iface
}
.
{
side
.
iptrunk_side_node
.
router_fqdn
}
"
...
...
@@ -57,48 +55,40 @@ def verify_ipam_records(subscription: Iptrunk) -> None:
# Validate IPv4 address allocation
record
=
infoblox
.
find_host_by_fqdn
(
lag_fqdn
)
if
not
record
:
ipam_errors
+=
[
f
"
No IPv4 host record found with FQDN
'
{
lag_fqdn
}
'"
]
ipam_errors
.
append
(
f
"
No IPv4 host record found with FQDN
'
{
lag_fqdn
}
'"
)
else
:
# Allocation inside IPv4 network must be correct
if
str
(
side_v4
)
!=
record
.
ipv4addr
:
ipam_errors
+=
[
(
f
"
Incorrectly allocated host record for FQDN
'
{
lag_fqdn
}
'
.
\n
"
f
"
Expected
'
{
side_v4
}
'
, actual:
'
{
record
.
ipv4addr
}
'"
)
]
ipam_errors
.
append
(
f
"
Incorrectly allocated host record for FQDN
'
{
lag_fqdn
}
'
.
\n
"
f
"
Expected
'
{
side_v4
}
'
, actual:
'
{
record
.
ipv4addr
}
'"
)
# Allocated host record needs to be set correctly
if
record
.
comment
!=
str
(
subscription
.
subscription_id
):
ipam_errors
+=
[
(
f
"
Incorrect host record found for
'
{
lag_fqdn
}
'
at
'
{
side_v4
}
'
. Comment should have been equal
"
f
"
to subscription ID
'
{
subscription
.
subscription_id
}
'
.
"
)
]
ipam_errors
.
append
(
f
"
Incorrect host record found for
'
{
lag_fqdn
}
'
at
'
{
side_v4
}
'
. Comment should have been equal
"
f
"
to subscription ID
'
{
subscription
.
subscription_id
}
'
.
"
)
# Validate IPv6 address allocation
record
=
infoblox
.
find_v6_host_by_fqdn
(
lag_fqdn
)
if
not
record
:
ipam_errors
+=
[
f
"
No IPv6 host record found with FQDN
'
{
lag_fqdn
}
'"
]
ipam_errors
.
append
(
f
"
No IPv6 host record found with FQDN
'
{
lag_fqdn
}
'"
)
else
:
# Allocation inside IPv6 network must be correct
if
str
(
side_v6
)
!=
record
.
ipv6addr
:
ipam_errors
+=
[
(
f
"
Incorrectly allocated host record for FQDN
'
{
lag_fqdn
}
'
.
\n
"
f
"
Expected
'
{
side_v6
}
'
, actual:
'
{
record
.
ipv6addr
}
'"
)
]
ipam_errors
.
append
(
f
"
Incorrectly allocated host record for FQDN
'
{
lag_fqdn
}
'
.
\n
"
f
"
Expected
'
{
side_v6
}
'
, actual:
'
{
record
.
ipv6addr
}
'"
)
# Allocated host record needs to be set correctly
if
record
.
comment
!=
str
(
subscription
.
subscription_id
):
ipam_errors
+=
[
(
f
"
Incorrect host record found for
'
{
lag_fqdn
}
'
at
'
{
side_v6
}
'
. Comment should have been equal
"
f
"
to subscription ID
'
{
subscription
.
subscription_id
}
'
.
"
)
]
ipam_errors
.
append
(
f
"
Incorrect host record found for
'
{
lag_fqdn
}
'
at
'
{
side_v6
}
'
. Comment should have been equal
"
f
"
to subscription ID
'
{
subscription
.
subscription_id
}
'
.
"
)
if
ipam_errors
:
raise
ProcessFailureError
(
message
=
"
IPAM misconfiguration(s) found
"
,
details
=
str
(
ipam_errors
))
...
...
@@ -116,27 +106,23 @@ def verify_netbox_entries(subscription: Iptrunk) -> None:
side
.
iptrunk_side_ae_iface
,
side
.
iptrunk_side_node
.
router_fqdn
)
if
interface
.
description
!=
str
(
subscription
.
subscription_id
):
netbox_errors
+=
[
(
f
"
Incorrect description for
'
{
side
.
iptrunk_side_ae_iface
}
'
, expected
"
f
"'
{
subscription
.
subscription_id
}
'
but got
'
{
interface
.
description
}
'"
)
]
netbox_errors
.
append
(
f
"
Incorrect description for
'
{
side
.
iptrunk_side_ae_iface
}
'
, expected
"
f
"'
{
subscription
.
subscription_id
}
'
but got
'
{
interface
.
description
}
'"
)
if
not
interface
.
enabled
:
netbox_errors
+=
[
f
"
NetBox interface
'
{
side
.
iptrunk_side_ae_iface
}
'
is not enabled.
"
]
netbox_errors
.
append
(
f
"
NetBox interface
'
{
side
.
iptrunk_side_ae_iface
}
'
is not enabled.
"
)
for
member
in
side
.
iptrunk_side_ae_members
:
interface
=
nbclient
.
get_interface_by_name_and_device
(
member
.
interface_name
,
side
.
iptrunk_side_node
.
router_fqdn
)
if
interface
.
description
!=
str
(
subscription
.
subscription_id
):
netbox_errors
+=
[
(
f
"
Incorrect description for
'
{
member
.
interface_name
}
'
, expected
"
f
"'
{
subscription
.
subscription_id
}
'
but got
'
{
interface
.
description
}
'"
)
]
netbox_errors
.
append
(
f
"
Incorrect description for
'
{
member
.
interface_name
}
'
, expected
"
f
"'
{
subscription
.
subscription_id
}
'
but got
'
{
interface
.
description
}
'"
)
if
not
interface
.
enabled
:
netbox_errors
+=
[
f
"
NetBox interface
'
{
side
.
iptrunk_side_ae_iface
}
'
is not enabled.
"
]
netbox_errors
.
append
(
f
"
NetBox interface
'
{
side
.
iptrunk_side_ae_iface
}
'
is not enabled.
"
)
if
netbox_errors
:
raise
ProcessFailureError
(
message
=
"
NetBox misconfiguration(s) found
"
,
details
=
str
(
netbox_errors
))
...
...
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