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

Commit

Permalink
Merge branch 'staging'
Browse files Browse the repository at this point in the history
  • Loading branch information
dweinholz committed Jul 28, 2023
2 parents 71f8208 + ae11dec commit 422e500
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 39 deletions.
85 changes: 50 additions & 35 deletions VirtualMachineService/VirtualMachineHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class VirtualMachineHandler(Iface):
ERROR = "ERROR"
SHUTOFF = "SHUTOFF"
NOT_FOUND = "NOT_FOUND"
CHECKING_STATUS = "CHECKING_STATUS"
PREPARE_PLAYBOOK_BUILD = "PREPARE_PLAYBOOK_BUILD"
BUILD_PLAYBOOK = "BUILD_PLAYBOOK"
PLAYBOOK_FAILED = "PLAYBOOK_FAILED"
Expand Down Expand Up @@ -385,7 +386,7 @@ def get_Flavors(self):
return flavors
except Exception as e:
self.LOG.exception(f"Get Flavors Error: {e}")
return ()
return []

@deprecated(
version="1.0.0",
Expand Down Expand Up @@ -472,7 +473,7 @@ def get_Images(self):
return images
except Exception as e:
self.LOG.exception(f"Get Images Error: {e}")
return ()
return []

def prepare_image(self, img):
try:
Expand Down Expand Up @@ -538,7 +539,7 @@ def get_public_Images(self):
return images
except Exception as e:
self.LOG.exception(f"Get Images Error: {e}")
return ()
return []

def get_private_Images(self):
"""
Expand All @@ -564,7 +565,7 @@ def get_private_Images(self):
return images
except Exception as e:
self.LOG.exception(f"Get Images Error: {e}")
return ()
return []

def get_Image_with_Tag(self, id):
"""
Expand Down Expand Up @@ -653,7 +654,7 @@ def get_Images_by_filter(self, filter_list):
return images
except Exception as e:
self.LOG.exception(f"Get Images Error: {e}")
return ()
return []

def delete_keypair(self, key_name):
key_pair = self.conn.compute.find_keypair(key_name)
Expand Down Expand Up @@ -730,18 +731,27 @@ def get_server(self, openstack_id: str) -> VM:
self.LOG.info(f"Get Server {openstack_id}")
try:
server: Server = self.conn.get_server_by_id(openstack_id)
if not server:
self.LOG.exception(f"No Server found {openstack_id}")
return VM(status=self.NOT_FOUND)
return self.openstack_server_to_thrift_server(server=server)
except Exception as e:
self.LOG.exception(f"No Server found {openstack_id} | Error {e}")
return VM(status=self.NOT_FOUND)


except Exception:
self.LOG.exception(f"Could get server {openstack_id}")
return VM(status=self.CHECKING_STATUS)

def get_servers_by_ids(self, ids):
servers = []
for id in ids:
self.LOG.info(f"Get server {id}")
try:
server = self.conn.get_server_by_id(id)
servers.append(server)
if server:
servers.append(server)
else:
self.LOG.exception(f"No Server found {openstack_id}")

except Exception as e:
self.LOG.exception(f"Requested VM {id} not found!\n {e}")
server_list = []
Expand Down Expand Up @@ -1417,7 +1427,6 @@ def cross_check_forc_image(self, tags):
template_dict["name"] in self.FORC_ALLOWED
and template_dict["name"] in cross_tags
):
self.LOG("name matches")
if template_dict["version"] in self.FORC_ALLOWED[template_dict["name"]]:
return True
return False
Expand Down Expand Up @@ -1735,7 +1744,7 @@ def get_playbook_logs(self, openstack_id):
if self.redis.exists(openstack_id) == 1 and openstack_id in active_playbooks:
key_name = self.redis.hget(openstack_id, "name").decode("utf-8")
playbook = active_playbooks.pop(openstack_id)
status, stdout, stderr = playbook.get_self.LOGs()
status, stdout, stderr = playbook.get_logs()
self.LOG.info(f" Playbook self.LOGs{openstack_id} stattus: {status}")

playbook.cleanup(openstack_id)
Expand Down Expand Up @@ -1776,28 +1785,34 @@ def get_volume(self, volume_id):
self.LOG.info(f"Get Volume {volume_id}")
try:
os_volume = self.conn.get_volume_by_id(id=volume_id)
self.LOG.info(os_volume)
if os_volume.attachments:
device = os_volume.attachments[0]["device"]
server_id = os_volume.attachments[0]["server_id"]
if os_volume:
self.LOG.info(os_volume)
if os_volume.attachments:
device = os_volume.attachments[0]["device"]
server_id = os_volume.attachments[0]["server_id"]
else:
device = None
server_id = None

thrift_volume = Volume(
status=os_volume.status,
id=os_volume.id,
name=os_volume.name,
description=os_volume.description,
created_at=os_volume.created_at,
device=device,
server_id=server_id,
size=os_volume.size,
)

return thrift_volume
else:
device = None
server_id = None

thrift_volume = Volume(
status=os_volume.status,
id=os_volume.id,
name=os_volume.name,
description=os_volume.description,
created_at=os_volume.created_at,
device=device,
server_id=server_id,
size=os_volume.size,
)
return thrift_volume
self.LOG.exception(f"Could not find volume {id}")
return Volume(status=self.NOT_FOUND)

except Exception:
self.LOG.exception(f"Could not find volume {id}")
return Volume(status=self.NOT_FOUND)
return Volume(status=self.CHECKING_STATUS)

def attach_volume_to_server(self, openstack_id, volume_id):
"""
Expand Down Expand Up @@ -1847,13 +1862,13 @@ def check_server_status(self, openstack_id: str) -> VM:
self.LOG.info(f"Check Status VM {openstack_id}")
try:
server = self.conn.compute.get_server(openstack_id)
if not server:
self.LOG.exception(f"No Server with id {openstack_id} ")
return VM(status=self.NOT_FOUND)
except Exception:
self.LOG.exception(f"No Server with id {openstack_id} ")
return VM(status=self.NOT_FOUND)
self.LOG.exception(f"Could not get server {openstack_id} ")
return VM(status=self.CHECKING_STATUS)

if server is None:
self.LOG.exception(f"No Server with id {openstack_id} ")
return VM(status=self.NOT_FOUND)

serv = server.to_dict()

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.bibigrid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ services:

# filebeat
filebeat:
image: docker.elastic.co/beats/filebeat:8.8.2
image: docker.elastic.co/beats/filebeat:8.9.0
env_file:
- .env
volumes:
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ services:
# filebeat
filebeat:
container_name: client_filebeat
image: docker.elastic.co/beats/filebeat:8.8.2
image: docker.elastic.co/beats/filebeat:8.9.0
env_file:
- .env
volumes:
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ thrift==0.16.0
python-keystoneclient==5.1.0
openstacksdk ==1.3.1
deprecated ==1.2.14
Click==8.1.5
ansible==8.1.0
Click==8.1.6
ansible==8.2.0
flake8==6.0.0
paramiko==3.2.0
ruamel.yaml==0.17.32
Expand Down

0 comments on commit 422e500

Please sign in to comment.