diff --git a/nova/api/metadata/base.py b/nova/api/metadata/base.py index f83bcf8e6c12..4edf7c483f10 100644 --- a/nova/api/metadata/base.py +++ b/nova/api/metadata/base.py @@ -22,13 +22,11 @@ import posixpath from oslo_log import log as logging from oslo_serialization import base64 from oslo_serialization import jsonutils -from oslo_utils import importutils from oslo_utils import timeutils import six from nova.api.ec2 import ec2utils from nova.api.metadata import password -from nova.api.metadata import vendordata from nova.api.metadata import vendordata_dynamic from nova.api.metadata import vendordata_json from nova import block_device @@ -110,7 +108,7 @@ class InstanceMetadata(object): """Instance metadata.""" def __init__(self, instance, address=None, content=None, extra_md=None, - network_info=None, vd_driver=None, network_metadata=None, + network_info=None, network_metadata=None, request_context=None): """Creation of this object should basically cover all time consuming collection. Methods after that should not cause time delays due to @@ -196,14 +194,6 @@ class InstanceMetadata(object): 'content_path': "/%s/%s" % (CONTENT_DIR, key)}) self.content[key] = contents - if vd_driver is None: - vdclass = importutils.import_class(CONF.vendordata_driver) - else: - vdclass = vd_driver - - self.vddriver = vdclass(instance=instance, address=address, - extra_md=extra_md, network_info=network_info) - self.route_configuration = None # NOTE(mikal): the decision to not pass extra_md here like we @@ -505,20 +495,10 @@ class InstanceMetadata(object): if self._check_os_version(HAVANA, version): self.set_mimetype(MIME_TYPE_APPLICATION_JSON) - # NOTE(mikal): backwards compatibility... If the deployer has - # specified providers, and one of those providers is StaticJSON, - # then do that thing here. Otherwise, if the deployer has - # specified an old style driver here, then use that. This second - # bit can be removed once old style vendordata is fully deprecated - # and removed. if (CONF.api.vendordata_providers and 'StaticJSON' in CONF.api.vendordata_providers): return jsonutils.dump_as_bytes( self.vendordata_providers['StaticJSON'].get()) - else: - # TODO(mikal): when we removed the old style vendordata - # drivers, we need to remove self.vddriver as well. - return jsonutils.dump_as_bytes(self.vddriver.get()) raise KeyError(path) @@ -752,8 +732,3 @@ def find_path_in_tree(data, path_tokens): raise KeyError("/".join(path_tokens[0:i])) data = data[path_tokens[i]] return data - - -# NOTE(mikal): this alias is to stop old style vendordata plugins from breaking -# post refactor. It should be removed when we finish deprecating those plugins. -VendorDataDriver = vendordata.VendorDataDriver diff --git a/nova/conf/api.py b/nova/conf/api.py index a9b9535c209f..6135d1236dfb 100644 --- a/nova/conf/api.py +++ b/nova/conf/api.py @@ -71,7 +71,7 @@ Possible values: * Any string that represents zero or more versions, separated by spaces. """), cfg.ListOpt('vendordata_providers', - default=[], + default=['StaticJSON'], deprecated_group="DEFAULT", help=""" A list of vendordata providers. @@ -351,22 +351,6 @@ so if your hypervisor does not support password injection, set this to False. """) ] -deprecated_opts = [ - cfg.StrOpt("vendordata_driver", - default="nova.api.metadata.vendordata_json.JsonFileVendorData", - deprecated_for_removal=True, - deprecated_since="13.0.0", - help=""" -When returning instance metadata, this is the class that is used -for getting vendor metadata when that class isn't specified in the individual -request. The value should be the full dot-separated path to the class to use. - -Possible values: - -* Any valid dot-separated class path that can be imported. -"""), -] - API_OPTS = (auth_opts + metadata_opts + file_opts + @@ -381,9 +365,7 @@ API_OPTS = (auth_opts + def register_opts(conf): conf.register_group(api_group) conf.register_opts(API_OPTS, group=api_group) - conf.register_opts(deprecated_opts) def list_opts(): - return {api_group: API_OPTS, - 'DEFAULT': deprecated_opts} + return {api_group: API_OPTS} diff --git a/nova/tests/unit/test_metadata.py b/nova/tests/unit/test_metadata.py index f90aedec88b3..9325a7c44e67 100644 --- a/nova/tests/unit/test_metadata.py +++ b/nova/tests/unit/test_metadata.py @@ -41,7 +41,6 @@ import webob from nova.api.metadata import base from nova.api.metadata import handler from nova.api.metadata import password -from nova.api.metadata import vendordata from nova.api.metadata import vendordata_dynamic from nova import block_device from nova.compute import flavors @@ -114,8 +113,7 @@ def fake_keypair_obj(name, data): def fake_InstanceMetadata(testcase, inst_data, address=None, sgroups=None, content=None, extra_md=None, - vd_driver=None, network_info=None, - network_metadata=None): + network_info=None, network_metadata=None): content = content or [] extra_md = extra_md or {} if sgroups is None: @@ -124,8 +122,7 @@ def fake_InstanceMetadata(testcase, inst_data, address=None, fakes.stub_out_secgroup_api(testcase, security_groups=sgroups) return base.InstanceMetadata(inst_data, address=address, content=content, extra_md=extra_md, - vd_driver=vd_driver, network_info=network_info, - network_metadata=network_metadata) + network_info=network_info, network_metadata=network_metadata) def fake_request(testcase, mdinst, relpath, address="127.0.0.1", @@ -857,36 +854,6 @@ class OpenStackMetadataTestCase(test.TestCase): # we didn't make a request self.assertIsNone(mdinst.vendordata_providers['DynamicJSON'].session) - def test_vendor_data_response(self): - inst = self.instance.obj_clone() - - mydata = {'mykey1': 'value1', 'mykey2': 'value2'} - - class myVdriver(vendordata.VendorDataDriver): - def __init__(self, *args, **kwargs): - super(myVdriver, self).__init__(*args, **kwargs) - data = mydata.copy() - uuid = kwargs['instance']['uuid'] - data.update({'inst_uuid': uuid}) - self.data = data - - def get(self): - return self.data - - mdinst = fake_InstanceMetadata(self, inst, vd_driver=myVdriver) - - # verify that 2013-10-17 has the vendor_data.json file - vdpath = "/openstack/2013-10-17/vendor_data.json" - vd = jsonutils.loads(mdinst.lookup(vdpath)) - - # the instance should be passed through, and our class copies the - # uuid through to 'inst_uuid'. - self.assertEqual(vd['inst_uuid'], inst['uuid']) - - # check the other expected values - for k, v in mydata.items(): - self.assertEqual(vd[k], v) - def _test_vendordata2_response_inner(self, request_mock, response_code, include_rest_result=True): fake_response = test_identity.FakeResponse(response_code) diff --git a/releasenotes/notes/remove-deprecated-vendordata_driver-opt-3ececc051e581070.yaml b/releasenotes/notes/remove-deprecated-vendordata_driver-opt-3ececc051e581070.yaml new file mode 100644 index 000000000000..ff195fecec5c --- /dev/null +++ b/releasenotes/notes/remove-deprecated-vendordata_driver-opt-3ececc051e581070.yaml @@ -0,0 +1,12 @@ +--- +upgrade: + - | + The ``[DEFAULT] vendordata_driver`` option was deprecated in Mitaka and has + now been removed. Configuration of vendordata drivers should now be done by + using the `[api] vendordata_providers`` option. For more information, refer + to the `vendordata documentation`__. + + __ https://docs.openstack.org/nova/latest/user/vendordata.html + - | + The ``[api] vendordata_providers`` option now defaults to ``[StaticJSON]``. + This ensures existing behavior of the vendordata v1 driver is preserved.