Commit fcb0150a by adamtorok

bug fix

parent bbe885fe
import Snapshot
import SnapshotManager
import openstack
class OpenstackSnapshotManager(SnapshotManager.SnapshotManager):
def __init__(self, cloud) -> None:
super().__init__()
self.openstack = openstack.connect(cloud=cloud)
@staticmethod
def os_snapshot_to_rc_snapshot(os_snapshot):
return Snapshot.Snapshot(
os_snapshot.id,
os_snapshot.size
)
def create_from_volume(self, id):
os_snapshot = self.openstack.block_storage.create_snapshot(volume_id=id)
return self.os_snapshot_to_rc_snapshot(os_snapshot)
def get(self, id):
os_snapshot = self.openstack.block_storage.get_snapshot(id)
return self.os_snapshot_to_rc_snapshot(os_snapshot)
def list(self):
snapshots = []
for os_snapshot in self.openstack.block_storage.snapshots():
snapshots.append(self.os_snapshot_to_rc_snapshot(os_snapshot))
return snapshots
def delete(self, id):
print(self.openstack.block_storage.delete_snapshot(id))
import Snapshot import Volume
import SnapshotManager
import openstack import openstack
import StorageManager
class OpenstackSnapshotManager(SnapshotManager.SnapshotManager): class OpenstackStorageManager(StorageManager.StorageManager):
def __init__(self, cloud) -> None: def __init__(self, cloud) -> None:
super().__init__() super().__init__()
self.openstack = openstack.connect(cloud=cloud) self.openstack = openstack.connect(cloud=cloud)
@staticmethod @staticmethod
def os_snapshot_to_rc_snapshot(os_snapshot): def os_volume_to_rc_volume(os_volume):
return Snapshot.Snapshot( return Volume.Volume(
os_snapshot.id, os_volume.id,
os_snapshot.size os_volume.size,
os_volume.is_bootable
) )
def create_from_volume(self, id): def create(self, size, bootable):
os_snapshot = self.openstack.block_storage.create_snapshot(volume_id=id) os_volume = self.openstack.block_storage.create_volume(size=size, bootable=bootable)
return self.os_snapshot_to_rc_snapshot(os_snapshot) return self.os_volume_to_rc_volume(os_volume)
def get(self, id): def get(self, id):
os_snapshot = self.openstack.block_storage.get_snapshot(id) os_volume = self.openstack.block_storage.get_volume(id)
return self.os_volume_to_rc_volume(os_volume)
return self.os_snapshot_to_rc_snapshot(os_snapshot) def delete(self, id):
print(self.openstack.block_storage.delete_volume(id))
def list(self): def list(self):
snapshots = [] volumes = []
for os_snapshot in self.openstack.block_storage.snapshots(): for os_volume in self.openstack.block_storage.volumes():
snapshots.append(self.os_snapshot_to_rc_snapshot(os_snapshot)) volumes.append(self.os_volume_to_rc_volume(os_volume))
return snapshots return volumes
def delete(self, id): def resize(self, id):
print(self.openstack.block_storage.delete_snapshot(id)) pass
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