diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-04-12 14:30:57 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-04-12 14:30:57 +0200 |
| commit | 878c22867424c3d361bf2b3d30b0af9e222829fa (patch) | |
| tree | cee540f9554b9a10c3645522ea85fa2a741eef82 | |
| parent | acfc5edaec2e3ee1f92551bcf3878e7dc8496b7e (diff) | |
feat: Make bare metal server uid deterministic
| -rw-r--r-- | opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriver.kt | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriver.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriver.kt index 8e15584a..844938db 100644 --- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriver.kt +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriver.kt @@ -62,6 +62,7 @@ import kotlin.math.min import kotlinx.coroutines.withContext import java.lang.Exception import kotlin.coroutines.ContinuationInterceptor +import kotlin.random.Random /** * A basic implementation of the [BareMetalDriver] that simulates an [Image] running on a bare-metal machine. @@ -116,6 +117,11 @@ public class SimpleBareMetalDriver( override val powerDraw: Flow<Double> = powerModel(this) + /** + * The internal random instance. + */ + private val random = Random(0) + override suspend fun init(): Node = withContext(domain.coroutineContext) { nodeState.value } @@ -128,7 +134,7 @@ public class SimpleBareMetalDriver( val events = EventFlow<ServerEvent>() val server = Server( - UUID.randomUUID(), + UUID(node.uid.leastSignificantBits xor node.uid.mostSignificantBits, random.nextLong()), node.name, emptyMap(), flavor, |
