From b3f390be783cad21cd4925bcbe8077b91f869b5d Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Tue, 9 Mar 2021 19:38:29 +0100 Subject: compute: Model storage of VM images --- .../kotlin/org/opendc/compute/api/ComputeClient.kt | 25 ++++++++++++++++++++++ .../main/kotlin/org/opendc/compute/api/Image.kt | 14 +++++------- 2 files changed, 30 insertions(+), 9 deletions(-) (limited to 'simulator/opendc-compute/opendc-compute-api/src') diff --git a/simulator/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/ComputeClient.kt b/simulator/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/ComputeClient.kt index 4fd32f98..b4fc03f7 100644 --- a/simulator/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/ComputeClient.kt +++ b/simulator/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/ComputeClient.kt @@ -28,6 +28,31 @@ import java.util.UUID * A client interface for the OpenDC Compute service. */ public interface ComputeClient : AutoCloseable { + /** + * Obtain the list of [Image]s accessible by the requesting user. + */ + public suspend fun queryImages(): List + + /** + * Obtain a [Image] by its unique identifier. + * + * @param id The identifier of the image. + */ + public suspend fun findImage(id: UUID): Image? + + /** + * Create a new [Image] instance at this compute service. + * + * @param name The name of the image. + * @param labels The identifying labels of the image. + * @param meta The non-identifying meta-data of the image. + */ + public suspend fun newImage( + name: String, + labels: Map = emptyMap(), + meta: Map = emptyMap() + ): Image + /** * Obtain the list of [Server]s accessible by the requesting user. */ diff --git a/simulator/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Image.kt b/simulator/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Image.kt index 8b673e84..83e63b81 100644 --- a/simulator/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Image.kt +++ b/simulator/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Image.kt @@ -22,16 +22,12 @@ package org.opendc.compute.api -import java.util.UUID - /** * An image containing a bootable operating system that can directly be executed by physical or virtual server. */ -public data class Image( - public override val uid: UUID, - public override val name: String, - override val labels: Map, - override val meta: Map -) : Resource { - override suspend fun refresh() {} +public interface Image : Resource { + /** + * Delete the image instance. + */ + public suspend fun delete() } -- cgit v1.2.3