Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #578 from deNBI/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
Timo authored Jan 12, 2021
2 parents 69422aa + 70c7b27 commit edec748
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 18 deletions.
1 change: 1 addition & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
queries: +security-extended, security-and-quality
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
Expand Down
34 changes: 23 additions & 11 deletions VirtualMachineService/VirtualMachineHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ class VirtualMachineHandler(Iface):
BUILD = "BUILD"
ACTIVE = "ACTIVE"
ERROR = "ERROR"
NOT_FOUND = "NOT FOUND"
SHUTOFF = "SHUTOFF"
NOT_FOUND = "NOT_FOUND"
PREPARE_PLAYBOOK_BUILD = "PREPARE_PLAYBOOK_BUILD"
BUILD_PLAYBOOK = "BUILD_PLAYBOOK"
PLAYBOOK_FAILED = "PLAYBOOK_FAILED"
Expand Down Expand Up @@ -634,12 +635,19 @@ def get_server(self, openstack_id):
floating_ip = address["addr"]
elif address["OS-EXT-IPS:type"] == "fixed":
fixed_ip = address["addr"]
task = serv["task_state"]
if task:
status = task.upper().replace("-", "_")
LOG.info(f"{openstack_id} Task: {task}")

else:
status = serv["status"]

if floating_ip:
server = VM(
flav=flav,
img=img,
status=serv["status"],
status=status,
metadata=serv["metadata"],
project_id=serv["project_id"],
keyname=serv["key_name"],
Expand All @@ -654,7 +662,7 @@ def get_server(self, openstack_id):
server = VM(
flav=flav,
img=img,
status=serv["status"],
status=status,
metadata=serv["metadata"],
project_id=serv["project_id"],
keyname=serv["key_name"],
Expand Down Expand Up @@ -1298,6 +1306,7 @@ def create_backend(self, elixir_id, user_key_url, template, upstream_url):
except Exception as e:
LOG.exception(e)
return {}
LOG.info(f"Backend created {data}")
return Backend(
id=data["id"],
owner=data["owner"],
Expand Down Expand Up @@ -1660,7 +1669,7 @@ def get_volume(self, volume_id):
return thrift_volume
except Exception:
LOG.exception("Could not find volume {}".format(id))
return Volume(status="NOT FOUND")
return Volume(status=self.NOT_FOUND)

def attach_volume_to_server(self, openstack_id, volume_id):
"""
Expand Down Expand Up @@ -1795,7 +1804,7 @@ def check_server_status(self, openstack_id):
return server
else:
server = self.get_server(openstack_id)
server.status = self.BUILD
# server.status = self.BUILD
return server
except Exception as e:
LOG.exception("Check Status VM {0} error: {1}".format(openstack_id, e))
Expand Down Expand Up @@ -2301,12 +2310,15 @@ def delete_server(self, openstack_id):
:param openstack_id: Id of the server
:return: True if deleted, False if not
"""
LOG.info("Delete Server {0}".format(openstack_id))
LOG.info(f"Delete Server {openstack_id}")
try:
server = self.conn.get_server(openstack_id)
server = self.conn.get_server(name_or_id=openstack_id)

if server is None:
LOG.exception("Instance {0} not found".format(openstack_id))
return False
server = self.conn.compute.get_server(openstack_id)
if server is None:
LOG.error("Instance {0} not found".format(openstack_id))
return False
task_state = self.check_server_task_state(openstack_id)
if (
task_state == "image_snapshot"
Expand Down Expand Up @@ -2428,7 +2440,7 @@ def stop_server(self, openstack_id):
LOG.exception("Instance {0} not found".format(openstack_id))
raise serverNotFoundException

if server.status == "ACTIVE":
if server.status == self.ACTIVE:
self.conn.compute.stop_server(server)
return True
else:
Expand Down Expand Up @@ -2482,7 +2494,7 @@ def resume_server(self, openstack_id):
if server is None:
LOG.exception("Instance {0} not found".format(openstack_id))
raise serverNotFoundException
if server.status == "SHUTOFF":
if server.status == self.SHUTOFF:
self.conn.compute.start_server(server)
return True
else:
Expand Down
5 changes: 3 additions & 2 deletions VirtualMachineService/VirtualMachineServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,18 @@ def catch_shutdown(signal, frame):
HOST = cfg["openstack_connection"]["host"]
PORT = cfg["openstack_connection"]["port"]
CERTFILE = cfg["openstack_connection"]["certfile"]
THREADS = cfg["openstack_connection"]["threads"]
click.echo("Server is running on port {}".format(PORT))
handler = VirtualMachineHandler(CONFIG_FILE)
processor = Processor(handler)
processor.resize_volume("1e4d223a-b450-47f8-b7f1-52df40e4c39b", 2)
transport = TSSLSocket.TSSLServerSocket(host=HOST, port=PORT, certfile=CERTFILE)
tfactory = TTransport.TBufferedTransportFactory()
pfactory = TBinaryProtocol.TBinaryProtocolFactory()
server = TServer.TThreadPoolServer(
processor, transport, tfactory, pfactory, daemon=True
)
server.setNumThreads(15)
server.setNumThreads(THREADS)
click.echo(f"Started with {THREADS} threads!")

server.serve()

Expand Down
1 change: 1 addition & 0 deletions VirtualMachineService/config/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
openstack_connection:
threads: 30
host: 0.0.0.0
# Client Port
port: 9090
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.bibigrid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ services:
- portal

redis:
image: redis:5.0.5
image: redis:6.0.9
expose:
- "6379"
networks:
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.dev.bibigrid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ services:
- portal

redis:
image: redis:5.0.5
image: redis:6.0.9
expose:
- "6379"
networks:
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ services:
- portal

redis:
image: redis:5.0.5
image: redis:6.0.9
expose:
- "6379"
networks:
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ services:


redis:
image: redis:5.0.5
image: redis:6.0.9
expose:
- "6379"
networks:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
setuptools==51.1.0.post20201221
setuptools==51.1.1
thrift >= 0.11.0,<0.20.0
python-keystoneclient
openstacksdk ==0.52.0
Expand Down

0 comments on commit edec748

Please sign in to comment.