Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inventory-provider
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
geant-swd
dashboardv3
inventory-provider
Commits
af6eefe7
Commit
af6eefe7
authored
6 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
remove config element 'routers-community.conf'
parent
d1300849
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
inventory_provider/config.py
+26
-22
26 additions, 22 deletions
inventory_provider/config.py
with
26 additions
and
22 deletions
inventory_provider/config.py
+
26
−
22
View file @
af6eefe7
...
...
@@ -27,7 +27,6 @@ CONFIG_SCHEMA = {
"
alarms-db
"
:
{
"
$ref
"
:
"
#/definitions/database_credentials
"
},
"
ops-db
"
:
{
"
$ref
"
:
"
#/definitions/database_credentials
"
},
"
oid_list.conf
"
:
{
"
type
"
:
"
string
"
},
"
routers_community.conf
"
:
{
"
type
"
:
"
string
"
},
"
ssh
"
:
{
"
type
"
:
"
object
"
,
"
properties
"
:
{
...
...
@@ -47,6 +46,11 @@ CONFIG_SCHEMA = {
"
required
"
:
[
"
hostname
"
,
"
port
"
],
"
additionalProperties
"
:
False
},
"
junosspace
"
:
{
"
api
"
:
{
"
type
"
:
"
string
"
},
"
username
"
:
{
"
type
"
:
"
string
"
},
"
password
"
:
{
"
type
"
:
"
string
"
}
},
"
infinera-dna
"
:
{
"
type
"
:
"
array
"
,
"
items
"
:
{
...
...
@@ -76,9 +80,9 @@ CONFIG_SCHEMA = {
"
alarms-db
"
,
"
ops-db
"
,
"
oid_list.conf
"
,
"
routers_community.conf
"
,
"
ssh
"
,
"
redis
"
,
"
junosspace
"
,
"
infinera-dna
"
,
"
coriant-tnms
"
],
"
additionalProperties
"
:
False
...
...
@@ -98,24 +102,24 @@ def _load_oids(config_file):
return
result
def
_load_routers
(
config_file
):
"""
:param config_file: file-like object
:return:
"""
for
line
in
config_file
:
m
=
re
.
match
(
r
'
^([a-z\d]+\.[a-z\d]{3,4}\.[a-z\d]{2}
'
r
'
\.(geant|eumedconnect)\d*\.net)\s*=([^,]+)\s*,(.*)\s*$
'
,
line
)
if
not
m
:
logging
.
warning
(
"
malformed config file line:
'
%s
'"
%
line
.
strip
())
continue
yield
{
"
hostname
"
:
m
.
group
(
1
),
"
community
"
:
m
.
group
(
3
),
"
address
"
:
m
.
group
(
4
)
}
#
def _load_routers(config_file):
#
"""
#
:param config_file: file-like object
#
:return:
#
"""
#
for line in config_file:
#
m = re.match(
#
r'^([a-z\d]+\.[a-z\d]{3,4}\.[a-z\d]{2}'
#
r'\.(geant|eumedconnect)\d*\.net)\s*=([^,]+)\s*,(.*)\s*$',
#
line)
#
if not m:
#
logging.warning("malformed config file line: '%s'" % line.strip())
#
continue
#
yield {
#
"hostname": m.group(1),
#
"community": m.group(3),
#
"address": m.group(4)
#
}
def
load
(
f
):
...
...
@@ -129,6 +133,6 @@ def load(f):
jsonschema
.
validate
(
config
,
CONFIG_SCHEMA
)
with
open
(
config
[
"
oid_list.conf
"
])
as
f
:
config
[
"
oids
"
]
=
_load_oids
(
f
)
with
open
(
config
[
"
routers_community.conf
"
])
as
f
:
config
[
"
routers
"
]
=
list
(
_load_routers
(
f
))
#
with open(config["routers_community.conf"]) as f:
#
config["routers"] = list(_load_routers(f))
return
config
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