Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kypo-ansible-runner
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository 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
MUNI-KYPO-CRP
backend-python
kypo-ansible-runner
Commits
c89ef2a3
Commit
c89ef2a3
authored
2 years ago
by
Radovan Krebs
Browse files
Options
Downloads
Patches
Plain Diff
added allocation id to answers, waiting for changes in answer storage
parent
b47b1890
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
entrypoint.sh
+1
-1
1 addition, 1 deletion
entrypoint.sh
manage_answers.py
+9
-7
9 additions, 7 deletions
manage_answers.py
with
10 additions
and
8 deletions
entrypoint.sh
+
1
−
1
View file @
c89ef2a3
...
...
@@ -65,7 +65,7 @@ echo {} > "$ANSWERS_FILE"
VARIABLES_FILE
=
'variables.yml'
if
[
-f
$VARIABLES_FILE
]
;
then
python3.8
"
$PREPARE_ANSWERS_PY
"
"
$INVENTORY_FILE
"
"
$ANSWERS_FILE
"
"
$ANSWERS_STORAGE_API
"
python3.8
"
$PREPARE_ANSWERS_PY
"
"
$INVENTORY_FILE
"
"
$ANSWERS_FILE
"
"
$ANSWERS_STORAGE_API
"
||
exit
1
fi
if
$USER_CLEANUP
;
then
python3.8
"
$PREPARE_ANSWERS_PY
"
"
$INVENTORY_FILE
"
"
$ANSWERS_FILE
"
"
$ANSWERS_STORAGE_API
"
--cleanup
...
...
This diff is collapsed.
Click to expand it.
manage_answers.py
+
9
−
7
View file @
c89ef2a3
...
...
@@ -35,9 +35,10 @@ def generate_answers(inventory_variables):
return
generate
(
variable_list
,
seed
)
def
get_post_data_json
(
sandbox_id
,
generated_answers
):
def
get_post_data_json
(
sandbox_id
,
allocation_id
,
generated_answers
):
post_data
=
{
'
sandbox_ref_id
'
:
sandbox_id
,
'
allocation_unit_id
'
:
allocation_id
,
'
sandbox_answers
'
:
[]
}
...
...
@@ -50,12 +51,12 @@ def get_post_data_json(sandbox_id, generated_answers):
return
json
.
dumps
(
post_data
,
indent
=
4
)
def
delete_answers
(
answers_storage_api
,
sandbox
_id
):
requests
.
delete
(
answers_storage_api
+
'
sandboxes/
'
+
str
(
sandbox
_id
)).
raise_for_status
()
def
delete_answers
(
answers_storage_api
,
allocation
_id
):
requests
.
delete
(
answers_storage_api
+
'
sandboxes/
'
+
str
(
allocation
_id
)).
raise_for_status
()
def
post_answers
(
answers_storage_api
,
sandbox_id
,
generated_answers
):
post_data_json
=
get_post_data_json
(
sandbox_id
,
generated_answers
)
def
post_answers
(
answers_storage_api
,
sandbox_id
,
allocation_id
,
generated_answers
):
post_data_json
=
get_post_data_json
(
sandbox_id
,
allocation_id
,
generated_answers
)
post_response
=
requests
.
post
(
answers_storage_api
+
'
sandboxes
'
,
data
=
post_data_json
,
headers
=
HEADERS
)
post_response
.
raise_for_status
()
...
...
@@ -71,6 +72,7 @@ def main():
args
=
parser
.
parse_args
()
inventory_variables
=
load_inventory_variables
(
args
.
inventory_path
)
sandbox_id
=
inventory_variables
[
'
kypo_global_sandbox_id
'
]
allocation_id
=
inventory_variables
[
'
kypo_global_sandbox_allocation_unit_id
'
]
answers_file_path
=
args
.
answers_file_path
answers_storage_api
=
args
.
answers_storage_api
...
...
@@ -80,13 +82,13 @@ def main():
try
:
if
args
.
cleanup
:
delete_answers
(
answers_storage_api
,
sandbox_id
)
delete_answers
(
answers_storage_api
,
sandbox_id
,
allocation_id
)
print
(
_success_msg
.
format
(
'
DELETE
'
))
return
generated_answers
=
generate_answers
(
inventory_variables
)
create_answers_file
(
generated_answers
,
answers_file_path
)
post_answers
(
answers_storage_api
,
sandbox_id
,
generated_answers
)
post_answers
(
answers_storage_api
,
sandbox_id
,
allocation_id
,
generated_answers
)
print
(
_success_msg
.
format
(
'
POST
'
))
except
ConnectionError
:
print
(
'
\n
[Warning]: Service answers-storage is unavailable.
\n
'
)
...
...
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