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
9433969d
Commit
9433969d
authored
4 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
added timestamp to version & latch schema
optional for now
parent
102dbff6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
inventory_provider/routes/default.py
+26
-25
26 additions, 25 deletions
inventory_provider/routes/default.py
inventory_provider/tasks/common.py
+11
-10
11 additions, 10 deletions
inventory_provider/tasks/common.py
test/test_general_routes.py
+29
-29
29 additions, 29 deletions
test/test_general_routes.py
with
66 additions
and
64 deletions
inventory_provider/routes/default.py
+
26
−
25
View file @
9433969d
...
...
@@ -4,42 +4,43 @@ from flask import Blueprint, jsonify, current_app
from
inventory_provider.routes
import
common
from
inventory_provider.tasks.common
import
get_current_redis
,
get_latch
routes
=
Blueprint
(
"
inventory-data-default-routes
"
,
__name__
)
routes
=
Blueprint
(
'
inventory-data-default-routes
'
,
__name__
)
API_VERSION
=
'
0.1
'
VERSION_SCHEMA
=
{
"
$schema
"
:
"
http://json-schema.org/draft-07/schema#
"
,
'
$schema
'
:
'
http://json-schema.org/draft-07/schema#
'
,
"
definitions
"
:
{
"
latch
"
:
{
"
type
"
:
"
object
"
,
"
properties
"
:
{
"
current
"
:
{
"
type
"
:
"
integer
"
},
"
next
"
:
{
"
type
"
:
"
integer
"
},
"
this
"
:
{
"
type
"
:
"
integer
"
},
"
failure
"
:
{
"
type
"
:
"
boolean
"
},
"
pending
"
:
{
"
type
"
:
"
boolean
"
},
'
definitions
'
:
{
'
latch
'
:
{
'
type
'
:
'
object
'
,
'
properties
'
:
{
'
current
'
:
{
'
type
'
:
'
integer
'
},
'
next
'
:
{
'
type
'
:
'
integer
'
},
'
this
'
:
{
'
type
'
:
'
integer
'
},
'
failure
'
:
{
'
type
'
:
'
boolean
'
},
'
pending
'
:
{
'
type
'
:
'
boolean
'
},
'
timestamp
'
:
{
'
type
'
:
'
number
'
}
},
"
required
"
:
[
"
current
"
,
"
next
"
,
"
this
"
,
"
pending
"
,
"
failure
"
],
"
additionalProperties
"
:
False
'
required
'
:
[
'
current
'
,
'
next
'
,
'
this
'
,
'
pending
'
,
'
failure
'
],
'
additionalProperties
'
:
False
}
},
"
type
"
:
"
object
"
,
"
properties
"
:
{
"
api
"
:
{
"
type
"
:
"
string
"
,
"
pattern
"
:
r
'
\d+\.\d+
'
'
type
'
:
'
object
'
,
'
properties
'
:
{
'
api
'
:
{
'
type
'
:
'
string
'
,
'
pattern
'
:
r
'
\d+\.\d+
'
},
"
module
"
:
{
"
type
"
:
"
string
"
,
"
pattern
"
:
r
'
\d+\.\d+
'
'
module
'
:
{
'
type
'
:
'
string
'
,
'
pattern
'
:
r
'
\d+\.\d+
'
},
"
latch
"
:
{
"
$ref
"
:
"
#/definitions/latch
"
}
'
latch
'
:
{
'
$ref
'
:
'
#/definitions/latch
'
}
},
"
required
"
:
[
"
api
"
,
"
module
"
],
"
additionalProperties
"
:
False
'
required
'
:
[
'
api
'
,
'
module
'
],
'
additionalProperties
'
:
False
}
...
...
@@ -48,7 +49,7 @@ def after_request(resp):
return
common
.
after_request
(
resp
)
@routes.route
(
"
/version
"
,
methods
=
[
'
GET
'
,
'
POST
'
])
@routes.route
(
'
/version
'
,
methods
=
[
'
GET
'
,
'
POST
'
])
@common.require_accepts_json
def
version
():
"""
...
...
This diff is collapsed.
Click to expand it.
inventory_provider/tasks/common.py
+
11
−
10
View file @
9433969d
...
...
@@ -11,17 +11,18 @@ DEFAULT_REDIS_SENTINEL_TIMEOUT = 0.1
DEFAULT_SENTINEL_SOCKET_TIMEOUT
=
0.1
DB_LATCH_SCHEMA
=
{
"
$schema
"
:
"
http://json-schema.org/draft-07/schema#
"
,
"
type
"
:
"
object
"
,
"
properties
"
:
{
"
current
"
:
{
"
type
"
:
"
integer
"
},
"
next
"
:
{
"
type
"
:
"
integer
"
},
"
this
"
:
{
"
type
"
:
"
integer
"
},
"
pending
"
:
{
"
type
"
:
"
boolean
"
},
"
failure
"
:
{
"
type
"
:
"
boolean
"
}
'
$schema
'
:
'
http://json-schema.org/draft-07/schema#
'
,
'
type
'
:
'
object
'
,
'
properties
'
:
{
'
current
'
:
{
'
type
'
:
'
integer
'
},
'
next
'
:
{
'
type
'
:
'
integer
'
},
'
this
'
:
{
'
type
'
:
'
integer
'
},
'
pending
'
:
{
'
type
'
:
'
boolean
'
},
'
failure
'
:
{
'
type
'
:
'
boolean
'
},
'
timestamp
'
:
{
'
type
'
:
'
number
'
}
},
"
required
"
:
[
"
current
"
,
"
next
"
,
"
this
"
],
"
additionalProperties
"
:
False
'
required
'
:
[
'
current
'
,
'
next
'
,
'
this
'
],
'
additionalProperties
'
:
False
}
TASK_LOG_SCHEMA
=
{
...
...
This diff is collapsed.
Click to expand it.
test/test_general_routes.py
+
29
−
29
View file @
9433969d
...
...
@@ -5,59 +5,59 @@ from inventory_provider.routes import common
from
inventory_provider.routes.default
import
VERSION_SCHEMA
DEFAULT_REQUEST_HEADERS
=
{
"
Content-type
"
:
"
application/json
"
,
"
Accept
"
:
[
"
application/json
"
]
'
Content-type
'
:
'
application/json
'
,
'
Accept
'
:
[
'
application/json
'
]
}
def
test_version_request
(
client
,
mocked_redis
):
rv
=
client
.
post
(
"
version
"
,
'
version
'
,
headers
=
DEFAULT_REQUEST_HEADERS
)
assert
rv
.
status_code
==
200
jsonschema
.
validate
(
json
.
loads
(
rv
.
data
.
decode
(
"
utf-8
"
)),
json
.
loads
(
rv
.
data
.
decode
(
'
utf-8
'
)),
VERSION_SCHEMA
)
def
test_load_json_docs
(
data_config
,
mocked_redis
):
INTERFACE_SCHEMA
=
{
"
$schema
"
:
"
http://json-schema.org/draft-07/schema#
"
,
'
$schema
'
:
'
http://json-schema.org/draft-07/schema#
'
,
"
definitions
"
:
{
"
interface
"
:
{
"
type
"
:
"
object
"
,
"
properties
"
:
{
"
logical-system
"
:
{
"
type
"
:
"
string
"
},
"
name
"
:
{
"
type
"
:
"
string
"
},
"
description
"
:
{
"
type
"
:
"
string
"
},
"
bundle
"
:
{
"
type
"
:
"
array
"
,
"
items
"
:
{
"
type
"
:
"
string
"
}
'
definitions
'
:
{
'
interface
'
:
{
'
type
'
:
'
object
'
,
'
properties
'
:
{
'
logical-system
'
:
{
'
type
'
:
'
string
'
},
'
name
'
:
{
'
type
'
:
'
string
'
},
'
description
'
:
{
'
type
'
:
'
string
'
},
'
bundle
'
:
{
'
type
'
:
'
array
'
,
'
items
'
:
{
'
type
'
:
'
string
'
}
},
"
ipv4
"
:
{
"
type
"
:
"
array
"
,
"
items
"
:
{
"
type
"
:
"
string
"
}
'
ipv4
'
:
{
'
type
'
:
'
array
'
,
'
items
'
:
{
'
type
'
:
'
string
'
}
},
"
ipv6
"
:
{
"
type
"
:
"
array
"
,
"
items
"
:
{
"
type
"
:
"
string
"
}
'
ipv6
'
:
{
'
type
'
:
'
array
'
,
'
items
'
:
{
'
type
'
:
'
string
'
}
}
},
"
required
"
:
[
"
name
"
,
"
description
"
,
"
ipv4
"
,
"
ipv6
"
],
"
additionalProperties
"
:
False
'
required
'
:
[
'
name
'
,
'
description
'
,
'
ipv4
'
,
'
ipv6
'
],
'
additionalProperties
'
:
False
}
},
"
type
"
:
"
object
"
,
"
properties
"
:
{
"
key
"
:
{
"
type
"
:
"
string
"
},
"
value
"
:
{
"
$ref
"
:
"
#/definitions/interface
"
}
'
type
'
:
'
object
'
,
'
properties
'
:
{
'
key
'
:
{
'
type
'
:
'
string
'
},
'
value
'
:
{
'
$ref
'
:
'
#/definitions/interface
'
}
},
"
required
"
:
[
"
key
"
,
"
value
"
],
"
additionalProperties
"
:
False
'
required
'
:
[
'
key
'
,
'
value
'
],
'
additionalProperties
'
:
False
}
for
ifc
in
common
.
load_json_docs
(
...
...
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