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
2c858652
Commit
2c858652
authored
1 year ago
by
Chukwuemeka Michael Muonagor
Browse files
Options
Downloads
Patches
Plain Diff
Delete delete_intents.py
parent
e18ab02c
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
delete_intents.py
+0
-50
0 additions, 50 deletions
delete_intents.py
with
0 additions
and
50 deletions
delete_intents.py
deleted
100644 → 0
+
0
−
50
View file @
e18ab02c
import
pandas
as
pd
import
sys
import
delete_command
from
elasticsearch
import
Elasticsearch
import
delete_intents_elasticsearch
#es = Elasticsearch('http://172.21.0.1:9200')
#IP address of the machine on which the IBI is running
#ip = sys.argv[1]
#ip = "192.168.56.1"
#workflow_url = "http://" + ip + ":7777/workflows"
#function for deleting intents
def
select_delete_fun
(
to_delete
,
ip
):
workflow_url
=
"
http://
"
+
ip
+
"
:7777/workflows
"
elasticsearch_url
=
"
http://
"
+
ip
+
"
:9200
"
es
=
Elasticsearch
(
elasticsearch_url
)
print
(
'
to delete intent
'
)
df
=
pd
.
read_csv
(
'
intent_store.csv
'
)
#join the parameters of the desired intent to be deleted as string
selected_delete_string
=
to_delete
[
'
intent_type
'
]
+
'
'
+
to_delete
[
'
threat
'
]
+
'
'
+
str
(
to_delete
[
'
host
'
])
\
+
'
'
+
to_delete
[
'
action
'
]
+
'
'
+
str
(
to_delete
[
'
duration
'
])
+
'
'
+
to_delete
[
'
intent_id
'
]
for
ind
in
range
(
len
(
df
.
index
)):
print
(
'
ind:
'
,
ind
)
if
ind
<
len
(
df
.
index
)
and
not
df
.
empty
:
#join the parameters of each of the intents in the store as string
delete_string
=
df
[
'
intent_type
'
][
ind
]
+
'
'
+
df
[
'
threat
'
][
ind
]
+
'
'
+
str
(
df
[
'
host
'
][
ind
])
\
+
'
'
+
df
[
'
action
'
][
ind
]
+
'
'
+
str
(
df
[
'
duration
'
][
ind
])
+
'
'
+
df
[
'
intent_id
'
][
ind
]
print
(
'
delete string:
'
,
delete_string
)
#if any joined string of parameters of intent corresponds with the string of intent to be deleted
#then that intent would be deleted
if
delete_string
==
selected_delete_string
:
#call the delete_intents_fun function which sends a json with ID of intent to delete to the RTR
delete_command
.
delete_intents_fun
(
df
[
'
intent_id
'
][
ind
],
workflow_url
)
# TO PUT FUNCTION FOR DELETING INTENTS IN ELASTICSEARCH HERE
resp
=
es
.
search
(
index
=
"
stored_intents
"
,
size
=
100
,
query
=
{
"
match_all
"
:
{}})
for
hit
in
resp
[
'
hits
'
][
'
hits
'
]:
if
hit
[
"
_source
"
][
'
intent_id
'
]
==
df
[
'
intent_id
'
][
ind
]:
delete_intents_elasticsearch
.
delete_intents_elasticsearch_fun
(
elasticsearch_url
,
hit
[
"
_source
"
][
'
id
'
])
# remove this intent to be deleted from the local intent store and reshuffle the intent store
df
=
df
.
drop
(
df
.
index
[
ind
])
df
=
df
.
reset_index
(
drop
=
True
)
# write the modified dataframe to the local intent store
df
.
to_csv
(
'
intent_store.csv
'
,
index
=
False
)
#select_delete_fun()
\ No newline at end of file
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