From f26739394f551ed50144d5d52419e15b1f5c04da Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 22 Jun 2016 16:37:38 -0400 Subject: [PATCH] remove preserve-ephemeral rebuild extension This folds this back into the main rebuild flow. As there were no unit tests for this, doing so was pretty simple. Part of bp:api-no-more-extensions Change-Id: I19f791ed5af917b5509940765fedc1b944fcf315 --- nova/api/openstack/compute/extension_info.py | 4 ++ nova/api/openstack/compute/helpers.py | 10 +++++ .../compute/preserve_ephemeral_rebuild.py | 44 ------------------- .../schemas/preserve_ephemeral_rebuild.py | 21 --------- nova/policies/__init__.py | 2 - nova/policies/preserve_ephemeral_rebuild.py | 32 -------------- nova/tests/unit/test_policy.py | 1 - setup.cfg | 2 - 8 files changed, 14 insertions(+), 102 deletions(-) delete mode 100644 nova/api/openstack/compute/preserve_ephemeral_rebuild.py delete mode 100644 nova/api/openstack/compute/schemas/preserve_ephemeral_rebuild.py delete mode 100644 nova/policies/preserve_ephemeral_rebuild.py diff --git a/nova/api/openstack/compute/extension_info.py b/nova/api/openstack/compute/extension_info.py index e145d223cb58..a040abb38b55 100644 --- a/nova/api/openstack/compute/extension_info.py +++ b/nova/api/openstack/compute/extension_info.py @@ -112,6 +112,10 @@ hardcoded_extensions = [ {'name': 'AccessIPs', 'description': 'Access IPs support.', 'alias': 'os-access-ips'}, + {'name': 'PreserveEphemeralOnRebuild', + 'description': ('Allow preservation of the ' + 'ephemeral partition on rebuild.'), + 'alias': 'os-preserve-ephemeral-rebuild'} ] # V2.1 does not support XML but we need to keep an entry in the diff --git a/nova/api/openstack/compute/helpers.py b/nova/api/openstack/compute/helpers.py index fff7c6b6f701..0e08d0e0399e 100644 --- a/nova/api/openstack/compute/helpers.py +++ b/nova/api/openstack/compute/helpers.py @@ -12,6 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. + +from oslo_utils import strutils from webob import exc from nova.i18n import _ @@ -66,3 +68,11 @@ def translate_attributes(server_dict, operation_kwargs): operation_kwargs['access_ip_v4'] = server_dict.pop(API_ACCESS_V4) if API_ACCESS_V6 in server_dict: operation_kwargs['access_ip_v6'] = server_dict.pop(API_ACCESS_V6) + + # This is only ever expected during rebuild operations, and only + # does anything with Ironic driver. It also demonstrates the lack + # of understanding of the word ephemeral. + if 'preserve_ephemeral' in server_dict: + preserve = strutils.bool_from_string( + server_dict.pop('preserve_ephemeral'), strict=True) + operation_kwargs['preserve_ephemeral'] = preserve diff --git a/nova/api/openstack/compute/preserve_ephemeral_rebuild.py b/nova/api/openstack/compute/preserve_ephemeral_rebuild.py deleted file mode 100644 index 78e30ccc01ca..000000000000 --- a/nova/api/openstack/compute/preserve_ephemeral_rebuild.py +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright 2015 IBM Corp. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - - -from oslo_utils import strutils - -from nova.api.openstack.compute.schemas import preserve_ephemeral_rebuild -from nova.api.openstack import extensions - -ALIAS = "os-preserve-ephemeral-rebuild" - - -class PreserveEphemeralRebuild(extensions.V21APIExtensionBase): - """Allow preservation of the ephemeral partition on rebuild.""" - - name = "PreserveEphemeralOnRebuild" - alias = ALIAS - version = 1 - - def get_controller_extensions(self): - return [] - - def get_resources(self): - return [] - - def server_rebuild(self, rebuild_dict, rebuild_kwargs, - body_deprecated_param=None): - if 'preserve_ephemeral' in rebuild_dict: - rebuild_kwargs['preserve_ephemeral'] = strutils.bool_from_string( - rebuild_dict['preserve_ephemeral'], strict=True) - - def get_server_rebuild_schema(self, version): - return preserve_ephemeral_rebuild.server_rebuild diff --git a/nova/api/openstack/compute/schemas/preserve_ephemeral_rebuild.py b/nova/api/openstack/compute/schemas/preserve_ephemeral_rebuild.py deleted file mode 100644 index 5035743f9d77..000000000000 --- a/nova/api/openstack/compute/schemas/preserve_ephemeral_rebuild.py +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 2015 IBM Corp. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - - -from nova.api.validation import parameter_types - - -server_rebuild = { - 'preserve_ephemeral': parameter_types.boolean, -} diff --git a/nova/policies/__init__.py b/nova/policies/__init__.py index 21d46cfe1dcb..17f12be84171 100644 --- a/nova/policies/__init__.py +++ b/nova/policies/__init__.py @@ -69,7 +69,6 @@ from nova.policies import networks_associate from nova.policies import pause_server from nova.policies import pci from nova.policies import personality -from nova.policies import preserve_ephemeral_rebuild from nova.policies import quota_class_sets from nova.policies import quota_sets from nova.policies import remote_consoles @@ -156,7 +155,6 @@ def list_rules(): pause_server.list_rules(), pci.list_rules(), personality.list_rules(), - preserve_ephemeral_rebuild.list_rules(), quota_class_sets.list_rules(), quota_sets.list_rules(), remote_consoles.list_rules(), diff --git a/nova/policies/preserve_ephemeral_rebuild.py b/nova/policies/preserve_ephemeral_rebuild.py deleted file mode 100644 index c0d842b7b8c3..000000000000 --- a/nova/policies/preserve_ephemeral_rebuild.py +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2016 Cloudbase Solutions Srl -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from oslo_policy import policy - -from nova.policies import base - - -POLICY_ROOT = 'os_compute_api:os-preserve-ephemeral-rebuild:%s' - - -preserve_ephemeral_rebuild_policies = [ - policy.RuleDefault( - name=POLICY_ROOT % 'discoverable', - check_str=base.RULE_ANY), -] - - -def list_rules(): - return preserve_ephemeral_rebuild_policies diff --git a/nova/tests/unit/test_policy.py b/nova/tests/unit/test_policy.py index 841e4f40c859..6a271f7940dd 100644 --- a/nova/tests/unit/test_policy.py +++ b/nova/tests/unit/test_policy.py @@ -467,7 +467,6 @@ class RealRolePolicyTestCase(test.NoDBTestCase): "os_compute_api:os-pause-server:discoverable", "os_compute_api:os-pci:discoverable", "os_compute_api:os-personality:discoverable", -"os_compute_api:os-preserve-ephemeral-rebuild:discoverable", "os_compute_api:os-quota-sets:discoverable", "os_compute_api:os-quota-class-sets:discoverable", "os_compute_api:os-rescue:discoverable", diff --git a/setup.cfg b/setup.cfg index 07454ec8da66..69a36b443289 100644 --- a/setup.cfg +++ b/setup.cfg @@ -123,7 +123,6 @@ nova.api.v21.extensions = # See https://bugs.launchpad.net/nova/+bug/1426241 # pci = nova.api.openstack.compute.pci:Pci personality = nova.api.openstack.compute.personality:Personality - preserve_ephemeral_rebuild = nova.api.openstack.compute.preserve_ephemeral_rebuild:PreserveEphemeralRebuild quota_classes = nova.api.openstack.compute.quota_classes:QuotaClasses quota_sets = nova.api.openstack.compute.quota_sets:QuotaSets remote_consoles = nova.api.openstack.compute.remote_consoles:RemoteConsoles @@ -165,7 +164,6 @@ nova.api.v21.extensions.server.create = nova.api.v21.extensions.server.rebuild = personality = nova.api.openstack.compute.personality:Personality - preserve_ephemeral_rebuild = nova.api.openstack.compute.preserve_ephemeral_rebuild:PreserveEphemeralRebuild nova.api.v21.test_extensions = basic = nova.tests.unit.api.openstack.compute.basic:Basic