File tree Expand file tree Collapse file tree 1 file changed +25
-2
lines changed
Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change 1919author: "Sebastian Gode (@SebastianGode)"
2020description:
2121 - Get Instance Statistics
22+ options:
23+ instance_id:
24+ description:
25+ - Instance ID to filter results for that instance
26+ type: str
27+ required: false
2228requirements: ["openstacksdk", "otcextensions"]
2329'''
2430
4753'''
4854
4955EXAMPLES = '''
50- # Query statistics
56+ # Query statistics about all instances
5157- opentelekomcloud.cloud.dcs_instance_statistics_info:
58+
59+ # Query statistics about a specific instance
60+ - opentelekomcloud.cloud.dcs_instance_statistics_info:
61+ instance_id: "12345678-b17b-434d-b6a1-4cc5abb1f2ca"
5262'''
5363
5464from ansible_collections .opentelekomcloud .cloud .plugins .module_utils .otc import OTCModule
5565
5666
5767class DcsInstanceStatisticsInfoModule (OTCModule ):
5868 argument_spec = dict (
69+ instance_id = dict (required = False )
5970 )
6071 module_kwargs = dict (
6172 supports_check_mode = True
6273 )
6374
6475 def run (self ):
6576 data = []
77+ final_data = []
6678
6779 for raw in self .conn .dcs .statistics ():
6880 dt = raw .to_dict ()
6981 dt .pop ('location' )
7082 data .append (dt )
7183
84+ i = 0
85+ while i < len (data ):
86+ if self .params ['instance_id' ]:
87+ if data [i ]['instance_id' ] == self .params ['instance_id' ]:
88+ final_data = data [i ]
89+ break
90+ else :
91+ final_data = data
92+ break
93+ i = i + 1
94+
7295 self .exit (
7396 changed = False ,
74- instances = data
97+ instances = final_data
7598 )
7699
77100
You can’t perform that action at this time.
0 commit comments