Skip to content

Commit 5127705

Browse files
author
Antti Myyrä
committed
Review improvements
1 parent 9b3ebb0 commit 5127705

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

docs/Storage.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ Storage can be created with the CloudManager's `.create_storage(size=10, tier="m
5353
storage1 = manager.create_storage(
5454
zone='fi-hel1',
5555
size=10,
56-
tier="maxiops",
57-
title="my storage disk"
56+
tier="maxiops",
57+
title="my storage disk"
5858
)
5959

6060
storage2 = manager.create_storage(zone='de-fra1', size=100)
@@ -86,16 +86,20 @@ storage.destroy()
8686
## Import
8787

8888
Storages can be imported either by passing a URL or by uploading the file. Currently .iso, .raw and .img formats
89-
are supported. Other formats like qcow2 or vmdk should be converted before uploading.
89+
are supported. Other formats like QCOW2 or VMDK should be converted before uploading
90+
(with e.g. [`qemu-img convert`](https://linux.die.net/man/1/qemu-img)).
9091

91-
Uploaded storage is expected to be uncompressed. It is possible to upload zip (`application/gzip`)
92-
or gzip (`application/x-xz`) compressed files, but you need to specify a separate `content_type`
92+
Uploaded storage is expected to be uncompressed. It is possible to upload gzip (`application/gzip`)
93+
or LZMA2 (`application/x-xz`) compressed files, but you need to specify a separate `content_type`
9394
when calling the `upload_file_for_storage_import` function.
9495

95-
Warning: size of the import cannot exceed the size of the storage. The data will be written starting from
96-
the beginning of the storage, and the storage will not be truncated before starting to write.
96+
Warning: the size of the import cannot exceed the size of the storage.
97+
The data will be written starting from the beginning of the storage,
98+
and the storage will not be truncated before starting to write.
9799

98-
Storages can be uploaded by providing a URL.
100+
Storages can be uploaded by providing a URL. Note that the upload is not
101+
done by the time `create_storage_import` returns, and you need to poll its
102+
status with `get_storage_import_details`.
99103
```python
100104

101105
new_storage = manager.create_storage(size=20, zone='nl-ams1')
@@ -109,8 +113,8 @@ import_details = manager.get_storage_import_details(new_storage.uuid)
109113

110114
```
111115

112-
Other way is to upload a storage directly. Note that unlike with URLs, file upload will block until it has been
113-
fully uploaded.
116+
Other way is to upload a storage directly. After finishing, you should confirm
117+
that the storage has been processed with `get_storage_import_details`.
114118
```python
115119

116120
new_storage = manager.create_storage(size=20, zone='de-fra1', title='New imported storage')

upcloud_api/cloud_manager/storage_mixin.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def create_storage(
4545
size: int = 10,
4646
tier: str = 'maxiops',
4747
title: str = 'Storage disk',
48+
*,
4849
backup_rule: Optional[dict] = None,
4950
) -> Storage:
5051
"""
@@ -184,8 +185,8 @@ def create_storage_import(
184185
Creates an import task to import data into an existing storage.
185186
Source types: http_import or direct_upload.
186187
"""
187-
if source not in ["http_import", "direct_upload"]:
188-
raise Exception("invalid storage import source: %s", source)
188+
if source not in ("http_import", "direct_upload"):
189+
raise Exception(f"invalid storage import source: {source}")
189190

190191
url = f'/storage/{storage}/import'
191192
body = {'storage_import': {'source': source}}
@@ -197,7 +198,7 @@ def create_storage_import(
197198
def upload_file_for_storage_import(
198199
self,
199200
storage_import: StorageImport,
200-
file: 'PathLike[str]',
201+
file: Union[str, PathLike],
201202
timeout: int = 30,
202203
content_type: str = 'application/octet-stream',
203204
):

0 commit comments

Comments
 (0)