1111
1212log = logging .getLogger (__name__ )
1313
14+ __deprecated__ = (
15+ 3009 ,
16+ "elasticsearch" ,
17+ "https://github.com/cesan3/salt-ext-elasticsearch" , # This is the repo with the issues tracker for this module
18+ # and the one that will be used to submit PRs, for now, until
19+ # PR actions are enabled in
20+ # http://salt-extensions/saltext-elasticsearch repo
21+ )
22+
1423
1524def index_absent (name ):
1625 """
@@ -26,20 +35,20 @@ def index_absent(name):
2635 index = __salt__ ["elasticsearch.index_get" ](index = name )
2736 if index and name in index :
2837 if __opts__ ["test" ]:
29- ret ["comment" ] = "Index {} will be removed" . format ( name )
38+ ret ["comment" ] = f "Index { name } will be removed"
3039 ret ["changes" ]["old" ] = index [name ]
3140 ret ["result" ] = None
3241 else :
3342 ret ["result" ] = __salt__ ["elasticsearch.index_delete" ](index = name )
3443 if ret ["result" ]:
35- ret ["comment" ] = "Successfully removed index {}" . format ( name )
44+ ret ["comment" ] = f "Successfully removed index { name } "
3645 ret ["changes" ]["old" ] = index [name ]
3746 else :
3847 ret [
3948 "comment"
40- ] = "Failed to remove index {} for unknown reasons" . format ( name )
49+ ] = f "Failed to remove index { name } for unknown reasons"
4150 else :
42- ret ["comment" ] = "Index {} is already absent" . format ( name )
51+ ret ["comment" ] = f "Index { name } is already absent"
4352 except Exception as err : # pylint: disable=broad-except
4453 ret ["result" ] = False
4554 ret ["comment" ] = str (err )
@@ -89,15 +98,15 @@ def index_present(name, definition=None):
8998 index = name , body = definition
9099 )
91100 if output :
92- ret ["comment" ] = "Successfully created index {}" . format ( name )
101+ ret ["comment" ] = f "Successfully created index { name } "
93102 ret ["changes" ] = {
94103 "new" : __salt__ ["elasticsearch.index_get" ](index = name )[name ]
95104 }
96105 else :
97106 ret ["result" ] = False
98- ret ["comment" ] = "Cannot create index {}, {}" . format ( name , output )
107+ ret ["comment" ] = f "Cannot create index { name } , { output } "
99108 else :
100- ret ["comment" ] = "Index {} is already present" . format ( name )
109+ ret ["comment" ] = f "Index { name } is already present"
101110 except Exception as err : # pylint: disable=broad-except
102111 ret ["result" ] = False
103112 ret ["comment" ] = str (err )
@@ -138,7 +147,7 @@ def alias_absent(name, index):
138147 if ret ["result" ]:
139148 ret [
140149 "comment"
141- ] = "Successfully removed alias {} for index {}" . format ( name , index )
150+ ] = f "Successfully removed alias { name } for index { index } "
142151 ret ["changes" ]["old" ] = (
143152 alias .get (index , {}).get ("aliases" , {}).get (name , {})
144153 )
@@ -257,7 +266,7 @@ def index_template_absent(name):
257266 index_template = __salt__ ["elasticsearch.index_template_get" ](name = name )
258267 if index_template and name in index_template :
259268 if __opts__ ["test" ]:
260- ret ["comment" ] = "Index template {} will be removed" . format ( name )
269+ ret ["comment" ] = f "Index template { name } will be removed"
261270 ret ["changes" ]["old" ] = index_template [name ]
262271 ret ["result" ] = None
263272 else :
@@ -276,7 +285,7 @@ def index_template_absent(name):
276285 name
277286 )
278287 else :
279- ret ["comment" ] = "Index template {} is already absent" . format ( name )
288+ ret ["comment" ] = f "Index template { name } is already absent"
280289 except Exception as err : # pylint: disable=broad-except
281290 ret ["result" ] = False
282291 ret ["comment" ] = str (err )
@@ -318,7 +327,7 @@ def index_template_present(name, definition, check_definition=False):
318327 if __opts__ ["test" ]:
319328 ret [
320329 "comment"
321- ] = "Index template {} does not exist and will be created" . format ( name )
330+ ] = f "Index template { name } does not exist and will be created"
322331 ret ["changes" ] = {"new" : definition }
323332 ret ["result" ] = None
324333 else :
@@ -371,7 +380,7 @@ def index_template_present(name, definition, check_definition=False):
371380 if output :
372381 ret [
373382 "comment"
374- ] = "Successfully updated index template {}" . format ( name )
383+ ] = f "Successfully updated index template { name } "
375384 ret ["changes" ] = diff
376385 else :
377386 ret ["result" ] = False
@@ -387,7 +396,7 @@ def index_template_present(name, definition, check_definition=False):
387396 name
388397 )
389398 else :
390- ret ["comment" ] = "Index template {} is already present" . format ( name )
399+ ret ["comment" ] = f "Index template { name } is already present"
391400 except Exception as err : # pylint: disable=broad-except
392401 ret ["result" ] = False
393402 ret ["comment" ] = str (err )
@@ -409,20 +418,20 @@ def pipeline_absent(name):
409418 pipeline = __salt__ ["elasticsearch.pipeline_get" ](id = name )
410419 if pipeline and name in pipeline :
411420 if __opts__ ["test" ]:
412- ret ["comment" ] = "Pipeline {} will be removed" . format ( name )
421+ ret ["comment" ] = f "Pipeline { name } will be removed"
413422 ret ["changes" ]["old" ] = pipeline [name ]
414423 ret ["result" ] = None
415424 else :
416425 ret ["result" ] = __salt__ ["elasticsearch.pipeline_delete" ](id = name )
417426 if ret ["result" ]:
418- ret ["comment" ] = "Successfully removed pipeline {}" . format ( name )
427+ ret ["comment" ] = f "Successfully removed pipeline { name } "
419428 ret ["changes" ]["old" ] = pipeline [name ]
420429 else :
421430 ret [
422431 "comment"
423- ] = "Failed to remove pipeline {} for unknown reasons" . format ( name )
432+ ] = f "Failed to remove pipeline { name } for unknown reasons"
424433 else :
425- ret ["comment" ] = "Pipeline {} is already absent" . format ( name )
434+ ret ["comment" ] = f "Pipeline { name } is already absent"
426435 except Exception as err : # pylint: disable=broad-except
427436 ret ["result" ] = False
428437 ret ["comment" ] = str (err )
@@ -467,7 +476,7 @@ def pipeline_present(name, definition):
467476 if not pipeline :
468477 ret [
469478 "comment"
470- ] = "Pipeline {} does not exist and will be created" . format ( name )
479+ ] = f "Pipeline { name } does not exist and will be created"
471480 else :
472481 ret ["comment" ] = (
473482 "Pipeline {} exists with wrong configuration and will be"
@@ -481,7 +490,7 @@ def pipeline_present(name, definition):
481490 )
482491 if output :
483492 if not pipeline :
484- ret ["comment" ] = "Successfully created pipeline {}" . format ( name )
493+ ret ["comment" ] = f "Successfully created pipeline { name } "
485494 else :
486495 ret ["comment" ] = "Successfully replaced pipeline {}" .format (
487496 name
@@ -492,7 +501,7 @@ def pipeline_present(name, definition):
492501 name , output
493502 )
494503 else :
495- ret ["comment" ] = "Pipeline {} is already present" . format ( name )
504+ ret ["comment" ] = f "Pipeline { name } is already present"
496505 except Exception as err : # pylint: disable=broad-except
497506 ret ["result" ] = False
498507 ret ["comment" ] = str (err )
@@ -514,7 +523,7 @@ def search_template_absent(name):
514523 template = __salt__ ["elasticsearch.search_template_get" ](id = name )
515524 if template :
516525 if __opts__ ["test" ]:
517- ret ["comment" ] = "Search template {} will be removed" . format ( name )
526+ ret ["comment" ] = f "Search template { name } will be removed"
518527 ret ["changes" ]["old" ] = salt .utils .json .loads (template ["template" ])
519528 ret ["result" ] = None
520529 else :
@@ -533,7 +542,7 @@ def search_template_absent(name):
533542 name
534543 )
535544 else :
536- ret ["comment" ] = "Search template {} is already absent" . format ( name )
545+ ret ["comment" ] = f "Search template { name } is already absent"
537546 except Exception as err : # pylint: disable=broad-except
538547 ret ["result" ] = False
539548 ret ["comment" ] = str (err )
@@ -593,20 +602,16 @@ def search_template_present(name, definition):
593602 )
594603 if output :
595604 if not template :
596- ret [
597- "comment"
598- ] = "Successfully created search template {}" .format (name )
605+ ret ["comment" ] = f"Successfully created search template { name } "
599606 else :
600- ret [
601- "comment"
602- ] = "Successfully replaced search template {}" .format (name )
607+ ret ["comment" ] = f"Successfully replaced search template { name } "
603608 else :
604609 ret ["result" ] = False
605610 ret ["comment" ] = "Cannot create search template {}, {}" .format (
606611 name , output
607612 )
608613 else :
609- ret ["comment" ] = "Search template {} is already present" . format ( name )
614+ ret ["comment" ] = f "Search template { name } is already present"
610615 except Exception as err : # pylint: disable=broad-except
611616 ret ["result" ] = False
612617 ret ["comment" ] = str (err )
0 commit comments