This commit is contained in:
2025-08-21 12:11:09 +02:00
parent 35eee2dcad
commit cbccce3413
4 changed files with 47 additions and 43 deletions

View File

@@ -2,6 +2,8 @@ module datamodelsimulator
import json
import freeflowuniverse.herolib.core.pathlib
import freeflowuniverse.herolib.threefold.grid4.datamodel { Node, NodeCapacity }
// load the cloudboxes from a path
pub fn load(path string) ![]Node {

View File

@@ -1,5 +1,5 @@
module datamodelsimulator
import freeflowuniverse.herolib.threefold.grid4.datamodel { Node, NodeCapacity }
import time
// NodeTotalSim represents the aggregated data for a node simulation, including hardware specs, pricing, and location.
@@ -15,50 +15,50 @@ pub mut:
capacity NodeCapacity // Aggregated hardware capacity
}
// total aggregates totals for a single NodeSim (e.g., storage, memory, price) from its slices and devices.
pub fn (n NodeSim) total() !NodeTotalSim {
if n.computeslices.len == 0 && n.storageslices.len == 0 {
return error('Node has no slices to aggregate')
}
// // total aggregates totals for a single NodeSim (e.g., storage, memory, price) from its slices and devices.
// pub fn (n NodeTotalSim) total() !NodeTotalSim {
// if n.computeslices.len == 0 && n.storageslices.len == 0 {
// return error('Node has no slices to aggregate')
// }
mut total := NodeTotalSim{
id: n.id
cost: n.cost
deliverytime: time.now() // Placeholder; replace with actual logic if needed
inca_reward: 0 // Placeholder; compute from policy if available
reputation: 50 // Default; compute from uptime/history
uptime: n.uptime
price_simulation: 0.0
capacity: NodeCapacity{}
}
// mut total := NodeTotalSim{
// id: n.id
// cost: n.cost
// deliverytime: time.now() // Placeholder; replace with actual logic if needed
// inca_reward: 0 // Placeholder; compute from policy if available
// reputation: 50 // Default; compute from uptime/history
// uptime: n.uptime
// price_simulation: 0.0
// capacity: NodeCapacity{}
// }
// Aggregate from compute slices
for slice in n.computeslices {
total.capacity.storage_gb += slice.storage_gb
total.capacity.mem_gb += slice.mem_gb
total.capacity.mem_gb_gpu += 0 // Add GPU logic if GPUs are in slices
total.capacity.passmark += slice.passmark
total.capacity.vcores += slice.vcores
total.price_simulation += slice.price_cc
}
// // Aggregate from compute slices
// for slice in n.computeslices {
// total.capacity.storage_gb += slice.storage_gb
// total.capacity.mem_gb += slice.mem_gb
// total.capacity.mem_gb_gpu += 0 // Add GPU logic if GPUs are in slices
// total.capacity.passmark += slice.passmark
// total.capacity.vcores += slice.vcores
// total.price_simulation += slice.price_cc
// }
// Aggregate from storage slices (focus on storage/price)
for slice in n.storageslices {
total.capacity.storage_gb += 1.0 // Assuming 1GB per storage slice as per model_slices.v
total.price_simulation += slice.price_cc
}
// // Aggregate from storage slices (focus on storage/price)
// for slice in n.storageslices {
// total.capacity.storage_gb += 1.0 // Assuming 1GB per storage slice as per model_slices.v
// total.price_simulation += slice.price_cc
// }
// Aggregate passmark/vcores from devices (e.g., CPUs)
for cpu in n.devices.cpu {
total.capacity.passmark += cpu.passmark
total.capacity.vcores += cpu.cores
}
// // Aggregate passmark/vcores from devices (e.g., CPUs)
// for cpu in n.devices.cpu {
// total.capacity.passmark += cpu.passmark
// total.capacity.vcores += cpu.cores
// }
// Additional aggregations (e.g., from GPUs if present)
for gpu in n.devices.gpu {
total.capacity.mem_gb_gpu += gpu.memory_gb
total.capacity.vcores += gpu.cores // If GPUs contribute to vcores
}
// // Additional aggregations (e.g., from GPUs if present)
// for gpu in n.devices.gpu {
// total.capacity.mem_gb_gpu += gpu.memory_gb
// total.capacity.vcores += gpu.cores // If GPUs contribute to vcores
// }
return total
}
// return total
// }

View File

@@ -1,5 +1,7 @@
module datamodelsimulator
import freeflowuniverse.herolib.threefold.grid4.datamodel { Node }
import freeflowuniverse.herolib.core.playbook { PlayBook }
// this play script should never be called from hero directly its called by gridsimulator
@@ -8,7 +10,7 @@ pub fn play(mut plbook PlayBook) !map[string]&Node {
mut nodesdict := map[string]&Node{}
for action in actions2 {
echo('TODO: Implement action handling for ${action.name}')
return error ('TODO: Implement action handling for ${action.name}')
}
return nodesdict
}