|
|
@@ -199,16 +199,16 @@ class AWSBlockStoreService(BaseBlockStoreService):
|
|
|
super(AWSBlockStoreService, self).__init__(provider)
|
|
|
|
|
|
# Initialize provider services
|
|
|
- self._volumes = AWSVolumeService(self.provider)
|
|
|
- self._snapshots = AWSSnapshotService(self.provider)
|
|
|
+ self._volume_svc = AWSVolumeService(self.provider)
|
|
|
+ self._snapshot_svc = AWSSnapshotService(self.provider)
|
|
|
|
|
|
@property
|
|
|
def volumes(self):
|
|
|
- return self._volumes
|
|
|
+ return self._volume_svc
|
|
|
|
|
|
@property
|
|
|
def snapshots(self):
|
|
|
- return self._snapshots
|
|
|
+ return self._snapshot_svc
|
|
|
|
|
|
|
|
|
class AWSVolumeService(BaseVolumeService):
|
|
|
@@ -216,28 +216,28 @@ class AWSVolumeService(BaseVolumeService):
|
|
|
def __init__(self, provider):
|
|
|
super(AWSVolumeService, self).__init__(provider)
|
|
|
|
|
|
- def get_volume(self, volume_id):
|
|
|
+ def get(self, volume_id):
|
|
|
"""
|
|
|
Returns a volume given its id.
|
|
|
"""
|
|
|
vols = self.provider.ec2_conn.get_all_volumes(volume_ids=[volume_id])
|
|
|
return AWSVolume(self.provider, vols[0]) if vols else None
|
|
|
|
|
|
- def find_volume(self, name):
|
|
|
+ def find(self, name):
|
|
|
"""
|
|
|
Searches for a volume by a given list of attributes.
|
|
|
"""
|
|
|
raise NotImplementedError(
|
|
|
'find_volume not implemented by this provider')
|
|
|
|
|
|
- def list_volumes(self):
|
|
|
+ def list(self):
|
|
|
"""
|
|
|
List all volumes.
|
|
|
"""
|
|
|
return [AWSVolume(self.provider, vol)
|
|
|
for vol in self.provider.ec2_conn.get_all_volumes()]
|
|
|
|
|
|
- def create_volume(self, name, size, zone, snapshot=None):
|
|
|
+ def create(self, name, size, zone, snapshot=None):
|
|
|
"""
|
|
|
Creates a new volume.
|
|
|
"""
|
|
|
@@ -254,52 +254,12 @@ class AWSVolumeService(BaseVolumeService):
|
|
|
return cb_vol
|
|
|
|
|
|
|
|
|
-class AWSObjectStoreService(BaseObjectStoreService):
|
|
|
-
|
|
|
- def __init__(self, provider):
|
|
|
- super(AWSObjectStoreService, self).__init__(provider)
|
|
|
-
|
|
|
- def get_container(self, container_id):
|
|
|
- """
|
|
|
- Returns a container given its id. Returns None if the container
|
|
|
- does not exist.
|
|
|
- """
|
|
|
- bucket = self.provider.s3_conn.lookup(container_id)
|
|
|
- if bucket:
|
|
|
- return AWSContainer(self.provider, bucket)
|
|
|
- else:
|
|
|
- return None
|
|
|
-
|
|
|
- def find_container(self, name):
|
|
|
- """
|
|
|
- Searches for a container by a given list of attributes
|
|
|
- """
|
|
|
- raise NotImplementedError(
|
|
|
- 'find_container not implemented by this provider')
|
|
|
-
|
|
|
- def list_containers(self):
|
|
|
- """
|
|
|
- List all containers.
|
|
|
- """
|
|
|
- buckets = self.provider.s3_conn.get_all_buckets()
|
|
|
- return [AWSContainer(self.provider, bucket) for bucket in buckets]
|
|
|
-
|
|
|
- def create_container(self, name, location=None):
|
|
|
- """
|
|
|
- Create a new container.
|
|
|
- """
|
|
|
- bucket = self.provider.s3_conn.create_bucket(
|
|
|
- name,
|
|
|
- location=location if location else '')
|
|
|
- return AWSContainer(self.provider, bucket)
|
|
|
-
|
|
|
-
|
|
|
class AWSSnapshotService(BaseSnapshotService):
|
|
|
|
|
|
def __init__(self, provider):
|
|
|
super(AWSSnapshotService, self).__init__(provider)
|
|
|
|
|
|
- def get_snapshot(self, snapshot_id):
|
|
|
+ def get(self, snapshot_id):
|
|
|
"""
|
|
|
Returns a snapshot given its id.
|
|
|
"""
|
|
|
@@ -307,14 +267,14 @@ class AWSSnapshotService(BaseSnapshotService):
|
|
|
snapshot_ids=[snapshot_id])
|
|
|
return AWSSnapshot(self.provider, snaps[0]) if snaps else None
|
|
|
|
|
|
- def find_snapshot(self, name):
|
|
|
+ def find(self, name):
|
|
|
"""
|
|
|
Searches for a volume by a given list of attributes.
|
|
|
"""
|
|
|
raise NotImplementedError(
|
|
|
'find_volume not implemented by this provider')
|
|
|
|
|
|
- def list_snapshots(self):
|
|
|
+ def list(self):
|
|
|
"""
|
|
|
List all snapshot.
|
|
|
"""
|
|
|
@@ -324,7 +284,7 @@ class AWSSnapshotService(BaseSnapshotService):
|
|
|
for snap in
|
|
|
self.provider.ec2_conn.get_all_snapshots(owner="self")]
|
|
|
|
|
|
- def create_snapshot(self, name, volume, description=None):
|
|
|
+ def create(self, name, volume, description=None):
|
|
|
"""
|
|
|
Creates a new snapshot of a given volume.
|
|
|
"""
|
|
|
@@ -340,6 +300,46 @@ class AWSSnapshotService(BaseSnapshotService):
|
|
|
return cb_snap
|
|
|
|
|
|
|
|
|
+class AWSObjectStoreService(BaseObjectStoreService):
|
|
|
+
|
|
|
+ def __init__(self, provider):
|
|
|
+ super(AWSObjectStoreService, self).__init__(provider)
|
|
|
+
|
|
|
+ def get_container(self, container_id):
|
|
|
+ """
|
|
|
+ Returns a container given its id. Returns None if the container
|
|
|
+ does not exist.
|
|
|
+ """
|
|
|
+ bucket = self.provider.s3_conn.lookup(container_id)
|
|
|
+ if bucket:
|
|
|
+ return AWSContainer(self.provider, bucket)
|
|
|
+ else:
|
|
|
+ return None
|
|
|
+
|
|
|
+ def find_container(self, name):
|
|
|
+ """
|
|
|
+ Searches for a container by a given list of attributes
|
|
|
+ """
|
|
|
+ raise NotImplementedError(
|
|
|
+ 'find_container not implemented by this provider')
|
|
|
+
|
|
|
+ def list_containers(self):
|
|
|
+ """
|
|
|
+ List all containers.
|
|
|
+ """
|
|
|
+ buckets = self.provider.s3_conn.get_all_buckets()
|
|
|
+ return [AWSContainer(self.provider, bucket) for bucket in buckets]
|
|
|
+
|
|
|
+ def create_container(self, name, location=None):
|
|
|
+ """
|
|
|
+ Create a new container.
|
|
|
+ """
|
|
|
+ bucket = self.provider.s3_conn.create_bucket(
|
|
|
+ name,
|
|
|
+ location=location if location else '')
|
|
|
+ return AWSContainer(self.provider, bucket)
|
|
|
+
|
|
|
+
|
|
|
class AWSImageService(BaseImageService):
|
|
|
|
|
|
def __init__(self, provider):
|