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 SnapshotManager
import Volume
import openstack
import StorageManager
class OpenstackSnapshotManager(SnapshotManager.SnapshotManager):
class OpenstackStorageManager(StorageManager.StorageManager):
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 os_volume_to_rc_volume(os_volume):
return Volume.Volume(
os_volume.id,
os_volume.size,
os_volume.is_bootable
)
def create_from_volume(self, id):
os_snapshot = self.openstack.block_storage.create_snapshot(volume_id=id)
def create(self, size, bootable):
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):
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):
snapshots = []
volumes = []
for os_snapshot in self.openstack.block_storage.snapshots():
snapshots.append(self.os_snapshot_to_rc_snapshot(os_snapshot))
for os_volume in self.openstack.block_storage.volumes():
volumes.append(self.os_volume_to_rc_volume(os_volume))
return snapshots
return volumes
def delete(self, id):
print(self.openstack.block_storage.delete_snapshot(id))
def resize(self, 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