Python 2.6 str.format() compatibility fixes.

This commit is contained in:
Matt Clay 2018-01-10 12:03:25 -08:00
parent 95ff8f1a90
commit 797664d9cb
20 changed files with 43 additions and 62 deletions

View file

@ -97,7 +97,7 @@ class ProxmoxAPI(object):
raise Exception('Missing mandatory parameter --password (or PROXMOX_PASSWORD).')
def auth(self):
request_path = '{}api2/json/access/ticket'.format(self.options.url)
request_path = '{0}api2/json/access/ticket'.format(self.options.url)
request_params = urlencode({
'username': self.options.username,
@ -112,9 +112,9 @@ class ProxmoxAPI(object):
}
def get(self, url, data=None):
request_path = '{}{}'.format(self.options.url, url)
request_path = '{0}{1}'.format(self.options.url, url)
headers = {'Cookie': 'PVEAuthCookie={}'.format(self.credentials['ticket'])}
headers = {'Cookie': 'PVEAuthCookie={0}'.format(self.credentials['ticket'])}
request = open_url(request_path, data=data, headers=headers)
response = json.load(request)
@ -124,10 +124,10 @@ class ProxmoxAPI(object):
return ProxmoxNodeList(self.get('api2/json/nodes'))
def vms_by_type(self, node, type):
return ProxmoxVMList(self.get('api2/json/nodes/{}/{}'.format(node, type)))
return ProxmoxVMList(self.get('api2/json/nodes/{0}/{1}'.format(node, type)))
def vm_description_by_type(self, node, vm, type):
return self.get('api2/json/nodes/{}/{}/{}/config'.format(node, type, vm))
return self.get('api2/json/nodes/{0}/{1}/{2}/config'.format(node, type, vm))
def node_qemu(self, node):
return self.vms_by_type(node, 'qemu')
@ -145,7 +145,7 @@ class ProxmoxAPI(object):
return ProxmoxPoolList(self.get('api2/json/pools'))
def pool(self, poolid):
return ProxmoxPool(self.get('api2/json/pools/{}'.format(poolid)))
return ProxmoxPool(self.get('api2/json/pools/{0}'.format(poolid)))
def main_list(options):