Skip to content

Commit 76e7889

Browse files
committed
Allow admin to query all servers and volumes via all_tenants=1
1 parent 98f5c5b commit 76e7889

File tree

4 files changed

+37
-12
lines changed

4 files changed

+37
-12
lines changed

src/BlockStorage/v2/Api.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,23 @@ public function getVolumesDetail(): array
5050
'method' => 'GET',
5151
'path' => 'volumes/detail',
5252
'params' => [
53-
'limit' => $this->params->limit(),
54-
'marker' => $this->params->marker(),
55-
'sort' => $this->params->sort(),
53+
'limit' => $this->params->limit(),
54+
'marker' => $this->params->marker(),
55+
'sort' => $this->params->sort(),
56+
'allTenants' => $this->params->allTenants(),
5657
],
5758
];
5859
}
5960

6061
public function getVolume(): array
6162
{
6263
return [
63-
'method' => 'GET',
64-
'path' => 'volumes/{id}',
65-
'params' => ['id' => $this->params->idPath()],
64+
'method' => 'GET',
65+
'path' => 'volumes/{id}',
66+
'params' => [
67+
'id' => $this->params->idPath(),
68+
],
69+
'allTenants' => $this->params->allTenants(),
6670
];
6771
}
6872

src/BlockStorage/v2/Models/Volume.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ class Volume extends OperatorResource implements Creatable, Listable, Updateable
5252
/** @var string */
5353
public $sourceVolumeId;
5454

55+
/** @var string */
56+
public $tenantId;
57+
58+
/** @var string */
59+
public $host;
60+
5561
/** @var array */
5662
public $metadata = [];
5763

@@ -60,11 +66,13 @@ class Volume extends OperatorResource implements Creatable, Listable, Updateable
6066
protected $markerKey = 'id';
6167

6268
protected $aliases = [
63-
'availability_zone' => 'availabilityZone',
64-
'source_volid' => 'sourceVolumeId',
65-
'snapshot_id' => 'snapshotId',
66-
'created_at' => 'createdAt',
67-
'volume_type' => 'volumeTypeName',
69+
'availability_zone' => 'availabilityZone',
70+
'source_volid' => 'sourceVolumeId',
71+
'snapshot_id' => 'snapshotId',
72+
'created_at' => 'createdAt',
73+
'volume_type' => 'volumeTypeName',
74+
'os-vol-tenant-attr:tenant_id' => 'tenantId',
75+
'os-vol-host-attr:host' => 'host'
6876
];
6977

7078
public function populateFromResponse(ResponseInterface $response): self

src/Common/Api/AbstractParams.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,14 @@ public function sortKey(): array
9797
'description' => "Sorts by one or more sets of attribute and sort direction combinations.",
9898
];
9999
}
100+
101+
public function allTenants(): array
102+
{
103+
return [
104+
'type' => self::STRING_TYPE,
105+
'location' => self::QUERY,
106+
'sentAs' => 'all_tenants',
107+
'description' => '(Admin only) Set this to 1 to pull volumes information from all tenants.',
108+
];
109+
}
100110
}

src/Compute/v2/Api.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ public function getServers(): array
219219
'name' => $this->params->filterName(),
220220
'status' => $this->params->filterStatus('server'),
221221
'host' => $this->params->filterHost(),
222+
'allTenants' => $this->params->allTenants()
222223
],
223224
];
224225
}
@@ -235,7 +236,9 @@ public function getServer(): array
235236
return [
236237
'method' => 'GET',
237238
'path' => 'servers/{id}',
238-
'params' => ['id' => $this->params->urlId('server')]
239+
'params' => [
240+
'id' => $this->params->urlId('server'),
241+
],
239242
];
240243
}
241244

0 commit comments

Comments
 (0)