Commit bbe885fe by adamtorok

Openstack Storage Manager added

parent 95958bf8
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))
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