mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
virt module: actually deprecate virt.nic option
virt.nic is considered as the old version of virt:nic in the code, but there is no warning of this. The documentation is also still mentioning virt.nic. Updating it all to move to virt:nic
This commit is contained in:
parent
6858c9931a
commit
3d3ed786cd
3 changed files with 74 additions and 65 deletions
|
@ -10,16 +10,17 @@ read from the ``config.option`` function, meaning that the configuration can be
|
|||
stored in the minion config file, the master config file, or the minion's
|
||||
pillar.
|
||||
|
||||
This configuration option is called ``virt.nic``. By default the ``virt.nic``
|
||||
This configuration option is called ``virt:nic``. By default the ``virt:nic``
|
||||
option is empty but defaults to a data structure which looks like this:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
virt.nic:
|
||||
default:
|
||||
eth0:
|
||||
bridge: br0
|
||||
model: virtio
|
||||
virt:
|
||||
nic:
|
||||
default:
|
||||
eth0:
|
||||
bridge: br0
|
||||
model: virtio
|
||||
|
||||
.. note::
|
||||
|
||||
|
@ -30,7 +31,7 @@ option is empty but defaults to a data structure which looks like this:
|
|||
This configuration sets up a network profile called default. The default
|
||||
profile creates a single Ethernet device on the virtual machine that is bridged
|
||||
to the hypervisor's :strong:`br0` interface. This default setup does not
|
||||
require setting up the ``virt.nic`` configuration, and is the reason why a
|
||||
require setting up the ``virt:nic`` configuration, and is the reason why a
|
||||
default install only requires setting up the :strong:`br0` bridge device on the
|
||||
hypervisor.
|
||||
|
||||
|
@ -42,42 +43,43 @@ more than one profile, this can be easily accomplished:
|
|||
|
||||
.. code-block:: yaml
|
||||
|
||||
virt.nic:
|
||||
dual:
|
||||
eth0:
|
||||
bridge: service_br
|
||||
eth1:
|
||||
bridge: storage_br
|
||||
single:
|
||||
eth0:
|
||||
bridge: service_br
|
||||
triple:
|
||||
eth0:
|
||||
bridge: service_br
|
||||
eth1:
|
||||
bridge: storage_br
|
||||
eth2:
|
||||
bridge: dmz_br
|
||||
all:
|
||||
eth0:
|
||||
bridge: service_br
|
||||
eth1:
|
||||
bridge: storage_br
|
||||
eth2:
|
||||
bridge: dmz_br
|
||||
eth3:
|
||||
bridge: database_br
|
||||
dmz:
|
||||
eth0:
|
||||
bridge: service_br
|
||||
eth1:
|
||||
bridge: dmz_br
|
||||
database:
|
||||
eth0:
|
||||
bridge: service_br
|
||||
eth1:
|
||||
bridge: database_br
|
||||
virt:
|
||||
nic:
|
||||
dual:
|
||||
eth0:
|
||||
bridge: service_br
|
||||
eth1:
|
||||
bridge: storage_br
|
||||
single:
|
||||
eth0:
|
||||
bridge: service_br
|
||||
triple:
|
||||
eth0:
|
||||
bridge: service_br
|
||||
eth1:
|
||||
bridge: storage_br
|
||||
eth2:
|
||||
bridge: dmz_br
|
||||
all:
|
||||
eth0:
|
||||
bridge: service_br
|
||||
eth1:
|
||||
bridge: storage_br
|
||||
eth2:
|
||||
bridge: dmz_br
|
||||
eth3:
|
||||
bridge: database_br
|
||||
dmz:
|
||||
eth0:
|
||||
bridge: service_br
|
||||
eth1:
|
||||
bridge: dmz_br
|
||||
database:
|
||||
eth0:
|
||||
bridge: service_br
|
||||
eth1:
|
||||
bridge: database_br
|
||||
|
||||
This configuration allows for one of six profiles to be selected, allowing
|
||||
virtual machines to be created which attach to different network depending
|
||||
on the needs of the deployed vm.
|
||||
on the needs of the deployed vm.
|
||||
|
|
|
@ -839,7 +839,13 @@ def _nic_profile(profile_name, hypervisor, **kwargs):
|
|||
profile_name, None
|
||||
)
|
||||
|
||||
if config_data is None:
|
||||
if config_data is not None:
|
||||
salt.utils.warn_until(
|
||||
'Sodium',
|
||||
'\'virt.nic\' has been deprecated in favor of \'virt:nic\'. '
|
||||
'\'virt.nic\' will stop being used in {version}.'
|
||||
)
|
||||
else:
|
||||
config_data = __salt__['config.get']('virt:nic', {}).get(
|
||||
profile_name, default
|
||||
)
|
||||
|
|
|
@ -455,31 +455,32 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
|
|||
def test_mixed_dict_and_list_as_profile_objects(self):
|
||||
|
||||
yaml_config = '''
|
||||
virt.nic:
|
||||
new-listonly-profile:
|
||||
- bridge: br0
|
||||
name: eth0
|
||||
- model: virtio
|
||||
name: eth1
|
||||
source: test_network
|
||||
type: network
|
||||
new-list-with-legacy-names:
|
||||
- eth0:
|
||||
bridge: br0
|
||||
- eth1:
|
||||
bridge: br1
|
||||
model: virtio
|
||||
non-default-legacy-profile:
|
||||
eth0:
|
||||
bridge: br0
|
||||
eth1:
|
||||
bridge: br1
|
||||
model: virtio
|
||||
virt:
|
||||
nic:
|
||||
new-listonly-profile:
|
||||
- bridge: br0
|
||||
name: eth0
|
||||
- model: virtio
|
||||
name: eth1
|
||||
source: test_network
|
||||
type: network
|
||||
new-list-with-legacy-names:
|
||||
- eth0:
|
||||
bridge: br0
|
||||
- eth1:
|
||||
bridge: br1
|
||||
model: virtio
|
||||
non-default-legacy-profile:
|
||||
eth0:
|
||||
bridge: br0
|
||||
eth1:
|
||||
bridge: br1
|
||||
model: virtio
|
||||
'''
|
||||
mock_config = salt.utils.yaml.safe_load(yaml_config)
|
||||
with patch.dict(salt.modules.config.__opts__, mock_config):
|
||||
|
||||
for name in six.iterkeys(mock_config['virt.nic']):
|
||||
for name in six.iterkeys(mock_config['virt']['nic']):
|
||||
profile = salt.modules.virt._nic_profile(name, 'kvm')
|
||||
self.assertEqual(len(profile), 2)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue