Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
HORSE
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
Iulisloi Zacarias
HORSE
Commits
74ac189b
Commit
74ac189b
authored
9 months ago
by
izacarias
Browse files
Options
Downloads
Patches
Plain Diff
Fixing issues on QoS Page, Removing Workflow API and fixing access token to RTR.
parent
95dc5623
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/main.py
+34
-27
34 additions, 27 deletions
app/main.py
with
34 additions
and
27 deletions
app/main.py
+
34
−
27
View file @
74ac189b
...
...
@@ -28,10 +28,13 @@ qos_intents_url = config.qos_intents_url
stored_qos_intents_url
=
config
.
stored_qos_intents_url
workflow_url
=
config
.
workflow_url
access_token
=
""
#if connection to rtr is set to true in the config file, then the user registers and logs in
if
parameters
[
'
to_connect_to_rtr
'
]
==
'
true
'
:
connect_rtr
.
register_rtr
(
workflow_url
)
#access_token = connect_rtr.login_rtr(workflow_url)
# access_token = connect_rtr.login_rtr(workflow_url)
print
(
'
cleared
'
)
#clears the existing intent store if you chose that in the config file
...
...
@@ -133,35 +136,35 @@ def replace_qos_intent(qos_intent: qos_Intent):
return
qos_intent
#API for sending workflows to the RTR
class
Workflow
(
BaseModel
):
command
:
str
intent_type
:
str
threat
:
str
attacked_host
:
str
mitigation_host
:
str
action
:
str
duration
:
str
intent_id
:
str
#
#API for sending workflows to the RTR
#
class Workflow(BaseModel):
#
command: str
#
intent_type: str
#
threat: str
#
attacked_host: str
#
mitigation_host: str
#
action: str
#
duration: str
#
intent_id: str
workflows
=
[
Workflow
(
command
=
''
,
intent_type
=
''
,
threat
=
''
,
attacked_host
=
''
,
mitigation_host
=
''
,
action
=
''
,
duration
=
''
,
intent_id
=
''
)]
#
workflows = [Workflow(command='', intent_type='', threat='', attacked_host='',
#
mitigation_host='', action='', duration='', intent_id='')]
workflow_endpoint
=
parameters
[
'
to_send_workflow
'
]
@app.get
(
workflow_endpoint
)
def
get_workflow
():
return
workflows
#
workflow_endpoint = parameters['to_send_workflow']
#
@app.get(workflow_endpoint)
#
def get_workflow():
#
return workflows
@app.post
(
workflow_endpoint
,
status_code
=
201
)
def
add_workflow
(
workflow
:
Workflow
):
workflows
.
append
(
workflow
)
return
workflow
#
@app.post(workflow_endpoint, status_code=201)
#
def add_workflow(workflow: Workflow):
#
workflows.append(workflow)
#
return workflow
@app.put
(
workflow_endpoint
)
def
replace_workflow
(
workflow
:
Workflow
):
workflows
.
clear
()
workflows
.
append
(
workflow
)
return
workflow
#
@app.put(workflow_endpoint)
#
def replace_workflow(workflow: Workflow):
#
workflows.clear()
#
workflows.append(workflow)
#
return workflow
#API for sending what-if question to the SAN
...
...
@@ -395,7 +398,11 @@ def intents_html():
def
qos_intents_html
():
stored_qos_intents_arr
=
get_intents_script
.
get_intent_fun
(
stored_qos_intents_url
)
items
=
stored_qos_intents_arr
[
0
].
items
()
if
len
(
stored_qos_intents_arr
)
>
0
:
items
=
stored_qos_intents_arr
[
0
].
items
()
else
:
items
=
dict
(
id
=
0
,
intent_type
=
''
,
name
=
''
,
value
=
0.0
,
host
=
''
,
qos_intent_id
=
''
).
items
()
keys
=
[
key
for
key
,
value
in
items
]
headings
=
tuple
(
keys
)
data
=
()
...
...
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