Allow empty CPU info of hypervisors in API response
CPU info of hypervisors in an API response was changed from string to
object at API microversion 2.28. CPU info in a hypervisor object can be
empty when using some virt drivers such as ironic virt driver. If the
CPU info is an empty string or None, it cannot be convert to a JSON
object with json.loads method. It causes an internal server error.
This patch sets CPU info in an API response to an empty dict without
using json.loads method in this case follwing the schema of the
response data.
This patch also adds unit tests for this fix. These tests copies a
hypervisor object locally and modified the copy. In
CellHypervisorsTestV21, hypervisor objects are wrapped by
ComputeNodeProxy. In order to apply deepcopy to a ComputeNodeProxy,
the test adds __deepcopy__ method to the class. Without __deepcopy__,
__deepcopy__ of an self._obj works due to __getattr__
method of the proxy, which creates a copy of self._obj.
Reviewed: https:/ /review. openstack. org/346868 /git.openstack. org/cgit/ openstack/ nova/commit/ ?id=72fb6726c07 707d6b7ec6052f9 7e24f44b2c45ab
Committed: https:/
Submitter: Jenkins
Branch: master
commit 72fb6726c07707d 6b7ec6052f97e24 f44b2c45ab
Author: Hironori Shiina <email address hidden>
Date: Mon Jul 25 23:29:55 2016 +0900
Allow empty CPU info of hypervisors in API response
CPU info of hypervisors in an API response was changed from string to
object at API microversion 2.28. CPU info in a hypervisor object can be
empty when using some virt drivers such as ironic virt driver. If the
CPU info is an empty string or None, it cannot be convert to a JSON
object with json.loads method. It causes an internal server error.
This patch sets CPU info in an API response to an empty dict without
using json.loads method in this case follwing the schema of the
response data.
This patch also adds unit tests for this fix. These tests copies a sorsTestV21, hypervisor objects are wrapped by Proxy. In order to apply deepcopy to a ComputeNodeProxy,
hypervisor object locally and modified the copy. In
CellHypervi
ComputeNode
the test adds __deepcopy__ method to the class. Without __deepcopy__,
__deepcopy__ of an self._obj works due to __getattr__
method of the proxy, which creates a copy of self._obj.
Change-Id: I34a7937ee6df98 5587fa98ccc3a17 c969516d5ef
Closes-Bug: #1594230