Skip to content

Commit 12f6742

Browse files
author
Elias Nygren
authored
Merge pull request #31 from UpCloudLtd/0.3.8-devel
0.3.8 devel
2 parents a6c6a77 + f853c81 commit 12f6742

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
setup(
66
name='upcloud-api',
7-
version='0.3.7',
7+
version='0.3.8',
88
description='UpCloud API Client',
99
author='Elias Nygren',
1010
author_email='elias.nygren@upcloud.com',
1111
maintainer='Elias Nygren',
1212
maintainer_email='elias.nygren@upcloud.com',
1313
url='https://github.com/UpCloudLtd/upcloud-python-api',
1414
packages=['upcloud_api', 'upcloud_api.cloud_manager'],
15-
download='https://github.com/UpCloudLtd/upcloud-python-api/tarball/v0.3.7',
15+
download='https://github.com/UpCloudLtd/upcloud-python-api/tarball/v0.3.8',
1616
license='MIT',
1717
install_requires=[
1818
'requests>=2.6.0',

upcloud_api/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from __future__ import unicode_literals
88
from __future__ import absolute_import
99

10-
__version__ = '0.3.7'
10+
__version__ = '0.3.8'
1111
__author__ = 'Elias Nygren'
1212
__author_email__ = 'elias.nygren@upcloud.com'
1313
__license__ = 'MIT'

upcloud_api/server.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ def save(self):
135135
def destroy(self): # noqa
136136
self.cloud_manager.delete_server(self.uuid)
137137

138-
def shutdown(self):
138+
def shutdown(self, hard=False, timeout=30):
139139
"""
140-
Shutdown/stop the server. Issue a soft shutdown with a timeout of 30s.
140+
Shutdown/stop the server. By default, issue a soft shutdown with a timeout of 30s.
141141
142142
After the a timeout a hard shutdown is performed if the server has not stopped.
143143
@@ -147,8 +147,8 @@ def shutdown(self):
147147
"""
148148
body = dict()
149149
body['stop_server'] = {
150-
'stop_type': 'soft',
151-
'timeout': '30'
150+
'stop_type': 'hard' if hard else 'soft',
151+
'timeout': '{0}'.format(timeout)
152152
}
153153

154154
path = '/server/{0}/stop'.format(self.uuid)
@@ -171,9 +171,10 @@ def start(self):
171171
self.cloud_manager.post_request(path)
172172
object.__setattr__(self, 'state', 'started')
173173

174-
def restart(self):
174+
def restart(self, hard=False, timeout=30, force=True):
175175
"""
176-
Restart the server. Issue a soft restart with a timeout of 30s.
176+
Restart the server. By default, issue a soft restart with a timeout of 30s
177+
and a hard restart after the timeout.
177178
178179
After the a timeout a hard restart is performed if the server has not stopped.
179180
@@ -183,9 +184,9 @@ def restart(self):
183184
"""
184185
body = dict()
185186
body['restart_server'] = {
186-
'stop_type': 'soft',
187-
'timeout': '30',
188-
'timeout_action': 'destroy'
187+
'stop_type': 'hard' if hard else 'soft',
188+
'timeout': '{0}'.format(timeout),
189+
'timeout_action': 'destroy' if force else 'ignore'
189190
}
190191

191192
path = '/server/{0}/restart'.format(self.uuid)

0 commit comments

Comments
 (0)