Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
Warden
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pavel Valach
Warden
Commits
aac2b3ed
Commit
aac2b3ed
authored
2 years ago
by
Jakub Maloštík
Browse files
Options
Downloads
Patches
Plain Diff
Store valid, read, debug, write and test for clients and valid for events as boolean values
parent
21c1da3a
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
warden_server/test_warden_server.py
+1
-1
1 addition, 1 deletion
warden_server/test_warden_server.py
warden_server/warden_3.0_postgres.sql
+6
-6
6 additions, 6 deletions
warden_server/warden_3.0_postgres.sql
warden_server/warden_server.py
+22
-22
22 additions, 22 deletions
warden_server/warden_server.py
with
29 additions
and
29 deletions
warden_server/test_warden_server.py
+
1
−
1
View file @
aac2b3ed
...
@@ -605,7 +605,7 @@ class PostgreSQL:
...
@@ -605,7 +605,7 @@ class PostgreSQL:
"
(registered, requestor, hostname, note, valid,
"
"
(registered, requestor, hostname, note, valid,
"
"
name, secret, read, debug, write, test)
"
"
name, secret, read, debug, write, test)
"
"
VALUES(NOW(),
'
warden-info@cesnet.cz
'
,
'
test.server.warden.cesnet.cz
'
,
"
"
VALUES(NOW(),
'
warden-info@cesnet.cz
'
,
'
test.server.warden.cesnet.cz
'
,
"
"
NULL,
1
,
'
cz.cesnet.warden3test
'
,
'
abc
'
,
1, 1, 1, 0
)
"
"
NULL,
true
,
'
cz.cesnet.warden3test
'
,
'
abc
'
,
true, true, true, false
)
"
)
)
conn
.
commit
()
conn
.
commit
()
except
self
.
ppg
.
OperationalError
as
ex
:
except
self
.
ppg
.
OperationalError
as
ex
:
...
...
This diff is collapsed.
Click to expand it.
warden_server/warden_3.0_postgres.sql
+
6
−
6
View file @
aac2b3ed
...
@@ -33,13 +33,13 @@ CREATE TABLE IF NOT EXISTS "clients" (
...
@@ -33,13 +33,13 @@ CREATE TABLE IF NOT EXISTS "clients" (
"requestor"
text
NOT
NULL
,
"requestor"
text
NOT
NULL
,
"hostname"
text
NOT
NULL
,
"hostname"
text
NOT
NULL
,
"note"
text
NULL
,
"note"
text
NULL
,
"valid"
smallint
NOT
NULL
DEFAULT
'1'
CHECK
(
"valid"
>=
0
)
,
"valid"
boolean
NOT
NULL
DEFAULT
true
,
"name"
text
NOT
NULL
,
"name"
text
NOT
NULL
,
"secret"
text
NULL
,
"secret"
text
NULL
,
"read"
smallint
NOT
NULL
DEFAULT
'1'
CHECK
(
"read"
>=
0
)
,
"read"
boolean
NOT
NULL
DEFAULT
true
,
"debug"
smallint
NOT
NULL
DEFAULT
'0'
CHECK
(
"debug"
>=
0
)
,
"debug"
boolean
NOT
NULL
DEFAULT
false
,
"write"
smallint
NOT
NULL
DEFAULT
'0'
CHECK
(
"write"
>=
0
)
,
"write"
boolean
NOT
NULL
DEFAULT
false
,
"test"
smallint
NOT
NULL
DEFAULT
'0'
CHECK
(
"test"
>=
0
)
"test"
boolean
NOT
NULL
DEFAULT
false
);
);
CREATE
INDEX
IF
NOT
EXISTS
"clients_1"
ON
"clients"
(
"valid"
,
"secret"
,
"hostname"
);
CREATE
INDEX
IF
NOT
EXISTS
"clients_1"
ON
"clients"
(
"valid"
,
"secret"
,
"hostname"
);
...
@@ -56,7 +56,7 @@ CREATE TABLE IF NOT EXISTS "events" (
...
@@ -56,7 +56,7 @@ CREATE TABLE IF NOT EXISTS "events" (
"received"
timestamp
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
,
"received"
timestamp
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
,
"client_id"
int
NOT
NULL
REFERENCES
"clients"
(
"id"
),
"client_id"
int
NOT
NULL
REFERENCES
"clients"
(
"id"
),
"data"
bytea
NOT
NULL
,
"data"
bytea
NOT
NULL
,
"valid"
smallint
NOT
NULL
DEFAULT
'1'
CHECK
(
"valid"
>=
0
)
"valid"
boolean
NOT
NULL
DEFAULT
true
);
);
CREATE
INDEX
IF
NOT
EXISTS
"id"
ON
"events"
(
"id"
,
"client_id"
);
CREATE
INDEX
IF
NOT
EXISTS
"id"
ON
"events"
(
"id"
,
"client_id"
);
...
...
This diff is collapsed.
Click to expand it.
warden_server/warden_server.py
+
22
−
22
View file @
aac2b3ed
...
@@ -1210,7 +1210,7 @@ class PostgreSQL(DataBaseAPIv2):
...
@@ -1210,7 +1210,7 @@ class PostgreSQL(DataBaseAPIv2):
def
_build_get_client_by_name
(
self
,
cert_names
=
None
,
name
=
None
,
secret
=
None
):
def
_build_get_client_by_name
(
self
,
cert_names
=
None
,
name
=
None
,
secret
=
None
):
"""
Build query and params for client lookup
"""
"""
Build query and params for client lookup
"""
query
=
[
"
SELECT * FROM clients WHERE valid
= 1
"
]
query
=
[
"
SELECT * FROM clients WHERE valid
"
]
params
=
[]
params
=
[]
if
name
:
if
name
:
query
.
append
(
"
AND name = %s
"
)
query
.
append
(
"
AND name = %s
"
)
...
@@ -1360,7 +1360,7 @@ class PostgreSQL(DataBaseAPIv2):
...
@@ -1360,7 +1360,7 @@ class PostgreSQL(DataBaseAPIv2):
query
.
append
(
"
AND %s (%s)
"
%
(
self
.
_get_not
(
group
),
"
OR
"
.
join
(
subquery
)))
query
.
append
(
"
AND %s (%s)
"
%
(
self
.
_get_not
(
group
),
"
OR
"
.
join
(
subquery
)))
query
.
append
(
"
AND e.valid
= 1
LIMIT %s
"
)
query
.
append
(
"
AND e.valid LIMIT %s
"
)
params
.
append
(
count
)
params
.
append
(
count
)
return
[
""
.
join
(
query
)],
[
params
],
0
return
[
""
.
join
(
query
)],
[
params
],
0
...
@@ -1478,7 +1478,7 @@ class PostgreSQL(DataBaseAPIv2):
...
@@ -1478,7 +1478,7 @@ class PostgreSQL(DataBaseAPIv2):
return
[
"
DELETE FROM events WHERE id <= %s
"
],
[(
id_
,)],
0
return
[
"
DELETE FROM events WHERE id <= %s
"
],
[(
id_
,)],
0
def
expose
(
read
=
1
,
write
=
0
,
debug
=
0
):
def
expose
(
read
=
True
,
write
=
False
,
debug
=
False
):
def
expose_deco
(
meth
):
def
expose_deco
(
meth
):
meth
.
exposed
=
True
meth
.
exposed
=
True
...
@@ -1641,7 +1641,7 @@ class WardenHandler(ObjectBase):
...
@@ -1641,7 +1641,7 @@ class WardenHandler(ObjectBase):
self
.
get_events_limit
=
get_events_limit
self
.
get_events_limit
=
get_events_limit
self
.
description
=
description
self
.
description
=
description
@expose
(
read
=
1
,
debug
=
1
)
@expose
(
read
=
True
,
debug
=
True
)
@json_wrapper
@json_wrapper
def
getDebug
(
self
):
def
getDebug
(
self
):
return
{
return
{
...
@@ -1665,7 +1665,7 @@ class WardenHandler(ObjectBase):
...
@@ -1665,7 +1665,7 @@ class WardenHandler(ObjectBase):
}
}
}
}
@expose
(
read
=
1
)
@expose
(
read
=
True
)
@json_wrapper
@json_wrapper
def
getInfo
(
self
):
def
getInfo
(
self
):
info
=
{
info
=
{
...
@@ -1677,7 +1677,7 @@ class WardenHandler(ObjectBase):
...
@@ -1677,7 +1677,7 @@ class WardenHandler(ObjectBase):
info
[
"
description
"
]
=
self
.
description
info
[
"
description
"
]
=
self
.
description
return
info
return
info
@expose
(
read
=
1
)
@expose
(
read
=
True
)
@json_wrapper
@json_wrapper
def
getEvents
(
def
getEvents
(
self
,
id
=
None
,
count
=
None
,
self
,
id
=
None
,
count
=
None
,
...
@@ -1751,7 +1751,7 @@ class WardenHandler(ObjectBase):
...
@@ -1751,7 +1751,7 @@ class WardenHandler(ObjectBase):
ev_ids
.
append
(
id
)
ev_ids
.
append
(
id
)
return
errlist
return
errlist
@expose
(
write
=
1
)
@expose
(
write
=
True
)
@json_wrapper
@json_wrapper
def
sendEvents
(
self
,
events
=
[]):
def
sendEvents
(
self
,
events
=
[]):
if
not
isinstance
(
events
,
list
):
if
not
isinstance
(
events
,
list
):
...
@@ -2089,11 +2089,11 @@ def list_clients(id=None):
...
@@ -2089,11 +2089,11 @@ def list_clients(id=None):
def
register_client
(
**
kwargs
):
def
register_client
(
**
kwargs
):
# argparse does _always_ return something, so we cannot rely on missing arguments
# argparse does _always_ return something, so we cannot rely on missing arguments
if
kwargs
[
"
valid
"
]
is
None
:
kwargs
[
"
valid
"
]
=
1
if
kwargs
[
"
valid
"
]
is
None
:
kwargs
[
"
valid
"
]
=
True
if
kwargs
[
"
read
"
]
is
None
:
kwargs
[
"
read
"
]
=
1
if
kwargs
[
"
read
"
]
is
None
:
kwargs
[
"
read
"
]
=
True
if
kwargs
[
"
write
"
]
is
None
:
kwargs
[
"
write
"
]
=
0
if
kwargs
[
"
write
"
]
is
None
:
kwargs
[
"
write
"
]
=
False
if
kwargs
[
"
debug
"
]
is
None
:
kwargs
[
"
debug
"
]
=
0
if
kwargs
[
"
debug
"
]
is
None
:
kwargs
[
"
debug
"
]
=
False
if
kwargs
[
"
test
"
]
is
None
:
kwargs
[
"
test
"
]
=
1
if
kwargs
[
"
test
"
]
is
None
:
kwargs
[
"
test
"
]
=
True
return
modify_client
(
id
=
None
,
**
kwargs
)
return
modify_client
(
id
=
None
,
**
kwargs
)
...
@@ -2198,33 +2198,33 @@ def add_client_args(subargp, mod=False):
...
@@ -2198,33 +2198,33 @@ def add_client_args(subargp, mod=False):
reg_valid
=
subargp
.
add_mutually_exclusive_group
(
required
=
False
)
reg_valid
=
subargp
.
add_mutually_exclusive_group
(
required
=
False
)
reg_valid
.
add_argument
(
reg_valid
.
add_argument
(
"
--valid
"
,
action
=
"
store_const
"
,
const
=
1
,
default
=
None
,
"
--valid
"
,
action
=
"
store_const
"
,
const
=
True
,
default
=
None
,
help
=
"
valid client (default)
"
)
help
=
"
valid client (default)
"
)
reg_valid
.
add_argument
(
"
--novalid
"
,
action
=
"
store_const
"
,
const
=
0
,
dest
=
"
valid
"
,
default
=
None
)
reg_valid
.
add_argument
(
"
--novalid
"
,
action
=
"
store_const
"
,
const
=
False
,
dest
=
"
valid
"
,
default
=
None
)
reg_read
=
subargp
.
add_mutually_exclusive_group
(
required
=
False
)
reg_read
=
subargp
.
add_mutually_exclusive_group
(
required
=
False
)
reg_read
.
add_argument
(
reg_read
.
add_argument
(
"
--read
"
,
action
=
"
store_const
"
,
const
=
1
,
default
=
None
,
"
--read
"
,
action
=
"
store_const
"
,
const
=
True
,
default
=
None
,
help
=
"
client is allowed to read (default)
"
)
help
=
"
client is allowed to read (default)
"
)
reg_read
.
add_argument
(
"
--noread
"
,
action
=
"
store_const
"
,
const
=
0
,
dest
=
"
read
"
,
default
=
None
)
reg_read
.
add_argument
(
"
--noread
"
,
action
=
"
store_const
"
,
const
=
False
,
dest
=
"
read
"
,
default
=
None
)
reg_write
=
subargp
.
add_mutually_exclusive_group
(
required
=
False
)
reg_write
=
subargp
.
add_mutually_exclusive_group
(
required
=
False
)
reg_write
.
add_argument
(
reg_write
.
add_argument
(
"
--nowrite
"
,
action
=
"
store_const
"
,
const
=
0
,
dest
=
"
write
"
,
default
=
None
,
"
--nowrite
"
,
action
=
"
store_const
"
,
const
=
False
,
dest
=
"
write
"
,
default
=
None
,
help
=
"
client is allowed to send (default - no)
"
)
help
=
"
client is allowed to send (default - no)
"
)
reg_write
.
add_argument
(
"
--write
"
,
action
=
"
store_const
"
,
const
=
1
,
default
=
None
)
reg_write
.
add_argument
(
"
--write
"
,
action
=
"
store_const
"
,
const
=
True
,
default
=
None
)
reg_debug
=
subargp
.
add_mutually_exclusive_group
(
required
=
False
)
reg_debug
=
subargp
.
add_mutually_exclusive_group
(
required
=
False
)
reg_debug
.
add_argument
(
reg_debug
.
add_argument
(
"
--nodebug
"
,
action
=
"
store_const
"
,
const
=
0
,
dest
=
"
debug
"
,
default
=
None
,
"
--nodebug
"
,
action
=
"
store_const
"
,
const
=
False
,
dest
=
"
debug
"
,
default
=
None
,
help
=
"
client is allowed receive debug output (default - no)
"
)
help
=
"
client is allowed receive debug output (default - no)
"
)
reg_debug
.
add_argument
(
"
--debug
"
,
action
=
"
store_const
"
,
const
=
1
,
default
=
None
)
reg_debug
.
add_argument
(
"
--debug
"
,
action
=
"
store_const
"
,
const
=
True
,
default
=
None
)
reg_test
=
subargp
.
add_mutually_exclusive_group
(
required
=
False
)
reg_test
=
subargp
.
add_mutually_exclusive_group
(
required
=
False
)
reg_test
.
add_argument
(
reg_test
.
add_argument
(
"
--test
"
,
action
=
"
store_const
"
,
const
=
1
,
default
=
None
,
"
--test
"
,
action
=
"
store_const
"
,
const
=
True
,
default
=
None
,
help
=
"
client is yet in testing phase (default - yes)
"
)
help
=
"
client is yet in testing phase (default - yes)
"
)
reg_test
.
add_argument
(
"
--notest
"
,
action
=
"
store_const
"
,
const
=
0
,
dest
=
"
test
"
,
default
=
None
)
reg_test
.
add_argument
(
"
--notest
"
,
action
=
"
store_const
"
,
const
=
False
,
dest
=
"
test
"
,
default
=
None
)
def
get_args
():
def
get_args
():
...
...
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