Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
snseventd
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OTDI Middleware
snseventd
Commits
5f86eac1
Commit
5f86eac1
authored
4 years ago
by
Edward Hicks
Browse files
Options
Downloads
Patches
Plain Diff
fix operation check
parent
e8e56823
No related branches found
No related tags found
No related merge requests found
Pipeline
#91827
passed
4 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
snseventd.py
+9
-4
9 additions, 4 deletions
snseventd.py
with
9 additions
and
4 deletions
snseventd.py
+
9
−
4
View file @
5f86eac1
...
...
@@ -9,6 +9,7 @@ import numbers
import
json
import
boto3
from
botocore.exceptions
import
ProfileNotFound
,
NoCredentialsError
from
botocore.config
import
Config
class
bcolors
:
HEADER
=
'
\033
[95m
'
...
...
@@ -107,6 +108,9 @@ def extractSettings(settingsFile):
return
out
def
sanityCheckMessage
(
body
,
payload
):
global
Config
global
Session
# Make sure message came from the right SNS channel
if
body
[
'
TopicArn
'
]
!=
Session
[
'
topicArn
'
]:
printLog
(
"
Message came from an invalid SNS topic
"
)
...
...
@@ -123,7 +127,7 @@ def sanityCheckMessage(body, payload):
# Verify that the payload includes a valid operation to perform
try
:
if
not
hasattr
(
payload
,
'
operation
'
)
or
not
hasattr
(
Config
[
'
events
'
]
,
payload
[
'
operation
'
])
:
if
payload
[
'
operation
'
]
not
in
Config
[
'
events
'
]:
printLog
(
"
Message has invalid operation
'"
+
str
(
payload
[
'
operation
'
])
+
"'"
)
return
false
except
KeyError
:
...
...
@@ -132,7 +136,7 @@ def sanityCheckMessage(body, payload):
# Verify that the payload includes a timestamp
try
:
if
not
hasattr
(
payload
,
'
timestamp
'
)
or
not
isinstance
(
payload
[
'
timestamp
'
],
numbers
.
Number
)
or
payload
[
'
timestamp
'
]
<
0
:
if
not
isinstance
(
payload
[
'
timestamp
'
],
numbers
.
Number
)
or
payload
[
'
timestamp
'
]
<
0
:
printLog
(
"
Message has invalid timestamp
'"
+
str
(
payload
[
'
timestamp
'
])
+
"'"
)
return
false
except
KeyError
:
...
...
@@ -174,6 +178,7 @@ args = parser.parse_args()
ret
=
1
# init as a failure code
logFile
=
False
Session
=
{}
Session
[
'
nodename
'
]
=
str
(
os
.
uname
().
nodename
.
split
(
'
.
'
)[
0
])
Config
=
{}
Config
[
'
events
'
]
=
{}
...
...
@@ -323,7 +328,7 @@ except Exception as e:
# Create an SQS queue to subscribe to the SNS topic
Session
[
'
queue
'
]
=
Config
[
'
sqsQueuePrefix
'
]
+
str
(
os
.
uname
().
nodename
.
split
(
'
.
'
)[
0
])
Session
[
'
queue
'
]
=
Config
[
'
sqsQueuePrefix
'
]
+
Session
[
'
nodename
'
]
printLog
(
"
Creating SQS queue
"
+
Session
[
'
queue
'
],
loglevels
.
INFO
)
try
:
Session
[
'
sqs
'
]
=
Session
[
'
boto3
'
].
client
(
'
sqs
'
)
...
...
@@ -439,7 +444,7 @@ while True:
# If the SQS message is ok then make sure it's meant for us
# check nodes for Session['nodename']
...
...
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