mirror of
https://opendev.org/openstack/ansible-collections-openstack.git
synced 2026-05-06 21:33:07 +00:00
Backport improvements to keypair_info
- Updates docs
- Improves test coverage
Change-Id: I09c75717a620272904b023179c726a19c4bca000
(cherry picked from commit 595f7d1093)
This commit is contained in:
@@ -54,7 +54,8 @@ RETURN = '''
|
||||
openstack_keypairs:
|
||||
description:
|
||||
- Lists keypairs that are associated with the account.
|
||||
type: complex
|
||||
type: list
|
||||
elements: dict
|
||||
returned: always
|
||||
contains:
|
||||
created_at:
|
||||
@@ -120,31 +121,15 @@ class KeyPairInfoModule(OpenStackModule):
|
||||
)
|
||||
|
||||
def run(self):
|
||||
name = self.params['name']
|
||||
user_id = self.params['user_id']
|
||||
limit = self.params['limit']
|
||||
marker = self.params['marker']
|
||||
|
||||
filters = {}
|
||||
data = []
|
||||
|
||||
if user_id:
|
||||
filters['user_id'] = user_id
|
||||
if limit:
|
||||
filters['limit'] = limit
|
||||
if marker:
|
||||
filters['marker'] = marker
|
||||
|
||||
result = self.conn.search_keypairs(name_or_id=name,
|
||||
filters=filters)
|
||||
raws = [raw if isinstance(raw, dict) else raw.to_dict()
|
||||
for raw in result]
|
||||
|
||||
for raw in raws:
|
||||
raw.pop('location')
|
||||
data.append(raw)
|
||||
|
||||
self.exit(changed=False, openstack_keypairs=data)
|
||||
filters = {k: self.params[k] for k in
|
||||
['user_id', 'name', 'limit', 'marker']
|
||||
if self.params[k] is not None}
|
||||
keypairs = self.conn.search_keypairs(name_or_id=self.params['name'],
|
||||
filters=filters)
|
||||
# self.conn.search_keypairs() returned munch.Munch objects before Train
|
||||
result = [raw if isinstance(raw, dict) else raw.to_dict(computed=False)
|
||||
for raw in keypairs]
|
||||
self.exit(changed=False, openstack_keypairs=result)
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
Reference in New Issue
Block a user