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.
218
218
.. sample :: compute/v2/servers/change_server_password.php
219
219
.. refdoc :: OpenStack/Compute/v2/Models/Server.html#method_changePassword
220
220
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
+
221
229
Reboot server
222
230
-------------
223
231
@@ -302,4 +310,4 @@ Further links
302
310
-------------
303
311
304
312
* 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
279
279
];
280
280
}
281
281
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
+
282
295
public function rebootServer (): array
283
296
{
284
297
return [
Original file line number Diff line number Diff line change @@ -183,6 +183,17 @@ public function changePassword(string $newPassword)
183
183
]);
184
184
}
185
185
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
+
186
197
/**
187
198
* Reboots the server.
188
199
*
Original file line number Diff line number Diff line change @@ -15,6 +15,19 @@ public function urlId(string $type): array
15
15
]);
16
16
}
17
17
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
+
18
31
public function minDisk (): array
19
32
{
20
33
return [
You can’t perform that action at this time.
0 commit comments