Remove deprecations from 0.13
Change-Id: I1da92c8ba3af2923d4ac8e16b787a9cdfc92fe4e
This commit is contained in:
parent
24d006b996
commit
70acccc489
@ -16,6 +16,5 @@
|
||||
from metalsmith._instance import Instance
|
||||
from metalsmith._instance import InstanceState
|
||||
from metalsmith._provisioner import Provisioner
|
||||
from metalsmith.instance_config import InstanceConfig
|
||||
|
||||
__all__ = ['Instance', 'InstanceConfig', 'InstanceState', 'Provisioner']
|
||||
__all__ = ['Instance', 'InstanceState', 'Provisioner']
|
||||
|
@ -16,9 +16,6 @@
|
||||
import copy
|
||||
import json
|
||||
import logging
|
||||
import warnings
|
||||
|
||||
from openstack.baremetal import configdrive
|
||||
|
||||
from metalsmith import _utils
|
||||
|
||||
@ -87,30 +84,6 @@ class GenericConfig(object):
|
||||
"""
|
||||
return self.user_data
|
||||
|
||||
def build_configdrive(self, node, hostname=None):
|
||||
"""Make the config drive ISO.
|
||||
|
||||
Deprecated, use :py:meth:`generate` with openstacksdk's
|
||||
``openstack.baremetal.configdrive.build`` instead.
|
||||
|
||||
:param node: `Node` object.
|
||||
:param hostname: Desired hostname (defaults to node's name or ID).
|
||||
:return: configdrive contents as a base64-encoded string.
|
||||
"""
|
||||
warnings.warn("build_configdrive is deprecated, use generate with "
|
||||
"openstacksdk's openstack.baremetal.configdrive.build "
|
||||
"instead", DeprecationWarning)
|
||||
cd = self.generate(node, hostname)
|
||||
metadata = cd.pop('meta_data')
|
||||
user_data = cd.pop('user_data')
|
||||
if user_data:
|
||||
user_data = user_data.encode('utf-8')
|
||||
|
||||
LOG.debug('Generating configdrive tree for node %(node)s with '
|
||||
'metadata %(meta)s', {'node': _utils.log_res(node),
|
||||
'meta': metadata})
|
||||
return configdrive.build(metadata, user_data=user_data, **cd)
|
||||
|
||||
|
||||
class CloudInitConfig(GenericConfig):
|
||||
"""Configuration of the target instance using cloud-init.
|
||||
@ -170,12 +143,3 @@ class CloudInitConfig(GenericConfig):
|
||||
|
||||
if user_data:
|
||||
return "#cloud-config\n" + json.dumps(user_data)
|
||||
|
||||
|
||||
class InstanceConfig(CloudInitConfig):
|
||||
"""DEPRECATED, use :class:`.GenericConfig` or :class:`.CloudInitConfig`."""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
warnings.warn('InstanceConfig is deprecated, use GenericConfig or '
|
||||
'CloudInitConfig instead', DeprecationWarning)
|
||||
super(InstanceConfig, self).__init__(*args, **kwargs)
|
||||
|
@ -16,10 +16,8 @@
|
||||
import json
|
||||
|
||||
import mock
|
||||
from openstack.baremetal import configdrive
|
||||
import testtools
|
||||
|
||||
import metalsmith
|
||||
from metalsmith import instance_config
|
||||
|
||||
|
||||
@ -43,15 +41,12 @@ class TestGenericConfig(testtools.TestCase):
|
||||
'meta': {}}
|
||||
expected_m.update(expected_metadata)
|
||||
|
||||
with mock.patch.object(configdrive, 'build', autospec=True) as mb:
|
||||
result = config.build_configdrive(self.node, hostname)
|
||||
mb.assert_called_once_with(expected_m, mock.ANY)
|
||||
self.assertIs(result, mb.return_value)
|
||||
user_data = mb.call_args[1].get('user_data')
|
||||
result = config.generate(self.node, hostname)
|
||||
self.assertEqual(expected_m, result['meta_data'])
|
||||
|
||||
user_data = result['user_data']
|
||||
if expected_userdata:
|
||||
self.assertIsNotNone(user_data)
|
||||
user_data = user_data.decode('utf-8')
|
||||
if cloud_init:
|
||||
header, user_data = user_data.split('\n', 1)
|
||||
self.assertEqual('#cloud-config', header)
|
||||
@ -144,7 +139,3 @@ class TestCloudInitConfig(TestGenericConfig):
|
||||
config = self.CLASS()
|
||||
config.user_data = "string"
|
||||
self.assertRaises(TypeError, config.populate_user_data)
|
||||
|
||||
|
||||
class TestDeprecatedInstanceConfig(TestCloudInitConfig):
|
||||
CLASS = metalsmith.InstanceConfig
|
||||
|
7
releasenotes/notes/deprecations-14-4292eaa456564782.yaml
Normal file
7
releasenotes/notes/deprecations-14-4292eaa456564782.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
upgrade:
|
||||
- |
|
||||
The deprecated class ``InstanceConfig`` has been removed.
|
||||
- |
|
||||
The deprecated instance configuration method ``build_configdrive`` has
|
||||
been removed.
|
Loading…
Reference in New Issue
Block a user