summaryrefslogtreecommitdiff
path: root/simulator/opendc-compute/opendc-compute-simulator/src/main
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-03-02 17:46:43 +0100
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-03-07 16:10:08 +0100
commit58c73773a75a0e0a8f85217e2e97c64128ce8ab8 (patch)
treee93ab16ebe650218d3d8abc7c18020addef5d97e /simulator/opendc-compute/opendc-compute-simulator/src/main
parent2977dd8a5f1d742193eae79364a284e68269f7b5 (diff)
compute: Pass simulation workload via image metadata
This change removes the SimWorkloadImage implementation and changes Image to a data class without workload. Simulation workloads should now be pased via image metadata as the image storage should be unaware of any simulation details.
Diffstat (limited to 'simulator/opendc-compute/opendc-compute-simulator/src/main')
-rw-r--r--simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimBareMetalDriver.kt5
-rw-r--r--simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimVirtDriver.kt3
-rw-r--r--simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimVirtProvisioningService.kt2
-rw-r--r--simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimWorkloadImage.kt43
4 files changed, 5 insertions, 48 deletions
diff --git a/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimBareMetalDriver.kt b/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimBareMetalDriver.kt
index 1e459e6f..8af45616 100644
--- a/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimBareMetalDriver.kt
+++ b/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimBareMetalDriver.kt
@@ -28,7 +28,6 @@ import org.opendc.compute.core.Flavor
import org.opendc.compute.core.Server
import org.opendc.compute.core.ServerEvent
import org.opendc.compute.core.ServerState
-import org.opendc.compute.core.image.EmptyImage
import org.opendc.compute.core.image.Image
import org.opendc.compute.core.metal.Node
import org.opendc.compute.core.metal.NodeEvent
@@ -88,7 +87,7 @@ public class SimBareMetalDriver(
* The machine state.
*/
private val nodeState =
- StateFlow(Node(uid, name, metadata + ("driver" to this), NodeState.SHUTOFF, EmptyImage, null, events))
+ StateFlow(Node(uid, name, metadata + ("driver" to this), NodeState.SHUTOFF, Image.EMPTY, null, events))
/**
* The [SimBareMetalMachine] we use to run the workload.
@@ -140,7 +139,7 @@ public class SimBareMetalDriver(
events
)
- val delegate = (node.image as SimWorkloadImage).workload
+ val delegate = node.image.tags["workload"] as SimWorkload
// Wrap the workload to pass in a ComputeSimExecutionContext
val workload = object : SimWorkload {
lateinit var wrappedCtx: ComputeSimExecutionContext
diff --git a/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimVirtDriver.kt b/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimVirtDriver.kt
index d7a8a8b2..86a671fc 100644
--- a/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimVirtDriver.kt
+++ b/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimVirtDriver.kt
@@ -27,6 +27,7 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.launch
import org.opendc.compute.core.*
+import org.opendc.compute.core.Flavor
import org.opendc.compute.core.image.Image
import org.opendc.compute.core.virt.HypervisorEvent
import org.opendc.compute.core.virt.driver.InsufficientMemoryOnServerException
@@ -170,7 +171,7 @@ public class SimVirtDriver(private val coroutineScope: CoroutineScope, hyperviso
val performanceInterferenceModel: PerformanceInterferenceModel? = server.image.tags[IMAGE_PERF_INTERFERENCE_MODEL] as? PerformanceInterferenceModel?
val job = coroutineScope.launch {
- val delegate = (server.image as SimWorkloadImage).workload
+ val delegate = server.image.tags["workload"] as SimWorkload
// Wrap the workload to pass in a ComputeSimExecutionContext
val workload = object : SimWorkload {
lateinit var wrappedCtx: ComputeSimExecutionContext
diff --git a/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimVirtProvisioningService.kt b/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimVirtProvisioningService.kt
index defea888..50ab7788 100644
--- a/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimVirtProvisioningService.kt
+++ b/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimVirtProvisioningService.kt
@@ -116,7 +116,7 @@ public class SimVirtProvisioningService(
val provisionedNodes = provisioningService.nodes()
provisionedNodes.forEach { node ->
val workload = SimVirtDriver(coroutineScope, hypervisor)
- val hypervisorImage = SimWorkloadImage(UUID.randomUUID(), "vmm", emptyMap(), workload)
+ val hypervisorImage = Image(UUID.randomUUID(), "vmm", mapOf("workload" to workload))
launch {
var init = false
val deployedNode = provisioningService.deploy(node, hypervisorImage)
diff --git a/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimWorkloadImage.kt b/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimWorkloadImage.kt
deleted file mode 100644
index b48de1d5..00000000
--- a/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimWorkloadImage.kt
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2020 AtLarge Research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package org.opendc.compute.simulator
-
-import org.opendc.compute.core.image.Image
-import org.opendc.core.resource.TagContainer
-import org.opendc.simulator.compute.workload.SimWorkload
-import java.util.*
-
-/**
- * An application [Image] that runs a [SimWorkload].
- *
- * @property uid The unique identifier of this image.
- * @property name The name of this image.
- * @property tags The tags attached to the image.
- * @property workload The workload to run for this image.
- */
-public data class SimWorkloadImage(
- public override val uid: UUID,
- public override val name: String,
- public override val tags: TagContainer,
- public val workload: SimWorkload
-) : Image