Skip to content

Commit

Permalink
Better loop for filter
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianGode committed Jul 1, 2021
1 parent a5c2b26 commit d1f0d9c
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions plugins/modules/dcs_instance_statistics_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,31 +66,24 @@

class DcsInstanceStatisticsInfoModule(OTCModule):
argument_spec = dict(
instance_id=dict(required=False)
instance_id=dict(required=False),
)
module_kwargs = dict(
supports_check_mode=True
)

def run(self):
data = []
final_data = []

for raw in self.conn.dcs.statistics():
dt = raw.to_dict()
dt.pop('location')
data.append(dt)

i = 0
while i < len(data):
if self.params['instance_id']:
if data[i]['instance_id'] == self.params['instance_id']:
final_data = data[i]
if raw.instance_id == self.params['instance_id']:
final_data = dt
break
else:
final_data = data
break
i = i + 1
final_data.append(dt)

self.exit(
changed=False,
Expand Down

0 comments on commit d1f0d9c

Please sign in to comment.