Skip to content

Commit

Permalink
Add NodeList Page
Browse files Browse the repository at this point in the history
  • Loading branch information
archeoss committed Feb 2, 2024
1 parent cf2cb42 commit 64594d3
Show file tree
Hide file tree
Showing 18 changed files with 1,087 additions and 58 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ Bob Management GUI changelog
- Login Page, backend (#16)
- Login Page, frontend (#17)
- Home page, backend (#18)
- Node list page, backend (#19)
- Home page, frontend (#22)
- Node list page, frontend (#23)
4 changes: 4 additions & 0 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<<<<<<< HEAD
openapi: 3.0.3
info:
title: bob-management
Expand Down Expand Up @@ -838,3 +839,6 @@ components:
tags:
- name: bob
description: BOB management API
=======

>>>>>>> 3a6bfd4 (Add NodeList Page)
8 changes: 8 additions & 0 deletions backend/src/connector/dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,8 @@ impl Ord for MetricsEntryModel {
impl Eq for MetricsEntryModel {}
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[cfg_attr(all(feature = "swagger", debug_assertions), derive(ToSchema))]
#[cfg_attr(all(feature = "swagger", debug_assertions), schema(as = dto::Node))]
pub struct Node {
#[serde(rename = "name")]
pub name: String,
Expand All @@ -418,6 +420,7 @@ pub struct Node {

#[serde(rename = "vdisks")]
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(all(feature = "swagger", debug_assertions), schema(value_type = Option<Vec<dto::VDisk>>))]
pub vdisks: Option<Vec<VDisk>>,
}

Expand Down Expand Up @@ -697,6 +700,8 @@ impl std::str::FromStr for Partition {

#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[cfg_attr(all(feature = "swagger", debug_assertions), derive(ToSchema))]
#[cfg_attr(all(feature = "swagger", debug_assertions), schema(as = dto::Replica))]
pub struct Replica {
#[serde(rename = "node")]
pub node: String,
Expand Down Expand Up @@ -896,12 +901,15 @@ impl std::str::FromStr for StatusExt {

#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[cfg_attr(all(feature = "swagger", debug_assertions), derive(ToSchema))]
#[cfg_attr(all(feature = "swagger", debug_assertions), schema(as = dto::VDisk))]
pub struct VDisk {
#[serde(rename = "id")]
pub id: i32,

#[serde(rename = "replicas")]
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(all(feature = "swagger", debug_assertions), schema(value_type = Option<Vec<dto::Replica>>))]
pub replicas: Option<Vec<Replica>>,
}

Expand Down
12 changes: 7 additions & 5 deletions backend/src/connector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ mod prelude {
headers::{authorization::Credentials, Authorization, HeaderMapExt},
http::{HeaderName, HeaderValue},
};
pub use futures::StreamExt;
pub use hyper::{service::Service, Response, Uri};
pub use futures::{Stream, StreamExt};
pub use hyper::{body::Bytes, service::Service, Response, Uri};

Check warning on line 14 in backend/src/connector/mod.rs

View workflow job for this annotation

GitHub Actions / gen-openapi

unused import: `body::Bytes`

Check warning on line 14 in backend/src/connector/mod.rs

View workflow job for this annotation

GitHub Actions / gen-openapi

unused import: `body::Bytes`

Check warning on line 14 in backend/src/connector/mod.rs

View workflow job for this annotation

GitHub Actions / gen-openapi

unused import: `body::Bytes`
pub use std::collections::BTreeMap;
pub use std::{
str::FromStr,
sync::Arc,
Expand Down Expand Up @@ -105,7 +106,7 @@ pub struct BobClient<Context: Send + Sync, Client: ApiNoContext<Context> + Send
main: Arc<Client>,

/// Clients for all known nodes
cluster: HashMap<NodeName, Arc<Client>>,
cluster: BTreeMap<NodeName, Arc<Client>>,

context_marker: PhantomData<fn(Context)>,
}
Expand Down Expand Up @@ -168,7 +169,7 @@ impl<Context: Send + Sync, ApiInterface: ApiNoContext<Context> + Send + Sync>
.attach_printable(format!("Hostname: {}", hostname.to_string()))?
};

let cluster: HashMap<NodeName, Arc<_>> = nodes
let cluster: BTreeMap<NodeName, Arc<_>> = nodes
.iter()
.filter_map(|node| HttpClient::from_node(node, &bob_data.hostname, context.clone()))
.collect();
Expand All @@ -177,6 +178,7 @@ impl<Context: Send + Sync, ApiInterface: ApiNoContext<Context> + Send + Sync>
id: Uuid::new_v4(),
hostname: bob_data.hostname,
main: Arc::new(client.with_context(context)),
// main: Arc::new(client),
cluster,
context_marker: PhantomData,
})
Expand Down Expand Up @@ -275,7 +277,7 @@ impl<Context: Send + Sync, ApiInterface: ApiNoContext<Context> + Send + Sync>
}

#[must_use]
pub const fn cluster_with_addr(&self) -> &HashMap<NodeName, Arc<ApiInterface>> {
pub const fn cluster_with_addr(&self) -> &BTreeMap<NodeName, Arc<ApiInterface>> {
&self.cluster
}

Expand Down
11 changes: 11 additions & 0 deletions backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,36 @@ impl Modify for SecurityAddon {
services::api::get_nodes_count,
services::api::get_rps,
services::api::get_space,
services::api::raw_metrics_by_node,
services::api::raw_configuration_by_node,
services::api::get_node_info,
services::api::get_nodes_list,
),
components(
schemas(models::shared::Credentials, models::shared::Hostname, models::shared::BobConnectionData,
models::api::Disk,
models::api::DiskProblem,
models::api::DiskStatus,
models::api::DiskStatusName,
models::api::DiskCount,
models::api::NodeInfo,
models::api::NodeProblem,
models::api::NodeStatus,
models::api::NodeStatusName,
models::api::NodeCount,
models::api::Replica,
models::api::ReplicaProblem,
models::api::ReplicaStatus,
models::api::SpaceInfo,
models::api::VDisk,
models::api::VDiskStatus,
models::api::Operation,
models::api::RPS,
models::api::RawMetricEntry,
models::api::TypedMetrics,
connector::dto::Node,
connector::dto::VDisk,
connector::dto::Replica,
connector::dto::MetricsEntryModel,
connector::dto::MetricsSnapshotModel,
connector::dto::NodeConfiguration
Expand Down
Loading

0 comments on commit 64594d3

Please sign in to comment.