Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CONF
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UvA
CONF
Commits
a2e4f508
Commit
a2e4f508
authored
Feb 11, 2020
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed thread for deployer
parent
0bb072e4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
17 deletions
+36
-17
__main__.py
deployer/__main__.py
+24
-4
docker-compose.yml
docker-compose.yml
+1
-1
__main__.py
planner/__main__.py
+11
-12
No files found.
deployer/__main__.py
View file @
a2e4f508
...
...
@@ -10,12 +10,17 @@ import logging
import
pika
import
yaml
import
sys
from
time
import
sleep
from
concurrent.futures
import
thread
from
threading
import
Thread
from
service
import
tosca
,
k8s_service
from
service
import
ansible_service
logger
=
logging
.
getLogger
(
__name__
)
done
=
False
# if not getattr(logger, 'handler_set', None):
# logger.setLevel(logging.INFO)
...
...
@@ -37,7 +42,7 @@ def init_chanel(args):
connection
=
pika
.
BlockingConnection
(
pika
.
ConnectionParameters
(
host
=
rabbitmq_host
))
channel
=
connection
.
channel
()
channel
.
queue_declare
(
queue
=
queue_name
)
return
channel
return
channel
,
connection
def
start
(
this_channel
):
...
...
@@ -106,6 +111,12 @@ def handle_delivery(message):
return
json
.
dumps
(
response
)
def
threaded_function
(
args
):
while
not
done
:
connection
.
process_data_events
()
sleep
(
5
)
if
__name__
==
"__main__"
:
logging
.
basicConfig
(
level
=
logging
.
INFO
)
if
sys
.
argv
[
1
]
==
"test_local"
:
...
...
@@ -124,7 +135,16 @@ if __name__ == "__main__":
else
:
logger
.
info
(
"Input args: "
+
sys
.
argv
[
0
]
+
' '
+
sys
.
argv
[
1
]
+
' '
+
sys
.
argv
[
2
])
channel
=
init_chanel
(
sys
.
argv
)
global
queue_name
global
channel
,
queue_name
,
connection
channel
,
connection
=
init_chanel
(
sys
.
argv
)
queue_name
=
sys
.
argv
[
2
]
start
(
channel
)
logger
.
info
(
"Awaiting RPC requests"
)
try
:
thread
=
Thread
(
target
=
threaded_function
,
args
=
(
1
,))
thread
.
start
()
start
(
channel
)
except
:
done
=
True
e
=
sys
.
exc_info
()[
0
]
logger
.
info
(
"Error: "
+
str
(
e
))
exit
(
-
1
)
docker-compose.yml
View file @
a2e4f508
...
...
@@ -20,7 +20,7 @@ services:
-
sure-tosca
image
:
alogo53/planner:3.0.0
environment
:
RABBITMQ_HOST
:
rabbit
RABBITMQ_HOST
:
rabbit
provisioner
:
depends_on
:
...
...
planner/__main__.py
View file @
a2e4f508
...
...
@@ -68,12 +68,13 @@ def on_request(ch, method, props, body):
ch
.
basic_ack
(
delivery_tag
=
method
.
delivery_tag
)
def
handle_delivery
(
message
):
def
handle_delivery
(
message
,
sys
=
None
):
logger
.
info
(
"Got: "
+
str
(
message
))
try
:
message
=
message
.
decode
()
except
(
UnicodeDecodeError
,
AttributeError
):
pass
e
=
sys
.
exc_info
()[
0
]
logger
.
info
(
"Parsing Error: "
+
str
(
e
))
parsed_json_message
=
json
.
loads
(
message
)
owner
=
parsed_json_message
[
'owner'
]
tosca_file_name
=
'tosca_template'
...
...
@@ -143,22 +144,20 @@ if __name__ == "__main__":
test_response
=
{
'toscaTemplate'
:
template_dict
}
logger
.
info
(
"Output message:"
+
json
.
dumps
(
test_response
))
else
:
print
(
"Input args: "
+
sys
.
argv
[
0
]
+
' '
+
sys
.
argv
[
1
]
+
' '
+
sys
.
argv
[
2
])
logger
.
info
(
"Input args: "
+
sys
.
argv
[
0
]
+
' '
+
sys
.
argv
[
1
]
+
' '
+
sys
.
argv
[
2
])
global
channel
global
connection
channel
,
connection
=
init_chanel
(
sys
.
argv
)
global
queue_name
queue_name
=
sys
.
argv
[
2
]
# start(channel)
thread
=
Thread
(
target
=
threaded_function
,
args
=
(
1
,))
thread
.
start
()
#
thread = Thread(target=threaded_function, args=(1,))
#
thread.start()
logger
.
info
(
"Awaiting RPC requests"
)
try
:
channel
.
start_consuming
()
except
KeyboardInterrupt
:
# thread.stop()
done
=
True
thread
.
join
()
logger
.
info
(
"Threads successfully closed"
)
start
(
channel
)
except
:
e
=
sys
.
exc_info
()[
0
]
logger
.
info
(
"Error: "
+
str
(
e
))
exit
(
-
1
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment