Host* set_pstate(int pstate_index);
std::vector<Disk*> get_disks() const;
+ /**
+ * @brief Create and add disk in the host
+ *
+ * @param name Disk name
+ * @param read_bandwidth Reading speed of the disk
+ * @param write_bandwidth Writing speed of the disk
+ */
Disk* create_disk(const std::string& name, double read_bandwidth, double write_bandwidth);
+ /**
+ * @brief Human-friendly version of create_disk function.
+ *
+ * @throw std::invalid_argument if read/write speeds are incorrect
+ */
+ Disk* create_disk(const std::string& name, const std::string& read_bandwidth, const std::string& write_bandwidth);
void add_disk(const Disk* disk);
void remove_disk(const std::string& disk_name);
});
}
+Disk* Host::create_disk(const std::string& name, const std::string& read_bandwidth, const std::string& write_bandwidth)
+{
+ double d_read, d_write;
+ try {
+ d_read = xbt_parse_get_bandwidth("", 0, read_bandwidth.c_str(), nullptr, "");
+ } catch (const simgrid::ParseError&) {
+ throw std::invalid_argument(std::string("Impossible to create disk: ") + name.c_str() +
+ std::string(". Invalid read bandwidth: ") + read_bandwidth);
+ }
+ try {
+ d_write = xbt_parse_get_bandwidth("", 0, write_bandwidth.c_str(), nullptr, "");
+ } catch (const simgrid::ParseError&) {
+ throw std::invalid_argument(std::string("Impossible to create disk: ") + name.c_str() +
+ std::string(". Invalid write bandwidth: ") + write_bandwidth);
+ }
+ return create_disk(name, d_read, d_write);
+}
+
void Host::add_disk(const Disk* disk)
{
kernel::actor::simcall([this, disk] { this->pimpl_->add_disk(disk); });