summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-06-09 16:10:59 +0000
committerGerrit Code Review <review@openstack.org>2017-06-09 16:10:59 +0000
commitc4fd270609af207e0ab422b980dd74d5e551a09f (patch)
tree5219a765fcbf8b5042b29a9554d30fc31b65edb9
parent6041572a4c95428f6b13a8d7569090b315a3abd1 (diff)
parent87989c5a37d0894e104ccfebeb05115d593291f4 (diff)
Merge "[BugFix] Release the memory quota for video ram when deleting an instance." into stable/ocata
-rw-r--r--nova/compute/api.py3
-rw-r--r--nova/tests/unit/compute/test_compute_api.py10
2 files changed, 11 insertions, 2 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py
index 87e76a7..588a812 100644
--- a/nova/compute/api.py
+++ b/nova/compute/api.py
@@ -2034,7 +2034,8 @@ class API(base.Base):
2034 else: 2034 else:
2035 flavor = flavor or instance.flavor 2035 flavor = flavor or instance.flavor
2036 instance_vcpus = flavor.vcpus 2036 instance_vcpus = flavor.vcpus
2037 instance_memory_mb = flavor.memory_mb 2037 vram_mb = int(flavor.get('extra_specs', {}).get(VIDEO_RAM, 0))
2038 instance_memory_mb = flavor.memory_mb + vram_mb
2038 2039
2039 quotas = objects.Quotas(context=context) 2040 quotas = objects.Quotas(context=context)
2040 quotas.reserve(project_id=project_id, 2041 quotas.reserve(project_id=project_id,
diff --git a/nova/tests/unit/compute/test_compute_api.py b/nova/tests/unit/compute/test_compute_api.py
index 1d43299..227894b 100644
--- a/nova/tests/unit/compute/test_compute_api.py
+++ b/nova/tests/unit/compute/test_compute_api.py
@@ -961,9 +961,11 @@ class _ComputeAPIUnitTestMixIn(object):
961 inst = self._create_instance_obj() 961 inst = self._create_instance_obj()
962 inst.update(attrs) 962 inst.update(attrs)
963 inst._context = self.context 963 inst._context = self.context
964 vram_mb = int(inst.flavor.get('extra_specs',
965 {}).get(compute_api.VIDEO_RAM, 0))
964 deltas = {'instances': -1, 966 deltas = {'instances': -1,
965 'cores': -inst.flavor.vcpus, 967 'cores': -inst.flavor.vcpus,
966 'ram': -inst.flavor.memory_mb} 968 'ram': -(inst.flavor.memory_mb + vram_mb)}
967 delete_time = datetime.datetime(1955, 11, 5, 9, 30, 969 delete_time = datetime.datetime(1955, 11, 5, 9, 30,
968 tzinfo=iso8601.iso8601.Utc()) 970 tzinfo=iso8601.iso8601.Utc())
969 self.useFixture(utils_fixture.TimeFixture(delete_time)) 971 self.useFixture(utils_fixture.TimeFixture(delete_time))
@@ -1105,6 +1107,12 @@ class _ComputeAPIUnitTestMixIn(object):
1105 def test_delete_in_resized(self): 1107 def test_delete_in_resized(self):
1106 self._test_delete('delete', vm_state=vm_states.RESIZED) 1108 self._test_delete('delete', vm_state=vm_states.RESIZED)
1107 1109
1110 def test_delete_with_vram(self):
1111 flavor = objects.Flavor(vcpus=1, memory_mb=512,
1112 extra_specs={compute_api.VIDEO_RAM: "64"})
1113 self._test_delete('delete',
1114 flavor=flavor)
1115
1108 def test_delete_shelved(self): 1116 def test_delete_shelved(self):
1109 fake_sys_meta = {'shelved_image_id': SHELVED_IMAGE} 1117 fake_sys_meta = {'shelved_image_id': SHELVED_IMAGE}
1110 self._test_delete('delete', 1118 self._test_delete('delete',