Skip to content

Commit e781aa8

Browse files
author
Elias Nygren
committed
fix python2.6 support broken by string formats
1 parent 6c80b1f commit e781aa8

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

upcloud_api/cloud_manager/server_mixin.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ def get_servers(self, populate=False, tags_has_one=None, tags_has_all=None):
3636
if tags_has_all:
3737
tags_has_all = [ str(tag) for tag in tags_has_all]
3838
taglist = ':'.join(tags_has_all)
39-
request = '/server/tag/{}'.format(taglist)
39+
request = '/server/tag/{0}'.format(taglist)
4040

4141
if tags_has_one:
4242
tags_has_one = [ str(tag) for tag in tags_has_one]
4343
taglist = ','.join(tags_has_one)
44-
request = '/server/tag/{}'.format(taglist)
44+
request = '/server/tag/{0}'.format(taglist)
4545

4646
servers = self.get_request(request)['servers']['server']
4747

@@ -134,10 +134,10 @@ def modify_server(self, UUID, **kwargs):
134134
body['server'] = {}
135135
for arg in kwargs:
136136
if arg not in Server.updateable_fields:
137-
Exception('{} is not an updateable field'.format(arg))
137+
Exception('{0} is not an updateable field'.format(arg))
138138
body['server'][arg] = kwargs[arg]
139139

140-
res = self.request('PUT', '/server/{}'.format(UUID), body)
140+
res = self.request('PUT', '/server/{0}'.format(UUID), body)
141141
server = res['server']
142142

143143
# Populate subobjects
@@ -160,15 +160,15 @@ def delete_server(self, UUID):
160160
161161
Returns an empty object.
162162
"""
163-
return self.request('DELETE', '/server/{}'.format(UUID))
163+
return self.request('DELETE', '/server/{0}'.format(UUID))
164164

165165

166166
def get_server_data(self, UUID):
167167
"""
168168
Returns '/server/uuid' data in Python dict.
169169
Creates object representations of any IP-address and Storage.
170170
"""
171-
data = self.get_request('/server/{}'.format(UUID))
171+
data = self.get_request('/server/{0}'.format(UUID))
172172
server = data['server']
173173

174174
# Populate subobjects

upcloud_api/server.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __setattr__(self, name, value):
4343
Override to prevent updating readonly fields.
4444
"""
4545
if name not in self.updateable_fields:
46-
raise Exception("'{}' is a readonly field".format(name))
46+
raise Exception("'{0}' is a readonly field".format(name))
4747
else:
4848
object.__setattr__(self, name, value)
4949

@@ -124,7 +124,7 @@ def shutdown(self):
124124
'timeout' : '30'
125125
}
126126

127-
path = '/server/{}/stop'.format(self.uuid)
127+
path = '/server/{0}/stop'.format(self.uuid)
128128
self.cloud_manager.post_request(path, body)
129129
object.__setattr__(self, 'state', 'maintenance')
130130

@@ -140,7 +140,7 @@ def start(self):
140140
Starts the server. Note: slow and blocking request.
141141
The API waits for confirmation from UpCloud's IaaS backend before responding.
142142
"""
143-
path = '/server/{}/start'.format(self.uuid)
143+
path = '/server/{0}/start'.format(self.uuid)
144144
res = self.cloud_manager.post_request(path)
145145
object.__setattr__(self, 'state', 'started')
146146

@@ -160,7 +160,7 @@ def restart(self):
160160
'timeout_action' : 'destroy'
161161
}
162162

163-
path = '/server/{}/restart'.format(self.uuid)
163+
path = '/server/{0}/restart'.format(self.uuid)
164164
self.cloud_manager.post_request(path, body)
165165
object.__setattr__(self, 'state', 'maintenance')
166166

0 commit comments

Comments
 (0)