File tree Expand file tree Collapse file tree 5 files changed +67
-1
lines changed
samples/compute/v2/servers Expand file tree Collapse file tree 5 files changed +67
-1
lines changed Original file line number Diff line number Diff line change @@ -218,6 +218,14 @@ This operation will replace the root password for a server.
218218.. sample :: compute/v2/servers/change_server_password.php
219219.. refdoc :: OpenStack/Compute/v2/Models/Server.html#method_changePassword
220220
221+ Reset server state
222+ ------------------
223+
224+ This operation will reset the state of the server.
225+
226+ .. sample :: compute/v2/servers/reset_server_state.php
227+ .. refdoc :: OpenStack/Compute/v2/Models/Server.html#method_resetState
228+
221229Reboot server
222230-------------
223231
@@ -302,4 +310,4 @@ Further links
302310-------------
303311
304312* Reference docs for Server class
305- * API docs
313+ * API docs
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ require 'vendor/autoload.php ' ;
4+
5+ $ openstack = new OpenStack \OpenStack ([
6+ 'authUrl ' => '{authUrl} ' ,
7+ 'region ' => '{region} ' ,
8+ 'user ' => [
9+ 'id ' => '{userId} ' ,
10+ 'password ' => '{password} '
11+ ],
12+ 'scope ' => ['project ' => ['id ' => '{projectId} ' ]]
13+ ]);
14+
15+ $ compute = $ openstack ->computeV2 (['region ' => '{region} ' ]);
16+
17+ $ server = $ compute ->getServer ([
18+ 'id ' => '{serverId} ' ,
19+ ]);
20+
21+ $ server ->resetState ();
Original file line number Diff line number Diff line change @@ -279,6 +279,19 @@ public function changeServerPassword(): array
279279 ];
280280 }
281281
282+
283+ public function resetServerState (): array
284+ {
285+ return [
286+ 'method ' => 'POST ' ,
287+ 'path ' => 'servers/{id}/action ' ,
288+ 'params ' => [
289+ 'id ' => $ this ->params ->urlId ('server ' ),
290+ 'resetState ' => $ this ->params ->resetState ()
291+ ]
292+ ];
293+ }
294+
282295 public function rebootServer (): array
283296 {
284297 return [
Original file line number Diff line number Diff line change @@ -183,6 +183,17 @@ public function changePassword(string $newPassword)
183183 ]);
184184 }
185185
186+ /**
187+ * Issue a resetState call to the server.
188+ */
189+ public function resetState ()
190+ {
191+ $ this ->execute ($ this ->api ->resetServerState (), [
192+ 'id ' => $ this ->id ,
193+ 'resetState ' => ['state ' => 'active ' ]
194+ ]);
195+ }
196+
186197 /**
187198 * Reboots the server.
188199 *
Original file line number Diff line number Diff line change @@ -15,6 +15,19 @@ public function urlId(string $type): array
1515 ]);
1616 }
1717
18+ public function resetState (): array
19+ {
20+ return [
21+ 'type ' => self ::OBJECT_TYPE ,
22+ 'location ' => self ::JSON ,
23+ 'sentAs ' => 'os-resetState ' ,
24+ 'required ' => true ,
25+ 'properties ' => [
26+ 'state ' => ['type ' => self ::STRING_TYPE ]
27+ ]
28+ ];
29+ }
30+
1831 public function minDisk (): array
1932 {
2033 return [
You can’t perform that action at this time.
0 commit comments