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
This commit is contained in:
Sean Dague 2016-06-22 16:37:38 -04:00
parent 600480e59d
commit f26739394f
8 changed files with 14 additions and 102 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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,
}

View File

@ -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(),

View File

@ -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

View File

@ -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",

View File

@ -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