Skip to content

Commit 98c2efa

Browse files
author
Antti Myyrä
committed
Doc: document storage uploading with examples
1 parent ea520e6 commit 98c2efa

File tree

1 file changed

+53
-5
lines changed

1 file changed

+53
-5
lines changed

docs/Storage.md

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,14 @@ Storage can be created with the CloudManager's `.create_storage(size=10, tier="m
5050

5151
```python
5252

53-
storage1 = manager.create_storage( size=10,
54-
tier="maxiops",
55-
title="my storage disk",
56-
zone='fi-hel1' )
53+
storage1 = manager.create_storage(
54+
zone='fi-hel1',
55+
size=10,
56+
tier="maxiops",
57+
title="my storage disk"
58+
)
5759

58-
storage2 = manager.create_storage(100, zone='fi-hel1')
60+
storage2 = manager.create_storage(zone='de-fra1', size=100)
5961

6062
```
6163

@@ -81,6 +83,52 @@ storage.destroy()
8183

8284
```
8385

86+
## Import
87+
88+
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.
90+
91+
Warning: size of the import cannot exceed the size of the storage. The data will be written starting from
92+
the beginning of the storage, and the storage will not be truncated before starting to write.
93+
94+
Storages can be uploaded by providing a URL.
95+
```python
96+
97+
new_storage = manager.create_storage(size=20, zone='nl-ams1')
98+
storage_import = manager.create_storage_import(
99+
storage=new_storage.uuid,
100+
source='http_import',
101+
source_location='https://username:password@example.server/path/to/data.raw',
102+
)
103+
104+
import_details = manager.get_storage_import_details(new_storage.uuid)
105+
106+
```
107+
108+
Other way is to upload a storage directly. Note that unlike with URLs, file upload will block until it has been
109+
fully uploaded.
110+
```python
111+
112+
from pathlib import Path
113+
114+
new_storage = manager.create_storage(size=20, zone='de-fra1', title='New imported storage')
115+
storage_import = manager.create_storage_import(storage=new_storage.uuid, source='direct_upload')
116+
117+
manager.upload_file_for_storage_import(
118+
storage_import=storage_import,
119+
file=Path('/path/to/your/storage.img'),
120+
)
121+
122+
import_details = manager.get_storage_import_details(new_storage.uuid)
123+
124+
```
125+
126+
Ongoing imports can also be cancelled:
127+
```python
128+
129+
manager.cancel_storage_import(new_storage.uuid)
130+
131+
```
84132

85133
## Clone
86134

0 commit comments

Comments
 (0)