Merge pull request #37644 from Ch3LL/fix_37643

digital ocean list_keypairs: increase limit for ssh keys parsed
This commit is contained in:
Mike Place 2016-11-12 09:28:46 +13:00 committed by GitHub
commit e1e8b81d16

View File

@ -617,22 +617,34 @@ def list_keypairs(call=None):
) )
return False return False
items = query(method='account/keys') fetch = True
page = 1
ret = {} ret = {}
for key_pair in items['ssh_keys']:
name = key_pair['name'] while fetch:
if name in ret: items = query(method='account/keys', command='?page=' + str(page) +
raise SaltCloudSystemExit( '&per_page=100')
'A duplicate key pair name, \'{0}\', was found in DigitalOcean\'s '
'key pair list. Please change the key name stored by DigitalOcean. ' for key_pair in items['ssh_keys']:
'Be sure to adjust the value of \'ssh_key_file\' in your cloud ' name = key_pair['name']
'profile or provider configuration, if necessary.'.format( if name in ret:
name raise SaltCloudSystemExit(
'A duplicate key pair name, \'{0}\', was found in DigitalOcean\'s '
'key pair list. Please change the key name stored by DigitalOcean. '
'Be sure to adjust the value of \'ssh_key_file\' in your cloud '
'profile or provider configuration, if necessary.'.format(
name
)
) )
) ret[name] = {}
ret[name] = {} for item in six.iterkeys(key_pair):
for item in six.iterkeys(key_pair): ret[name][item] = str(key_pair[item])
ret[name][item] = str(key_pair[item])
page += 1
try:
fetch = 'next' in items['links']['pages']
except KeyError:
fetch = False
return ret return ret