@@ -263,6 +263,56 @@ impl Node {
263263 env
264264 }
265265
266+ /// Executes `ccm updateconf` and applies it for this node.
267+ /// It accepts the key-value pairs to update the configuration.
268+ ///
269+ /// ### Example
270+ /// ```
271+ /// # use crate::ccm::cluster::Node;
272+ /// # async fn check_only_compiles(node: &Node) -> Result<(), Box<dyn Error>> {
273+ /// let args = [
274+ /// ("client_encryption_options.enabled", "true"),
275+ /// ("client_encryption_options.certificate", "db.cert"),
276+ /// ("client_encryption_options.keyfile", "db.key"),
277+ /// ];
278+ ///
279+ /// node.updateconf(args).await?
280+ /// # Ok(())
281+ /// # }
282+ /// ```
283+ ///
284+ /// The code above is equivalent to the following scylla.yaml:
285+ /// ```yaml
286+ /// client_encryption_options:
287+ /// enabled: true
288+ /// certificate: db.cert
289+ /// keyfile: db.key
290+ /// ```
291+ pub ( crate ) async fn updateconf < K , V > (
292+ & self ,
293+ key_values : impl IntoIterator < Item = ( K , V ) > ,
294+ ) -> Result < ( ) , Error >
295+ where
296+ K : AsRef < str > ,
297+ V : AsRef < str > ,
298+ {
299+ let config_dir = & self . config_dir ;
300+ let mut args: Vec < String > = vec ! [
301+ self . opts. name( ) ,
302+ "updateconf" . to_string( ) ,
303+ "--config-dir" . to_string( ) ,
304+ config_dir. to_string_lossy( ) . into_owned( ) ,
305+ ] ;
306+ for ( k, v) in key_values. into_iter ( ) {
307+ args. push ( format ! ( "{}:{}" , k. as_ref( ) , v. as_ref( ) ) ) ;
308+ }
309+
310+ self . logged_cmd
311+ . run_command ( "ccm" , & args, RunOptions :: new ( ) )
312+ . await ?;
313+ Ok ( ( ) )
314+ }
315+
266316 /// This method starts the node. User can provide optional [`NodeStartOptions`] to control the behavior of the node start.
267317 /// If `None` is provided, the default options are used (see the implementation of Default for [`NodeStartOptions`]).
268318 pub ( crate ) async fn start ( & mut self , opts : Option < NodeStartOptions > ) -> Result < ( ) , Error > {
@@ -580,6 +630,55 @@ impl Cluster {
580630 Ok ( ( ) )
581631 }
582632
633+ /// Executes `ccm updateconf` and applies it for all nodes in the cluster.
634+ /// It accepts the key-value pairs to update the configuration.
635+ ///
636+ /// ### Example
637+ /// ```
638+ /// # use crate::ccm::cluster::Cluster;
639+ /// # async fn check_only_compiles(cluster: &Cluster) -> Result<(), Box<dyn Error>> {
640+ /// let args = [
641+ /// ("client_encryption_options.enabled", "true"),
642+ /// ("client_encryption_options.certificate", "db.cert"),
643+ /// ("client_encryption_options.keyfile", "db.key"),
644+ /// ];
645+ ///
646+ /// cluster.updateconf(args).await?
647+ /// # Ok(())
648+ /// # }
649+ /// ```
650+ ///
651+ /// The code above is equivalent to the following scylla.yaml:
652+ /// ```yaml
653+ /// client_encryption_options:
654+ /// enabled: true
655+ /// certificate: db.cert
656+ /// keyfile: db.key
657+ /// ```
658+ pub ( crate ) async fn updateconf < K , V > (
659+ & self ,
660+ key_values : impl IntoIterator < Item = ( K , V ) > ,
661+ ) -> Result < ( ) , Error >
662+ where
663+ K : AsRef < str > ,
664+ V : AsRef < str > ,
665+ {
666+ let config_dir = self . config_dir ( ) ;
667+ let mut args: Vec < String > = vec ! [
668+ "updateconf" . to_string( ) ,
669+ "--config-dir" . to_string( ) ,
670+ config_dir. to_string_lossy( ) . into_owned( ) ,
671+ ] ;
672+ for ( k, v) in key_values. into_iter ( ) {
673+ args. push ( format ! ( "{}:{}" , k. as_ref( ) , v. as_ref( ) ) ) ;
674+ }
675+
676+ self . logged_cmd
677+ . run_command ( "ccm" , & args, RunOptions :: new ( ) )
678+ . await ?;
679+ Ok ( ( ) )
680+ }
681+
583682 fn get_ccm_env ( & self ) -> HashMap < String , String > {
584683 let mut env: HashMap < String , String > = HashMap :: new ( ) ;
585684 env. insert (
0 commit comments