maas-region patch: PartitionTable does not exist
An API request for the list of partitions associated with a block device should simply return an empty list if there are no partitions. Instead, we get an maasserver.models.partitiontable.DoesNotExist exception. This patch allows the API server to respond correctly. Before: maas admin partitions read x76dma 9 PartitionTable matching query does not exist. After: maas admin partitions read x76dma 9 Success. Machine-readable output follows: [] Reference: https://old-docs.maas.io/2.3/en/api#get-api20nodessystem_idblockdevicesdevice_idpartitions Change-Id: I427a17686e257bbcc89843dead60f297b4903489
This commit is contained in:
parent
5af724cff0
commit
a351d51b84
|
@ -0,0 +1,13 @@
|
||||||
|
diff --git a/src/maasserver/api/partitions.py b/src/maasserver/api/partitions.py
|
||||||
|
index fb75600a8..f03fc5685 100644
|
||||||
|
--- a/src/maasserver/api/partitions.py
|
||||||
|
+++ b/src/maasserver/api/partitions.py
|
||||||
|
@@ -89,7 +89,7 @@ class PartitionsHandler(OperationsHandler):
|
||||||
|
"""
|
||||||
|
device = BlockDevice.objects.get_block_device_or_404(
|
||||||
|
system_id, device_id, request.user, NODE_PERMISSION.VIEW)
|
||||||
|
- partition_table = device.partitiontable_set.get()
|
||||||
|
+ partition_table = device.get_partitiontable()
|
||||||
|
if partition_table is None:
|
||||||
|
return []
|
||||||
|
else:
|
|
@ -79,6 +79,7 @@ COPY 2.3_proxy_acl.patch /tmp/2.3_proxy_acl.patch
|
||||||
copy 2.3_configure_ipmi_user.patch /tmp/2.3_configure_ipmi_user.patch
|
copy 2.3_configure_ipmi_user.patch /tmp/2.3_configure_ipmi_user.patch
|
||||||
COPY 2.3_secure_headers.patch /tmp/2.3_secure_headers.patch
|
COPY 2.3_secure_headers.patch /tmp/2.3_secure_headers.patch
|
||||||
COPY 2.3_region_secret_rotate.patch /tmp/2.3_region_secret_rotate.patch
|
COPY 2.3_region_secret_rotate.patch /tmp/2.3_region_secret_rotate.patch
|
||||||
|
COPY 2.3_partitiontable_does_not_exist.patch /tmp/2.3_partitiontable_does_not_exist.patch
|
||||||
|
|
||||||
RUN cd /usr/lib/python3/dist-packages/maasserver && patch preseed_network.py < /tmp/2.3_route.patch
|
RUN cd /usr/lib/python3/dist-packages/maasserver && patch preseed_network.py < /tmp/2.3_route.patch
|
||||||
RUN cd /usr/lib/python3/dist-packages/maasserver && patch preseed.py < /tmp/2.3_kernel_package.patch
|
RUN cd /usr/lib/python3/dist-packages/maasserver && patch preseed.py < /tmp/2.3_kernel_package.patch
|
||||||
|
@ -90,6 +91,7 @@ RUN cd /usr/lib/python3/dist-packages/metadataserver/user_data/templates/snippet
|
||||||
RUN cd /usr/lib/python3/dist-packages/provisioningserver/utils && patch ipaddr.py < /tmp/2.3_mac_address.patch
|
RUN cd /usr/lib/python3/dist-packages/provisioningserver/utils && patch ipaddr.py < /tmp/2.3_mac_address.patch
|
||||||
RUN cd /usr/lib/python3/dist-packages/provisioningserver/templates/proxy && patch maas-proxy.conf.template < /tmp/2.3_proxy_acl.patch
|
RUN cd /usr/lib/python3/dist-packages/provisioningserver/templates/proxy && patch maas-proxy.conf.template < /tmp/2.3_proxy_acl.patch
|
||||||
RUN cd /usr/lib/python3/dist-packages/twisted/web && patch server.py < /tmp/2.3_secure_headers.patch
|
RUN cd /usr/lib/python3/dist-packages/twisted/web && patch server.py < /tmp/2.3_secure_headers.patch
|
||||||
|
RUN cd /usr/lib/python3/dist-packages/maasserver/api && patch partitions.py < /tmp/2.3_partitiontable_does_not_exist.patch
|
||||||
|
|
||||||
|
|
||||||
COPY journalctl-to-tty.service /etc/systemd/system/journalctl-to-tty.service
|
COPY journalctl-to-tty.service /etc/systemd/system/journalctl-to-tty.service
|
||||||
|
|
Loading…
Reference in New Issue