Skip to content

Commit 73502af

Browse files
committed
BlockStorage: setBootable, setImageMetadata, resetStatus
1 parent 1d5eb28 commit 73502af

File tree

4 files changed

+125
-10
lines changed

4 files changed

+125
-10
lines changed

src/BlockStorage/v2/Api.php

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public function postVolumes(): array
2929
'imageId' => $this->params->imageRef(),
3030
'volumeType' => $this->params->volumeType(),
3131
'metadata' => $this->params->metadata(),
32+
'projectId' => $this->params->projectId(),
3233
],
3334
];
3435
}
@@ -191,21 +192,21 @@ public function getSnapshots(): array
191192
'method' => 'GET',
192193
'path' => 'snapshots',
193194
'params' => [
194-
'marker' => $this->params->marker(),
195-
'limit' => $this->params->limit(),
196-
'sortDir' => $this->params->sortDir(),
197-
'sortKey' => $this->params->sortKey(),
195+
'marker' => $this->params->marker(),
196+
'limit' => $this->params->limit(),
197+
'sortDir' => $this->params->sortDir(),
198+
'sortKey' => $this->params->sortKey(),
199+
'allTenants' => $this->params->allTenants(),
198200
],
199201
];
200202
}
201203

202204
public function getSnapshotsDetail(): array
203205
{
204-
return [
205-
'method' => 'GET',
206-
'path' => 'snapshots/detail',
207-
'params' => [],
208-
];
206+
$api = $this->getSnapshots();
207+
$api['path'] .= '/detail';
208+
209+
return $api;
209210
}
210211

211212
public function getSnapshot(): array
@@ -304,4 +305,45 @@ public function putQuotaSet(): array
304305
],
305306
];
306307
}
308+
309+
public function postVolumeBootable(): array
310+
{
311+
return [
312+
'method' => 'POST',
313+
'path' => 'volumes/{id}/action',
314+
'jsonKey' => 'os-set_bootable',
315+
'params' => [
316+
'id' => $this->params->idPath(),
317+
'bootable' => $this->params->bootable(),
318+
],
319+
];
320+
}
321+
322+
public function postImageMetadata(): array
323+
{
324+
return [
325+
'method' => 'POST',
326+
'path' => 'volumes/{id}/action',
327+
'jsonKey' => 'os-set_image_metadata',
328+
'params' => [
329+
'id' => $this->params->idPath(),
330+
'metadata' => $this->params->metadata(),
331+
],
332+
];
333+
}
334+
335+
public function postResetStatus(): array
336+
{
337+
return [
338+
'method' => 'POST',
339+
'path' => 'volumes/{id}/action',
340+
'jsonKey' => 'os-reset_status',
341+
'params' => [
342+
'id' => $this->params->idPath(),
343+
'status' => $this->params->volumeStatus(),
344+
'migrationStatus' => $this->params->volumeMigrationStatus(),
345+
'attachStatus' => $this->params->volumeAttachStatus(),
346+
],
347+
];
348+
}
307349
}

src/BlockStorage/v2/Models/Snapshot.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,16 @@ class Snapshot extends OperatorResource implements Listable, Creatable, Updateab
4747
/** @var int */
4848
public $size;
4949

50+
/** @var string */
51+
public $projectId;
52+
5053
protected $resourceKey = 'snapshot';
5154
protected $resourcesKey = 'snapshots';
5255
protected $markerKey = 'id';
5356

5457
protected $aliases = [
55-
'volume_id' => 'volumeId',
58+
'volume_id' => 'volumeId',
59+
'os-extended-snapshot-attributes:project_id' => 'projectId',
5660
];
5761

5862
/**

src/BlockStorage/v2/Models/Volume.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ class Volume extends OperatorResource implements Creatable, Listable, Updateable
6262
/** @var string */
6363
public $host;
6464

65+
/** @var string */
66+
public $bootable;
67+
6568
/** @var array */
6669
public $metadata = [];
6770

@@ -156,4 +159,21 @@ public function parseMetadata(ResponseInterface $response): array
156159

157160
return isset($json['metadata']) ? $json['metadata'] : [];
158161
}
162+
163+
public function setBootable(bool $bootable)
164+
{
165+
$bootable = boolval($bootable);
166+
$this->execute($this->api->postVolumeBootable(), ['id' => $this->id, 'bootable' => $bootable]);
167+
}
168+
169+
public function setImageMetadata(array $metadata)
170+
{
171+
$this->execute($this->api->postImageMetadata(), ['id' => $this->id, 'metadata' => $metadata]);
172+
}
173+
174+
public function resetStatus(array $options)
175+
{
176+
$options += ['id' => $this->id];
177+
$this->execute($this->api->postResetStatus(), $options);
178+
}
159179
}

src/BlockStorage/v2/Params.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,45 @@ public function volumeType(): array
8080
];
8181
}
8282

83+
public function bootable(): array
84+
{
85+
return [
86+
'type' => self::BOOL_TYPE,
87+
'location' => self::JSON,
88+
'description' => 'Enables or disables the bootable attribute. You can boot an instance from a bootable volume.',
89+
];
90+
}
91+
92+
public function volumeStatus(): array
93+
{
94+
return [
95+
'type' => self::STRING_TYPE,
96+
'location' => self::JSON,
97+
'required' => true,
98+
'description' => 'The volume status.',
99+
];
100+
}
101+
102+
public function volumeMigrationStatus(): array
103+
{
104+
return [
105+
'type' => self::STRING_TYPE,
106+
'location' => self::JSON,
107+
'required' => false,
108+
'description' => 'The volume migration status.',
109+
];
110+
}
111+
112+
public function volumeAttachStatus(): array
113+
{
114+
return [
115+
'type' => self::STRING_TYPE,
116+
'location' => self::JSON,
117+
'required' => false,
118+
'description' => 'The volume attach status.',
119+
];
120+
}
121+
83122
public function metadata(): array
84123
{
85124
return [
@@ -226,4 +265,14 @@ public function quotaSetVolumesIscsi(): array
226265
{
227266
return $this->quotaSetLimit('volumes_iscsi', 'The number of allowed volumes iscsi');
228267
}
268+
269+
public function projectId(): array
270+
{
271+
return [
272+
'type' => self::STRING_TYPE,
273+
'location' => self::URL,
274+
'sentAs' => 'project_id',
275+
'description' => 'The UUID of the project in a multi-tenancy cloud.',
276+
];
277+
}
229278
}

0 commit comments

Comments
 (0)