File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -15,3 +15,19 @@ allocation = my_nomad.allocation.get_allocation('32c54571-fb79-97d2-ee38-16673ba
15
15
16
16
print (allocation)
17
17
```
18
+
19
+ ### Stop an allocation
20
+
21
+ This endpoint stops and reschedules a specific allocation.
22
+
23
+ https://www.nomadproject.io/api-docs/allocations/#stop-allocation
24
+
25
+ Example of stopping an allocation
26
+
27
+ ```
28
+ import nomad
29
+
30
+ my_nomad = nomad.Nomad(host='192.168.33.10')
31
+
32
+ my_nomad.allocation.stop_allocation('32c54571-fb79-97d2-ee38-16673bab692c')
33
+ ```
Original file line number Diff line number Diff line change @@ -55,3 +55,15 @@ def get_allocation(self, id):
55
55
- nomad.api.exceptions.URLNotFoundNomadException
56
56
"""
57
57
return self .request (id , method = "get" ).json ()
58
+
59
+ def stop_allocation (self , id ):
60
+ """ Stop a specific allocation.
61
+
62
+ https://www.nomadproject.io/api-docs/allocations/#stop-allocation
63
+
64
+ returns: dict
65
+ raises:
66
+ - nomad.api.exceptions.BaseNomadException
67
+ - nomad.api.exceptions.URLNotFoundNomadException
68
+ """
69
+ return self .request (id , "stop" , method = "post" ).json ()
Original file line number Diff line number Diff line change @@ -19,6 +19,11 @@ def test_get_allocation(nomad_setup):
19
19
assert isinstance (nomad_setup .allocation .get_allocation (id ), dict ) == True
20
20
21
21
22
+ def test_stop_allocation (nomad_setup ):
23
+ id = nomad_setup .job .get_allocations ("example" )[0 ]["ID" ]
24
+ assert isinstance (nomad_setup .allocation .stop_allocation (id ), dict ) == True
25
+
26
+
22
27
def test_dunder_getitem_exist (nomad_setup ):
23
28
id = nomad_setup .job .get_allocations ("example" )[0 ]["ID" ]
24
29
a = nomad_setup .allocation [id ]
You can’t perform that action at this time.
0 commit comments