WIP: rook-ceph install score #122
| @ -1 +1,4 @@ | |||||||
| pub mod ceph_osd_replacement_score; | pub mod ceph_remove_osd_score; | ||||||
|  | pub mod rook_ceph_helm_chart_score; | ||||||
|  | pub mod rook_ceph_cluster_helm_chart_score; | ||||||
|  | pub mod rook_ceph_install_score; | ||||||
|  | |||||||
| @ -0,0 +1,44 @@ | |||||||
|  | 
 | ||||||
|  | use std::str::FromStr; | ||||||
|  | 
 | ||||||
|  | use non_blank_string_rs::NonBlankString; | ||||||
|  | 
 | ||||||
|  | use crate::modules::helm::chart::HelmChartScore; | ||||||
|  | 
 | ||||||
|  | pub fn rook_ceph_cluster_helm_chart(ns: &str) -> HelmChartScore { | ||||||
|  |     let values = r#" | ||||||
|  | monitoring: | ||||||
|  |   enabled: true | ||||||
|  |   createPrometheusRules: true | ||||||
|  | cephClusterSpec: | ||||||
|  |   placement: | ||||||
|  |     all: | ||||||
|  |       nodeAffinity: | ||||||
|  |         requiredDuringSchedulingIgnoredDuringExecution: | ||||||
|  |           nodeSelectorTerms: | ||||||
|  |             - matchExpressions: | ||||||
|  |               - key: storage-node | ||||||
|  |                 operator: In | ||||||
|  |                 values: | ||||||
|  |                 - "true" | ||||||
|  | dashboard: | ||||||
|  |   ssl: false | ||||||
|  |   prometheusEndpoint: http://prometheus-operated:9090
 | ||||||
|  |   prometheusEndpointSSLVerify: false | ||||||
|  | toolbox: | ||||||
|  |   enabled: true | ||||||
|  | 
 | ||||||
|  |         "#
 | ||||||
|  |         .to_string(); | ||||||
|  |     HelmChartScore { | ||||||
|  |         namespace: Some(NonBlankString::from_str(ns).unwrap()), | ||||||
|  |         release_name: NonBlankString::from_str("rook-ceph").unwrap(), | ||||||
|  |         chart_name: NonBlankString::from_str("https://charts.rook.io/release/rook-release/rook-ceph-cluster").unwrap(), | ||||||
|  |         chart_version: todo!(), | ||||||
|  |         values_overrides: todo!(), | ||||||
|  |         values_yaml: Some(values.to_string()), | ||||||
|  |         create_namespace: todo!(), | ||||||
|  |         install_only: todo!(), | ||||||
|  |         repository: todo!(), | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -0,0 +1,24 @@ | |||||||
|  | use std::str::FromStr; | ||||||
|  | 
 | ||||||
|  | use non_blank_string_rs::NonBlankString; | ||||||
|  | 
 | ||||||
|  | use crate::modules::helm::chart::HelmChartScore; | ||||||
|  | 
 | ||||||
|  | pub fn rook_ceph_helm_chart(ns: &str) -> HelmChartScore { | ||||||
|  |     let values = r#" | ||||||
|  | monitoring: | ||||||
|  |   enabled: true | ||||||
|  |         "#
 | ||||||
|  |     .to_string(); | ||||||
|  |     HelmChartScore { | ||||||
|  |         namespace: Some(NonBlankString::from_str(ns).unwrap()), | ||||||
|  |         release_name: NonBlankString::from_str("rook-ceph").unwrap(), | ||||||
|  |         chart_name: NonBlankString::from_str("https://charts.rook.io/release/rook-release/rook-ceph").unwrap(), | ||||||
|  |         chart_version: todo!(), | ||||||
|  |         values_overrides: todo!(), | ||||||
|  |         values_yaml: Some(values.to_string()), | ||||||
|  |         create_namespace: todo!(), | ||||||
|  |         install_only: todo!(), | ||||||
|  |         repository: todo!(), | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										81
									
								
								harmony/src/modules/storage/ceph/rook_ceph_install_score.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								harmony/src/modules/storage/ceph/rook_ceph_install_score.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,81 @@ | |||||||
|  | use serde::Serialize; | ||||||
|  | 
 | ||||||
|  | use crate::{ | ||||||
|  |     data::{Id, Version}, | ||||||
|  |     interpret::{Interpret, InterpretError, InterpretName, InterpretStatus, Outcome}, | ||||||
|  |     inventory::Inventory, | ||||||
|  |     score::Score, | ||||||
|  |     topology::{HelmCommand, Topology}, | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | #[derive(Debug, Clone, Serialize)] | ||||||
|  | pub struct RookCephInstall { | ||||||
|  |     namespace: String, | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | impl<T: Topology + HelmCommand> Score<T> for RookCephInstall { | ||||||
|  |     fn name(&self) -> String { | ||||||
|  |         "RookCephInstall".to_string() | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     fn create_interpret(&self) -> Box<dyn Interpret<T>> { | ||||||
|  |         Box::new(RookCephInstallInterpret { | ||||||
|  |             score: self.score.clone(), | ||||||
|  |         }) | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | #[derive(Debug, Clone)] | ||||||
|  | pub struct RookCephInstallInterpret { | ||||||
|  |     score: RookCephInstall, | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | #[async_trait] | ||||||
|  | impl<T: Topology + HelmCommand> Interpret<T> for RookCephInstallInterpret { | ||||||
|  |     async fn execute( | ||||||
|  |         &self, | ||||||
|  |         inventory: &Inventory, | ||||||
|  |         topology: &T, | ||||||
|  |     ) -> Result<InterpretError, Outcome> { | ||||||
|  |         self.label_nodes(); | ||||||
|  |         self.install_rook_helm_chart(self.score.namespace); | ||||||
|  |         self.install_rook_cluster_helm_chart(self.score.namespace); | ||||||
|  |         //TODO I think we will need to add a capability OCClient to interact with the okd
 | ||||||
|  |         //cli tool 
 | ||||||
|  |         self.add_oc_adm_policy(self.score.namespace); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     fn get_name(&self) -> InterpretName { | ||||||
|  |         todo!() | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     fn get_version(&self) -> Version { | ||||||
|  |         todo!() | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     fn get_status(&self) -> InterpretStatus { | ||||||
|  |         todo!() | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     fn get_children(&self) -> Vec<Id> { | ||||||
|  |         todo!() | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | impl RookCephInstallInterpret { | ||||||
|  |     fn label_nodes(&self) -> _ { | ||||||
|  |         todo!() | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     fn install_rook_helm_chart(&self, namespace: String) -> _ { | ||||||
|  |         todo!() | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     fn install_rook_cluster_helm_chart(&self, namespace: String) -> _ { | ||||||
|  |         todo!() | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     fn add_oc_adm_policy(&self, namespace: String) -> _ { | ||||||
|  |         todo!() | ||||||
|  |     } | ||||||
|  | } | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user