Skip to content

Commit a22f6da

Browse files
authored
fix: only query the chassis sub-system to determine vendor if the redfish client is not anonymous (#65)
1 parent 696fcde commit a22f6da

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/network.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,11 @@ impl RedfishHttpClient {
279279
}
280280
}
281281

282+
/// Returns `true` if this client has no credentials (i.e. anonymous/unauthenticated).
283+
pub fn is_anonymous(&self) -> bool {
284+
self.endpoint.user.is_none()
285+
}
286+
282287
pub async fn get<T>(&self, api: &str) -> Result<(StatusCode, T), RedfishError>
283288
where
284289
T: DeserializeOwned + ::std::fmt::Debug,

src/standard.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,16 @@ impl Redfish for RedfishStandard {
632632
}
633633

634634
async fn get_service_root(&self) -> Result<ServiceRoot, RedfishError> {
635-
let (_status_code, body) = self.client.get("").await?;
635+
let (_status_code, mut body): (StatusCode, ServiceRoot) = self.client.get("").await?;
636+
if body.vendor.is_none() && !self.client.is_anonymous() {
637+
let chassis_all = self.get_chassis_all().await?;
638+
if chassis_all.contains(&"powershelf".to_string()) {
639+
let chassis = self.get_chassis("powershelf").await?;
640+
if let Some(x) = chassis.manufacturer {
641+
body.vendor = Some(x);
642+
}
643+
}
644+
}
636645
Ok(body)
637646
}
638647

0 commit comments

Comments
 (0)