summaryrefslogtreecommitdiff
path: root/simulator/opendc-compute/opendc-compute-api
diff options
context:
space:
mode:
Diffstat (limited to 'simulator/opendc-compute/opendc-compute-api')
-rw-r--r--simulator/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/ComputeClient.kt4
-rw-r--r--simulator/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Server.kt15
-rw-r--r--simulator/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/ServerState.kt18
3 files changed, 27 insertions, 10 deletions
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 025513e6..c7c507ed 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
@@ -32,11 +32,13 @@ public interface ComputeClient : AutoCloseable {
* @param name The name of the server to deploy.
* @param image The image to be deployed.
* @param flavor The flavor of the machine instance to run this [image] on.
+ * @param start A flag to indicate that the server should be started immediately.
*/
public suspend fun newServer(
name: String,
image: Image,
- flavor: Flavor
+ flavor: Flavor,
+ start: Boolean = true
): Server
/**
diff --git a/simulator/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Server.kt b/simulator/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Server.kt
index ab1eb860..a4f61c03 100644
--- a/simulator/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Server.kt
+++ b/simulator/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Server.kt
@@ -54,6 +54,21 @@ public interface Server : Resource {
public val state: ServerState
/**
+ * Start the server.
+ */
+ public suspend fun start()
+
+ /**
+ * Stop the server.
+ */
+ public suspend fun stop()
+
+ /**
+ * Delete the server instance from the service.
+ */
+ public suspend fun delete()
+
+ /**
* Register the specified [ServerWatcher] to watch the state of the server.
*
* @param watcher The watcher to register for the server.
diff --git a/simulator/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/ServerState.kt b/simulator/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/ServerState.kt
index 25d2e519..a4d7d7d7 100644
--- a/simulator/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/ServerState.kt
+++ b/simulator/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/ServerState.kt
@@ -27,27 +27,27 @@ package org.opendc.compute.api
*/
public enum class ServerState {
/**
- * The server has not yet finished the original build process.
+ * Resources are being allocated for the instance. The instance is not running yet.
*/
- BUILD,
+ PROVISIONING,
/**
- * The server was powered down by the user.
+ * A user shut down the instance.
*/
- SHUTOFF,
+ TERMINATED,
/**
- * The server is active and running.
+ * The server instance is booting up or running.
*/
- ACTIVE,
+ RUNNING,
/**
- * The server is in error.
+ * The server is in an error state.
*/
ERROR,
/**
- * The state of the server is unknown.
+ * The server has been deleted and cannot be started later on.
*/
- UNKNOWN,
+ DELETED,
}