Commit d3e11cc8 by adamtorok

upgrades

parent 34480589
import openstack
import Image
import ImageManager
from openstack.exceptions import ResourceNotFound
from interface.image.ImageManager import ImageManager
from interface.image.Image import Image
class OpenstackImageManager(ImageManager.ImageManager):
def __init__(self, cloud) -> None:
class OpenstackImageManager(ImageManager):
def __init__(self, openstack) -> None:
super().__init__()
self.openstack = openstack.connect(cloud=cloud)
self.openstack = openstack
@staticmethod
def os_image_to_rc_image(os_image):
return Image.Image(
return Image(
os_image.id,
os_image.name,
os_image.disk_format
)
def upload_file(self, path):
os_image = self.openstack.image.create_image(name=path, filename=path, disk_format='iso')
def upload_file(self, name, path, format):
os_image = self.openstack.image.create_image(
name=name,
filename=path,
disk_format=format
)
return self.os_image_to_rc_image(os_image)
def get(self, id):
try:
os_image = self.openstack.image.get_image(id)
except ResourceNotFound:
return None
return self.os_image_to_rc_image(os_image)
def delete(self, id):
try:
self.openstack.image.delete_image(id)
except ResourceNotFound:
return False
return True
def list(self):
images = []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment