Moves keypair_info from cloud to proxy object

This makes keypair_info compatible with new sdk version

Change-Id: I09c75717a620272904b023179c726a19c4bca000
This commit is contained in:
anbanerj
2022-02-01 17:43:52 +05:30
parent 86b573883a
commit 595f7d1093
3 changed files with 85 additions and 64 deletions

View File

@@ -51,10 +51,11 @@ EXAMPLES = '''
'''
RETURN = '''
openstack_keypairs:
keypairs:
description:
- Lists keypairs that are associated with the account.
type: complex
type: list
elements: dict
returned: always
contains:
created_at:
@@ -120,31 +121,13 @@ 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)
result = [raw.to_dict(computed=False) for raw in keypairs]
self.exit(changed=False, keypairs=result)
def main():