Conversation
imobachgs
left a comment
There was a problem hiding this comment.
I have a few comments about the overall approach.
You are using an empty struct which does not hold any kind of state. Actually, the &self arguments are not needed (e.g., check is_available).
I guess you want to somehow group all those functions together and in the future you might want to keep some state (e.g., caching is_available or something like that).
Additionally, you are using some hard-coded values (two paths). What about moving those paths to the struct itself?
struct Ipmi {
tool: PathBuf, // feel free to use better names
dev: PathBuf
}
impl Ipmi {
fn new(tool: &str, dev: &str) -> Self { // you can use a String if you prefer
Self {
tool: tool.to_string(),
dev: dev.to_string()
}
}
}
impl Default for Impi {
fn default() -> Self {
Self::new("/usr/bin/ipmitool", "/dev/ipmi0")
}
}This approach would enable you to write unit tests (that are actually missing).
rust/agama-manager/src/ipmi.rs
Outdated
| const IPMI_ABORTED: u8 = 0x09; | ||
| const IPMI_FAILED: u8 = 0x0A; | ||
|
|
||
| pub fn new() -> Self { |
There was a problem hiding this comment.
What about returning an error if the ipmi is not available? In that case, this struct does not have any usage. I do not have a strong opinion about this, it is just a suggestion.
There was a problem hiding this comment.
Well ipmi is kind of optional from our POV and in fact we do not care whether it is available or not ... And wrapping return value into a Result would make coding little bit more noisy ;-)
There was a problem hiding this comment.
Yes, I understand, that's why I say it is just a suggestion. All those functions are now a no-op. At least I would log in the send_command function that IPMI is not available. Or if you prefer, you could call is_available when the manager starts printing whether it is supported or not.
yes, that was the idea. However originally I wanted to do a (kind of) 1:1 version of original ruby code. As it wasn't according to your taste I've added basic update according to your comments |
imobachgs
left a comment
There was a problem hiding this comment.
I am still not convinced by the no-op and, more important, the lack of tests.
But please, do not merge until you can try a full installation.
rust/package/agama.changes
Outdated
| - jsc#PED-12285 | ||
| - re-introduced initial implementation for installer state status | ||
| report via IPMI. Original implementation lost due to transition | ||
| from ruby to rust. |
There was a problem hiding this comment.
| from ruby to rust. | |
| from Ruby to Rust. |
Prepare to release version 20. * #3294 * #3295 * #3296 * #3297 * #3298 * #3299 * #3300 * #3301 * #3302 * #3303 * #3304 * #3305 * #3306 * #3307 * #3308 * #3309 * #3310 * #3311 * #3312 * #3313 * #3315 * #3316 * #3317 * #3318 * #3319 * #3320 * #3322 * #3323 * #3325 * #3326 * #3327 * #3329 * #3330 * #3331 * #3333 * #3334 * #3336 * #3338 * #3339 * #3342 * #3343 * #3349 * #3351 * #3352 * #3353 * #3354 * #3356 * #3357 * #3358 * #3359 * #3360 * #3361 * #3362 * #3363 * #3364 * #3365 * #3366 * #3367 * #3368 * #3371 * #3372 * #3373 * #3375 * #3376 * #3378 * #3379 * #3380 * #3381 * #3382 * #3385 * #3386
Problem
There used to be support for Ipmi reporting (#2490) which was lost during transformation of manager service from ruby to rust.
Solution
Ipmi code rewritten from ruby to rust and hooked into the manager service
TODO
Testing