Skip to content

Commit

Permalink
Tidy up pep8 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianSidebotham authored and Akm0d committed Oct 18, 2019
1 parent 410941e commit f010c57
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions salt/cloud/clouds/proxmox.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ def list_nodes_select(call=None):
list_nodes_full(), __opts__['query.selection'], call,
)


def _stringlist_to_dictionary(input_string):
'''
Convert a stringlist (comma separated settings) to a dictionary
Expand All @@ -502,14 +503,15 @@ def _stringlist_to_dictionary(input_string):
li = str(input_string).split(',')
ret = {}
for item in li:
pair = str(item).replace(' ','').split('=')
pair = str(item).replace(' ', '').split('=')
if len(pair) != 2:
log.warn("Cannot process stringlist item %s", item)
continue

ret[pair[0]] = pair[1]
return ret


def _dictionary_to_stringlist(input_dict):
'''
Convert a dictionary to a stringlist (comma separated settings)
Expand All @@ -518,12 +520,13 @@ def _dictionary_to_stringlist(input_dict):
setting1=value1,setting2=value2
'''
string_value=""
string_value = ""
for s in input_dict:
string_value += "{0}={1},".format(s, input_dict[s])
string_value = string_value[:-1]
return string_value


def create(vm_):
'''
Create a single VM from a data dict
Expand Down Expand Up @@ -659,10 +662,9 @@ def create(vm_):
new_setting.update(_stringlist_to_dictionary(vm_[setting]))

# Convert the dictionary back into a string list
postParams = { setting: _dictionary_to_stringlist(new_setting) }
postParams = {setting: _dictionary_to_stringlist(new_setting)}
query('post', 'nodes/{0}/qemu/{1}/config'.format(vm_['host'], vmid), postParams)


# VM has been created. Starting..
if not start(name, vmid, call='action'):
log.error('Node %s (%s) failed to start!', name, vmid)
Expand Down

0 comments on commit f010c57

Please sign in to comment.