Media management
A virtual machine needs media to work with. Velocity attaches media to a group and stores it in pools, giving groups read or write access. Pools cannot be created via the API, but are rather defined by the Velocity host configuration.
The pool id (mpid) identifies the pool, but does not hold any reference to where the data is stored. This allows for pools to be moved on the filesystem without loosing references to the files. The Velocity administrator is in charge of tracking the pool ids.
Warning
The administrator is in charge of keeping the
mpidstable between restarts and configuration changes, else media references may become invalid
A pool allows groups to access media with two permissions:
-
write: Write to the media (if it is not read-only) -
manage: Create / remove media from this pool
Every piece of media is identified by its media id (mid) that is a UUID string and its type, which can be anything, but some strings are recommended:
-
ISO: ISO images for bootable read-only media -
DISK: Disk images to use for virtual machine storage devices -
IPSW:macOSrestore / installer images
Available endpoints
-
/m/pool/assign- PUT: Assign permissions on a pool for a group -
/m/pool/assign- DELETE: Revoke a group's permission from the pool -
/m/pool/list- POST: List available pools
/m/media/create- PUT: Create new media/m/media/upload- PUT: Upload media/m/media- DELETE: Remove media/m/media/list- POST: List available media
Pool management
/m/pool/assign - PUT
Assign a group to a mediapool with permissions
If the group is already assigned to the pool, this call will update the permissions
Note
The calling user needs the
velocity.pool.assignpermission on the target group
Request:
{
"gid": "<GID>",
"mpid": "<MPID>",
"quota": "<Quota in Bytes>",
"write": true,
"manage": true
}
Response:
-
200: OK -
403 - Forbidden: The calling user lacks permissions -
404 - Not Found: Thegidormpidhas not been found
/m/pool/assign - DELETE
Revoke a group's permissions from a mediapool
Note
The calling user needs the
velocity.pool.revokepermission on the target group
Request:
{
"gid": "<GID>",
"mpid": "<MPID>"
}
Response:
-
200: OK -
403 - Forbidden: The calling user lacks permissions -
404 - Not Found: Thegidormpidhas not been found
/m/pool/list - POST
List back available pools for a group
Note
The calling user needs the
velocity.pool.listpermission on the target group
Request:
{
"gid": "<GID>"
}
Response:
200
{
"pools": [
{
"mpid": "<MPID>",
"name": "<Pool name>",
"write": true,
"manage": true,
}
]
}
-
403 - Forbidden: The calling user lacks permissions -
404 - Not Found: Thegidhas not been found
Media management
/m/media/create - PUT
Allocate new media on a pool (pid) owned by a group (gid)
Note
The calling user needs the
velocity.media.createpermission on the target group
Request:
{
"mpid": "<MPID>",
"gid": "<GID>",
"name": "<Media name>",
"type": "<Media type>",
"size": "<Size in Bytes>"
}
Response:
200: Media created
{
"mid": "<MID>",
"size": "<Size in Bytes>"
}
-
403 - Forbidden: The calling user lacks permissions or the group does not have themanagepermission on the pool -
404 - Not Found: Thegidorpidhas not been found -
406 - Not Acceptable: Some quota has been surpassed -
409 - Conflict: A file with the samenamedoes already exist in this pool
/m/media/upload - PUT
In contrast to the whole rest of the Velocity API, uploads are handled uniquely: Using HTTP headers to describe and authenticate the upload.
Request:
-
HTTPAdditional HTTP Headers:-
Content-Length: The amount of bytes to be submitted. The server will not accept any more bytes than specified here -
x-velocity-mpid: The mediapool id (MPID) -
x-velocity-gid: The group id (GID) -
x-velocity-name: The name of the file -
x-velocity-type: The type of file -
x-velocity-readonly: If the file should be read only or not (trueorfalse)
-
-
body: The binary data for the file
Response:
200: Media uploaded
{
"mid": "<MID>",
"size": "<Size in Bytes>"
}
-
400 - Bad Request: The http header is missing required fields -
403 - Forbidden: The calling user lacks permissions or the group does not have themanagepermission on the pool -
404 - Not Found: Thegidorpidhas not been found -
406 - Not Acceptable: Some quota has been surpassed -
413 - Payload Too Large: The promisedContent-Lengthhas been surpassed
/m/media - DELETE
Remove media (delete it)
Note
The calling user needs the
velocity.media.removepermission
Request:
{
"mid": "<MID>"
}
Response:
-
200: Media removed -
403 - Forbidden: The calling user lacks permissions -
404 - Not Found: Themidhas not been found
/m/media/list - POST
List back available media to a group
Note
The calling user needs the
velocity.media.listpermission on the target group
Request:
{
"gid": "<GID>"
}
Response:
200
{
"media": [
{
"mid": "<MID>",
"mpid": "<MPID>",
"name": "<Media name>",
"type": "<Media type>",
"size": "<Size in Bytes>",
"readonly": true
}
]
}
The readonly flag is also true if the group does not have the write permission on the pool
-
403 - Forbidden: THe calling user lacks permissions -
404 - Not Found: Thegidhas not been found