Add a --display argument to kayobe physical network configure

This will output the candidate configuration, without applying it.
This commit is contained in:
Mark Goddard 2017-10-17 11:43:53 +00:00
parent 4f1ba98167
commit 13a14664f9
4 changed files with 30 additions and 2 deletions

View File

@ -16,6 +16,9 @@
# to configure in order to restrict configuration to a subset of
# interfaces.
physical_network_interface_description_limit: ''
# Set this variable to True in order to display the candidate switch
# configuration and exit without applying it.
physical_network_display: False
tasks:
- name: Fail if both interface name and description limits are specified
fail:
@ -30,6 +33,10 @@
group_by:
key: "switches_of_type_{{ switch_type }}"
- name: Group hosts by whether display mode is set
group_by:
key: "switches_in_display_mode_{{ physical_network_display | bool }}"
- name: Add discovery interface configuration when performing discovery
set_fact:
switch_interface_config: >
@ -50,8 +57,20 @@
switch_interface_config_select_description(physical_network_interface_description_limit.split(",")) }}
when: physical_network_interface_description_limit != ''
- name: Display switch configuration
hosts: switches_in_display_mode_True
gather_facts: no
tasks:
- name: Display the candidate global switch configuration
debug:
var: switch_config
- name: Display the candidate switch interface configuration
debug:
var: switch_interface_config
- name: Ensure DellOS physical switches are configured
hosts: switches_of_type_dellos6:switches_of_type_dellos9
hosts: switches_of_type_dellos6:switches_of_type_dellos9:&switches_in_display_mode_False
gather_facts: no
roles:
- role: ssh-known-host
@ -63,7 +82,7 @@
dell_switch_interface_config: "{{ switch_interface_config }}"
- name: Ensure Juniper physical switches are configured
hosts: switches_of_type_junos
hosts: switches_of_type_junos:&switches_in_display_mode_False
gather_facts: no
roles:
- role: ssh-known-host

View File

@ -50,6 +50,9 @@ The names or descriptions should be separated by commas. This may be useful
when adding compute nodes to an existing deployment, in order to avoid changing
the configuration interfaces in use by active nodes.
The ``display`` argument will display the candidate switch configuration,
without actually applying it.
Seed Hypervisor
===============

View File

@ -11,6 +11,8 @@ Features
* Adds ``--interface-limit`` and ``--interface-description-limit`` arguments to
the ``kayobe physical network configure`` command. These arguments allow
configuration to be limited to a subset of switch interfaces.
* Adds a ``display`` argument to ``kayobe physical network configure`` command.
This will output the candidate switch configuration without applying it.
Upgrade Notes
-------------

View File

@ -227,6 +227,9 @@ class PhysicalNetworkConfigure(KayobeAnsibleMixin, VaultMixin, Command):
group = parser.add_argument_group("Physical Networking")
group.add_argument("--group", required=True,
help="the Ansible group to apply configuration to")
group.add_argument("--display", action="store_true",
help="display the candidate configuration and exit "
"without applying it")
group.add_argument("--enable-discovery", action="store_true",
help="configure the network for hardware discovery")
group.add_argument("--interface-limit",
@ -240,6 +243,7 @@ class PhysicalNetworkConfigure(KayobeAnsibleMixin, VaultMixin, Command):
def take_action(self, parsed_args):
self.app.LOG.debug("Configuring a physical network")
extra_vars = {}
extra_vars["physical_network_display"] = parsed_args.display
if parsed_args.enable_discovery:
extra_vars["physical_network_enable_discovery"] = True
if parsed_args.interface_limit: