@@ -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