@@ -36,13 +36,31 @@ mod opt_bytesize_as_u64 {
3636
3737// Newtype so aide can generate a path parameter schema for Ulid.
3838/// VM ID, in the format of ULID
39+ #[ repr( transparent) ]
3940#[ derive( Serialize , Deserialize , Debug , JsonSchema , OperationIo , Default , Clone ) ]
4041pub struct VmId ( #[ schemars( with = "String" ) ] pub Ulid ) ;
4142
4243/// Volume ID, in the format of ULID
44+ #[ repr( transparent) ]
4345#[ derive( Serialize , Deserialize , Debug , JsonSchema , OperationIo , Default , Clone ) ]
4446pub struct VolumeId ( #[ schemars( with = "String" ) ] pub Ulid ) ;
4547
48+ /// A URI pointing to the volume's location, e.g an iSCSI URL in `iscsi-inq` format, a local file, or an RBD image.
49+ ///
50+ /// examples:
51+ /// - `iscsi://[<username>[%<password>]@]<host>[:<port>]/<target-iqn-name>/<lun>`
52+ /// - `file:///path/to/volume.img`
53+ /// - `rbd://<pool>/<image>`
54+ #[ repr( transparent) ]
55+ #[ derive( Serialize , Deserialize , Debug , JsonSchema , OperationIo , Clone ) ]
56+ pub struct StorageUri ( #[ schemars( with = "String" ) ] pub url:: Url ) ;
57+
58+ impl Default for StorageUri {
59+ fn default ( ) -> Self {
60+ StorageUri ( url:: Url :: parse ( "file:///tmp" ) . unwrap ( ) )
61+ }
62+ }
63+
4664#[ derive( Serialize , Deserialize , Debug , JsonSchema , Default , Clone ) ]
4765pub struct CreateVMRequest {
4866 /// Data of the VM to create
@@ -51,6 +69,7 @@ pub struct CreateVMRequest {
5169 pub boot : bool ,
5270}
5371
72+
5473/// An internal, debug-only request for creating a VM.
5574///
5675/// please don't use this in production, this is for debugging
@@ -148,8 +167,16 @@ pub struct Volume {
148167 #[ schemars( with = "u64" ) ]
149168 #[ serde( with = "bytesize_as_u64" ) ]
150169 pub size : ByteSize ,
170+
171+ /// A URI pointing to the volume's location, e.g an iSCSI URL in `iscsi-inq` format, a local file, or an RBD image.
172+ ///
173+ /// examples:
174+ /// - `iscsi://[<username>[%<password>]@]<host>[:<port>]/<target-iqn-name>/<lun>`
175+ /// - `file:///path/to/volume.img`
176+ /// - `rbd://<pool>/<image>`
177+ ///
178+ pub uri : StorageUri ,
151179}
152-
153180// for now
154181pub type CreateVolumeRequest = Volume ;
155182
0 commit comments