in gstack/controllers/project.py [0:0]
def _list_ssh_keys(authorization):
command = 'listTags'
args = {
'resourcetype': 'UserVm',
'keyword': 'sshkey-segment'
}
cloudstack_response = requester.make_request(
command,
args,
authorization.client_id,
authorization.client_secret
)
resources = {}
sshkeys = set()
if cloudstack_response['listtagsresponse']:
for tag in cloudstack_response['listtagsresponse']['tag']:
if tag['resourceid'] not in resources:
resources[tag['resourceid']] = {}
resources[tag['resourceid']][tag['key']] = tag['value']
for resource in resources:
sorted_resource = collections.OrderedDict(
sorted(
resources[resource].items()))
sshkey = ''
for keychunk in sorted_resource:
sshkey = sshkey + sorted_resource[keychunk]
sshkeys.add(sshkey)
sshkeys = '\n'.join(sshkeys)
return sshkeys